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 - 2009, 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>
48 #include "prototypes.h"
53 #include "exitcodes.h"
58 /* The name of this command, as it is invoked */
62 /* Indicate if shadow groups are enabled on the system
63 * (/etc/gshadow present) */
64 static bool is_shadowgrp;
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 (int status);
98 static RETSIGTYPE catch_signals (int killed);
99 static bool is_valid_user_list (const char *users);
100 static void process_flags (int argc, char **argv);
101 static void check_flags (int argc, int opt_index);
102 static void open_files (void);
103 static void close_files (void);
105 static void get_group (struct group *gr, struct sgrp *sg);
106 static void check_perms (const struct group *gr, const struct sgrp *sg);
107 static void update_group (struct group *gr, struct sgrp *sg);
108 static void change_passwd (struct group *gr, struct sgrp *sg);
110 static void get_group (struct group *gr);
111 static void check_perms (const struct group *gr);
112 static void update_group (struct group *gr);
113 static void change_passwd (struct group *gr);
115 static void log_gpasswd_failure (const char *suffix);
116 static void log_gpasswd_failure_system (unused void *arg);
117 static void log_gpasswd_failure_group (unused void *arg);
119 static void log_gpasswd_failure_gshadow (unused void *arg);
121 static void log_gpasswd_success (const char *suffix);
122 static void log_gpasswd_success_system (unused void *arg);
123 static void log_gpasswd_success_group (unused void *arg);
125 static void log_gpasswd_success_gshadow (unused void *arg);
129 * usage - display usage message
131 static void usage (int status)
133 fprintf (status ? stderr : stdout,
134 _("Usage: %s [option] GROUP\n"
137 " -a, --add USER add USER to GROUP\n"
138 " -d, --delete USER remove USER from GROUP\n"
139 " -h, --help display this help message and exit\n"
140 " -r, --remove-password remove the GROUP's password\n"
141 " -R, --restrict restrict access to GROUP to its members\n"
142 " -M, --members USER,... set the list of members of GROUP\n"
147 _(" -A, --administrators ADMIN,...\n"
148 " set the list of administrators for GROUP\n"
149 "Except for the -A and -M options, the options cannot be combined.\n")
151 _("The options cannot be combined.\n")
158 * catch_signals - set or reset termio modes.
160 * catch_signals() is called before processing begins. signal() is then
161 * called with catch_signals() as the signal handler. If signal later
162 * calls catch_signals() with a signal number, the terminal modes are
165 static RETSIGTYPE catch_signals (int killed)
176 (void) putchar ('\n');
177 (void) fflush (stdout);
183 * is_valid_user_list - check a comma-separated list of user names for validity
185 * is_valid_user_list scans a comma-separated list of user names and
186 * checks that each listed name exists is the user database.
188 * It returns true if the list of users is valid.
190 static bool is_valid_user_list (const char *users)
192 char *username, *end;
193 bool is_valid = true;
194 char *tmpusers = xstrdup (users);
196 for (username = tmpusers;
197 (NULL != username) && ('\0' != *username);
199 end = strchr (username, ',');
206 * This user must exist.
209 /* local, no need for xgetpwnam */
210 if (getpwnam (username) == NULL) {
211 fprintf (stderr, _("%s: user '%s' does not exist\n"),
222 static void failure (void)
224 fprintf (stderr, _("%s: Permission denied.\n"), Prog);
225 log_gpasswd_failure (": Permission denied");
230 * process_flags - process the command line options and arguments
232 static void process_flags (int argc, char **argv)
235 int option_index = 0;
236 static struct option long_options[] = {
237 {"add", required_argument, NULL, 'a'},
238 {"delete", required_argument, NULL, 'd'},
239 {"help", no_argument, NULL, 'h'},
240 {"remove-password", no_argument, NULL, 'r'},
241 {"restrict", no_argument, NULL, 'R'},
242 {"administrators", required_argument, NULL, 'A'},
243 {"members", required_argument, NULL, 'M'},
244 {NULL, 0, NULL, '\0'}
247 while ((flag = getopt_long (argc, argv, "a:A:d:ghM:rR", long_options, &option_index)) != -1) {
249 case 'a': /* add a user */
252 /* local, no need for xgetpwnam */
253 if (getpwnam (user) == NULL) {
255 _("%s: user '%s' does not exist\n"),
261 case 'A': /* set the list of administrators */
264 _("%s: shadow group passwords required for -A\n"),
266 exit (E_GSHADOW_NOTFOUND);
269 if (!is_valid_user_list (admins)) {
274 #endif /* SHADOWGRP */
275 case 'd': /* delete a user */
279 case 'g': /* no-op from normal password */
283 case 'M': /* set the list of members */
285 if (!is_valid_user_list (members)) {
290 case 'r': /* remove group password */
293 case 'R': /* restrict group password */
301 /* Get the name of the group that is being affected. */
302 group = argv[optind];
304 check_flags (argc, optind);
308 * check_flags - check the validity of options
310 static void check_flags (int argc, int opt_index)
314 * Make sure exclusive flags are exclusive
336 * Make sure one (and only one) group was provided
338 if ((argc != (opt_index+1)) || (NULL == group)) {
344 * open_files - lock and open the group databases
346 * It will call exit in case of error.
348 static void open_files (void)
350 if (gr_lock () == 0) {
352 _("%s: cannot lock %s; try again later.\n"),
356 add_cleanup (cleanup_unlock_group, NULL);
360 if (sgr_lock () == 0) {
362 _("%s: cannot lock %s; try again later.\n"),
363 Prog, sgr_dbname ());
366 add_cleanup (cleanup_unlock_gshadow, NULL);
368 #endif /* SHADOWGRP */
370 add_cleanup (log_gpasswd_failure_system, NULL);
372 if (gr_open (O_RDWR) == 0) {
374 _("%s: cannot open %s\n"),
376 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
382 if (sgr_open (O_RDWR) == 0) {
384 _("%s: cannot open %s\n"),
385 Prog, sgr_dbname ());
386 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
389 add_cleanup (log_gpasswd_failure_gshadow, NULL);
391 #endif /* SHADOWGRP */
393 add_cleanup (log_gpasswd_failure_group, NULL);
394 del_cleanup (log_gpasswd_failure_system);
397 static void log_gpasswd_failure (const char *suffix)
404 "%s failed to add user %s to group %s%s",
405 myname, user, group, suffix));
408 "%s failed to add user %s to group %s%s",
409 myname, user, group, suffix);
411 audit_logger (AUDIT_USER_ACCT, Prog,
414 SHADOW_AUDIT_FAILURE);
418 "%s failed to remove user %s from group %s%s",
419 myname, user, group, suffix));
422 "%s failed to remove user %s from group %s%s",
423 myname, user, group, suffix);
425 audit_logger (AUDIT_USER_ACCT, Prog,
428 SHADOW_AUDIT_FAILURE);
432 "%s failed to remove password of group %s%s",
433 myname, group, suffix));
436 "%s failed to remove password of group %s%s",
437 myname, group, suffix);
439 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
442 SHADOW_AUDIT_FAILURE);
446 "%s failed to restrict access to group %s%s",
447 myname, group, suffix));
450 "%s failed to restrict access to group %s%s",
451 myname, group, suffix);
453 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
456 SHADOW_AUDIT_FAILURE);
458 } else if (Aflg || Mflg) {
462 "%s failed to set the administrators of group %s to %s%s",
463 myname, group, admins, suffix));
466 "%s failed to set the administrators of group %s to %s%s",
467 myname, group, admins, suffix);
469 audit_logger (AUDIT_USER_ACCT, Prog,
472 SHADOW_AUDIT_FAILURE);
475 #endif /* SHADOWGRP */
478 "%s failed to set the members of group %s to %s%s",
479 myname, group, members, suffix));
482 "%s failed to set the members of group %s to %s%s",
483 myname, group, members, suffix);
485 audit_logger (AUDIT_USER_ACCT, Prog,
488 SHADOW_AUDIT_FAILURE);
493 "%s failed to change password of group %s%s",
494 myname, group, suffix));
497 "%s failed to change password of group %s%s",
498 myname, group, suffix);
500 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
503 SHADOW_AUDIT_FAILURE);
508 static void log_gpasswd_failure_system (unused void *arg)
510 log_gpasswd_failure ("");
513 static void log_gpasswd_failure_group (unused void *arg)
516 snprintf (buf, 1023, " in %s", gr_dbname ());
518 log_gpasswd_failure (buf);
522 static void log_gpasswd_failure_gshadow (unused void *arg)
525 snprintf (buf, 1023, " in %s", sgr_dbname ());
527 log_gpasswd_failure (buf);
529 #endif /* SHADOWGRP */
531 static void log_gpasswd_success (const char *suffix)
538 "user %s added by %s to group %s%s",
539 user, myname, group, suffix));
542 "user %s added by %s to group %s%s",
543 user, myname, group, suffix);
545 audit_logger (AUDIT_USER_ACCT, Prog,
548 SHADOW_AUDIT_SUCCESS);
552 "user %s removed by %s from group %s%s",
553 user, myname, group, suffix));
556 "user %s removed by %s from group %s%s",
557 user, myname, group, suffix);
559 audit_logger (AUDIT_USER_ACCT, Prog,
562 SHADOW_AUDIT_SUCCESS);
566 "password of group %s removed by %s%s",
567 group, myname, suffix));
570 "password of group %s removed by %s%s",
571 group, myname, suffix);
573 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
576 SHADOW_AUDIT_SUCCESS);
580 "access to group %s restricted by %s%s",
581 group, myname, suffix));
584 "access to group %s restricted by %s%s",
585 group, myname, suffix);
587 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
590 SHADOW_AUDIT_SUCCESS);
592 } else if (Aflg || Mflg) {
596 "administrators of group %s set by %s to %s%s",
597 group, myname, admins, suffix));
600 "administrators of group %s set by %s to %s%s",
601 group, myname, admins, suffix);
603 audit_logger (AUDIT_USER_ACCT, Prog,
606 SHADOW_AUDIT_SUCCESS);
609 #endif /* SHADOWGRP */
612 "members of group %s set by %s to %s%s",
613 group, myname, members, suffix));
616 "members of group %s set by %s to %s%s",
617 group, myname, members, suffix);
619 audit_logger (AUDIT_USER_ACCT, Prog,
622 SHADOW_AUDIT_SUCCESS);
627 "password of group %s changed by %s%s",
628 group, myname, suffix));
631 "password of group %s changed by %s%s",
632 group, myname, suffix);
634 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
637 SHADOW_AUDIT_SUCCESS);
642 static void log_gpasswd_success_system (unused void *arg)
644 log_gpasswd_success ("");
647 static void log_gpasswd_success_group (unused void *arg)
650 snprintf (buf, 1023, " in %s", gr_dbname ());
652 log_gpasswd_success (buf);
656 static void log_gpasswd_success_gshadow (unused void *arg)
659 snprintf (buf, 1023, " in %s", sgr_dbname ());
661 log_gpasswd_success (buf);
663 #endif /* SHADOWGRP */
666 * close_files - close and unlock the group databases
668 * This cause any changes in the databases to be committed.
670 * It will call exit in case of error.
672 static void close_files (void)
674 if (gr_close () == 0) {
676 _("%s: failure while writing changes to %s\n"),
680 add_cleanup (log_gpasswd_success_group, NULL);
681 del_cleanup (log_gpasswd_failure_group);
683 cleanup_unlock_group (NULL);
684 del_cleanup (cleanup_unlock_group);
688 if (sgr_close () == 0) {
690 _("%s: failure while writing changes to %s\n"),
691 Prog, sgr_dbname ());
694 add_cleanup (log_gpasswd_success_gshadow, NULL);
695 del_cleanup (log_gpasswd_failure_gshadow);
697 cleanup_unlock_gshadow (NULL);
698 del_cleanup (cleanup_unlock_gshadow);
700 #endif /* SHADOWGRP */
702 log_gpasswd_success_system (NULL);
703 del_cleanup (log_gpasswd_success_group);
706 del_cleanup (log_gpasswd_success_gshadow);
712 * check_perms - check if the user is allowed to change the password of
713 * the specified group.
715 * It only returns if the user is allowed.
718 static void check_perms (const struct group *gr, const struct sgrp *sg)
720 static void check_perms (const struct group *gr)
724 * Only root can use the -M and -A options.
726 if (!amroot && (Aflg || Mflg)) {
733 * The policy here for changing a group is that
734 * 1) you must be root or
735 * 2) you must be listed as an administrative member.
736 * Administrative members can do anything to a group that
739 if (!amroot && !is_on_list (sg->sg_adm, myname)) {
743 #endif /* SHADOWGRP */
745 #ifdef FIRST_MEMBER_IS_ADMIN
747 * The policy here for changing a group is that
748 * 1) you must be root or
749 * 2) you must be the first listed member of the group.
750 * The first listed member of a group can do anything to
751 * that group that the root user can. The rationale for
752 * this hack is that the FIRST user is probably the most
753 * important user in this entire group.
755 * This feature enabled by default could be a security
756 * problem when installed on existing systems where the
757 * first group member might be just a normal user.
761 if (gr->gr_mem[0] == (char *) 0) {
765 if (strcmp (gr->gr_mem[0], myname) != 0) {
769 #else /* ! FIRST_MEMBER_IS_ADMIN */
778 * update_group - Update the group information in the databases
781 static void update_group (struct group *gr, struct sgrp *sg)
783 static void update_group (struct group *gr)
786 if (gr_update (gr) == 0) {
788 _("%s: failed to prepare the new %s entry '%s'\n"),
789 Prog, gr_dbname (), gr->gr_name);
793 if (is_shadowgrp && (sgr_update (sg) == 0)) {
795 _("%s: failed to prepare the new %s entry '%s'\n"),
796 Prog, sgr_dbname (), sg->sg_name);
799 #endif /* SHADOWGRP */
803 * get_group - get the current information for the group
805 * The information are copied in group structure(s) so that they can be
808 * Note: If !is_shadowgrp, *sg will not be initialized.
811 static void get_group (struct group *gr, struct sgrp *sg)
813 static void get_group (struct group *gr)
816 struct group const*tmpgr = NULL;
818 struct sgrp const*tmpsg = NULL;
821 if (gr_open (O_RDONLY) == 0) {
822 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
823 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
827 tmpgr = gr_locate (group);
830 _("%s: group '%s' does not exist in %s\n"),
831 Prog, group, gr_dbname ());
836 gr->gr_name = xstrdup (tmpgr->gr_name);
837 gr->gr_passwd = xstrdup (tmpgr->gr_passwd);
838 gr->gr_mem = dup_list (tmpgr->gr_mem);
840 if (gr_close () == 0) {
842 _("%s: failure while closing read-only %s\n"),
845 "failure while closing read-only %s",
852 if (sgr_open (O_RDONLY) == 0) {
854 _("%s: cannot open %s\n"),
855 Prog, sgr_dbname ());
856 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
859 tmpsg = sgr_locate (group);
862 sg->sg_name = xstrdup (tmpsg->sg_name);
863 sg->sg_passwd = xstrdup (tmpsg->sg_passwd);
865 sg->sg_mem = dup_list (tmpsg->sg_mem);
866 sg->sg_adm = dup_list (tmpsg->sg_adm);
868 sg->sg_name = xstrdup (group);
869 sg->sg_passwd = gr->gr_passwd;
870 gr->gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
872 sg->sg_mem = dup_list (gr->gr_mem);
874 sg->sg_adm = (char **) xmalloc (sizeof (char *) * 2);
875 #ifdef FIRST_MEMBER_IS_ADMIN
877 sg->sg_adm[0] = xstrdup (sg->sg_mem[0]);
878 sg->sg_adm[1] = NULL;
882 sg->sg_adm[0] = NULL;
886 if (sgr_close () == 0) {
888 _("%s: failure while closing read-only %s\n"),
889 Prog, sgr_dbname ());
891 "failure while closing read-only %s",
896 #endif /* SHADOWGRP */
900 * change_passwd - change the group's password
902 * Get the new password from the user and update the password in the
905 * It will call exit in case of error.
908 static void change_passwd (struct group *gr, struct sgrp *sg)
910 static void change_passwd (struct group *gr)
914 static char pass[BUFSIZ];
918 * A new password is to be entered and it must be encrypted, etc.
919 * The password will be prompted for twice, and both entries must be
920 * identical. There is no need to validate the old password since
921 * the invoker is either the group owner, or root.
923 printf (_("Changing the password for group %s\n"), group);
925 for (retries = 0; retries < RETRIES; retries++) {
926 cp = getpass (_("New Password: "));
933 cp = getpass (_("Re-enter new password: "));
938 if (strcmp (pass, cp) == 0) {
944 memzero (pass, sizeof pass);
946 if (retries + 1 < RETRIES) {
947 puts (_("They don't match; try again"));
951 if (retries == RETRIES) {
952 fprintf (stderr, _("%s: Try again later\n"), Prog);
956 cp = pw_encrypt (pass, crypt_make_salt (NULL, NULL));
957 memzero (pass, sizeof pass);
969 * gpasswd - administer the /etc/group file
971 int main (int argc, char **argv)
977 struct passwd *pw = NULL;
984 (void) setlocale (LC_ALL, "");
985 (void) bindtextdomain (PACKAGE, LOCALEDIR);
986 (void) textdomain (PACKAGE);
989 * Make a note of whether or not this command was invoked by root.
990 * This will be used to bypass certain checks later on. Also, set
991 * the real user ID to match the effective user ID. This will
992 * prevent the invoker from issuing signals which would interfere
996 Prog = Basename (argv[0]);
999 setbuf (stdout, NULL);
1000 setbuf (stderr, NULL);
1003 is_shadowgrp = sgr_file_present ();
1007 * Determine the name of the user that invoked this command. This
1008 * is really hit or miss because there are so many ways that command
1009 * can be executed and so many ways to trip up the routines that
1010 * report the user name.
1012 pw = get_my_pwent ();
1014 fprintf (stderr, _("%s: Cannot determine your user name.\n"),
1017 "Cannot determine the user name of the caller (UID %lu)",
1018 (unsigned long) getuid ()));
1021 myname = xstrdup (pw->pw_name);
1024 * Register an exit function to warn for any inconsistency that we
1027 if (atexit (do_cleanups) != 0) {
1028 fprintf(stderr, "%s: cannot set exit function\n", Prog);
1032 /* Parse the options */
1033 process_flags (argc, argv);
1036 * Replicate the group so it can be modified later on.
1039 get_group (&grent, &sgent);
1045 * Check if the user is allowed to change the password of this group.
1048 check_perms (&grent, &sgent);
1050 check_perms (&grent);
1054 * Removing a password is straight forward. Just set the password
1058 grent.gr_passwd = ""; /* XXX warning: const */
1060 sgent.sg_passwd = ""; /* XXX warning: const */
1065 * Same thing for restricting the group. Set the password
1068 grent.gr_passwd = "!"; /* XXX warning: const */
1070 sgent.sg_passwd = "!"; /* XXX warning: const */
1076 * Adding a member to a member list is pretty straightforward as
1077 * well. Call the appropriate routine and split.
1080 printf (_("Adding user %s to group %s\n"), user, group);
1081 grent.gr_mem = add_list (grent.gr_mem, user);
1084 sgent.sg_mem = add_list (sgent.sg_mem, user);
1091 * Removing a member from the member list is the same deal as adding
1092 * one, except the routine is different.
1095 bool removed = false;
1097 printf (_("Removing user %s from group %s\n"), user, group);
1099 if (is_on_list (grent.gr_mem, user)) {
1101 grent.gr_mem = del_list (grent.gr_mem, user);
1105 if (is_on_list (sgent.sg_mem, user)) {
1107 sgent.sg_mem = del_list (sgent.sg_mem, user);
1113 _("%s: user '%s' is not a member of '%s'\n"),
1121 * Replacing the entire list of administrators is simple. Check the
1122 * list to make sure everyone is a real user. Then slap the new list
1126 sgent.sg_adm = comma_to_list (admins);
1131 #endif /* SHADOWGRP */
1134 * Replacing the entire list of members is simple. Check the list to
1135 * make sure everyone is a real user. Then slap the new list in
1140 sgent.sg_mem = comma_to_list (members);
1142 grent.gr_mem = comma_to_list (members);
1147 * If the password is being changed, the input and output must both
1148 * be a tty. The typical keyboard signals are caught so the termio
1149 * modes can be restored.
1151 if ((isatty (0) == 0) || (isatty (1) == 0)) {
1152 fprintf (stderr, _("%s: Not a tty\n"), Prog);
1156 catch_signals (0); /* save tty modes */
1158 (void) signal (SIGHUP, catch_signals);
1159 (void) signal (SIGINT, catch_signals);
1160 (void) signal (SIGQUIT, catch_signals);
1161 (void) signal (SIGTERM, catch_signals);
1163 (void) signal (SIGTSTP, catch_signals);
1166 /* Prompt for the new password */
1168 change_passwd (&grent, &sgent);
1170 change_passwd (&grent);
1174 * This is the common arrival point to output the new group file.
1175 * The freshly crafted entry is in allocated space. The group file
1176 * will be locked and opened for writing. The new entry will be
1180 if (setuid (0) != 0) {
1181 fputs (_("Cannot change ID to root.\n"), stderr);
1182 SYSLOG ((LOG_ERR, "can't setuid(0)"));
1191 update_group (&grent, &sgent);
1193 update_group (&grent);
1198 nscd_flush_cache ("group");