summaryrefslogtreecommitdiffstats
path: root/release/sysinstall
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1999-01-08 09:13:00 +0000
committerjkh <jkh@FreeBSD.org>1999-01-08 09:13:00 +0000
commit866fba04c355ed78fd514f852b0e61d3af7fdc9f (patch)
tree7f7700e40658367db7b0b02ce146c6b9a7c79500 /release/sysinstall
parent32e869f75cc7294f8cb82f2d7c757c022385b943 (diff)
downloadFreeBSD-src-866fba04c355ed78fd514f852b0e61d3af7fdc9f.zip
FreeBSD-src-866fba04c355ed78fd514f852b0e61d3af7fdc9f.tar.gz
close doc race.
Diffstat (limited to 'release/sysinstall')
-rw-r--r--release/sysinstall/system.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c
index 289ef90..97b7d57 100644
--- a/release/sysinstall/system.c
+++ b/release/sysinstall/system.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: system.c,v 1.85 1998/11/03 03:38:56 jkh Exp $
+ * $Id: system.c,v 1.86 1999/01/08 00:14:22 jkh Exp $
*
* Jordan Hubbard
*
@@ -22,12 +22,12 @@
#include <machine/console.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
-#include <sys/wait.h>
+#include <sys/stat.h>
/* Where we stick our temporary expanded doc file */
-#define DOC_TMP_DIR "/tmp"
-#define DOC_TMP_FILE "/tmp/doc.tmp"
+#define DOC_TMP_DIR "/tmp/.doc"
+#define DOC_TMP_FILE "/tmp/.doc/doc.tmp"
static pid_t ehs_pid;
@@ -53,8 +53,15 @@ expand(char *fname)
{
char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip";
- Mkdir(DOC_TMP_DIR);
- unlink(DOC_TMP_FILE);
+ if (!directory_exists(DOC_TMP_DIR)) {
+ Mkdir(DOC_TMP_DIR);
+ if (chown(DOC_TMP_DIR, 0, 0) < 0)
+ return NULL;
+ if (chmod(DOC_TMP_DIR, S_IRWXU) < 0)
+ return NULL;
+ }
+ else
+ unlink(DOC_TMP_FILE);
if (!file_readable(fname) || vsystem("%s < %s > %s", gunzip, fname, DOC_TMP_FILE))
return NULL;
return DOC_TMP_FILE;
@@ -131,6 +138,7 @@ systemInitialize(int argc, char **argv)
if (!getenv("HOME"))
setenv("HOME", "/", 1);
signal(SIGINT, handle_intr);
+ (void)vsystem("rm -rf %s", DOC_TMP_DIR);
}
/* Close down and prepare to exit */
@@ -153,8 +161,8 @@ systemShutdown(int status)
/* Shut down curses */
endwin();
- /* If we have a temporary doc file lying around, nuke it */
- unlink(DOC_TMP_FILE);
+ /* If we have a temporary doc dir lying around, nuke it */
+ (void)vsystem("rm -rf %s", DOC_TMP_DIR);
/* REALLY exit! */
if (RunningAsInit) {
OpenPOWER on IntegriCloud