X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=coreutils%2Fchown.c;h=985d18d6f43b5a58d01e39c5a867c581ea2f2024;hb=22542eca18e5807b72ddc78999f5101e33f17a53;hp=cb07bbcbb91d42e76b014acc60fa1fef52585b89;hpb=16ca379b55eb5dc1cacfaabf4ca026c49fb516bd;p=oweals%2Fbusybox.git diff --git a/coreutils/chown.c b/coreutils/chown.c index cb07bbcbb..985d18d6f 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c @@ -6,14 +6,29 @@ * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ +//config:config CHOWN +//config: bool "chown (7.2 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: "[-RhLHP"IF_DESKTOP("cvf")"]... 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( @@ -40,7 +55,7 @@ /* 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) @@ -112,15 +127,11 @@ int chown_main(int argc UNUSED_PARAM, char **argv) 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) */