*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
+//config:config CHMOD
+//config: bool "chmod (5.1 kb)"
+//config: default y
+//config: help
+//config: chmod is used to change the access permission of files.
+
+//applet:IF_CHMOD(APPLET_NOEXEC(chmod, chmod, BB_DIR_BIN, BB_SUID_DROP, chmod))
+
+//kbuild:lib-$(CONFIG_CHMOD) += chmod.o
/* BB_AUDIT SUSv3 compliant */
/* BB_AUDIT GNU defects - unsupported long options. */
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) {
}
/* Parse options */
- opt_complementary = "-2";
- getopt32(argv, ("-"OPT_STR) + 1); /* Reuse string */
+ getopt32(argv, "^" OPT_STR "\0" "-2");
argv += optind;
/* Restore option-like mode if needed */