summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/chmod.c4
-rw-r--r--coreutils/install.c2
-rw-r--r--coreutils/libcoreutils/getopt_mk_fifo_nod.c4
-rw-r--r--coreutils/mkdir.c4
4 files changed, 8 insertions, 6 deletions
diff --git a/coreutils/chmod.c b/coreutils/chmod.c
index 5ee45b9..a21c6d5 100644
--- a/coreutils/chmod.c
+++ b/coreutils/chmod.c
@@ -69,9 +69,9 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void
if (S_ISLNK(statbuf->st_mode))
return TRUE;
}
- newmode = statbuf->st_mode;
- if (!bb_parse_mode((char *)param, &newmode))
+ newmode = bb_parse_mode((char *)param, statbuf->st_mode);
+ if (newmode == (mode_t)-1)
bb_error_msg_and_die("invalid mode '%s'", (char *)param);
if (chmod(fileName, newmode) == 0) {
diff --git a/coreutils/install.c b/coreutils/install.c
index 73f9c70..8aa51cc 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -159,7 +159,7 @@ int install_main(int argc, char **argv)
}
mode = 0755; /* GNU coreutils 6.10 compat */
if (opts & OPT_MODE)
- bb_parse_mode(mode_str, &mode);
+ mode = bb_parse_mode(mode_str, mode);
uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
index 2227171..47375ff 100644
--- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c
+++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
@@ -33,7 +33,9 @@ mode_t FAST_FUNC getopt_mk_fifo_nod(char **argv)
int opt;
opt = getopt32(argv, "m:" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
if (opt & 1) {
- if (bb_parse_mode(smode, &mode))
+ mode = bb_parse_mode(smode, mode);
+ if (mode != (mode_t)-1) /* if mode is valid */
+ /* make future mknod/mkfifo set mode bits exactly */
umask(0);
}
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 864edfb..6f7b004 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -71,8 +71,8 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
#endif
opt = getopt32(argv, "m:pv" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
if (opt & 1) {
- mode_t mmode = 0777;
- if (!bb_parse_mode(smode, &mmode)) {
+ mode_t mmode = bb_parse_mode(smode, 0777);
+ if (mmode == (mode_t)-1) {
bb_error_msg_and_die("invalid mode '%s'", smode);
}
mode = mmode;