Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/coreutils/chgrp.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/coreutils/chgrp.c
r821 r1770 8 8 */ 9 9 10 /* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */ 11 /* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */ 12 /* BB_AUDIT Note: gnu chgrp does not support -H, -L, or -P. */ 10 /* BB_AUDIT SUSv3 defects - none? */ 11 /* BB_AUDIT GNU defects - unsupported long options. */ 13 12 /* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */ 14 13 15 #include <stdlib.h> 16 #include <unistd.h> 17 #include "busybox.h" 14 #include "libbb.h" 18 15 19 /* Don't use lchown glibc older then 2.1.x */ 20 #if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1) 21 #define lchown chown 22 #endif 16 /* This is a NOEXEC applet. Be very careful! */ 23 17 24 static int fileAction(const char *fileName, struct stat *statbuf, void* junk)25 {26 if (lchown(fileName, statbuf->st_uid, *((long *) junk)) == 0) {27 return (TRUE);28 }29 bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */30 return (FALSE);31 }32 18 19 int chgrp_main(int argc, char **argv); 33 20 int chgrp_main(int argc, char **argv) 34 21 { 35 long gid; 36 int recursiveFlag; 37 int retval = EXIT_SUCCESS; 38 39 recursiveFlag = bb_getopt_ulflags(argc, argv, "R"); 40 41 if (argc - optind < 2) { 42 bb_show_usage(); 22 /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ 23 char **p = argv; 24 while (*++p) { 25 if (p[0][0] != '-') { 26 p[0] = xasprintf(":%s", p[0]); 27 break; 28 } 43 29 } 44 45 argv += optind; 46 47 /* Find the selected group */ 48 gid = get_ug_id(*argv, bb_xgetgrnam); 49 ++argv; 50 51 /* Ok, ready to do the deed now */ 52 do { 53 if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE, 54 fileAction, fileAction, &gid)) { 55 retval = EXIT_FAILURE; 56 } 57 } while (*++argv); 58 59 return retval; 30 return chown_main(argc, argv); 60 31 }
Note:
See TracChangeset
for help on using the changeset viewer.