Eliminate the idea of nested "playpens" entirely - it just obfuscated
the code and, in at least one case, made it more dangerous to no gain.
This commit is contained in:
parent
22b8189d67
commit
79af7eafa8
@ -1,6 +1,6 @@
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: perform.c,v 1.47 1998/01/17 12:26:19 jkh Exp $";
|
||||
"$Id: perform.c,v 1.48 1998/01/21 06:08:35 jkh Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -272,7 +272,7 @@ pkg_do(char *pkg)
|
||||
else if (Verbose)
|
||||
printf("\t`%s' loaded successfully.\n", p->name);
|
||||
/* Nuke the temporary playpen */
|
||||
leave_playpen(cp);
|
||||
leave_playpen();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -443,7 +443,7 @@ pkg_do(char *pkg)
|
||||
success:
|
||||
/* delete the packing list contents */
|
||||
free_plist(&Plist);
|
||||
leave_playpen(Home);
|
||||
leave_playpen();
|
||||
return code;
|
||||
}
|
||||
|
||||
@ -470,10 +470,15 @@ sanity_check(char *pkg)
|
||||
void
|
||||
cleanup(int signo)
|
||||
{
|
||||
if (signo)
|
||||
printf("Signal %d received, cleaning up..\n", signo);
|
||||
if (!Fake && LogDir[0])
|
||||
vsystem("%s -rf %s", REMOVE_CMD, LogDir);
|
||||
leave_playpen(Home);
|
||||
static int in_cleanup = 0;
|
||||
|
||||
if (!in_cleanup) {
|
||||
in_cleanup = 1;
|
||||
if (signo)
|
||||
printf("Signal %d received, cleaning up..\n", signo);
|
||||
if (!Fake && LogDir[0])
|
||||
vsystem("%s -rf %s", REMOVE_CMD, LogDir);
|
||||
leave_playpen();
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: perform.c,v 1.39 1997/11/13 11:49:23 jkh Exp $";
|
||||
"$Id: perform.c,v 1.40 1997/11/14 01:56:04 jkh Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -180,7 +180,7 @@ pkg_perform(char **pkgs)
|
||||
free(Comment);
|
||||
free(Desc);
|
||||
free_plist(&plist);
|
||||
leave_playpen(home);
|
||||
leave_playpen();
|
||||
return TRUE; /* Success */
|
||||
}
|
||||
|
||||
@ -290,6 +290,11 @@ sanity_check()
|
||||
void
|
||||
cleanup(int sig)
|
||||
{
|
||||
leave_playpen(home);
|
||||
int in_cleanup = 0;
|
||||
|
||||
if (!in_cleanup) {
|
||||
in_cleanup = 1;
|
||||
leave_playpen();
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: perform.c,v 1.22 1997/10/08 07:47:29 charnier Exp $";
|
||||
"$Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -192,7 +192,7 @@ pkg_do(char *pkg)
|
||||
}
|
||||
free_plist(&plist);
|
||||
bail:
|
||||
leave_playpen(Home);
|
||||
leave_playpen();
|
||||
if (isTMP)
|
||||
unlink(fname);
|
||||
return code;
|
||||
@ -201,6 +201,11 @@ pkg_do(char *pkg)
|
||||
void
|
||||
cleanup(int sig)
|
||||
{
|
||||
leave_playpen(Home);
|
||||
static int in_cleanup = 0;
|
||||
|
||||
if (!in_cleanup) {
|
||||
in_cleanup = 1;
|
||||
leave_playpen();
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: lib.h,v 1.24 1997/02/22 16:09:49 peter Exp $ */
|
||||
/* $Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp $ */
|
||||
|
||||
/*
|
||||
* FreeBSD install - a package for the installation and maintainance
|
||||
@ -108,7 +108,7 @@ int vsystem(const char *, ...);
|
||||
void cleanup(int);
|
||||
char *make_playpen(char *, size_t);
|
||||
char *where_playpen(void);
|
||||
void leave_playpen(char *);
|
||||
void leave_playpen(void);
|
||||
off_t min_free(char *);
|
||||
|
||||
/* String */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: pen.c,v 1.25 1997/10/08 07:48:12 charnier Exp $";
|
||||
"$Id: pen.c,v 1.26 1998/01/09 14:52:18 jkh Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -30,13 +30,13 @@ static const char rcsid[] =
|
||||
#include <sys/mount.h>
|
||||
|
||||
/* For keeping track of where we are */
|
||||
static char Current[FILENAME_MAX];
|
||||
static char PenLocation[FILENAME_MAX];
|
||||
static char Previous[FILENAME_MAX];
|
||||
|
||||
char *
|
||||
where_playpen(void)
|
||||
{
|
||||
return Current;
|
||||
return PenLocation;
|
||||
}
|
||||
|
||||
/* Find a good place to play. */
|
||||
@ -76,6 +76,10 @@ find_play_pen(char *pen, size_t sz)
|
||||
char *
|
||||
make_playpen(char *pen, size_t sz)
|
||||
{
|
||||
if (PenLocation[0]) {
|
||||
errx(2, "make_playpen() called before closing previous pen: %s", pen);
|
||||
return NULL;
|
||||
}
|
||||
if (!find_play_pen(pen, sz))
|
||||
return NULL;
|
||||
|
||||
@ -98,21 +102,19 @@ make_playpen(char *pen, size_t sz)
|
||||
"Please set your PKG_TMPDIR environment variable to a location\n"
|
||||
"with more space and\ntry the command again", pen);
|
||||
}
|
||||
if (Current[0])
|
||||
strcpy(Previous, Current);
|
||||
else if (!getcwd(Previous, FILENAME_MAX)) {
|
||||
if (!getcwd(Previous, FILENAME_MAX)) {
|
||||
upchuck("getcwd");
|
||||
return NULL;
|
||||
}
|
||||
if (chdir(pen) == FAIL)
|
||||
cleanup(0), errx(2, "can't chdir to '%s'", pen);
|
||||
strcpy(Current, pen);
|
||||
strcpy(PenLocation, pen);
|
||||
return Previous;
|
||||
}
|
||||
|
||||
/* Convenience routine for getting out of playpen */
|
||||
void
|
||||
leave_playpen(char *save)
|
||||
leave_playpen()
|
||||
{
|
||||
void (*oldsig)(int);
|
||||
|
||||
@ -120,15 +122,11 @@ leave_playpen(char *save)
|
||||
oldsig = signal(SIGINT, SIG_IGN);
|
||||
if (Previous[0] && chdir(Previous) == FAIL)
|
||||
cleanup(0), errx(2, "can't chdir back to '%s'", Previous);
|
||||
else if (Current[0] && strcmp(Current, Previous)) {
|
||||
if (Current[0] == '/' && vsystem("rm -rf %s", Current))
|
||||
warnx("couldn't remove temporary dir '%s'", Current);
|
||||
strcpy(Current, Previous);
|
||||
else if (PenLocation[0]) {
|
||||
if (PenLocation[0] == '/' && vsystem("rm -rf %s", PenLocation))
|
||||
warnx("couldn't remove temporary dir '%s'", PenLocation);
|
||||
}
|
||||
if (save)
|
||||
strcpy(Previous, save);
|
||||
else
|
||||
Previous[0] = '\0';
|
||||
Previous[0] = PenLocation[0] = '\0';
|
||||
signal(SIGINT, oldsig);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user