*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
+//config:config CHOWN
+//config: bool "chown (7.6 kb)"
+//config: default y
+//config: help
+//config: chown is used to change the user and/or group ownership
+//config: of files.
+//config:
+//config:config FEATURE_CHOWN_LONG_OPTIONS
+//config: bool "Enable long options"
+//config: default y
+//config: depends on CHOWN && LONG_OPTS
+
+//applet:IF_CHOWN(APPLET_NOEXEC(chown, chown, BB_DIR_BIN, BB_SUID_DROP, chown))
+
+//kbuild:lib-$(CONFIG_CHOWN) += chown.o
/* BB_AUDIT SUSv3 defects - none? */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
//usage:#define chown_trivial_usage
-//usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... OWNER[<.|:>[GROUP]] FILE..."
+//usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... USER[:[GRP]] FILE..."
//usage:#define chown_full_usage "\n\n"
-//usage: "Change the owner and/or group of each FILE to OWNER and/or GROUP\n"
+//usage: "Change the owner and/or group of each FILE to USER and/or GRP\n"
//usage: "\n -R Recurse"
//usage: "\n -h Affect symlinks instead of symlink targets"
//usage: IF_DESKTOP(
/* This is a NOEXEC applet. Be very careful! */
-#define OPT_STR ("Rh" IF_DESKTOP("vcfLHP"))
+#define OPT_STR "Rh" IF_DESKTOP("vcfLHP")
#define BIT_RECURSE 1
#define OPT_RECURSE (opt & 1)
#define OPT_NODEREF (opt & 2)
int opt, flags;
struct param_t param;
- /* Just -1 might not work: uid_t may be unsigned long */
- param.ugid.uid = -1L;
- param.ugid.gid = -1L;
-
#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
- applet_long_options = chown_longopts;
+ opt = getopt32long(argv, "^" OPT_STR "\0" "-2", chown_longopts);
+#else
+ opt = getopt32(argv, "^" OPT_STR "\0" "-2");
#endif
- opt_complementary = "-2";
- opt = getopt32(argv, OPT_STR);
argv += optind;
/* This matches coreutils behavior (almost - see below) */