2007-10-07 17:17:57 +05:30
|
|
|
/*
|
2008-04-27 06:10:09 +05:30
|
|
|
* Copyright (c) 2000 , International Business Machines
|
|
|
|
* George Kraft IV, gk4@us.ibm.com, 03/23/2000
|
|
|
|
* Copyright (c) 2000 - 2006, Tomasz Kłoczko
|
|
|
|
* Copyright (c) 2007 - 2008, Nicolas François
|
2007-10-07 17:17:57 +05:30
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2008-04-27 06:10:09 +05:30
|
|
|
* 3. The name of the copyright holders or contributors may not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
2007-10-07 17:17:57 +05:30
|
|
|
*
|
2008-04-27 06:10:09 +05:30
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2007-10-07 17:17:57 +05:30
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <grp.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef USE_PAM
|
|
|
|
#include "pam_defs.h"
|
|
|
|
#endif /* USE_PAM */
|
2007-10-07 17:18:07 +05:30
|
|
|
#include <pwd.h>
|
2007-10-07 17:17:57 +05:30
|
|
|
#include "defines.h"
|
2008-07-27 05:51:42 +05:30
|
|
|
#include "prototypes.h"
|
2007-10-07 17:17:57 +05:30
|
|
|
#include "groupio.h"
|
|
|
|
|
|
|
|
/* Exit Status Values */
|
|
|
|
|
|
|
|
#define EXIT_SUCCESS 0 /* success */
|
|
|
|
#define EXIT_USAGE 1 /* invalid command syntax */
|
|
|
|
#define EXIT_GROUP_FILE 2 /* group file access problems */
|
2007-10-07 20:06:51 +05:30
|
|
|
#define EXIT_NOT_ROOT 3 /* not superuser */
|
|
|
|
#define EXIT_NOT_EROOT 4 /* not effective superuser */
|
2007-10-07 17:17:57 +05:30
|
|
|
#define EXIT_NOT_PRIMARY 5 /* not primary owner of group */
|
|
|
|
#define EXIT_NOT_MEMBER 6 /* member of group does not exist */
|
|
|
|
#define EXIT_MEMBER_EXISTS 7 /* member of group already exists */
|
2008-07-26 21:41:49 +05:30
|
|
|
#define EXIT_INVALID_USER 8 /* specified user does not exist */
|
|
|
|
#define EXIT_INVALID_GROUP 9 /* specified group does not exist */
|
2007-10-07 17:17:57 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
static char *adduser = NULL;
|
|
|
|
static char *deluser = NULL;
|
|
|
|
static char *thisgroup = NULL;
|
2008-07-26 21:54:27 +05:30
|
|
|
static bool purge = false;
|
|
|
|
static bool list = false;
|
2007-10-07 17:17:57 +05:30
|
|
|
static int exclusive = 0;
|
2008-07-26 21:41:49 +05:30
|
|
|
static char *Prog;
|
2008-07-27 07:05:08 +05:30
|
|
|
static bool group_locked = false;
|
2007-10-07 17:17:57 +05:30
|
|
|
|
2008-07-27 07:17:56 +05:30
|
|
|
static char *whoami (void);
|
2008-08-10 04:58:30 +05:30
|
|
|
static void display_members (char **members);
|
2008-07-27 07:17:56 +05:30
|
|
|
static void usage (void);
|
2008-07-27 06:29:42 +05:30
|
|
|
static void process_flags (int argc, char **argv);
|
|
|
|
static void check_perms (void);
|
2008-07-27 07:05:08 +05:30
|
|
|
static void fail_exit (int code);
|
2008-07-27 05:41:25 +05:30
|
|
|
#define isroot() (getuid () == 0)
|
2007-10-07 17:17:57 +05:30
|
|
|
|
|
|
|
static char *whoami (void)
|
|
|
|
{
|
* lib/prototypes.h, configure.in, libmisc/Makefile.am,
libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetpwuid.c,
libmisc/xgetgrnam.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c:
Added functions xgetpwnam(), xgetpwuid(), xgetgrnam(),
xgetgrgid(), and xgetspnam(). They allocate memory for the
returned structure and are more robust to successive calls. They
are implemented with the libc's getxxyyy_r() functions if
available.
* libmisc/limits.c, libmisc/entry.c, libmisc/chowntty.c,
libmisc/addgrps.c, libmisc/myname.c, libmisc/rlogin.c,
libmisc/pwdcheck.c, src/newgrp.c, src/login_nopam.c,
src/userdel.c, src/lastlog.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/chfn.c, src/groupmems.c,
src/usermod.c, src/expiry.c, src/groupdel.c, src/chgpasswd.c,
src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/suauth.c,
src/faillog.c, src/groups.c, src/chsh.c, src/id.c: Review all the
usage of one of the getpwnam(), getpwuid(), getgrnam(),
getgrgid(), and getspnam() functions. It was noticed on
http://bugs.debian.org/341230 that chfn and chsh use a passwd
structure after calling a pam function, which result in using
information from the passwd structure requested by pam, not the
original one. It is much easier to use the new xget... functions
to avoid these issues. I've checked which call to the original
get... functions could be left (reducing the scope of the
structure if possible), and I've left comments to ease future
reviews (e.g. /* local, no need for xgetpwnam */).
Note: the getpwent/getgrent calls should probably be checked also.
* src/groupdel.c, src/expiry.c: Fix typos in comments.
* src/groupmod.c: Re-indent.
* libmisc/Makefile.am, lib/groupmem.c, lib/groupio.c, lib/pwmem.c,
lib/pwio.c, lib/shadowmem.c, lib/shadowio.c: Move the __<xx>_dup
functions (used by the xget... functions) from the <xx>io.c files
to the new <xx>mem.c files. This avoid linking some utils against
the SELinux library.
2007-11-19 04:45:26 +05:30
|
|
|
/* local, no need for xgetgrgid */
|
2007-10-07 17:17:57 +05:30
|
|
|
struct group *grp = getgrgid (getgid ());
|
* lib/prototypes.h, configure.in, libmisc/Makefile.am,
libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetpwuid.c,
libmisc/xgetgrnam.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c:
Added functions xgetpwnam(), xgetpwuid(), xgetgrnam(),
xgetgrgid(), and xgetspnam(). They allocate memory for the
returned structure and are more robust to successive calls. They
are implemented with the libc's getxxyyy_r() functions if
available.
* libmisc/limits.c, libmisc/entry.c, libmisc/chowntty.c,
libmisc/addgrps.c, libmisc/myname.c, libmisc/rlogin.c,
libmisc/pwdcheck.c, src/newgrp.c, src/login_nopam.c,
src/userdel.c, src/lastlog.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/chfn.c, src/groupmems.c,
src/usermod.c, src/expiry.c, src/groupdel.c, src/chgpasswd.c,
src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/suauth.c,
src/faillog.c, src/groups.c, src/chsh.c, src/id.c: Review all the
usage of one of the getpwnam(), getpwuid(), getgrnam(),
getgrgid(), and getspnam() functions. It was noticed on
http://bugs.debian.org/341230 that chfn and chsh use a passwd
structure after calling a pam function, which result in using
information from the passwd structure requested by pam, not the
original one. It is much easier to use the new xget... functions
to avoid these issues. I've checked which call to the original
get... functions could be left (reducing the scope of the
structure if possible), and I've left comments to ease future
reviews (e.g. /* local, no need for xgetpwnam */).
Note: the getpwent/getgrent calls should probably be checked also.
* src/groupdel.c, src/expiry.c: Fix typos in comments.
* src/groupmod.c: Re-indent.
* libmisc/Makefile.am, lib/groupmem.c, lib/groupio.c, lib/pwmem.c,
lib/pwio.c, lib/shadowmem.c, lib/shadowio.c: Move the __<xx>_dup
functions (used by the xget... functions) from the <xx>io.c files
to the new <xx>mem.c files. This avoid linking some utils against
the SELinux library.
2007-11-19 04:45:26 +05:30
|
|
|
/* local, no need for xgetpwuid */
|
2007-10-07 17:17:57 +05:30
|
|
|
struct passwd *usr = getpwuid (getuid ());
|
|
|
|
|
2008-07-28 04:00:31 +05:30
|
|
|
if ( (NULL != usr)
|
|
|
|
&& (NULL != grp)
|
|
|
|
&& (0 == strcmp (usr->pw_name, grp->gr_name))) {
|
2008-07-28 04:00:22 +05:30
|
|
|
return xstrdup (usr->pw_name);
|
2007-10-07 17:17:57 +05:30
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 04:58:30 +05:30
|
|
|
static void display_members (char **members)
|
2007-10-07 17:17:57 +05:30
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; NULL != members[i]; i++) {
|
|
|
|
printf ("%s ", members[i]);
|
|
|
|
|
|
|
|
if (NULL == members[i + 1]) {
|
|
|
|
printf ("\n");
|
|
|
|
} else {
|
|
|
|
printf (" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usage (void)
|
|
|
|
{
|
2008-07-30 05:57:55 +05:30
|
|
|
(void) fputs (_("Usage: groupmems -a username | -d username | -p | -l [-g groupname]\n"), stderr);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_USAGE);
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
|
|
|
|
2008-07-27 06:29:42 +05:30
|
|
|
/*
|
|
|
|
* process_flags - perform command line argument setting
|
|
|
|
*/
|
|
|
|
static void process_flags (int argc, char **argv)
|
2007-10-07 17:17:57 +05:30
|
|
|
{
|
|
|
|
int arg;
|
|
|
|
int option_index = 0;
|
|
|
|
static struct option long_options[] = {
|
|
|
|
{"add", required_argument, NULL, 'a'},
|
|
|
|
{"delete", required_argument, NULL, 'd'},
|
|
|
|
{"group", required_argument, NULL, 'g'},
|
|
|
|
{"list", no_argument, NULL, 'l'},
|
|
|
|
{"purge", no_argument, NULL, 'p'},
|
|
|
|
{NULL, 0, NULL, '\0'}
|
|
|
|
};
|
|
|
|
|
2008-07-27 06:29:42 +05:30
|
|
|
while ((arg = getopt_long (argc, argv, "a:d:g:lp", long_options,
|
|
|
|
&option_index)) != EOF) {
|
2007-10-07 17:17:57 +05:30
|
|
|
switch (arg) {
|
|
|
|
case 'a':
|
2008-07-28 04:00:22 +05:30
|
|
|
adduser = xstrdup (optarg);
|
2007-10-07 17:17:57 +05:30
|
|
|
++exclusive;
|
|
|
|
break;
|
|
|
|
case 'd':
|
2008-07-28 04:00:22 +05:30
|
|
|
deluser = xstrdup (optarg);
|
2007-10-07 17:17:57 +05:30
|
|
|
++exclusive;
|
|
|
|
break;
|
|
|
|
case 'p':
|
2008-07-26 21:54:27 +05:30
|
|
|
purge = true;
|
2007-10-07 17:17:57 +05:30
|
|
|
++exclusive;
|
|
|
|
break;
|
|
|
|
case 'g':
|
2008-07-28 04:00:22 +05:30
|
|
|
thisgroup = xstrdup (optarg);
|
2007-10-07 17:17:57 +05:30
|
|
|
break;
|
|
|
|
case 'l':
|
2008-07-26 21:54:27 +05:30
|
|
|
list = true;
|
2007-10-07 17:17:57 +05:30
|
|
|
++exclusive;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if ((exclusive > 1) || (optind < argc)) {
|
2007-10-07 17:17:57 +05:30
|
|
|
usage ();
|
|
|
|
}
|
|
|
|
|
2008-07-26 21:54:27 +05:30
|
|
|
/* local, no need for xgetpwnam */
|
2008-07-30 19:41:09 +05:30
|
|
|
if ( (NULL != adduser)
|
|
|
|
&& (getpwnam (adduser) == NULL)) {
|
* src/chfn.c, src/chsh.c, src/groupdel.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/login.c, src/logoutd.c,
src/newgrp.c, src/newusers.c, src/passwd.c, src/pwck.c,
src/suauth.c, src/useradd.c, src/userdel.c, src/usermod.c,
src/vipw.c: Complete the switch from the `' quotation style to ''.
Do it also in SYSLOG messages. Quote some parameters. All this
permits to merge some messages.
2008-08-06 21:21:52 +05:30
|
|
|
fprintf (stderr, _("%s: user '%s' does not exist\n"),
|
2008-07-26 21:41:49 +05:30
|
|
|
Prog, adduser);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_INVALID_USER);
|
2008-07-26 21:41:49 +05:30
|
|
|
}
|
|
|
|
|
2008-07-27 06:29:42 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static void check_perms (void)
|
|
|
|
{
|
|
|
|
#ifdef USE_PAM
|
|
|
|
pam_handle_t *pamh = NULL;
|
2008-07-27 07:11:07 +05:30
|
|
|
int retval = PAM_SUCCESS;
|
|
|
|
struct passwd *pampw;
|
2007-10-07 17:17:57 +05:30
|
|
|
|
2008-07-27 07:11:07 +05:30
|
|
|
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
2008-07-28 04:00:12 +05:30
|
|
|
if (NULL == pampw) {
|
2008-07-27 07:11:07 +05:30
|
|
|
retval = PAM_USER_UNKNOWN;
|
2008-07-28 04:00:47 +05:30
|
|
|
} else {
|
2008-07-27 07:11:07 +05:30
|
|
|
retval = pam_start ("groupmod", pampw->pw_name,
|
|
|
|
&conv, &pamh);
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if (PAM_SUCCESS == retval) {
|
2007-10-07 17:17:57 +05:30
|
|
|
retval = pam_authenticate (pamh, 0);
|
|
|
|
}
|
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if (PAM_SUCCESS == retval) {
|
2007-10-07 17:17:57 +05:30
|
|
|
retval = pam_acct_mgmt (pamh, 0);
|
|
|
|
}
|
|
|
|
|
2008-07-27 07:11:07 +05:30
|
|
|
(void) pam_end (pamh, retval);
|
2008-07-28 04:00:12 +05:30
|
|
|
if (PAM_SUCCESS != retval) {
|
2008-07-27 06:29:42 +05:30
|
|
|
fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (1);
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
|
|
|
#endif
|
2008-07-27 06:29:42 +05:30
|
|
|
}
|
|
|
|
|
2008-07-27 07:05:08 +05:30
|
|
|
static void fail_exit (int code)
|
|
|
|
{
|
|
|
|
if (group_locked) {
|
|
|
|
if (gr_unlock () == 0) {
|
|
|
|
fprintf (stderr,
|
2008-08-10 05:03:46 +05:30
|
|
|
_("%s: failed to unlock %s\n"),
|
2008-08-10 04:58:30 +05:30
|
|
|
Prog, gr_dbname ());
|
|
|
|
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
|
|
|
|
/* continue */
|
2008-07-27 07:05:08 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
exit (code);
|
|
|
|
}
|
|
|
|
|
2008-08-10 04:58:30 +05:30
|
|
|
int main (int argc, char **argv)
|
2008-07-27 06:29:42 +05:30
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
struct group *grp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get my name so that I can use it to report errors.
|
|
|
|
*/
|
|
|
|
Prog = Basename (argv[0]);
|
|
|
|
|
2008-08-10 04:58:30 +05:30
|
|
|
OPENLOG ("groupmems");
|
|
|
|
|
2008-07-27 06:29:42 +05:30
|
|
|
(void) setlocale (LC_ALL, "");
|
|
|
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
(void) textdomain (PACKAGE);
|
|
|
|
|
|
|
|
process_flags (argc, argv);
|
|
|
|
|
2008-07-27 06:46:13 +05:30
|
|
|
if (NULL == thisgroup) {
|
|
|
|
name = whoami ();
|
2008-07-27 08:03:37 +05:30
|
|
|
if (!list && (NULL == name)) {
|
2008-07-27 06:46:13 +05:30
|
|
|
fprintf (stderr, _("%s: your groupname does not match your username\n"), Prog);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_NOT_PRIMARY);
|
2008-07-27 06:46:13 +05:30
|
|
|
}
|
|
|
|
} else {
|
2008-07-27 06:29:42 +05:30
|
|
|
name = thisgroup;
|
2008-07-27 08:03:37 +05:30
|
|
|
if (!list && !isroot ()) {
|
2008-07-27 06:46:13 +05:30
|
|
|
fprintf (stderr, _("%s: only root can use the -g/--group option\n"), Prog);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_NOT_ROOT);
|
2008-07-27 06:46:13 +05:30
|
|
|
}
|
2008-07-27 06:29:42 +05:30
|
|
|
}
|
|
|
|
|
2008-07-27 08:03:37 +05:30
|
|
|
if (!list) {
|
|
|
|
check_perms ();
|
2007-10-07 17:17:57 +05:30
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if (gr_lock () == 0) {
|
2008-07-27 08:03:37 +05:30
|
|
|
fprintf (stderr,
|
* src/chage.c, src/chgpasswd.c, src/chpasswd.c, src/chsh.c,
src/gpasswd.c, src/groupadd.c, src/groupdel.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
src/newusers.c, src/passwd.c, src/pwck.c, src/pwconv.c,
src/pwunconv.c, src/useradd.c, src/userdel.c, src/usermod.c: In
case of a lock failure, indicate to the user that she can try
again later. Do not log to syslog.
2008-08-22 07:50:53 +05:30
|
|
|
_("%s: cannot lock %s; try again later.\n"),
|
2008-08-10 04:58:30 +05:30
|
|
|
Prog, gr_dbname ());
|
2008-07-27 08:03:37 +05:30
|
|
|
fail_exit (EXIT_GROUP_FILE);
|
|
|
|
}
|
|
|
|
group_locked = true;
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if (gr_open (list ? O_RDONLY : O_RDWR) == 0) {
|
2008-08-10 04:58:30 +05:30
|
|
|
fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_GROUP_FILE);
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
grp = (struct group *) gr_locate (name);
|
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if (NULL == grp) {
|
2008-08-10 04:58:30 +05:30
|
|
|
fprintf (stderr, _("%s: group '%s' does not exist in %s\n"),
|
|
|
|
Prog, name, gr_dbname ());
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_INVALID_GROUP);
|
2008-07-26 21:41:49 +05:30
|
|
|
}
|
|
|
|
|
2008-07-27 08:03:37 +05:30
|
|
|
if (list) {
|
2008-08-10 04:58:30 +05:30
|
|
|
display_members (grp->gr_mem);
|
2008-07-27 08:03:37 +05:30
|
|
|
} else if (NULL != adduser) {
|
2008-07-27 05:51:42 +05:30
|
|
|
if (is_on_list (grp->gr_mem, adduser)) {
|
|
|
|
fprintf (stderr,
|
* src/chfn.c, src/chsh.c, src/groupdel.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/login.c, src/logoutd.c,
src/newgrp.c, src/newusers.c, src/passwd.c, src/pwck.c,
src/suauth.c, src/useradd.c, src/userdel.c, src/usermod.c,
src/vipw.c: Complete the switch from the `' quotation style to ''.
Do it also in SYSLOG messages. Quote some parameters. All this
permits to merge some messages.
2008-08-06 21:21:52 +05:30
|
|
|
_("%s: user '%s' is already a member of '%s'\n"),
|
2008-07-27 05:51:42 +05:30
|
|
|
Prog, adduser, grp->gr_name);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_MEMBER_EXISTS);
|
2008-07-27 05:51:42 +05:30
|
|
|
}
|
|
|
|
grp->gr_mem = add_list (grp->gr_mem, adduser);
|
2007-10-07 17:17:57 +05:30
|
|
|
gr_update (grp);
|
|
|
|
} else if (NULL != deluser) {
|
2008-07-27 05:51:42 +05:30
|
|
|
if (!is_on_list (grp->gr_mem, adduser)) {
|
|
|
|
fprintf (stderr,
|
* src/chfn.c, src/chsh.c, src/groupdel.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/login.c, src/logoutd.c,
src/newgrp.c, src/newusers.c, src/passwd.c, src/pwck.c,
src/suauth.c, src/useradd.c, src/userdel.c, src/usermod.c,
src/vipw.c: Complete the switch from the `' quotation style to ''.
Do it also in SYSLOG messages. Quote some parameters. All this
permits to merge some messages.
2008-08-06 21:21:52 +05:30
|
|
|
_("%s: user '%s' is not a member of '%s'\n"),
|
2008-07-27 05:51:42 +05:30
|
|
|
Prog, deluser, grp->gr_name);
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_NOT_MEMBER);
|
2008-07-27 05:51:42 +05:30
|
|
|
}
|
|
|
|
grp->gr_mem = del_list (grp->gr_mem, deluser);
|
2007-10-07 17:17:57 +05:30
|
|
|
gr_update (grp);
|
|
|
|
} else if (purge) {
|
2008-07-27 05:51:42 +05:30
|
|
|
grp->gr_mem[0] = NULL;
|
2007-10-07 17:17:57 +05:30
|
|
|
gr_update (grp);
|
|
|
|
}
|
|
|
|
|
2008-07-28 04:00:12 +05:30
|
|
|
if (gr_close () == 0) {
|
2008-08-10 04:58:30 +05:30
|
|
|
fprintf (stderr, _("%s: failure while writing %s\n"), Prog, gr_dbname ());
|
|
|
|
SYSLOG ((LOG_ERR, "failure while writing %s", gr_dbname ()));
|
2008-07-27 07:05:08 +05:30
|
|
|
fail_exit (EXIT_GROUP_FILE);
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
2008-08-10 04:58:30 +05:30
|
|
|
if (gr_unlock () == 0) {
|
2008-08-10 05:03:46 +05:30
|
|
|
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
|
2008-08-10 04:58:30 +05:30
|
|
|
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
|
|
|
|
/* continue */
|
|
|
|
}
|
2007-10-07 17:17:57 +05:30
|
|
|
|
2008-08-10 04:58:30 +05:30
|
|
|
exit (EXIT_SUCCESS);
|
2007-10-07 17:17:57 +05:30
|
|
|
}
|
2008-07-27 07:05:08 +05:30
|
|
|
|