2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2008-04-27 06:10:09 +05:30
|
|
|
* Copyright (c) 1991 - 1994, Julianne Frances Haugh
|
|
|
|
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
|
|
|
* Copyright (c) 2000 - 2006, Tomasz Kłoczko
|
2011-07-14 19:00:05 +05:30
|
|
|
* Copyright (c) 2007 - 2011, Nicolas François
|
2007-10-07 17:14:02 +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:14:02 +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:14:02 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-11-11 05:16:11 +05:30
|
|
|
#ident "$Id$"
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#include <ctype.h>
|
|
|
|
#include <fcntl.h>
|
2007-10-07 17:17:57 +05:30
|
|
|
#include <getopt.h>
|
2007-10-07 17:17:01 +05:30
|
|
|
#include <grp.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
* configure.in: Added option --enable-account-tools-setuid to
enable/disable the usage of PAM to authenticate the callers of
account management tools: chage, chgpasswd, chpasswd, groupadd,
groupdel, groupmod, useradd, userdel, usermod.
* src/Makefile.am: Do not link the above tools with libpam if
account-tools-setuid is disabled.
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/usermod.c,
src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c,
src/groupadd.c, src/chage.c: Implement ACCT_TOOLS_SETUID
(--enable-account-tools-setuid).
* etc/pam.d/Makefile.am: Install the pam service file for the
above tools only when needed.
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
needed to initialize retval to PAM_SUCCESS.
2008-09-07 03:05:37 +05:30
|
|
|
#ifdef ACCT_TOOLS_SETUID
|
2007-10-07 17:14:38 +05:30
|
|
|
#ifdef USE_PAM
|
2007-10-07 17:17:11 +05:30
|
|
|
#include "pam_defs.h"
|
2007-10-07 17:14:38 +05:30
|
|
|
#include <pwd.h>
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* USE_PAM */
|
* configure.in: Added option --enable-account-tools-setuid to
enable/disable the usage of PAM to authenticate the callers of
account management tools: chage, chgpasswd, chpasswd, groupadd,
groupdel, groupmod, useradd, userdel, usermod.
* src/Makefile.am: Do not link the above tools with libpam if
account-tools-setuid is disabled.
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/usermod.c,
src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c,
src/groupadd.c, src/chage.c: Implement ACCT_TOOLS_SETUID
(--enable-account-tools-setuid).
* etc/pam.d/Makefile.am: Install the pam service file for the
above tools only when needed.
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
needed to initialize retval to PAM_SUCCESS.
2008-09-07 03:05:37 +05:30
|
|
|
#endif /* ACCT_TOOLS_SETUID */
|
2007-10-07 17:14:02 +05:30
|
|
|
#include "chkname.h"
|
|
|
|
#include "defines.h"
|
|
|
|
#include "groupio.h"
|
2008-03-09 04:31:49 +05:30
|
|
|
#include "pwio.h"
|
2007-10-07 17:15:23 +05:30
|
|
|
#include "nscd.h"
|
2007-10-07 17:17:01 +05:30
|
|
|
#include "prototypes.h"
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SHADOWGRP
|
|
|
|
#include "sgroupio.h"
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* exit status values
|
|
|
|
*/
|
* src/newgrp.c, src/chfn.c, src/groupmems.c, src/usermod.c,
src/userdel.c, src/chpasswd.c, src/grpck.c, src/gpasswd.c,
src/groupdel.c, src/chgpasswd.c, src/vipw.c, src/useradd.c,
src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/faillog.c,
src/sulogin.c, src/chsh.c, src/pwconv.c: Added splint annotations.
* src/userdel.c, src/pwconv.c, src/lastlog.c, src/grpck.c,
src/vipw.c, src/groupmod.c, src/passwd.c, src/pwck.c, src/login.c,
src/sulogin.c, src/usermod.c: Use return instead of exit at the
end of main().
* src/gpasswd.c, src/passwd.c, src/faillog.c: Use the exitcodes.h
exit codes.
* src/chpasswd.c: Added missing ||.
* src/nologin.c: Do not include exitcodes.h.
* src/nologin.c: Added brackets.
* src/nologin.c: Avoid assignments in comparisons.
2009-05-01 03:09:38 +05:30
|
|
|
/*@-exitarg@*/
|
2007-10-07 17:14:02 +05:30
|
|
|
#define E_SUCCESS 0 /* success */
|
|
|
|
#define E_USAGE 2 /* invalid command syntax */
|
|
|
|
#define E_BAD_ARG 3 /* invalid argument to option */
|
|
|
|
#define E_GID_IN_USE 4 /* gid already in use (and no -o) */
|
|
|
|
#define E_NOTFOUND 6 /* specified group doesn't exist */
|
|
|
|
#define E_NAME_IN_USE 9 /* group name already in use */
|
|
|
|
#define E_GRP_UPDATE 10 /* can't update group file */
|
2007-10-07 17:17:01 +05:30
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
* src/newgrp.c, src/userdel.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/pwconv.c, src/chpasswd.c, src/logoutd.c,
src/chfn.c, src/groupmems.c, src/usermod.c, src/pwunconv.c,
src/expiry.c, src/groupdel.c, src/chgpasswd.c, src/useradd.c,
src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c, src/chage.c,
src/groupadd.c, src/login.c, src/grpconv.c, src/groups.c,
src/grpunconv.c, src/chsh.c: Prog changed to a constant string.
2010-08-23 01:06:09 +05:30
|
|
|
const char *Prog;
|
* src/newgrp.c, src/userdel.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/pwconv.c, src/chpasswd.c, src/logoutd.c,
src/chfn.c, src/groupmems.c, src/usermod.c, src/pwunconv.c,
src/expiry.c, src/groupdel.c, src/chgpasswd.c, src/useradd.c,
src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/grpconv.c,
src/groups.c, src/grpunconv.c, src/chsh.c: Prog is now global (not
static to the file) so that it can be used by the helper functions
of libmisc.
* lib/prototypes.h: Added extern char *Prog.
* libmisc/find_new_gid.c, libmisc/find_new_uid.c: Indicate the
program name with the warning.
2008-09-06 18:21:53 +05:30
|
|
|
|
2007-10-07 17:17:01 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-06-10 23:15:08 +05:30
|
|
|
static bool is_shadow_grp;
|
2008-03-18 04:32:23 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2007-10-07 17:14:59 +05:30
|
|
|
static char *group_name;
|
|
|
|
static char *group_newname;
|
2008-01-05 19:47:43 +05:30
|
|
|
static char *group_passwd;
|
2007-10-07 17:14:59 +05:30
|
|
|
static gid_t group_id;
|
|
|
|
static gid_t group_newid;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-12-23 03:22:43 +05:30
|
|
|
struct cleanup_info_mod info_passwd;
|
|
|
|
struct cleanup_info_mod info_group;
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
struct cleanup_info_mod info_gshadow;
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
static bool
|
|
|
|
oflg = false, /* permit non-unique group ID to be specified with -g */
|
|
|
|
gflg = false, /* new ID value for the group */
|
|
|
|
nflg = false, /* a new name has been specified for the group */
|
|
|
|
pflg = false; /* new encrypted password */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/* local function prototypes */
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
static void usage (int status);
|
2007-10-07 17:14:59 +05:30
|
|
|
static void new_grent (struct group *);
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SHADOWGRP
|
2007-10-07 17:14:59 +05:30
|
|
|
static void new_sgent (struct sgrp *);
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
2007-10-07 17:14:59 +05:30
|
|
|
static void grp_update (void);
|
|
|
|
static void check_new_gid (void);
|
|
|
|
static void check_new_name (void);
|
|
|
|
static void process_flags (int, char **);
|
2008-12-23 03:22:43 +05:30
|
|
|
static void lock_files (void);
|
|
|
|
static void prepare_failure_reports (void);
|
2007-10-07 17:14:59 +05:30
|
|
|
static void open_files (void);
|
2008-12-23 03:22:43 +05:30
|
|
|
static void close_files (void);
|
2008-03-09 04:31:49 +05:30
|
|
|
static void update_primary_groups (gid_t ogid, gid_t ngid);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* usage - display usage message and exit
|
|
|
|
*/
|
|
|
|
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
static void usage (int status)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
* src/userdel.c, src/lastlog.c, src/gpasswd.c, src/newusers.c,
src/chpasswd.c, src/groupmems.c, src/usermod.c, src/chgpasswd.c,
src/vipw.c, src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c,
src/groupadd.c, src/chage.c, src/faillog.c, src/chsh.c: Use
booleans for tests.
* src/userdel.c, src/gpasswd.c, src/groupmems.c, src/usermod.c,
src/groupmod.c, src/passwd.c: Use a break even after usage().
2009-09-06 04:01:29 +05:30
|
|
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
(void) fprintf (usageout,
|
2009-06-06 03:46:56 +05:30
|
|
|
_("Usage: %s [options] GROUP\n"
|
|
|
|
"\n"
|
|
|
|
"Options:\n"),
|
|
|
|
Prog);
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
(void) fputs (_(" -g, --gid GID change the group ID to GID\n"), usageout);
|
|
|
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
|
|
|
(void) fputs (_(" -n, --new-name NEW_GROUP change the name to NEW_GROUP\n"), usageout);
|
|
|
|
(void) fputs (_(" -o, --non-unique allow to use a duplicate (non-unique) GID\n"), usageout);
|
2009-06-06 03:46:56 +05:30
|
|
|
(void) fputs (_(" -p, --password PASSWORD change the password to this (encrypted)\n"
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
" PASSWORD\n"), usageout);
|
|
|
|
(void) fputs ("\n", usageout);
|
|
|
|
exit (status);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* new_grent - updates the values in a group file entry
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* new_grent() takes all of the values that have been entered and fills
|
|
|
|
* in a (struct group) with them.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void new_grent (struct group *grent)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2008-08-06 21:26:51 +05:30
|
|
|
if (nflg) {
|
2007-10-07 17:14:02 +05:30
|
|
|
grent->gr_name = xstrdup (group_newname);
|
2008-08-06 21:26:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-08-06 21:26:51 +05:30
|
|
|
if (gflg) {
|
2007-10-07 17:14:02 +05:30
|
|
|
grent->gr_gid = group_newid;
|
2008-08-06 21:26:51 +05:30
|
|
|
}
|
2008-01-05 19:47:43 +05:30
|
|
|
|
2011-07-14 19:00:05 +05:30
|
|
|
if ( pflg
|
|
|
|
#ifdef SHADOWGRP
|
|
|
|
&& ( (!is_shadow_grp)
|
|
|
|
|| (strcmp (grent->gr_passwd, SHADOW_PASSWD_STRING) != 0))
|
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
/* Update the password in group if there is no gshadow
|
|
|
|
* file or if the password is currently in group
|
|
|
|
* (gr_passwd != "x"). We do not force the usage of
|
|
|
|
* shadow passwords if it was not the case before.
|
|
|
|
*/
|
2008-01-05 19:47:43 +05:30
|
|
|
grent->gr_passwd = group_passwd;
|
2008-08-06 21:26:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SHADOWGRP
|
|
|
|
/*
|
|
|
|
* new_sgent - updates the values in a shadow group file entry
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* new_sgent() takes all of the values that have been entered and fills
|
|
|
|
* in a (struct sgrp) with them.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void new_sgent (struct sgrp *sgent)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2008-08-06 21:26:51 +05:30
|
|
|
if (nflg) {
|
2007-10-07 17:14:02 +05:30
|
|
|
sgent->sg_name = xstrdup (group_newname);
|
2008-08-06 21:26:51 +05:30
|
|
|
}
|
2008-01-05 19:47:43 +05:30
|
|
|
|
2011-07-14 19:00:05 +05:30
|
|
|
/* Always update the shadowed password if there is a shadow entry
|
|
|
|
* (even if shadowed passwords might not be enabled for this group
|
|
|
|
* (gr_passwd != "x")).
|
|
|
|
* It seems better to update the password in both places in case a
|
|
|
|
* shadow and a non shadow entry exist.
|
|
|
|
* This might occur only if there were already both entries.
|
|
|
|
*/
|
2008-08-06 21:26:51 +05:30
|
|
|
if (pflg) {
|
2008-01-05 19:47:43 +05:30
|
|
|
sgent->sg_passwd = group_passwd;
|
2008-08-06 21:26:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* grp_update - update group file entries
|
|
|
|
*
|
2008-12-23 03:22:43 +05:30
|
|
|
* grp_update() updates the new records in the memory databases.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void grp_update (void)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
struct group grp;
|
|
|
|
const struct group *ogrp;
|
2007-10-07 17:14:59 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SHADOWGRP
|
|
|
|
struct sgrp sgrp;
|
|
|
|
const struct sgrp *osgrp = NULL;
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the current settings for this group.
|
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
ogrp = gr_locate (group_name);
|
2011-07-09 01:28:40 +05:30
|
|
|
if (NULL == ogrp) {
|
2007-10-07 17:14:59 +05:30
|
|
|
fprintf (stderr,
|
2008-12-23 03:36:27 +05:30
|
|
|
_("%s: group '%s' does not exist in %s\n"),
|
|
|
|
Prog, group_name, gr_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
grp = *ogrp;
|
|
|
|
new_grent (&grp);
|
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
if ( is_shadow_grp
|
|
|
|
&& (pflg || nflg)) {
|
2008-06-10 23:15:08 +05:30
|
|
|
osgrp = sgr_locate (group_name);
|
|
|
|
if (NULL != osgrp) {
|
|
|
|
sgrp = *osgrp;
|
|
|
|
new_sgent (&sgrp);
|
2011-07-14 19:00:05 +05:30
|
|
|
} else if ( pflg
|
|
|
|
&& (strcmp (grp.gr_passwd, SHADOW_PASSWD_STRING) == 0)) {
|
|
|
|
static char *empty = NULL;
|
|
|
|
/* If there is a gshadow file with no entries for
|
|
|
|
* the group, but the group file indicates a
|
|
|
|
* shadowed password, we force the creation of a
|
|
|
|
* gshadow entry when a new password is requested.
|
|
|
|
*/
|
|
|
|
memset (&sgrp, 0, sizeof sgrp);
|
|
|
|
sgrp.sg_name = xstrdup (grp.gr_name);
|
|
|
|
sgrp.sg_passwd = xstrdup (grp.gr_passwd);
|
|
|
|
sgrp.sg_adm = ∅
|
|
|
|
sgrp.sg_mem = dup_list (grp.gr_mem);
|
|
|
|
new_sgent (&sgrp);
|
|
|
|
osgrp = &sgrp; /* entry needs to be committed */
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-03-09 04:31:49 +05:30
|
|
|
if (gflg) {
|
|
|
|
update_primary_groups (ogrp->gr_gid, group_newid);
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* Write out the new group file entry.
|
|
|
|
*/
|
2008-06-10 23:15:08 +05:30
|
|
|
if (gr_update (&grp) == 0) {
|
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
Added *_dbname() functions to retrieve the name of the databases.
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
*_name() functions renamed *setname().
* src/grpck.c, src/pwck.c: Likewise.
* lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added
the name of the arguments to the prototypes.
* src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.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:
Harmonize the erro & syslog messages in case of failure of the
*_lock(), *_open(), *_close(), *_unlock(), *_remove() functions.
* src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid
capitalized messages.
* src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages
in case of inexistent entries.
* src/usermod.c: Harmonize messages in case of already existing
entries.
* src/newusers.c, src/useradd.c: Simplify PAM error handling.
* src/useradd.c: Report failures to unlock files (stderr, syslog,
and audit). But do not fail (continue).
* src/useradd.c (open_files): Do not report to syslog & audit
failures to lock or open the databases. This might be harmless,
and the logs were not already informed that a change was
requested.
* src/usermod.c: It's not the account which is unlocked, but its
password.
2008-08-06 21:27:31 +05:30
|
|
|
fprintf (stderr,
|
* src/groupmems.c: Check the return value of gr_update().
* src/chage.c, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
src/passwd.c, src/pwck.c, src/pwconv.c, src/pwunconv.c,
src/useradd.c, src/userdel.c, src/usermod.c: Harmonize the error
message sent to stderr in case of *_update () failure.
* src/chage.c, src/chsh.c, src/groupadd.c, src/passwd.c: Do not
log to syslog when pw_update() or spw_update() fail.
* src/newusers.c: Do not log specific error message to stderr when
sgr_update() fails.
* src/pwconv.c: Remove duplicated definition of Prog.
2008-08-30 23:57:34 +05:30
|
|
|
_("%s: failed to prepare the new %s entry '%s'\n"),
|
|
|
|
Prog, gr_dbname (), grp.gr_name);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-06-10 23:15:08 +05:30
|
|
|
if (nflg && (gr_remove (group_name) == 0)) {
|
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
Added *_dbname() functions to retrieve the name of the databases.
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
*_name() functions renamed *setname().
* src/grpck.c, src/pwck.c: Likewise.
* lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added
the name of the arguments to the prototypes.
* src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.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:
Harmonize the erro & syslog messages in case of failure of the
*_lock(), *_open(), *_close(), *_unlock(), *_remove() functions.
* src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid
capitalized messages.
* src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages
in case of inexistent entries.
* src/usermod.c: Harmonize messages in case of already existing
entries.
* src/newusers.c, src/useradd.c: Simplify PAM error handling.
* src/useradd.c: Report failures to unlock files (stderr, syslog,
and audit). But do not fail (continue).
* src/useradd.c (open_files): Do not report to syslog & audit
failures to lock or open the databases. This might be harmless,
and the logs were not already informed that a change was
requested.
* src/usermod.c: It's not the account which is unlocked, but its
password.
2008-08-06 21:27:31 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: cannot remove entry '%s' from %s\n"),
|
|
|
|
Prog, grp.gr_name, gr_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2011-07-09 01:28:40 +05:30
|
|
|
#ifdef SHADOWGRP
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2008-12-23 03:22:43 +05:30
|
|
|
* Make sure there was a shadow entry to begin with.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2011-07-09 01:28:40 +05:30
|
|
|
if (NULL != osgrp) {
|
2008-12-23 03:22:43 +05:30
|
|
|
/*
|
|
|
|
* Write out the new shadow group entries as well.
|
|
|
|
*/
|
|
|
|
if (sgr_update (&sgrp) == 0) {
|
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: failed to prepare the new %s entry '%s'\n"),
|
|
|
|
Prog, sgr_dbname (), sgrp.sg_name);
|
|
|
|
exit (E_GRP_UPDATE);
|
|
|
|
}
|
|
|
|
if (nflg && (sgr_remove (group_name) == 0)) {
|
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: cannot remove entry '%s' from %s\n"),
|
|
|
|
Prog, group_name, sgr_dbname ());
|
|
|
|
exit (E_GRP_UPDATE);
|
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check_new_gid - check the new GID value for uniqueness
|
|
|
|
*
|
|
|
|
* check_new_gid() insures that the new GID value is unique.
|
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void check_new_gid (void)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* First, the easy stuff. If the ID can be duplicated, or if the ID
|
|
|
|
* didn't really change, just return. If the ID didn't change, turn
|
|
|
|
* off those flags. No sense doing needless work.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
|
|
|
if (group_id == group_newid) {
|
|
|
|
gflg = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (oflg ||
|
|
|
|
(getgrgid (group_newid) == NULL) /* local, no need for xgetgrgid */
|
|
|
|
) {
|
2007-10-07 17:14:02 +05:30
|
|
|
return;
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell the user what they did wrong.
|
|
|
|
*/
|
2008-12-23 03:36:27 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: GID '%lu' already exists\n"),
|
2008-06-10 23:15:08 +05:30
|
|
|
Prog, (unsigned long int) group_newid);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GID_IN_USE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check_new_name - check the new name for uniqueness
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* check_new_name() insures that the new name does not exist already.
|
|
|
|
* You can't have the same name twice, period.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void check_new_name (void)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Make sure they are actually changing the name.
|
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
if (strcmp (group_name, group_newname) == 0) {
|
2007-10-07 17:14:02 +05:30
|
|
|
nflg = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-26 02:28:16 +05:30
|
|
|
if (is_valid_group_name (group_newname)) {
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* If the entry is found, too bad.
|
|
|
|
*/
|
* 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 xgetgrnam */
|
2008-06-10 23:15:08 +05:30
|
|
|
if (getgrnam (group_newname) != NULL) {
|
2007-10-07 17:14:59 +05:30
|
|
|
fprintf (stderr,
|
2008-12-23 03:36:27 +05:30
|
|
|
_("%s: group '%s' already exists\n"),
|
|
|
|
Prog, group_newname);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_NAME_IN_USE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All invalid group names land here.
|
|
|
|
*/
|
|
|
|
|
2008-12-23 03:36:27 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: invalid group name '%s'\n"),
|
|
|
|
Prog, group_newname);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_BAD_ARG);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* process_flags - perform command line argument setting
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* process_flags() interprets the command line arguments and sets the
|
|
|
|
* values that the user will be created with accordingly. The values
|
|
|
|
* are checked for sanity.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void process_flags (int argc, char **argv)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2008-12-23 03:36:27 +05:30
|
|
|
int option_index = 0;
|
|
|
|
int c;
|
|
|
|
static struct option long_options[] = {
|
|
|
|
{"gid", required_argument, NULL, 'g'},
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"new-name", required_argument, NULL, 'n'},
|
|
|
|
{"non-unique", no_argument, NULL, 'o'},
|
|
|
|
{"password", required_argument, NULL, 'p'},
|
|
|
|
{NULL, 0, NULL, '\0'}
|
|
|
|
};
|
|
|
|
while ((c =
|
|
|
|
getopt_long (argc, argv, "g:hn:op:",
|
|
|
|
long_options, &option_index)) != -1) {
|
|
|
|
switch (c) {
|
|
|
|
case 'g':
|
|
|
|
gflg = true;
|
2009-03-09 02:13:15 +05:30
|
|
|
if ( (get_gid (optarg, &group_newid) == 0)
|
|
|
|
|| (group_newid == (gid_t)-1)) {
|
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: invalid group ID '%s'\n"),
|
|
|
|
Prog, optarg);
|
|
|
|
exit (E_BAD_ARG);
|
|
|
|
}
|
2008-12-23 03:36:27 +05:30
|
|
|
break;
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
case 'h':
|
|
|
|
usage (E_SUCCESS);
|
* src/userdel.c, src/lastlog.c, src/gpasswd.c, src/newusers.c,
src/chpasswd.c, src/groupmems.c, src/usermod.c, src/chgpasswd.c,
src/vipw.c, src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c,
src/groupadd.c, src/chage.c, src/faillog.c, src/chsh.c: Use
booleans for tests.
* src/userdel.c, src/gpasswd.c, src/groupmems.c, src/usermod.c,
src/groupmod.c, src/passwd.c: Use a break even after usage().
2009-09-06 04:01:29 +05:30
|
|
|
break;
|
2008-12-23 03:36:27 +05:30
|
|
|
case 'n':
|
|
|
|
nflg = true;
|
|
|
|
group_newname = optarg;
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
oflg = true;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
group_passwd = optarg;
|
|
|
|
pflg = true;
|
|
|
|
break;
|
|
|
|
default:
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
usage (E_USAGE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
}
|
2007-10-07 17:17:57 +05:30
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (oflg && !gflg) {
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
usage (E_USAGE);
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (optind != (argc - 1)) {
|
* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
the usage should not go to stderr nor should the utility exit with
non-zero status. All of the shadow utils do just this
unfortunately, so convert them over to sanity.
* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
2009-09-05 04:32:33 +05:30
|
|
|
usage (E_USAGE);
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
group_name = argv[argc - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* close_files - close all of the files that were opened
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* close_files() closes all of the files that were opened for this new
|
|
|
|
* group. This causes any modified entries to be written out.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static void close_files (void)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2008-06-10 23:15:08 +05:30
|
|
|
if (gr_close () == 0) {
|
2008-12-23 03:22:43 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: failure while writing changes to %s\n"),
|
|
|
|
Prog, gr_dbname ());
|
|
|
|
exit (E_GRP_UPDATE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-08-06 21:26:51 +05:30
|
|
|
#ifdef WITH_AUDIT
|
2008-12-23 03:22:43 +05:30
|
|
|
audit_logger (AUDIT_USER_ACCT, Prog,
|
|
|
|
info_group.audit_msg,
|
|
|
|
group_name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_SUCCESS);
|
2008-08-06 21:26:51 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
SYSLOG ((LOG_INFO,
|
|
|
|
"group changed in %s (%s)",
|
|
|
|
gr_dbname (), info_group.action));
|
|
|
|
del_cleanup (cleanup_report_mod_group);
|
|
|
|
|
|
|
|
cleanup_unlock_group (NULL);
|
|
|
|
del_cleanup (cleanup_unlock_group);
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
if ( is_shadow_grp
|
|
|
|
&& (pflg || nflg)) {
|
2008-08-22 08:01:55 +05:30
|
|
|
if (sgr_close () == 0) {
|
2008-08-06 21:26:51 +05:30
|
|
|
fprintf (stderr,
|
2008-12-23 03:22:43 +05:30
|
|
|
_("%s: failure while writing changes to %s\n"),
|
|
|
|
Prog, sgr_dbname ());
|
|
|
|
exit (E_GRP_UPDATE);
|
2008-08-06 21:26:51 +05:30
|
|
|
}
|
|
|
|
#ifdef WITH_AUDIT
|
2008-12-23 03:22:43 +05:30
|
|
|
audit_logger (AUDIT_USER_ACCT, Prog,
|
|
|
|
info_gshadow.audit_msg,
|
|
|
|
group_name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_SUCCESS);
|
2008-08-06 21:26:51 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
SYSLOG ((LOG_INFO,
|
|
|
|
"group changed in %s (%s)",
|
|
|
|
sgr_dbname (), info_gshadow.action));
|
|
|
|
del_cleanup (cleanup_report_mod_gshadow);
|
|
|
|
|
|
|
|
cleanup_unlock_gshadow (NULL);
|
|
|
|
del_cleanup (cleanup_unlock_gshadow);
|
2008-03-09 04:31:49 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2008-12-23 03:22:43 +05:30
|
|
|
|
2008-03-09 04:31:49 +05:30
|
|
|
if (gflg) {
|
2008-06-10 23:15:08 +05:30
|
|
|
if (pw_close () == 0) {
|
2008-03-09 04:31:49 +05:30
|
|
|
fprintf (stderr,
|
2008-12-23 03:22:43 +05:30
|
|
|
_("%s: failure while writing changes to %s\n"),
|
|
|
|
Prog, pw_dbname ());
|
|
|
|
exit (E_GRP_UPDATE);
|
|
|
|
}
|
2008-08-06 21:26:51 +05:30
|
|
|
#ifdef WITH_AUDIT
|
2008-12-23 03:22:43 +05:30
|
|
|
audit_logger (AUDIT_USER_ACCT, Prog,
|
|
|
|
info_passwd.audit_msg,
|
|
|
|
group_name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_SUCCESS);
|
2008-08-06 21:26:51 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
SYSLOG ((LOG_INFO,
|
|
|
|
"group changed in %s (%s)",
|
|
|
|
pw_dbname (), info_passwd.action));
|
|
|
|
del_cleanup (cleanup_report_mod_passwd);
|
|
|
|
|
|
|
|
cleanup_unlock_passwd (NULL);
|
|
|
|
del_cleanup (cleanup_unlock_passwd);
|
|
|
|
}
|
|
|
|
|
2008-08-06 21:26:51 +05:30
|
|
|
#ifdef WITH_AUDIT
|
2008-12-23 03:22:43 +05:30
|
|
|
audit_logger (AUDIT_USER_ACCT, Prog,
|
|
|
|
"modifying group",
|
|
|
|
group_name, AUDIT_NO_ID,
|
|
|
|
SHADOW_AUDIT_SUCCESS);
|
2008-08-06 21:26:51 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare_failure_reports - Prepare the cleanup_info structure for logging
|
|
|
|
* of success and failure to syslog or audit.
|
|
|
|
*/
|
|
|
|
static void prepare_failure_reports (void)
|
|
|
|
{
|
|
|
|
info_group.name = group_name;
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
info_gshadow.name = group_name;
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
info_passwd.name = group_name;
|
|
|
|
|
|
|
|
info_group.audit_msg = xmalloc (512);
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
info_gshadow.audit_msg = xmalloc (512);
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
info_passwd.audit_msg = xmalloc (512);
|
|
|
|
|
|
|
|
snprintf (info_group.audit_msg, 511,
|
|
|
|
"changing %s; ", gr_dbname ());
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
snprintf (info_gshadow.audit_msg, 511,
|
|
|
|
"changing %s; ", sgr_dbname ());
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
snprintf (info_passwd.audit_msg, 511,
|
|
|
|
"changing %s; ", pw_dbname ());
|
|
|
|
|
|
|
|
info_group.action = info_group.audit_msg
|
|
|
|
+ strlen (info_group.audit_msg);
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
info_gshadow.action = info_gshadow.audit_msg
|
|
|
|
+ strlen (info_gshadow.audit_msg);
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
info_passwd.action = info_passwd.audit_msg
|
|
|
|
+ strlen (info_passwd.audit_msg);
|
|
|
|
|
|
|
|
snprintf (info_group.action, 511 - strlen (info_group.audit_msg),
|
2009-04-24 02:09:29 +05:30
|
|
|
"group %s/%lu", group_name, (unsigned long int) group_id);
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
snprintf (info_gshadow.action, 511 - strlen (info_group.audit_msg),
|
|
|
|
"group %s", group_name);
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
snprintf (info_passwd.action, 511 - strlen (info_group.audit_msg),
|
2009-04-24 02:09:29 +05:30
|
|
|
"group %s/%lu", group_name, (unsigned long int) group_id);
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
if (nflg) {
|
|
|
|
strncat (info_group.action, ", new name: ",
|
|
|
|
511 - strlen (info_group.audit_msg));
|
|
|
|
strncat (info_group.action, group_newname,
|
|
|
|
511 - strlen (info_group.audit_msg));
|
|
|
|
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
strncat (info_gshadow.action, ", new name: ",
|
|
|
|
511 - strlen (info_gshadow.audit_msg));
|
|
|
|
strncat (info_gshadow.action, group_newname,
|
|
|
|
511 - strlen (info_gshadow.audit_msg));
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
strncat (info_passwd.action, ", new name: ",
|
|
|
|
511 - strlen (info_passwd.audit_msg));
|
|
|
|
strncat (info_passwd.action, group_newname,
|
|
|
|
511 - strlen (info_passwd.audit_msg));
|
2008-03-09 04:31:49 +05:30
|
|
|
}
|
2008-12-23 03:22:43 +05:30
|
|
|
if (pflg) {
|
|
|
|
strncat (info_group.action, ", new password",
|
|
|
|
511 - strlen (info_group.audit_msg));
|
|
|
|
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
strncat (info_gshadow.action, ", new password",
|
|
|
|
511 - strlen (info_gshadow.audit_msg));
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
}
|
|
|
|
if (gflg) {
|
|
|
|
strncat (info_group.action, ", new gid: ",
|
|
|
|
511 - strlen (info_group.audit_msg));
|
|
|
|
snprintf (info_group.action+strlen (info_group.action),
|
|
|
|
511 - strlen (info_group.audit_msg),
|
2009-04-24 02:09:29 +05:30
|
|
|
"%lu", (unsigned long int) group_newid);
|
2008-12-23 03:22:43 +05:30
|
|
|
|
|
|
|
strncat (info_passwd.action, ", new gid: ",
|
|
|
|
511 - strlen (info_passwd.audit_msg));
|
|
|
|
snprintf (info_passwd.action+strlen (info_passwd.action),
|
|
|
|
511 - strlen (info_passwd.audit_msg),
|
2009-04-24 02:09:29 +05:30
|
|
|
"%lu", (unsigned long int) group_newid);
|
2008-12-23 03:22:43 +05:30
|
|
|
}
|
|
|
|
info_group.audit_msg[511] = '\0';
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
info_gshadow.audit_msg[511] = '\0';
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
info_passwd.audit_msg[511] = '\0';
|
|
|
|
|
|
|
|
// FIXME: add a system cleanup
|
|
|
|
add_cleanup (cleanup_report_mod_group, &info_group);
|
2009-03-16 03:08:08 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
if ( is_shadow_grp
|
|
|
|
&& (pflg || nflg)) {
|
|
|
|
add_cleanup (cleanup_report_mod_gshadow, &info_gshadow);
|
|
|
|
}
|
2009-03-16 03:08:08 +05:30
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
if (gflg) {
|
|
|
|
add_cleanup (cleanup_report_mod_passwd, &info_passwd);
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-12-23 03:22:43 +05:30
|
|
|
* lock_files - lock the accounts databases
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2008-12-23 03:22:43 +05:30
|
|
|
* lock_files() locks the group, gshadow, and passwd databases.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2008-12-23 03:22:43 +05:30
|
|
|
static void lock_files (void)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2008-06-10 23:15:08 +05:30
|
|
|
if (gr_lock () == 0) {
|
* 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
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: cannot lock %s; try again later.\n"),
|
|
|
|
Prog, gr_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-12-23 03:22:43 +05:30
|
|
|
add_cleanup (cleanup_unlock_group, NULL);
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SHADOWGRP
|
2008-12-23 03:22:43 +05:30
|
|
|
if ( is_shadow_grp
|
|
|
|
&& (pflg || nflg)) {
|
2008-06-10 23:15:08 +05:30
|
|
|
if (sgr_lock () == 0) {
|
2008-03-09 04:31:49 +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"),
|
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
Added *_dbname() functions to retrieve the name of the databases.
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
*_name() functions renamed *setname().
* src/grpck.c, src/pwck.c: Likewise.
* lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added
the name of the arguments to the prototypes.
* src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.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:
Harmonize the erro & syslog messages in case of failure of the
*_lock(), *_open(), *_close(), *_unlock(), *_remove() functions.
* src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid
capitalized messages.
* src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages
in case of inexistent entries.
* src/usermod.c: Harmonize messages in case of already existing
entries.
* src/newusers.c, src/useradd.c: Simplify PAM error handling.
* src/useradd.c: Report failures to unlock files (stderr, syslog,
and audit). But do not fail (continue).
* src/useradd.c (open_files): Do not report to syslog & audit
failures to lock or open the databases. This might be harmless,
and the logs were not already informed that a change was
requested.
* src/usermod.c: It's not the account which is unlocked, but its
password.
2008-08-06 21:27:31 +05:30
|
|
|
Prog, sgr_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
|
|
|
}
|
|
|
|
add_cleanup (cleanup_unlock_gshadow, NULL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (gflg) {
|
|
|
|
if (pw_lock () == 0) {
|
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: cannot lock %s; try again later.\n"),
|
|
|
|
Prog, pw_dbname ());
|
|
|
|
exit (E_GRP_UPDATE);
|
2008-03-09 04:31:49 +05:30
|
|
|
}
|
2008-12-23 03:22:43 +05:30
|
|
|
add_cleanup (cleanup_unlock_passwd, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* open_files - open the accounts databases
|
|
|
|
*
|
|
|
|
* open_files() opens the group, gshadow, and passwd databases.
|
|
|
|
*/
|
|
|
|
static void open_files (void)
|
|
|
|
{
|
|
|
|
if (gr_open (O_RDWR) == 0) {
|
|
|
|
fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
|
|
|
|
SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
|
|
|
|
exit (E_GRP_UPDATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SHADOWGRP
|
|
|
|
if ( is_shadow_grp
|
|
|
|
&& (pflg || nflg)) {
|
2008-06-10 23:15:08 +05:30
|
|
|
if (sgr_open (O_RDWR) == 0) {
|
2008-03-09 04:31:49 +05:30
|
|
|
fprintf (stderr,
|
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
Added *_dbname() functions to retrieve the name of the databases.
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
*_name() functions renamed *setname().
* src/grpck.c, src/pwck.c: Likewise.
* lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added
the name of the arguments to the prototypes.
* src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.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:
Harmonize the erro & syslog messages in case of failure of the
*_lock(), *_open(), *_close(), *_unlock(), *_remove() functions.
* src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid
capitalized messages.
* src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages
in case of inexistent entries.
* src/usermod.c: Harmonize messages in case of already existing
entries.
* src/newusers.c, src/useradd.c: Simplify PAM error handling.
* src/useradd.c: Report failures to unlock files (stderr, syslog,
and audit). But do not fail (continue).
* src/useradd.c (open_files): Do not report to syslog & audit
failures to lock or open the databases. This might be harmless,
and the logs were not already informed that a change was
requested.
* src/usermod.c: It's not the account which is unlocked, but its
password.
2008-08-06 21:27:31 +05:30
|
|
|
_("%s: cannot open %s\n"),
|
|
|
|
Prog, sgr_dbname ());
|
|
|
|
SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2008-03-09 04:31:49 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SHADOWGRP */
|
2008-12-23 03:22:43 +05:30
|
|
|
|
2008-03-09 04:31:49 +05:30
|
|
|
if (gflg) {
|
2008-06-10 23:15:08 +05:30
|
|
|
if (pw_open (O_RDWR) == 0) {
|
2008-03-09 04:31:49 +05:30
|
|
|
fprintf (stderr,
|
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
Added *_dbname() functions to retrieve the name of the databases.
* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
*_name() functions renamed *setname().
* src/grpck.c, src/pwck.c: Likewise.
* lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added
the name of the arguments to the prototypes.
* src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.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:
Harmonize the erro & syslog messages in case of failure of the
*_lock(), *_open(), *_close(), *_unlock(), *_remove() functions.
* src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid
capitalized messages.
* src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages
in case of inexistent entries.
* src/usermod.c: Harmonize messages in case of already existing
entries.
* src/newusers.c, src/useradd.c: Simplify PAM error handling.
* src/useradd.c: Report failures to unlock files (stderr, syslog,
and audit). But do not fail (continue).
* src/useradd.c (open_files): Do not report to syslog & audit
failures to lock or open the databases. This might be harmless,
and the logs were not already informed that a change was
requested.
* src/usermod.c: It's not the account which is unlocked, but its
password.
2008-08-06 21:27:31 +05:30
|
|
|
_("%s: cannot open %s\n"),
|
|
|
|
Prog, pw_dbname ());
|
|
|
|
SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2008-03-09 04:31:49 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_primary_groups (gid_t ogid, gid_t ngid)
|
|
|
|
{
|
|
|
|
struct passwd *pwd;
|
|
|
|
|
|
|
|
setpwent ();
|
|
|
|
while ((pwd = getpwent ()) != NULL) {
|
|
|
|
if (pwd->pw_gid == ogid) {
|
|
|
|
const struct passwd *lpwd;
|
|
|
|
struct passwd npwd;
|
|
|
|
lpwd = pw_locate (pwd->pw_name);
|
|
|
|
if (NULL == lpwd) {
|
|
|
|
fprintf (stderr,
|
* src/groupmems.c: Check the return value of gr_update().
* src/chage.c, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
src/passwd.c, src/pwck.c, src/pwconv.c, src/pwunconv.c,
src/useradd.c, src/userdel.c, src/usermod.c: Harmonize the error
message sent to stderr in case of *_update () failure.
* src/chage.c, src/chsh.c, src/groupadd.c, src/passwd.c: Do not
log to syslog when pw_update() or spw_update() fail.
* src/newusers.c: Do not log specific error message to stderr when
sgr_update() fails.
* src/pwconv.c: Remove duplicated definition of Prog.
2008-08-30 23:57:34 +05:30
|
|
|
_("%s: user '%s' does not exist in %s\n"),
|
|
|
|
Prog, pwd->pw_name, pw_dbname ());
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2008-03-09 04:31:49 +05:30
|
|
|
} else {
|
|
|
|
npwd = *lpwd;
|
|
|
|
npwd.pw_gid = ngid;
|
2008-06-10 23:15:08 +05:30
|
|
|
if (pw_update (&npwd) == 0) {
|
2008-03-09 04:31:49 +05:30
|
|
|
fprintf (stderr,
|
* src/groupmems.c: Check the return value of gr_update().
* src/chage.c, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
src/passwd.c, src/pwck.c, src/pwconv.c, src/pwunconv.c,
src/useradd.c, src/userdel.c, src/usermod.c: Harmonize the error
message sent to stderr in case of *_update () failure.
* src/chage.c, src/chsh.c, src/groupadd.c, src/passwd.c: Do not
log to syslog when pw_update() or spw_update() fail.
* src/newusers.c: Do not log specific error message to stderr when
sgr_update() fails.
* src/pwconv.c: Remove duplicated definition of Prog.
2008-08-30 23:57:34 +05:30
|
|
|
_("%s: failed to prepare the new %s entry '%s'\n"),
|
|
|
|
Prog, pw_dbname (), npwd.pw_name);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_GRP_UPDATE);
|
2008-03-09 04:31:49 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Ensure that getpwent() is used in setpwent(), getpwent(),
endpwend() sequences (ditto for getgrent(), getspent(), and
getsgent()). The only real (minor) issue was in login, which kept
the passwd file open.
* libmisc/entry.c: Remove unneeded setspent() and endspent() (only
getspnam is called in the middle).
* libmisc/find_new_ids.c: Make sure to close the password and
group files with endpwent() and endgrent().
* libmisc/pwdcheck.c: Remove unneeded endspent() (only getspnam()
is called before).
* src/lastlog.c, src/passwd.c, src/groupmod.c, src/faillog.c,
src/groups.c: Make sure to close
the password file with endpwent().
* src/login.c: Remove unneeded setpwent() (only xgetpwnam is
called before).
* src/login.c, src/newgrp.c: Fix typos in comments.
2008-04-17 03:22:46 +05:30
|
|
|
endpwent ();
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* main - groupmod command
|
|
|
|
*
|
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
int main (int argc, char **argv)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
* configure.in: Added option --enable-account-tools-setuid to
enable/disable the usage of PAM to authenticate the callers of
account management tools: chage, chgpasswd, chpasswd, groupadd,
groupdel, groupmod, useradd, userdel, usermod.
* src/Makefile.am: Do not link the above tools with libpam if
account-tools-setuid is disabled.
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/usermod.c,
src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c,
src/groupadd.c, src/chage.c: Implement ACCT_TOOLS_SETUID
(--enable-account-tools-setuid).
* etc/pam.d/Makefile.am: Install the pam service file for the
above tools only when needed.
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
needed to initialize retval to PAM_SUCCESS.
2008-09-07 03:05:37 +05:30
|
|
|
#ifdef ACCT_TOOLS_SETUID
|
2007-10-07 17:14:38 +05:30
|
|
|
#ifdef USE_PAM
|
|
|
|
pam_handle_t *pamh = NULL;
|
|
|
|
int retval;
|
* configure.in: Added option --enable-account-tools-setuid to
enable/disable the usage of PAM to authenticate the callers of
account management tools: chage, chgpasswd, chpasswd, groupadd,
groupdel, groupmod, useradd, userdel, usermod.
* src/Makefile.am: Do not link the above tools with libpam if
account-tools-setuid is disabled.
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/usermod.c,
src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c,
src/groupadd.c, src/chage.c: Implement ACCT_TOOLS_SETUID
(--enable-account-tools-setuid).
* etc/pam.d/Makefile.am: Install the pam service file for the
above tools only when needed.
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
needed to initialize retval to PAM_SUCCESS.
2008-09-07 03:05:37 +05:30
|
|
|
#endif /* USE_PAM */
|
|
|
|
#endif /* ACCT_TOOLS_SETUID */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:01 +05:30
|
|
|
#ifdef WITH_AUDIT
|
|
|
|
audit_help_open ();
|
|
|
|
#endif
|
2008-12-23 03:22:43 +05:30
|
|
|
atexit (do_cleanups);
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* Get my name so that I can use it to report errors.
|
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
Prog = Basename (argv[0]);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
(void) setlocale (LC_ALL, "");
|
|
|
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
(void) textdomain (PACKAGE);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:16:07 +05:30
|
|
|
process_flags (argc, argv);
|
2007-10-07 17:15:40 +05:30
|
|
|
|
2007-10-07 17:16:52 +05:30
|
|
|
OPENLOG ("groupmod");
|
|
|
|
|
* configure.in: Added option --enable-account-tools-setuid to
enable/disable the usage of PAM to authenticate the callers of
account management tools: chage, chgpasswd, chpasswd, groupadd,
groupdel, groupmod, useradd, userdel, usermod.
* src/Makefile.am: Do not link the above tools with libpam if
account-tools-setuid is disabled.
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/usermod.c,
src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c,
src/groupadd.c, src/chage.c: Implement ACCT_TOOLS_SETUID
(--enable-account-tools-setuid).
* etc/pam.d/Makefile.am: Install the pam service file for the
above tools only when needed.
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
needed to initialize retval to PAM_SUCCESS.
2008-09-07 03:05:37 +05:30
|
|
|
#ifdef ACCT_TOOLS_SETUID
|
2007-10-07 17:14:38 +05:30
|
|
|
#ifdef USE_PAM
|
* 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
|
|
|
{
|
|
|
|
struct passwd *pampw;
|
|
|
|
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
2009-11-06 03:33:36 +05:30
|
|
|
if (NULL == pampw) {
|
Additional PAM cleanup:
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/chfn.c,
src/groupmems.c, src/usermod.c, src/groupdel.c, src/chgpasswd.c,
src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c,
src/chsh.c: If the username cannot be determined, report it as
such (not a PAM authentication failure).
2008-09-07 05:16:44 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: Cannot determine your user name.\n"),
|
|
|
|
Prog);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (1);
|
* 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
|
|
|
}
|
Additional PAM cleanup:
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/chfn.c,
src/groupmems.c, src/usermod.c, src/groupdel.c, src/chgpasswd.c,
src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c,
src/chsh.c: If the username cannot be determined, report it as
such (not a PAM authentication failure).
2008-09-07 05:16:44 +05:30
|
|
|
|
|
|
|
retval = pam_start ("groupmod", pampw->pw_name, &conv, &pamh);
|
2007-10-07 17:14:38 +05:30
|
|
|
}
|
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (PAM_SUCCESS == retval) {
|
2007-10-07 17:14:59 +05:30
|
|
|
retval = pam_authenticate (pamh, 0);
|
2007-10-07 17:14:38 +05:30
|
|
|
}
|
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (PAM_SUCCESS == retval) {
|
2007-10-07 17:14:59 +05:30
|
|
|
retval = pam_acct_mgmt (pamh, 0);
|
2007-10-07 17:14:38 +05:30
|
|
|
}
|
|
|
|
|
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/chfn.c,
src/groupmems.c, src/usermod.c, src/groupdel.c, src/chgpasswd.c,
src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c,
src/chsh.c: Simplify the PAM error handling. Do not keep the pamh
handle, but terminate the PAM transaction as soon as possible if
there are no PAM session opened.
2008-09-06 18:58:02 +05:30
|
|
|
if (NULL != pamh) {
|
2008-08-06 21:26:51 +05:30
|
|
|
(void) pam_end (pamh, retval);
|
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/chfn.c,
src/groupmems.c, src/usermod.c, src/groupdel.c, src/chgpasswd.c,
src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c,
src/chsh.c: Simplify the PAM error handling. Do not keep the pamh
handle, but terminate the PAM transaction as soon as possible if
there are no PAM session opened.
2008-09-06 18:58:02 +05:30
|
|
|
}
|
|
|
|
if (PAM_SUCCESS != retval) {
|
2007-10-07 17:16:07 +05:30
|
|
|
fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:38 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* USE_PAM */
|
* configure.in: Added option --enable-account-tools-setuid to
enable/disable the usage of PAM to authenticate the callers of
account management tools: chage, chgpasswd, chpasswd, groupadd,
groupdel, groupmod, useradd, userdel, usermod.
* src/Makefile.am: Do not link the above tools with libpam if
account-tools-setuid is disabled.
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/usermod.c,
src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c,
src/groupadd.c, src/chage.c: Implement ACCT_TOOLS_SETUID
(--enable-account-tools-setuid).
* etc/pam.d/Makefile.am: Install the pam service file for the
above tools only when needed.
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
needed to initialize retval to PAM_SUCCESS.
2008-09-07 03:05:37 +05:30
|
|
|
#endif /* ACCT_TOOLS_SETUID */
|
2007-10-07 17:14:38 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SHADOWGRP
|
2007-10-07 17:14:59 +05:30
|
|
|
is_shadow_grp = sgr_file_present ();
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
* 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
|
|
|
{
|
|
|
|
struct group *grp;
|
|
|
|
/*
|
|
|
|
* Start with a quick check to see if the group exists.
|
|
|
|
*/
|
2008-06-10 23:15:08 +05:30
|
|
|
grp = getgrnam (group_name); /* local, no need for xgetgrnam */
|
|
|
|
if (NULL == grp) {
|
2008-12-23 03:36:27 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: group '%s' does not exist\n"),
|
|
|
|
Prog, group_name);
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_NOTFOUND);
|
2008-06-10 23:15:08 +05:30
|
|
|
} else {
|
* 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
|
|
|
group_id = grp->gr_gid;
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
* 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
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
#ifdef USE_NIS
|
|
|
|
/*
|
|
|
|
* Now make sure it isn't an NIS group.
|
|
|
|
*/
|
|
|
|
if (__isgrNIS ()) {
|
2007-10-07 17:14:59 +05:30
|
|
|
char *nis_domain;
|
|
|
|
char *nis_master;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-12-23 03:36:27 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: group %s is a NIS group\n"),
|
|
|
|
Prog, group_name);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
if (!yp_get_default_domain (&nis_domain) &&
|
|
|
|
!yp_master (nis_domain, "group.byname", &nis_master)) {
|
2008-12-23 03:36:27 +05:30
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: %s is the NIS master\n"),
|
|
|
|
Prog, nis_master);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-12-23 03:22:43 +05:30
|
|
|
exit (E_NOTFOUND);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (gflg) {
|
2007-10-07 17:14:02 +05:30
|
|
|
check_new_gid ();
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-10 23:15:08 +05:30
|
|
|
if (nflg) {
|
2007-10-07 17:14:02 +05:30
|
|
|
check_new_name ();
|
2008-06-10 23:15:08 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-12-23 03:22:43 +05:30
|
|
|
lock_files ();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now if the group is not changed, it's our fault.
|
|
|
|
* Make sure failures will be reported.
|
|
|
|
*/
|
|
|
|
prepare_failure_reports ();
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* Do the hard stuff - open the files, create the group entries,
|
|
|
|
* then close and update the files.
|
|
|
|
*/
|
|
|
|
open_files ();
|
|
|
|
|
|
|
|
grp_update ();
|
2008-03-09 04:31:49 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
close_files ();
|
2007-10-07 17:14:38 +05:30
|
|
|
|
2007-10-07 20:06:51 +05:30
|
|
|
nscd_flush_cache ("group");
|
|
|
|
|
* src/newgrp.c, src/chfn.c, src/groupmems.c, src/usermod.c,
src/userdel.c, src/chpasswd.c, src/grpck.c, src/gpasswd.c,
src/groupdel.c, src/chgpasswd.c, src/vipw.c, src/useradd.c,
src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/faillog.c,
src/sulogin.c, src/chsh.c, src/pwconv.c: Added splint annotations.
* src/userdel.c, src/pwconv.c, src/lastlog.c, src/grpck.c,
src/vipw.c, src/groupmod.c, src/passwd.c, src/pwck.c, src/login.c,
src/sulogin.c, src/usermod.c: Use return instead of exit at the
end of main().
* src/gpasswd.c, src/passwd.c, src/faillog.c: Use the exitcodes.h
exit codes.
* src/chpasswd.c: Added missing ||.
* src/nologin.c: Do not include exitcodes.h.
* src/nologin.c: Added brackets.
* src/nologin.c: Avoid assignments in comparisons.
2009-05-01 03:09:38 +05:30
|
|
|
return E_SUCCESS;
|
2007-10-07 17:15:23 +05:30
|
|
|
}
|
2008-03-09 04:31:49 +05:30
|
|
|
|