summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-04-25 05:09:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-04-25 05:09:08 +0000
commita61f8bc4e46cda34ca2b67fff5c53fba4ba4e7ab (patch)
tree9e1f87c823a69f1668dc8d8efa59335ab583db66 /usr.sbin/pkg_install/lib
parent6ab4aad5ac1df1eb874c34310d43edd1717908cd (diff)
Use mkdtemp(3), not mktemp(3).
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-rw-r--r--usr.sbin/pkg_install/lib/pen.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index e31c8ff8fce..31b35e22f5f 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.5 1997/07/14 14:13:17 graichen Exp $ */
+/* $OpenBSD: pen.c,v 1.6 1998/04/25 05:09:07 millert Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: pen.c,v 1.5 1997/07/14 14:13:17 graichen Exp $";
+static const char *rcsid = "$OpenBSD: pen.c,v 1.6 1998/04/25 05:09:07 millert Exp $";
#endif
/*
@@ -74,36 +74,18 @@ find_play_pen(char *pen, size_t sz)
char *
make_playpen(char *pen, size_t sz)
{
- char *tmp;
- int i = 0;
- mode_t um;
- um = umask(S_IWGRP|S_IWOTH);
- while (1) {
- if (!find_play_pen(pen, sz)) {
- umask(um);
- return NULL;
- }
-
- if (!mktemp(pen)) {
- barf("Can't mktemp '%s'.", pen);
- umask(um);
- return NULL;
- }
-
- if (mkdir(pen, 0755) == FAIL) {
- if (i++ < 100) {
- /* try again! */
- continue;
- }
- } else
- break;
-
- barf("Can't mkdir '%s'.", pen);
- umask(um);
+ if (!find_play_pen(pen, sz)) {
+ return NULL;
+ }
+ if (!mkdtemp(pen)) {
+ barf("Can't mkdtemp '%s'.", pen);
+ return NULL;
+ }
+ if (chmod(pen, 0755) == FAIL) {
+ barf("Can't chmod 0755 '%s'.", pen);
return NULL;
}
- umask(um);
if (Verbose) {
if (sz)