2 * Copyright (c) 1990 - 1994, Julianne Frances Haugh
3 * Copyright (c) 1996 - 2000, Marek Michałkiewicz
4 * Copyright (c) 2001 - 2006, Tomasz Kłoczko
5 * Copyright (c) 2007 - 2008, Nicolas François
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the copyright holders or contributors may not be used to
17 * endorse or promote products derived from this software without
18 * specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #include <sys/types.h>
46 #include "exitcodes.h"
49 #include "prototypes.h"
56 /* The name of this command, as it is invoked */
60 /* Indicate if shadow groups are enabled on the system
61 * (/etc/gshadow present) */
62 static bool is_shadowgrp;
63 static bool sgr_locked = false;
65 static bool gr_locked = false;
67 /* Flags set by options */
68 static bool aflg = false;
69 static bool Aflg = false;
70 static bool dflg = false;
71 static bool Mflg = false;
72 static bool rflg = false;
73 static bool Rflg = false;
74 /* The name of the group that is being affected */
75 static char *group = NULL;
76 /* The name of the user being added (-a) or removed (-d) from group */
77 static char *user = NULL;
78 /* The new list of members set with -M */
79 static char *members = NULL;
81 /* The new list of group administrators set with -A */
82 static char *admins = NULL;
84 /* The name of the caller */
85 static char *myname = NULL;
86 /* The UID of the caller */
88 /* Indicate if gpasswd was called by root */
89 #define amroot (0 == bywho)
91 /* The number of retries for th user to provide and repeat a new password */
96 /* local function prototypes */
97 static void usage (void);
98 static RETSIGTYPE catch_signals (int killed);
99 static void fail_exit (int status);
100 static bool is_valid_user_list (const char *users);
101 static void process_flags (int argc, char **argv);
102 static void check_flags (int argc, int opt_index);
103 static void open_files (void);
104 static void close_files (void);
106 static void get_group (struct group *gr, struct sgrp *sg);
107 static void check_perms (const struct group *gr, const struct sgrp *sg);
108 static void update_group (struct group *gr, struct sgrp *sg);
109 static void change_passwd (struct group *gr, struct sgrp *sg);
111 static void get_group (struct group *gr);
112 static void check_perms (const struct group *gr);
113 static void update_group (struct group *gr);
114 static void change_passwd (struct group *gr);
118 * usage - display usage message
120 static void usage (void)
122 fprintf (stderr, _("Usage: %s [-r|-R] group\n"), Prog);
123 fprintf (stderr, _(" %s [-a user] group\n"), Prog);
124 fprintf (stderr, _(" %s [-d user] group\n"), Prog);
127 _(" %s [-A user,...] [-M user,...] group\n"), Prog);
129 fprintf (stderr, _(" %s [-M user,...] group\n"), Prog);
135 * catch_signals - set or reset termio modes.
137 * catch_signals() is called before processing begins. signal() is then
138 * called with catch_signals() as the signal handler. If signal later
139 * calls catch_signals() with a signal number, the terminal modes are
142 static RETSIGTYPE catch_signals (int killed)
153 (void) putchar ('\n');
154 (void) fflush (stdout);
160 * fail_exit - undo as much as possible
162 static void fail_exit (int status)
165 if (gr_unlock () == 0) {
166 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
167 SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
169 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
170 "unlocking group file",
171 group, AUDIT_NO_ID, 0);
177 if (sgr_unlock () == 0) {
178 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
179 SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
181 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
182 "unlocking gshadow file",
183 group, AUDIT_NO_ID, 0);
193 * is_valid_user_list - check a comma-separated list of user names for validity
195 * is_valid_user_list scans a comma-separated list of user names and
196 * checks that each listed name exists is the user database.
198 * It returns true if the list of users is valid.
200 static bool is_valid_user_list (const char *users)
202 const char *start, *end;
207 for (start = users; (NULL != start) && ('\0' != *start); start = end) {
208 end = strchr (start, ',');
210 len = (size_t) (end - start);
213 len = strlen (start);
216 if (len > sizeof (username) - 1) {
217 len = sizeof (username) - 1;
219 strncpy (username, start, len);
220 username[len] = '\0';
223 * This user must exist.
226 /* local, no need for xgetpwnam */
227 if (getpwnam (username) == NULL) {
228 fprintf (stderr, _("%s: user '%s' does not exist\n"),
236 static void failure (void)
238 fprintf (stderr, _("%s: Permission denied.\n"), Prog);
243 * process_flags - process the command line options and arguments
245 static void process_flags (int argc, char **argv)
248 int option_index = 0;
249 static struct option long_options[] = {
250 {"add", required_argument, NULL, 'a'},
251 {"delete", required_argument, NULL, 'd'},
252 {"remove-password", no_argument, NULL, 'r'},
253 {"restrict", no_argument, NULL, 'R'},
254 {"administrators", required_argument, NULL, 'A'},
255 {"members", required_argument, NULL, 'M'},
256 {NULL, 0, NULL, '\0'}
259 while ((flag = getopt_long (argc, argv, "a:A:d:gM:rR", long_options, &option_index)) != -1) {
261 case 'a': /* add a user */
263 /* local, no need for xgetpwnam */
264 if (getpwnam (user) == NULL) {
266 _("%s: user '%s' does not exist\n"), Prog,
269 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
271 user, AUDIT_NO_ID, 0);
281 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
282 "Listing administrators",
283 NULL, (unsigned int) bywho, 0);
289 _("%s: shadow group passwords required for -A\n"),
294 if (!is_valid_user_list (admins)) {
300 case 'd': /* delete a user */
304 case 'g': /* no-op from normal password */
309 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
311 NULL, (unsigned int) bywho, 0);
316 if (!is_valid_user_list (members)) {
321 case 'r': /* remove group password */
324 case 'R': /* restrict group password */
332 /* Get the name of the group that is being affected. */
333 group = argv[optind];
335 check_flags (argc, optind);
339 * check_flags - check the validity of options
341 static void check_flags (int argc, int opt_index)
345 * Make sure exclusive flags are exclusive
367 * Make sure one (and only one) group was provided
369 if ((argc != (opt_index+1)) || (NULL == group)) {
375 * open_files - lock and open the group databases
377 * It will call exit in case of error.
379 static void open_files (void)
381 if (gr_lock () == 0) {
383 _("%s: cannot lock %s; try again later.\n"),
386 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
387 "locking /etc/group",
388 group, AUDIT_NO_ID, 0);
395 if (sgr_lock () == 0) {
397 _("%s: cannot lock %s; try again later.\n"),
398 Prog, sgr_dbname ());
400 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
401 "locking /etc/gshadow",
402 group, AUDIT_NO_ID, 0);
409 if (gr_open (O_RDWR) == 0) {
410 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
411 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
413 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
414 "opening /etc/group",
415 group, AUDIT_NO_ID, 0);
420 if (is_shadowgrp && (sgr_open (O_RDWR) == 0)) {
421 fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ());
422 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
424 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
425 "opening /etc/gshadow",
426 group, AUDIT_NO_ID, 0);
434 * close_files - close and unlock the group databases
436 * This cause any changes in the databases to be committed.
438 * It will call exit in case of error.
440 static void close_files (void)
442 if (gr_close () == 0) {
443 fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
444 SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
446 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
447 "rewriting /etc/group",
448 group, AUDIT_NO_ID, 0);
454 if (sgr_close () == 0) {
455 fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
456 SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
458 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
459 "rewriting /etc/gshadow",
460 group, AUDIT_NO_ID, 0);
464 if (sgr_unlock () == 0) {
465 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
466 SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
468 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
469 "unlocking gshadow file",
470 group, AUDIT_NO_ID, 0);
477 if (gr_unlock () == 0) {
478 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
479 SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
481 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
482 "unlocking group file",
483 group, AUDIT_NO_ID, 0);
491 * check_perms - check if the user is allowed to change the password of
492 * the specified group.
494 * It only returns if the user is allowed.
497 static void check_perms (const struct group *gr, const struct sgrp *sg)
499 static void check_perms (const struct group *gr)
505 * The policy here for changing a group is that
506 * 1) you must be root or
507 * 2) you must be listed as an administrative member.
508 * Administrative members can do anything to a group that
511 if (!amroot && !is_on_list (sg->sg_adm, myname)) {
513 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
515 group, AUDIT_NO_ID, 0);
520 #endif /* ! SHADOWGRP */
522 #ifdef FIRST_MEMBER_IS_ADMIN
524 * The policy here for changing a group is that
525 * 1) you must be root or
526 * 2) you must be the first listed member of the group.
527 * The first listed member of a group can do anything to
528 * that group that the root user can. The rationale for
529 * this hack is that the FIRST user is probably the most
530 * important user in this entire group.
532 * This feature enabled by default could be a security
533 * problem when installed on existing systems where the
534 * first group member might be just a normal user.
538 if (gr->gr_mem[0] == (char *) 0) {
540 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
542 group, AUDIT_NO_ID, 0);
547 if (strcmp (gr->gr_mem[0], myname) != 0) {
549 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
551 myname, AUDIT_NO_ID, 0);
556 #else /* ! FIRST_MEMBER_IS_ADMIN */
559 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
561 group, AUDIT_NO_ID, 0);
570 * update_group - Update the group information in the databases
573 static void update_group (struct group *gr, struct sgrp *sg)
575 static void update_group (struct group *gr)
578 if (gr_update (gr) == 0) {
580 _("%s: cannot update entry '%s' in %s\n"),
581 Prog, gr->gr_name, gr_dbname ());
582 SYSLOG ((LOG_WARN, "cannot update entry '%s' in %s", gr->gr_name, gr_dbname ()));
584 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
585 "updating /etc/group",
586 group, AUDIT_NO_ID, 0);
591 if (is_shadowgrp && (sgr_update (sg) == 0)) {
592 fprintf (stderr, _("%s: cannot update entry '%s' in %s\n"), Prog, sg->sg_name, sgr_dbname ());
593 SYSLOG ((LOG_WARN, "cannot update entry '%s' in %s", sg->sg_name, sgr_dbname ()));
595 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
596 "updating /etc/gshadow",
597 group, AUDIT_NO_ID, 0);
605 * get_group - get the current information for the group
607 * The information are copied in group structure(s) so that they can be
610 * Note: If !is_shadowgrp, *sg will not be initialized.
613 static void get_group (struct group *gr, struct sgrp *sg)
615 static void get_group (struct group *gr)
618 struct group const*tmpgr = NULL;
620 struct sgrp const*tmpsg = NULL;
623 if (gr_open (O_RDONLY) == 0) {
624 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
625 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
627 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
628 "opening /etc/group",
629 group, AUDIT_NO_ID, 0);
634 tmpgr = gr_locate (group);
636 fprintf (stderr, _("%s: group '%s' does not exist in %s\n"), Prog, group, gr_dbname ());
638 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
640 group, AUDIT_NO_ID, 0);
646 gr->gr_name = xstrdup (tmpgr->gr_name);
647 gr->gr_passwd = xstrdup (tmpgr->gr_passwd);
648 gr->gr_mem = dup_list (tmpgr->gr_mem);
650 if (gr_close () == 0) {
651 fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
652 SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
654 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
655 "closing /etc/group",
656 group, AUDIT_NO_ID, 0);
663 if (sgr_open (O_RDONLY) == 0) {
665 _("%s: cannot open %s\n"), Prog, sgr_dbmane ());
666 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
668 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
669 "opening /etc/gshadow",
670 group, AUDIT_NO_ID, 0);
674 tmpsg = sgr_locate (group);
677 sg->sg_name = xstrdup (tmpsg->sg_name);
678 sg->sg_passwd = xstrdup (tmpsg->sg_passwd);
680 sg->sg_mem = dup_list (tmpsg->sg_mem);
681 sg->sg_adm = dup_list (tmpsg->sg_adm);
683 sg->sg_name = xstrdup (group);
684 sg->sg_passwd = gr->gr_passwd;
685 gr->gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
687 sg->sg_mem = dup_list (gr->gr_mem);
689 sg->sg_adm = (char **) xmalloc (sizeof (char *) * 2);
690 #ifdef FIRST_MEMBER_IS_ADMIN
692 sg->sg_adm[0] = xstrdup (sg->sg_mem[0]);
693 sg->sg_adm[1] = NULL;
697 sg->sg_adm[0] = NULL;
701 if (sgr_close () == 0) {
703 _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
704 SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
706 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
707 "closing /etc/gshadow",
708 group, AUDIT_NO_ID, 0);
713 #endif /* SHADOWGRP */
717 * change_passwd - change the group's password
719 * Get the new password from the user and update the password in the
722 * It will call exit in case of error.
725 static void change_passwd (struct group *gr, struct sgrp *sg)
727 static void change_passwd (struct group *gr)
731 static char pass[BUFSIZ];
735 * A new password is to be entered and it must be encrypted, etc.
736 * The password will be prompted for twice, and both entries must be
737 * identical. There is no need to validate the old password since
738 * the invoker is either the group owner, or root.
740 printf (_("Changing the password for group %s\n"), group);
742 for (retries = 0; retries < RETRIES; retries++) {
743 cp = getpass (_("New Password: "));
750 cp = getpass (_("Re-enter new password: "));
755 if (strcmp (pass, cp) == 0) {
761 memzero (pass, sizeof pass);
763 if (retries + 1 < RETRIES) {
764 puts (_("They don't match; try again"));
766 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
768 group, AUDIT_NO_ID, 0);
773 if (retries == RETRIES) {
774 fprintf (stderr, _("%s: Try again later\n"), Prog);
778 cp = pw_encrypt (pass, crypt_make_salt (NULL, NULL));
779 memzero (pass, sizeof pass);
789 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
791 group, AUDIT_NO_ID, 1);
793 SYSLOG ((LOG_INFO, "change the password for group %s by %s", group,
798 * gpasswd - administer the /etc/group file
800 * -a user add user to the named group
801 * -d user remove user from the named group
802 * -r remove password from the named group
803 * -R restrict access to the named group
804 * -A user,... make list of users the administrative users
805 * -M user,... make list of users the group members
807 int main (int argc, char **argv)
813 struct passwd *pw = NULL;
820 (void) setlocale (LC_ALL, "");
821 (void) bindtextdomain (PACKAGE, LOCALEDIR);
822 (void) textdomain (PACKAGE);
825 * Make a note of whether or not this command was invoked by root.
826 * This will be used to bypass certain checks later on. Also, set
827 * the real user ID to match the effective user ID. This will
828 * prevent the invoker from issuing signals which would interfer
832 Prog = Basename (argv[0]);
835 setbuf (stdout, NULL);
836 setbuf (stderr, NULL);
839 is_shadowgrp = sgr_file_present ();
842 /* Parse the options */
843 process_flags (argc, argv);
846 * Determine the name of the user that invoked this command. This
847 * is really hit or miss because there are so many ways that command
848 * can be executed and so many ways to trip up the routines that
849 * report the user name.
852 pw = get_my_pwent ();
854 fputs (_("Who are you?\n"), stderr);
856 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
858 NULL, (unsigned int) bywho, 0);
862 myname = xstrdup (pw->pw_name);
865 * Replicate the group so it can be modified later on.
868 get_group (&grent, &sgent);
874 * Check if the user is allowed to change the password of this group.
877 check_perms (&grent, &sgent);
879 check_perms (&grent);
883 * Removing a password is straight forward. Just set the password
887 grent.gr_passwd = ""; /* XXX warning: const */
889 sgent.sg_passwd = ""; /* XXX warning: const */
892 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
893 "deleting group password",
894 group, AUDIT_NO_ID, 1);
896 SYSLOG ((LOG_INFO, "remove password from group %s by %s",
901 * Same thing for restricting the group. Set the password
904 grent.gr_passwd = "!"; /* XXX warning: const */
906 sgent.sg_passwd = "!"; /* XXX warning: const */
909 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
910 "restrict access to group",
911 group, AUDIT_NO_ID, 1);
913 SYSLOG ((LOG_INFO, "restrict access to group %s by %s",
919 * Adding a member to a member list is pretty straightforward as
920 * well. Call the appropriate routine and split.
923 printf (_("Adding user %s to group %s\n"), user, group);
924 grent.gr_mem = add_list (grent.gr_mem, user);
927 sgent.sg_mem = add_list (sgent.sg_mem, user);
931 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
932 "adding group member",
933 user, AUDIT_NO_ID, 1);
935 SYSLOG ((LOG_INFO, "add member %s to group %s by %s", user,
941 * Removing a member from the member list is the same deal as adding
942 * one, except the routine is different.
945 bool removed = false;
947 printf (_("Removing user %s from group %s\n"), user, group);
949 if (is_on_list (grent.gr_mem, user)) {
951 grent.gr_mem = del_list (grent.gr_mem, user);
955 if (is_on_list (sgent.sg_mem, user)) {
957 sgent.sg_mem = del_list (sgent.sg_mem, user);
962 fprintf (stderr, _("%s: user '%s' is not a member of '%s'\n"),
965 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
967 user, AUDIT_NO_ID, 0);
972 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
974 user, AUDIT_NO_ID, 1);
976 SYSLOG ((LOG_INFO, "remove member %s from group %s by %s",
977 user, group, myname));
982 * Replacing the entire list of administrators is simple. Check the
983 * list to make sure everyone is a real user. Then slap the new list
988 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
989 "setting group admin",
990 group, AUDIT_NO_ID, 1);
992 SYSLOG ((LOG_INFO, "set administrators of %s to %s",
994 sgent.sg_adm = comma_to_list (admins);
1002 * Replacing the entire list of members is simple. Check the list to
1003 * make sure everyone is a real user. Then slap the new list in
1008 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
1009 "setting group members",
1010 group, AUDIT_NO_ID, 1);
1012 SYSLOG ((LOG_INFO, "set members of %s to %s", group, members));
1014 sgent.sg_mem = comma_to_list (members);
1016 grent.gr_mem = comma_to_list (members);
1021 * If the password is being changed, the input and output must both
1022 * be a tty. The typical keyboard signals are caught so the termio
1023 * modes can be restored.
1025 if ((isatty (0) == 0) || (isatty (1) == 0)) {
1026 fprintf (stderr, _("%s: Not a tty\n"), Prog);
1028 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
1029 "changing password",
1030 group, AUDIT_NO_ID, 0);
1035 catch_signals (0); /* save tty modes */
1037 (void) signal (SIGHUP, catch_signals);
1038 (void) signal (SIGINT, catch_signals);
1039 (void) signal (SIGQUIT, catch_signals);
1040 (void) signal (SIGTERM, catch_signals);
1042 (void) signal (SIGTSTP, catch_signals);
1045 /* Prompt for the new password */
1047 change_passwd (&grent, &sgent);
1049 change_passwd (&grent);
1053 * This is the common arrival point to output the new group file.
1054 * The freshly crafted entry is in allocated space. The group file
1055 * will be locked and opened for writing. The new entry will be
1059 if (setuid (0) != 0) {
1060 fputs (_("Cannot change ID to root.\n"), stderr);
1061 SYSLOG ((LOG_ERR, "can't setuid(0)"));
1063 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
1064 "changing id to root",
1065 group, AUDIT_NO_ID, 0);
1075 update_group (&grent, &sgent);
1077 update_group (&grent);
1082 nscd_flush_cache ("group");