Move generated gitweb_config.perl to hidden tmp directory

Since some systems have a /tmp autocleaner, we don't want to trust
our gitweb configuration file to stay there.  Instead keep it with
the extracted WARs inside of our own private temporary location.

Change-Id: I5f4dea46a755bf3296f15ae38361452fe8df6655
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-03-13 19:20:09 -08:00
parent 0ddb5ba3c8
commit 8d9fc99a6a
3 changed files with 9 additions and 3 deletions

View File

@@ -74,6 +74,12 @@ limitations under the License.
<artifactId>gwtjsonrpc</artifactId> <artifactId>gwtjsonrpc</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.gerrit</groupId>
<artifactId>gerrit-launcher</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.gerrit</groupId> <groupId>com.google.gerrit</groupId>
<artifactId>gerrit-server</artifactId> <artifactId>gerrit-server</artifactId>

View File

@@ -31,6 +31,7 @@ package com.google.gerrit.httpd.gitweb;
import com.google.gerrit.common.data.GerritConfig; import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.httpd.GitWebConfig; import com.google.gerrit.httpd.GitWebConfig;
import com.google.gerrit.launcher.GerritLauncher;
import com.google.gerrit.reviewdb.Project; import com.google.gerrit.reviewdb.Project;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.SitePaths;
@@ -117,7 +118,7 @@ class GitWebServlet extends HttpServlet {
private void makeSiteConfig(final SitePaths site, private void makeSiteConfig(final SitePaths site,
final GerritConfig gerritConfig) throws IOException { final GerritConfig gerritConfig) throws IOException {
final File myconf = File.createTempFile("gitweb_config_", ".perl"); final File myconf = GerritLauncher.createTempFile("gitweb_config", ".perl");
// To make our configuration file only readable or writable by us; // To make our configuration file only readable or writable by us;
// this reduces the chances of someone tampering with the file. // this reduces the chances of someone tampering with the file.
@@ -128,7 +129,6 @@ class GitWebServlet extends HttpServlet {
myconf.setWritable(true, true /* owner only */); myconf.setWritable(true, true /* owner only */);
myconf.setReadable(true, true /* owner only */); myconf.setReadable(true, true /* owner only */);
myconf.deleteOnExit();
_env.set("GIT_DIR", "."); _env.set("GIT_DIR", ".");
_env.set("GITWEB_CONFIG", myconf.getAbsolutePath()); _env.set("GITWEB_CONFIG", myconf.getAbsolutePath());

View File

@@ -361,7 +361,7 @@ public final class GerritLauncher {
* directory if a directory was preferred. * directory if a directory was preferred.
* @throws IOException the file could not be created. * @throws IOException the file could not be created.
*/ */
public static File createTempFile(String prefix, String suffix) public static synchronized File createTempFile(String prefix, String suffix)
throws IOException { throws IOException {
if (!temporaryDirectoryFound) { if (!temporaryDirectoryFound) {
final File d = File.createTempFile("gerrit_", "_app", tmproot()); final File d = File.createTempFile("gerrit_", "_app", tmproot());