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>
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;
65 /* Flags set by options */
66 static bool aflg = false;
67 static bool Aflg = false;
68 static bool dflg = false;
69 static bool Mflg = false;
70 static bool rflg = false;
71 static bool Rflg = false;
72 /* The name of the group that is being affected */
73 static char *group = NULL;
74 /* The name of the user being added (-a) or removed (-d) from group */
75 static char *user = NULL;
76 /* The new list of members set with -M */
77 static char *members = NULL;
79 /* The new list of group administrators set with -A */
80 static char *admins = NULL;
82 /* The name of the caller */
83 static char *myname = NULL;
84 /* The UID of the caller */
86 /* Indicate if gpasswd was called by root */
87 #define amroot (0 == bywho)
89 /* The number of retries for th user to provide and repeat a new password */
94 /* local function prototypes */
95 static void usage (void);
96 static RETSIGTYPE catch_signals (int killed);
97 static bool is_valid_user_list (const char *users);
98 static void process_flags (int argc, char **argv);
99 static void check_flags (int argc, int opt_index);
100 static void open_files (void);
101 static void close_files (void);
103 static void get_group (struct group *gr, struct sgrp *sg);
104 static void check_perms (const struct group *gr, const struct sgrp *sg);
105 static void update_group (struct group *gr, struct sgrp *sg);
106 static void change_passwd (struct group *gr, struct sgrp *sg);
108 static void get_group (struct group *gr);
109 static void check_perms (const struct group *gr);
110 static void update_group (struct group *gr);
111 static void change_passwd (struct group *gr);
113 static void log_gpasswd_failure (const char *suffix);
114 static void log_gpasswd_failure_system (void *unused(arg));
115 static void log_gpasswd_failure_group (void *unused(arg));
117 static void log_gpasswd_failure_gshadow (void *unused(arg));
119 static void log_gpasswd_success (const char *suffix);
120 static void log_gpasswd_success_system (void *unused(arg));
121 static void log_gpasswd_success_group (void *unused(arg));
123 static void log_gpasswd_success_gshadow (void *unused(arg));
127 * usage - display usage message
129 static void usage (void)
132 _("Usage: %s [option] GROUP\n"
135 " -a, --add USER add USER to GROUP\n"
136 " -d, --delete USER remove USER from GROUP\n"
137 " -r, --remove-password remove the GROUP's password\n"
138 " -R, --restrict restrict access to GROUP to its members\n"
139 " -M, --members USER,... set the list of members of GROUP\n"
144 _(" -A, --administrators ADMIN,...\n"
145 " set the list of administrators for GROUP\n"
146 "Except for the -A and -M options, the options cannot be combined.\n")
148 _("The options cannot be combined.\n")
155 * catch_signals - set or reset termio modes.
157 * catch_signals() is called before processing begins. signal() is then
158 * called with catch_signals() as the signal handler. If signal later
159 * calls catch_signals() with a signal number, the terminal modes are
162 static RETSIGTYPE catch_signals (int killed)
173 (void) putchar ('\n');
174 (void) fflush (stdout);
180 * is_valid_user_list - check a comma-separated list of user names for validity
182 * is_valid_user_list scans a comma-separated list of user names and
183 * checks that each listed name exists is the user database.
185 * It returns true if the list of users is valid.
187 static bool is_valid_user_list (const char *users)
189 char *username, *end;
190 bool is_valid = true;
191 char *tmpusers = xstrdup (users);
193 for (username = tmpusers;
194 (NULL != username) && ('\0' != *username);
196 end = strchr (username, ',');
203 * This user must exist.
206 /* local, no need for xgetpwnam */
207 if (getpwnam (username) == NULL) {
208 fprintf (stderr, _("%s: user '%s' does not exist\n"),
219 static void failure (void)
221 fprintf (stderr, _("%s: Permission denied.\n"), Prog);
222 log_gpasswd_failure (": Permission denied");
227 * process_flags - process the command line options and arguments
229 static void process_flags (int argc, char **argv)
232 int option_index = 0;
233 static struct option long_options[] = {
234 {"add", required_argument, NULL, 'a'},
235 {"delete", required_argument, NULL, 'd'},
236 {"remove-password", no_argument, NULL, 'r'},
237 {"restrict", no_argument, NULL, 'R'},
238 {"administrators", required_argument, NULL, 'A'},
239 {"members", required_argument, NULL, 'M'},
240 {NULL, 0, NULL, '\0'}
243 while ((flag = getopt_long (argc, argv, "a:A:d:gM:rR", long_options, &option_index)) != -1) {
245 case 'a': /* add a user */
248 /* local, no need for xgetpwnam */
249 if (getpwnam (user) == NULL) {
251 _("%s: user '%s' does not exist\n"), Prog,
257 case 'A': /* set the list of administrators */
260 _("%s: shadow group passwords required for -A\n"),
265 if (!is_valid_user_list (admins)) {
270 #endif /* SHADOWGRP */
271 case 'd': /* delete a user */
275 case 'g': /* no-op from normal password */
277 case 'M': /* set the list of members */
279 if (!is_valid_user_list (members)) {
284 case 'r': /* remove group password */
287 case 'R': /* restrict group password */
295 /* Get the name of the group that is being affected. */
296 group = argv[optind];
298 check_flags (argc, optind);
302 * check_flags - check the validity of options
304 static void check_flags (int argc, int opt_index)
308 * Make sure exclusive flags are exclusive
330 * Make sure one (and only one) group was provided
332 if ((argc != (opt_index+1)) || (NULL == group)) {
338 * open_files - lock and open the group databases
340 * It will call exit in case of error.
342 static void open_files (void)
344 if (gr_lock () == 0) {
346 _("%s: cannot lock %s; try again later.\n"),
350 add_cleanup (cleanup_unlock_group, NULL);
354 if (sgr_lock () == 0) {
356 _("%s: cannot lock %s; try again later.\n"),
357 Prog, sgr_dbname ());
360 add_cleanup (cleanup_unlock_gshadow, NULL);
362 #endif /* SHADOWGRP */
364 add_cleanup (log_gpasswd_failure_system, NULL);
366 if (gr_open (O_RDWR) == 0) {
368 _("%s: cannot open %s\n"),
370 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
376 if (sgr_open (O_RDWR) == 0) {
378 _("%s: cannot open %s\n"),
379 Prog, sgr_dbname ());
380 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
383 add_cleanup (log_gpasswd_failure_gshadow, NULL);
385 #endif /* SHADOWGRP */
387 add_cleanup (log_gpasswd_failure_group, NULL);
388 del_cleanup (log_gpasswd_failure_system);
391 static void log_gpasswd_failure (const char *suffix)
398 "%s failed to add user %s to group %s%s",
399 myname, user, group, suffix));
402 "%s failed to add user %s to group %s%s",
403 myname, user, group, suffix);
405 audit_logger (AUDIT_USER_ACCT, Prog,
408 SHADOW_AUDIT_FAILURE);
412 "%s failed to remove user %s from group %s%s",
413 myname, user, group, suffix));
416 "%s failed to remove user %s from group %s%s",
417 myname, user, group, suffix);
419 audit_logger (AUDIT_USER_ACCT, Prog,
422 SHADOW_AUDIT_FAILURE);
426 "%s failed to remove password of group %s%s",
427 myname, group, suffix));
430 "%s failed to remove password of group %s%s",
431 myname, group, suffix);
433 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
436 SHADOW_AUDIT_FAILURE);
440 "%s failed to restrict access to group %s%s",
441 myname, group, suffix));
444 "%s failed to restrict access to group %s%s",
445 myname, group, suffix);
447 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
450 SHADOW_AUDIT_FAILURE);
452 } else if (Aflg || Mflg) {
456 "%s failed to set the administrators of group %s to %s%s",
457 myname, group, admins, suffix));
460 "%s failed to set the administrators of group %s to %s%s",
461 myname, group, admins, suffix);
463 audit_logger (AUDIT_USER_ACCT, Prog,
466 SHADOW_AUDIT_FAILURE);
469 #endif /* SHADOWGRP */
472 "%s failed to set the members of group %s to %s%s",
473 myname, group, members, suffix));
476 "%s failed to set the members of group %s to %s%s",
477 myname, group, members, suffix);
479 audit_logger (AUDIT_USER_ACCT, Prog,
482 SHADOW_AUDIT_FAILURE);
487 "%s failed to change password of group %s%s",
488 myname, group, suffix));
491 "%s failed to change password of group %s%s",
492 myname, group, suffix);
494 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
497 SHADOW_AUDIT_FAILURE);
502 static void log_gpasswd_failure_system (void *unused(arg))
504 log_gpasswd_failure ("");
507 static void log_gpasswd_failure_group (void *unused(arg))
510 snprintf (buf, 1023, " in %s", gr_dbname ());
512 log_gpasswd_failure (buf);
516 static void log_gpasswd_failure_gshadow (void *unused(arg))
519 snprintf (buf, 1023, " in %s", sgr_dbname ());
521 log_gpasswd_failure (buf);
523 #endif /* SHADOWGRP */
525 static void log_gpasswd_success (const char *suffix)
532 "user %s added by %s to group %s%s",
533 user, myname, group, suffix));
536 "user %s added by %s to group %s%s",
537 user, myname, group, suffix);
539 audit_logger (AUDIT_USER_ACCT, Prog,
542 SHADOW_AUDIT_SUCCESS);
546 "user %s removed by %s from group %s%s",
547 user, myname, group, suffix));
550 "user %s removed by %s from group %s%s",
551 user, myname, group, suffix);
553 audit_logger (AUDIT_USER_ACCT, Prog,
556 SHADOW_AUDIT_SUCCESS);
560 "password of group %s removed by %s%s",
561 group, myname, suffix));
564 "password of group %s removed by %s%s",
565 group, myname, suffix);
567 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
570 SHADOW_AUDIT_SUCCESS);
574 "access to group %s restricted by %s%s",
575 group, myname, suffix));
578 "access to group %s restricted by %s%s",
579 group, myname, suffix);
581 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
584 SHADOW_AUDIT_SUCCESS);
586 } else if (Aflg || Mflg) {
590 "administrators of group %s set by %s to %s%s",
591 group, myname, admins, suffix));
594 "administrators of group %s set by %s to %s%s",
595 group, myname, admins, suffix);
597 audit_logger (AUDIT_USER_ACCT, Prog,
600 SHADOW_AUDIT_SUCCESS);
603 #endif /* SHADOWGRP */
606 "members of group %s set by %s to %s%s",
607 group, myname, members, suffix));
610 "members of group %s set by %s to %s%s",
611 group, myname, members, suffix);
613 audit_logger (AUDIT_USER_ACCT, Prog,
616 SHADOW_AUDIT_SUCCESS);
621 "password of group %s changed by %s%s",
622 group, myname, suffix));
625 "password of group %s changed by %s%s",
626 group, myname, suffix);
628 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
631 SHADOW_AUDIT_SUCCESS);
636 static void log_gpasswd_success_system (void *unused(arg))
638 log_gpasswd_success ("");
641 static void log_gpasswd_success_group (void *unused(arg))
644 snprintf (buf, 1023, " in %s", gr_dbname ());
646 log_gpasswd_success (buf);
650 static void log_gpasswd_success_gshadow (void *unused(arg))
653 snprintf (buf, 1023, " in %s", sgr_dbname ());
655 log_gpasswd_success (buf);
657 #endif /* SHADOWGRP */
660 * close_files - close and unlock the group databases
662 * This cause any changes in the databases to be committed.
664 * It will call exit in case of error.
666 static void close_files (void)
668 if (gr_close () == 0) {
670 _("%s: failure while writing changes to %s\n"),
674 add_cleanup (log_gpasswd_success_group, NULL);
675 del_cleanup (log_gpasswd_failure_group);
677 cleanup_unlock_group (NULL);
678 del_cleanup (cleanup_unlock_group);
682 if (sgr_close () == 0) {
684 _("%s: failure while writing changes to %s\n"),
685 Prog, sgr_dbname ());
688 add_cleanup (log_gpasswd_success_gshadow, NULL);
689 del_cleanup (log_gpasswd_failure_gshadow);
691 cleanup_unlock_gshadow (NULL);
692 del_cleanup (cleanup_unlock_gshadow);
694 #endif /* SHADOWGRP */
696 log_gpasswd_success_system (NULL);
697 del_cleanup (log_gpasswd_success_group);
699 del_cleanup (log_gpasswd_success_gshadow);
704 * check_perms - check if the user is allowed to change the password of
705 * the specified group.
707 * It only returns if the user is allowed.
710 static void check_perms (const struct group *gr, const struct sgrp *sg)
712 static void check_perms (const struct group *gr)
716 * Only root can use the -M and -A options.
718 if (!amroot && (Aflg || Mflg)) {
725 * The policy here for changing a group is that
726 * 1) you must be root or
727 * 2) you must be listed as an administrative member.
728 * Administrative members can do anything to a group that
731 if (!amroot && !is_on_list (sg->sg_adm, myname)) {
735 #endif /* SHADOWGRP */
737 #ifdef FIRST_MEMBER_IS_ADMIN
739 * The policy here for changing a group is that
740 * 1) you must be root or
741 * 2) you must be the first listed member of the group.
742 * The first listed member of a group can do anything to
743 * that group that the root user can. The rationale for
744 * this hack is that the FIRST user is probably the most
745 * important user in this entire group.
747 * This feature enabled by default could be a security
748 * problem when installed on existing systems where the
749 * first group member might be just a normal user.
753 if (gr->gr_mem[0] == (char *) 0) {
757 if (strcmp (gr->gr_mem[0], myname) != 0) {
761 #else /* ! FIRST_MEMBER_IS_ADMIN */
770 * update_group - Update the group information in the databases
773 static void update_group (struct group *gr, struct sgrp *sg)
775 static void update_group (struct group *gr)
778 if (gr_update (gr) == 0) {
780 _("%s: failed to prepare the new %s entry '%s'\n"),
781 Prog, gr_dbname (), gr->gr_name);
785 if (is_shadowgrp && (sgr_update (sg) == 0)) {
787 _("%s: failed to prepare the new %s entry '%s'\n"),
788 Prog, sgr_dbname (), sg->sg_name);
791 #endif /* SHADOWGRP */
795 * get_group - get the current information for the group
797 * The information are copied in group structure(s) so that they can be
800 * Note: If !is_shadowgrp, *sg will not be initialized.
803 static void get_group (struct group *gr, struct sgrp *sg)
805 static void get_group (struct group *gr)
808 struct group const*tmpgr = NULL;
810 struct sgrp const*tmpsg = NULL;
813 if (gr_open (O_RDONLY) == 0) {
814 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
815 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
819 tmpgr = gr_locate (group);
822 _("%s: group '%s' does not exist in %s\n"),
823 Prog, group, gr_dbname ());
828 gr->gr_name = xstrdup (tmpgr->gr_name);
829 gr->gr_passwd = xstrdup (tmpgr->gr_passwd);
830 gr->gr_mem = dup_list (tmpgr->gr_mem);
832 if (gr_close () == 0) {
834 _("%s: failure while closing read-only %s\n"),
837 "failure while closing read-only %s",
844 if (sgr_open (O_RDONLY) == 0) {
846 _("%s: cannot open %s\n"),
847 Prog, sgr_dbname ());
848 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
851 tmpsg = sgr_locate (group);
854 sg->sg_name = xstrdup (tmpsg->sg_name);
855 sg->sg_passwd = xstrdup (tmpsg->sg_passwd);
857 sg->sg_mem = dup_list (tmpsg->sg_mem);
858 sg->sg_adm = dup_list (tmpsg->sg_adm);
860 sg->sg_name = xstrdup (group);
861 sg->sg_passwd = gr->gr_passwd;
862 gr->gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
864 sg->sg_mem = dup_list (gr->gr_mem);
866 sg->sg_adm = (char **) xmalloc (sizeof (char *) * 2);
867 #ifdef FIRST_MEMBER_IS_ADMIN
869 sg->sg_adm[0] = xstrdup (sg->sg_mem[0]);
870 sg->sg_adm[1] = NULL;
874 sg->sg_adm[0] = NULL;
878 if (sgr_close () == 0) {
880 _("%s: failure while closing read-only %s\n"),
881 Prog, sgr_dbname ());
883 "failure while closing read-only %s",
888 #endif /* SHADOWGRP */
892 * change_passwd - change the group's password
894 * Get the new password from the user and update the password in the
897 * It will call exit in case of error.
900 static void change_passwd (struct group *gr, struct sgrp *sg)
902 static void change_passwd (struct group *gr)
906 static char pass[BUFSIZ];
910 * A new password is to be entered and it must be encrypted, etc.
911 * The password will be prompted for twice, and both entries must be
912 * identical. There is no need to validate the old password since
913 * the invoker is either the group owner, or root.
915 printf (_("Changing the password for group %s\n"), group);
917 for (retries = 0; retries < RETRIES; retries++) {
918 cp = getpass (_("New Password: "));
925 cp = getpass (_("Re-enter new password: "));
930 if (strcmp (pass, cp) == 0) {
936 memzero (pass, sizeof pass);
938 if (retries + 1 < RETRIES) {
939 puts (_("They don't match; try again"));
943 if (retries == RETRIES) {
944 fprintf (stderr, _("%s: Try again later\n"), Prog);
948 cp = pw_encrypt (pass, crypt_make_salt (NULL, NULL));
949 memzero (pass, sizeof pass);
961 * gpasswd - administer the /etc/group file
963 * -a user add user to the named group
964 * -d user remove user from the named group
965 * -r remove password from the named group
966 * -R restrict access to the named group
967 * -A user,... make list of users the administrative users
968 * -M user,... make list of users the group members
970 int main (int argc, char **argv)
976 struct passwd *pw = NULL;
983 (void) setlocale (LC_ALL, "");
984 (void) bindtextdomain (PACKAGE, LOCALEDIR);
985 (void) textdomain (PACKAGE);
988 * Make a note of whether or not this command was invoked by root.
989 * This will be used to bypass certain checks later on. Also, set
990 * the real user ID to match the effective user ID. This will
991 * prevent the invoker from issuing signals which would interfere
995 Prog = Basename (argv[0]);
998 setbuf (stdout, NULL);
999 setbuf (stderr, NULL);
1002 is_shadowgrp = sgr_file_present ();
1006 * Determine the name of the user that invoked this command. This
1007 * is really hit or miss because there are so many ways that command
1008 * can be executed and so many ways to trip up the routines that
1009 * report the user name.
1011 pw = get_my_pwent ();
1013 fprintf (stderr, _("%s: Cannot determine your user name.\n"),
1016 "Cannot determine the user name of the caller (UID %lu)",
1017 (unsigned long) getuid ()));
1020 myname = xstrdup (pw->pw_name);
1023 * Register an exit function to warn for any inconsistency that we
1026 if (atexit (do_cleanups) != 0) {
1027 fprintf(stderr, "%s: cannot set exit function\n", Prog);
1031 /* Parse the options */
1032 process_flags (argc, argv);
1035 * Replicate the group so it can be modified later on.
1038 get_group (&grent, &sgent);
1044 * Check if the user is allowed to change the password of this group.
1047 check_perms (&grent, &sgent);
1049 check_perms (&grent);
1053 * Removing a password is straight forward. Just set the password
1057 grent.gr_passwd = ""; /* XXX warning: const */
1059 sgent.sg_passwd = ""; /* XXX warning: const */
1064 * Same thing for restricting the group. Set the password
1067 grent.gr_passwd = "!"; /* XXX warning: const */
1069 sgent.sg_passwd = "!"; /* XXX warning: const */
1075 * Adding a member to a member list is pretty straightforward as
1076 * well. Call the appropriate routine and split.
1079 printf (_("Adding user %s to group %s\n"), user, group);
1080 grent.gr_mem = add_list (grent.gr_mem, user);
1083 sgent.sg_mem = add_list (sgent.sg_mem, user);
1090 * Removing a member from the member list is the same deal as adding
1091 * one, except the routine is different.
1094 bool removed = false;
1096 printf (_("Removing user %s from group %s\n"), user, group);
1098 if (is_on_list (grent.gr_mem, user)) {
1100 grent.gr_mem = del_list (grent.gr_mem, user);
1104 if (is_on_list (sgent.sg_mem, user)) {
1106 sgent.sg_mem = del_list (sgent.sg_mem, user);
1112 _("%s: user '%s' is not a member of '%s'\n"),
1120 * Replacing the entire list of administrators is simple. Check the
1121 * list to make sure everyone is a real user. Then slap the new list
1125 sgent.sg_adm = comma_to_list (admins);
1130 #endif /* SHADOWGRP */
1133 * Replacing the entire list of members is simple. Check the list to
1134 * make sure everyone is a real user. Then slap the new list in
1139 sgent.sg_mem = comma_to_list (members);
1141 grent.gr_mem = comma_to_list (members);
1146 * If the password is being changed, the input and output must both
1147 * be a tty. The typical keyboard signals are caught so the termio
1148 * modes can be restored.
1150 if ((isatty (0) == 0) || (isatty (1) == 0)) {
1151 fprintf (stderr, _("%s: Not a tty\n"), Prog);
1155 catch_signals (0); /* save tty modes */
1157 (void) signal (SIGHUP, catch_signals);
1158 (void) signal (SIGINT, catch_signals);
1159 (void) signal (SIGQUIT, catch_signals);
1160 (void) signal (SIGTERM, catch_signals);
1162 (void) signal (SIGTSTP, catch_signals);
1165 /* Prompt for the new password */
1167 change_passwd (&grent, &sgent);
1169 change_passwd (&grent);
1173 * This is the common arrival point to output the new group file.
1174 * The freshly crafted entry is in allocated space. The group file
1175 * will be locked and opened for writing. The new entry will be
1179 if (setuid (0) != 0) {
1180 fputs (_("Cannot change ID to root.\n"), stderr);
1181 SYSLOG ((LOG_ERR, "can't setuid(0)"));
1190 update_group (&grent, &sgent);
1192 update_group (&grent);
1197 nscd_flush_cache ("group");