Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/coreutils/chgrp.c

    r821 r1765  
    88 */
    99
    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. */
    1312/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
    1413
    15 #include <stdlib.h>
    16 #include <unistd.h>
    17 #include "busybox.h"
     14#include "libbb.h"
    1815
    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! */
    2317
    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 }
    3218
     19int chgrp_main(int argc, char **argv);
    3320int chgrp_main(int argc, char **argv)
    3421{
    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        }
    4329    }
    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);
    6031}
Note: See TracChangeset for help on using the changeset viewer.