diff options
author | Jim Meyering <jim@meyering.net> | 1999-04-26 13:22:23 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-04-26 13:22:23 +0000 |
commit | 22cce6dadc901db6a9dcb587c9ad19a23d5284db (patch) | |
tree | 19905bd89d37bd89c8001c4933cf78139d018e6d /lib | |
parent | 82893aff556f8f6ffed37e0fdcce9d7aca50dfba (diff) | |
download | coreutils-22cce6dadc901db6a9dcb587c9ad19a23d5284db.tar.xz |
(S_IRWXU, S_IRWXG, S_IRWXO): Define if not defined.
Use proper mode_t types and macros.
Don't assume the traditional Unix values for mode bits.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mkdir.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/mkdir.c b/lib/mkdir.c index 5ca5af696..1829a9e25 100644 --- a/lib/mkdir.c +++ b/lib/mkdir.c @@ -34,6 +34,16 @@ extern int errno; # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif +#ifndef S_IRWXU +# define S_IRWXU 0700 +#endif +#ifndef S_IRWXG +# define S_IRWXG 0070 +#endif +#ifndef S_IRWXO +# define S_IRWXO 0007 +#endif + /* mkdir adapted from GNU tar. */ /* Make directory DPATH, with permission mode DMODE. @@ -48,9 +58,10 @@ extern int errno; subroutine didn't return EEXIST. It does now. */ int -mkdir (const char *dpath, int dmode) +mkdir (const char *dpath, mode_t dmode) { pid_t cpid; + mode_t mode; int status; struct stat statbuf; @@ -75,8 +86,9 @@ mkdir (const char *dpath, int dmode) process is going away anyway, we zap its umask. This won't suffice to set SUID, SGID, etc. on this directory, so the parent process calls chmod afterward. */ - status = umask (0); /* Get current umask. */ - umask (status | (0777 & ~dmode)); /* Set for mkdir. */ + mode = umask (0); /* Get current umask. */ + /* Set for mkdir. */ + umask (mode | ((S_IRWXU | S_IRWXG | S_IRWXO) & ~dmode)); execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); _exit (1); |