aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1998-02-16 17:16:51 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1998-02-16 17:16:51 +0000
commit79af7eafa8aca94dba0e792b27349453804a3576 (patch)
treee8ebee7bb42150ce34c5d27002854ff57eee1ced /usr.sbin/pkg_install
parent22b8189d6782d83e0f9d9ea1855c655d52f4bdc5 (diff)
Notes
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/add/perform.c21
-rw-r--r--usr.sbin/pkg_install/create/perform.c11
-rw-r--r--usr.sbin/pkg_install/info/perform.c11
-rw-r--r--usr.sbin/pkg_install/lib/lib.h4
-rw-r--r--usr.sbin/pkg_install/lib/pen.c30
5 files changed, 45 insertions, 32 deletions
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 10b26286d205..983c835ae768 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -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);
}
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 21dbaa614a4d..f04562e4c110 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -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);
}
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index 5625f621fbdb..1d7f14f23a58 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -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);
}
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 5d16f5625f97..a0de2a459bc9 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -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 */
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index e34e6286efbf..0549f27fe950 100644
--- a/usr.sbin/pkg_install/lib/pen.c
+++ b/usr.sbin/pkg_install/lib/pen.c
@@ -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);
}