diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-27 23:28:38 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-27 23:28:38 +0000 |
commit | e80e2a3660bf09cc549cb2dfd2bdeb77ccde1231 (patch) | |
tree | 94303277042044e84dbdc28e2c2457e5b27009d4 /coreutils | |
parent | 3b8fc1c582884d356df04b4984db3963bc129c48 (diff) | |
download | busybox-e80e2a3660bf09cc549cb2dfd2bdeb77ccde1231.tar.gz |
chgrp: just call chown! :)
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Kbuild | 2 | ||||
-rw-r--r-- | coreutils/chgrp.c | 48 |
2 files changed, 11 insertions, 39 deletions
diff --git a/coreutils/Kbuild b/coreutils/Kbuild index cf1718419..cfb508d81 100644 --- a/coreutils/Kbuild +++ b/coreutils/Kbuild @@ -11,7 +11,7 @@ lib-$(CONFIG_BASENAME) += basename.o lib-$(CONFIG_CAL) += cal.o lib-$(CONFIG_CAT) += cat.o lib-$(CONFIG_CATV) += catv.o -lib-$(CONFIG_CHGRP) += chgrp.o +lib-$(CONFIG_CHGRP) += chgrp.o chown.o lib-$(CONFIG_CHMOD) += chmod.o lib-$(CONFIG_CHOWN) += chown.o lib-$(CONFIG_CHROOT) += chroot.o diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c index e62bd16f0..da5b12964 100644 --- a/coreutils/chgrp.c +++ b/coreutils/chgrp.c @@ -7,49 +7,21 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */ -/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */ -/* BB_AUDIT Note: gnu chgrp does not support -H, -L, or -P. */ +/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */ +/* BB_AUDIT GNU defects - unsupported long options. */ /* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */ -#include <stdlib.h> -#include <unistd.h> #include "busybox.h" -static int fileAction(const char *fileName, struct stat *statbuf, void* junk) -{ - if (lchown(fileName, statbuf->st_uid, *((long *) junk)) == 0) { - return (TRUE); - } - bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */ - return (FALSE); -} - int chgrp_main(int argc, char **argv) { - long gid; - int recursiveFlag; - int retval = EXIT_SUCCESS; - - recursiveFlag = getopt32(argc, argv, "R"); - - if (argc - optind < 2) { - bb_show_usage(); - } - - argv += optind; - - /* Find the selected group */ - gid = get_ug_id(*argv, bb_xgetgrnam); - ++argv; - - /* Ok, ready to do the deed now */ - do { - if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE, - fileAction, fileAction, &gid)) { - retval = EXIT_FAILURE; + /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ + char **p = argv; + while (*++p) { + if (p[0][0] != '-') { + p[0] = xasprintf(":%s", p[0]); + break; } - } while (*++argv); - - return retval; + } + return chown_main(argc, argv); } |