summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/lib/pen.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-26 05:04:34 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-26 05:04:34 +0000
commit42c156187e1501831aed701070935c6e1cc4fcb3 (patch)
tree604514bb78ab651f88a031808e09ad4ab444c6b4 /usr.sbin/pkg_install/lib/pen.c
parenta97cf58f2b9ffb68f4c476a5bd2e42a6e0d1648c (diff)
mostly mark signal races
Diffstat (limited to 'usr.sbin/pkg_install/lib/pen.c')
-rw-r--r--usr.sbin/pkg_install/lib/pen.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index 55160413ddb..5253fa7aa79 100644
--- a/usr.sbin/pkg_install/lib/pen.c
+++ b/usr.sbin/pkg_install/lib/pen.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: pen.c,v 1.9 2001/04/08 16:45:48 espie Exp $ */
+/* $OpenBSD: pen.c,v 1.10 2001/11/26 05:04:33 deraadt Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: pen.c,v 1.9 2001/04/08 16:45:48 espie Exp $";
+static const char *rcsid = "$OpenBSD: pen.c,v 1.10 2001/11/26 05:04:33 deraadt Exp $";
#endif
/*
@@ -29,6 +29,7 @@ static const char *rcsid = "$OpenBSD: pen.c,v 1.9 2001/04/08 16:45:48 espie Exp
#include <sys/signal.h>
#include <sys/param.h>
#include <sys/mount.h>
+#include <errno.h>
/* For keeping track of where we are */
static char Current[FILENAME_MAX];
@@ -139,27 +140,31 @@ make_playpen(char *pen, size_t pensize, size_t sz)
void
leave_playpen(char *save)
{
+ int save_errno = errno;
void (*oldsig)(int);
+ /* XXX big signal race! */
/* Don't interrupt while we're cleaning up */
oldsig = signal(SIGINT, SIG_IGN);
if (Previous[0] && chdir(Previous) == FAIL) {
- cleanup(0);
- errx(2, "can't chdir back to '%s'", Previous);
+ cleanup(0); /* XXX */
+ warnx("can't chdir back to '%s'", Previous);
+ _exit(2);
} else if (Current[0] && strcmp(Current, Previous)) {
if (strcmp(Current,"/")==0) {
fprintf(stderr,"PANIC: About to rm -rf / (not doing so, aborting)\n");
- abort();
+ abort(); /* XXX is abort safe? */
}
if (vsystem("rm -rf %s", Current))
pwarnx("couldn't remove temporary dir '%s'", Current);
- strcpy(Current, Previous);
+ strcpy(Current, Previous); /* XXX */
}
if (save)
- strcpy(Previous, save);
+ strcpy(Previous, save); /* XXX */
else
Previous[0] = '\0';
signal(SIGINT, oldsig);
+ errno = save_errno;
}
off_t