diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2015-07-19 18:27:27 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2015-07-19 18:27:27 +0000 |
commit | 73d7f7b9284bec53c04be79a8c6dfb02f961a0e3 (patch) | |
tree | 9e10b27a8d7957bba4facc570d8c9a3bf024c22b /usr.bin/xinstall/xinstall.c | |
parent | e3b22269d4f10ceed13504d466cc3f8bcc436c3e (diff) |
when using -D, do not use the mode set for the target file as the directory mode
ok millert@
Diffstat (limited to 'usr.bin/xinstall/xinstall.c')
-rw-r--r-- | usr.bin/xinstall/xinstall.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 2084ab20834..d48e0b3d6c7 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xinstall.c,v 1.61 2015/07/18 15:42:37 jasper Exp $ */ +/* $OpenBSD: xinstall.c,v 1.62 2015/07/19 18:27:26 jasper Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* @@ -72,7 +72,7 @@ gid_t gid; void copy(int, char *, int, char *, off_t, int); int compare(int, const char *, off_t, int, const char *, off_t); void install(char *, char *, u_long, u_int); -void install_dir(char *); +void install_dir(char *, int); void strip(char *); void usage(void); int create_newfile(char *, struct stat *); @@ -167,7 +167,7 @@ main(int argc, char *argv[]) if (dodir) { for (; *argv != NULL; ++argv) - install_dir(*argv); + install_dir(*argv, mode); exit(EX_OK); /* NOTREACHED */ } @@ -176,7 +176,12 @@ main(int argc, char *argv[]) char *dest = dirname(argv[argc - 1]); if (dest == NULL) errx(EX_OSERR, "cannot determine dirname"); - install_dir(dest); + /* + * When -D is passed, do not chmod the directory with the mode set for + * the target file. If more restrictive permissions are required then + * '-d -m' ought to be used instead. + */ + install_dir(dest, 0755); } no_target = stat(to_name = argv[argc - 1], &to_sb); @@ -572,7 +577,7 @@ strip(char *to_name) * build directory hierarchy */ void -install_dir(char *path) +install_dir(char *path, int mode) { char *p; struct stat sb; |