diff options
author | ache <ache@FreeBSD.org> | 1997-10-28 14:20:10 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-10-28 14:20:10 +0000 |
commit | 2603f3ad79f649a321ba17f98bd34b17f4f406bc (patch) | |
tree | dc7933f48fc321d8c147f56d28f5e0d25b061bac /usr.bin/xinstall | |
parent | 974f2bea1556f5ae1054c9eb170a5205429a982a (diff) | |
download | FreeBSD-src-2603f3ad79f649a321ba17f98bd34b17f4f406bc.zip FreeBSD-src-2603f3ad79f649a321ba17f98bd34b17f4f406bc.tar.gz |
1) Create intermediate directories with 755, not 777
2) Exit with error diagnostic if file exists but not a directory (-d)
3) Do chmod independently of chown (-d)
Diffstat (limited to 'usr.bin/xinstall')
-rw-r--r-- | usr.bin/xinstall/xinstall.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index d7f607a..53c7f9c 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #endif static const char rcsid[] = - "$Id: xinstall.c,v 1.25 1997/09/14 08:21:44 peter Exp $"; + "$Id: xinstall.c,v 1.26 1997/10/27 22:53:33 ache Exp $"; #endif /* not lint */ /*- @@ -669,18 +669,19 @@ install_dir(path) ch = *p; *p = '\0'; if (stat(path, &sb)) { - if (errno != ENOENT || mkdir(path, 0777) < 0) { + if (errno != ENOENT || mkdir(path, 0755) < 0) { err(EX_OSERR, "mkdir %s", path); /* NOTREACHED */ } - } + } else if (!S_ISDIR(sb.st_mode)) + errx(EX_OSERR, "%s exists but is not a directory", path); if (!(*p = ch)) break; } if ((gid != (gid_t)-1 || uid != (uid_t)-1) && chown(path, uid, gid)) warn("chown %u:%u %s", uid, gid, path); - else if (chmod(path, mode)) + if (chmod(path, mode)) warn("chmod %o %s", mode, path); } |