~ubuntu-branches/ubuntu/raring/shadow/raring-proposed

« back to all changes in this revision

Viewing changes to src/groupmems.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2010-11-24 13:42:42 UTC
  • mfrom: (1.1.9 upstream) (18.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20101124134242-832f4tew5s81ntj7
Tags: 1:4.1.4.2+svn3283-2ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Ubuntu specific:
    + debian/login.defs: use SHA512 by default for password crypt routine.
  - debian/{source_shadow.py,rules}: Add apport hook
  - debian/rules: fix FTBFS from newer libtools
  - debian/patches/495_stdout-encrypted-password: chpasswd can report
    password hashes on stdout (Debian bug 505640).
  - Rework 495_stdout-encrypted-password to cope with chpasswd using PAM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Copyright (c) 2000       , International Business Machines
3
3
 *                            George Kraft IV, gk4@us.ibm.com, 03/23/2000
4
4
 * Copyright (c) 2000 - 2006, Tomasz Kłoczko
5
 
 * Copyright (c) 2007 - 2008, Nicolas François
 
5
 * Copyright (c) 2007 - 2009, Nicolas François
6
6
 * All rights reserved.
7
7
 *
8
8
 * Redistribution and use in source and binary forms, with or without
64
64
/*
65
65
 * Global variables
66
66
 */
67
 
char *Prog;
 
67
const char *Prog;
68
68
 
69
69
static char *adduser = NULL;
70
70
static char *deluser = NULL;
88
88
                         const struct group *grp);
89
89
static void purge_members (const struct group *grp);
90
90
static void display_members (const char *const *members);
91
 
static void usage (void);
 
91
static void usage (int status);
92
92
static void process_flags (int argc, char **argv);
93
93
static void check_perms (void);
94
94
static void fail_exit (int code);
361
361
        }
362
362
}
363
363
 
364
 
static void usage (void)
 
364
static void usage (int status)
365
365
{
366
 
        (void) fputs (_("Usage: groupmems [options] [action]\n"
367
 
                        "\n"
368
 
                        "Options:\n"
369
 
                        "  -g, --group groupname         change groupname instead of the user's group\n"
370
 
                        "                                (root only)\n"
371
 
                        "\n"
372
 
                        "Actions:\n"
373
 
                        "  -a, --add username            add username to the members of the group\n"
374
 
                        "  -d, --delete username         remove username from the members of the group\n"
375
 
                        "  -p, --purge                   purge all members from the group\n"
376
 
                        "  -l, --list                    list the members of the group\n"
377
 
                        "\n"), stderr);
378
 
        fail_exit (EXIT_USAGE);
 
366
        FILE *usageout = (EXIT_SUCCESS != status) ? stderr : stdout;
 
367
        (void) fprintf (usageout,
 
368
                        _("Usage: %s [options] [action]\n"
 
369
                          "\n"
 
370
                          "Options:\n"),
 
371
                        Prog);
 
372
        (void) fputs (_("  -g, --group groupname         change groupname instead of the user's group\n"
 
373
                        "                                (root only)\n"), usageout);
 
374
        (void) fputs (_("\n"), usageout);
 
375
        (void) fputs (_("Actions:\n"), usageout);
 
376
        (void) fputs (_("  -a, --add username            add username to the members of the group\n"), usageout);
 
377
        (void) fputs (_("  -d, --delete username         remove username from the members of the group\n"), usageout);
 
378
        (void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
 
379
        (void) fputs (_("  -p, --purge                   purge all members from the group\n"), usageout);
 
380
        (void) fputs (_("  -l, --list                    list the members of the group\n"), usageout);
 
381
        fail_exit (status);
379
382
}
380
383
 
381
384
/*
389
392
                {"add", required_argument, NULL, 'a'},
390
393
                {"delete", required_argument, NULL, 'd'},
391
394
                {"group", required_argument, NULL, 'g'},
 
395
                {"help", no_argument, NULL, 'h'},
392
396
                {"list", no_argument, NULL, 'l'},
393
397
                {"purge", no_argument, NULL, 'p'},
394
398
                {NULL, 0, NULL, '\0'}
395
399
        };
396
400
 
397
 
        while ((arg = getopt_long (argc, argv, "a:d:g:lp", long_options,
 
401
        while ((arg = getopt_long (argc, argv, "a:d:g:hlp", long_options,
398
402
                                   &option_index)) != EOF) {
399
403
                switch (arg) {
400
404
                case 'a':
408
412
                case 'g':
409
413
                        thisgroup = xstrdup (optarg);
410
414
                        break;
 
415
                case 'h':
 
416
                        usage (EXIT_SUCCESS);
 
417
                        break;
411
418
                case 'l':
412
419
                        list = true;
413
420
                        ++exclusive;
417
424
                        ++exclusive;
418
425
                        break;
419
426
                default:
420
 
                        usage ();
 
427
                        usage (EXIT_USAGE);
421
428
                }
422
429
        }
423
430
 
424
431
        if ((exclusive > 1) || (optind < argc)) {
425
 
                usage ();
 
432
                usage (EXIT_USAGE);
426
433
        }
427
434
 
428
435
        /* local, no need for xgetpwnam */