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 FILE *usageout = status ? stderr : stdout;
134 (void) fprintf (usageout,
135 _("Usage: %s [option] GROUP\n"
139 (void) fputs (_(" -a, --add USER add USER to GROUP\n"), usageout);
140 (void) fputs (_(" -d, --delete USER remove USER from GROUP\n"), usageout);
141 (void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
142 (void) fputs (_(" -r, --remove-password remove the GROUP's password\n"), usageout);
143 (void) fputs (_(" -R, --restrict restrict access to GROUP to its members\n"), usageout);
144 (void) fputs (_(" -M, --members USER,... set the list of members of GROUP\n"), usageout);
146 (void) fputs (_(" -A, --administrators ADMIN,...\n"
147 " set the list of administrators for GROUP\n"), usageout);
148 (void) fputs (_("Except for the -A and -M options, the options cannot be combined.\n"), usageout);
150 (void) fputs (_("The options cannot be combined.\n"), usageout);
156 * catch_signals - set or reset termio modes.
158 * catch_signals() is called before processing begins. signal() is then
159 * called with catch_signals() as the signal handler. If signal later
160 * calls catch_signals() with a signal number, the terminal modes are
163 static RETSIGTYPE catch_signals (int killed)
174 (void) putchar ('\n');
175 (void) fflush (stdout);
181 * is_valid_user_list - check a comma-separated list of user names for validity
183 * is_valid_user_list scans a comma-separated list of user names and
184 * checks that each listed name exists is the user database.
186 * It returns true if the list of users is valid.
188 static bool is_valid_user_list (const char *users)
190 char *username, *end;
191 bool is_valid = true;
192 char *tmpusers = xstrdup (users);
194 for (username = tmpusers;
195 (NULL != username) && ('\0' != *username);
197 end = strchr (username, ',');
204 * This user must exist.
207 /* local, no need for xgetpwnam */
208 if (getpwnam (username) == NULL) {
209 fprintf (stderr, _("%s: user '%s' does not exist\n"),
220 static void failure (void)
222 fprintf (stderr, _("%s: Permission denied.\n"), Prog);
223 log_gpasswd_failure (": Permission denied");
228 * process_flags - process the command line options and arguments
230 static void process_flags (int argc, char **argv)
233 int option_index = 0;
234 static struct option long_options[] = {
235 {"add", required_argument, NULL, 'a'},
236 {"delete", required_argument, NULL, 'd'},
237 {"help", no_argument, NULL, 'h'},
238 {"remove-password", no_argument, NULL, 'r'},
239 {"restrict", no_argument, NULL, 'R'},
240 {"administrators", required_argument, NULL, 'A'},
241 {"members", required_argument, NULL, 'M'},
242 {NULL, 0, NULL, '\0'}
245 while ((flag = getopt_long (argc, argv, "a:A:d:ghM:rR", long_options, &option_index)) != -1) {
247 case 'a': /* add a user */
250 /* local, no need for xgetpwnam */
251 if (getpwnam (user) == NULL) {
253 _("%s: user '%s' does not exist\n"),
259 case 'A': /* set the list of administrators */
262 _("%s: shadow group passwords required for -A\n"),
264 exit (E_GSHADOW_NOTFOUND);
267 if (!is_valid_user_list (admins)) {
272 #endif /* SHADOWGRP */
273 case 'd': /* delete a user */
277 case 'g': /* no-op from normal password */
281 case 'M': /* set the list of members */
283 if (!is_valid_user_list (members)) {
288 case 'r': /* remove group password */
291 case 'R': /* restrict group password */
299 /* Get the name of the group that is being affected. */
300 group = argv[optind];
302 check_flags (argc, optind);
306 * check_flags - check the validity of options
308 static void check_flags (int argc, int opt_index)
312 * Make sure exclusive flags are exclusive
334 * Make sure one (and only one) group was provided
336 if ((argc != (opt_index+1)) || (NULL == group)) {
342 * open_files - lock and open the group databases
344 * It will call exit in case of error.
346 static void open_files (void)
348 if (gr_lock () == 0) {
350 _("%s: cannot lock %s; try again later.\n"),
354 add_cleanup (cleanup_unlock_group, NULL);
358 if (sgr_lock () == 0) {
360 _("%s: cannot lock %s; try again later.\n"),
361 Prog, sgr_dbname ());
364 add_cleanup (cleanup_unlock_gshadow, NULL);
366 #endif /* SHADOWGRP */
368 add_cleanup (log_gpasswd_failure_system, NULL);
370 if (gr_open (O_RDWR) == 0) {
372 _("%s: cannot open %s\n"),
374 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
380 if (sgr_open (O_RDWR) == 0) {
382 _("%s: cannot open %s\n"),
383 Prog, sgr_dbname ());
384 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
387 add_cleanup (log_gpasswd_failure_gshadow, NULL);
389 #endif /* SHADOWGRP */
391 add_cleanup (log_gpasswd_failure_group, NULL);
392 del_cleanup (log_gpasswd_failure_system);
395 static void log_gpasswd_failure (const char *suffix)
402 "%s failed to add user %s to group %s%s",
403 myname, user, group, suffix));
406 "%s failed to add user %s to group %s%s",
407 myname, user, group, suffix);
409 audit_logger (AUDIT_USER_ACCT, Prog,
412 SHADOW_AUDIT_FAILURE);
416 "%s failed to remove user %s from group %s%s",
417 myname, user, group, suffix));
420 "%s failed to remove user %s from group %s%s",
421 myname, user, group, suffix);
423 audit_logger (AUDIT_USER_ACCT, Prog,
426 SHADOW_AUDIT_FAILURE);
430 "%s failed to remove password of group %s%s",
431 myname, group, suffix));
434 "%s failed to remove password of group %s%s",
435 myname, group, suffix);
437 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
440 SHADOW_AUDIT_FAILURE);
444 "%s failed to restrict access to group %s%s",
445 myname, group, suffix));
448 "%s failed to restrict access to group %s%s",
449 myname, group, suffix);
451 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
454 SHADOW_AUDIT_FAILURE);
456 } else if (Aflg || Mflg) {
460 "%s failed to set the administrators of group %s to %s%s",
461 myname, group, admins, suffix));
464 "%s failed to set the administrators of group %s to %s%s",
465 myname, group, admins, suffix);
467 audit_logger (AUDIT_USER_ACCT, Prog,
470 SHADOW_AUDIT_FAILURE);
473 #endif /* SHADOWGRP */
476 "%s failed to set the members of group %s to %s%s",
477 myname, group, members, suffix));
480 "%s failed to set the members of group %s to %s%s",
481 myname, group, members, suffix);
483 audit_logger (AUDIT_USER_ACCT, Prog,
486 SHADOW_AUDIT_FAILURE);
491 "%s failed to change password of group %s%s",
492 myname, group, suffix));
495 "%s failed to change password of group %s%s",
496 myname, group, suffix);
498 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
501 SHADOW_AUDIT_FAILURE);
506 static void log_gpasswd_failure_system (unused void *arg)
508 log_gpasswd_failure ("");
511 static void log_gpasswd_failure_group (unused void *arg)
514 snprintf (buf, 1023, " in %s", gr_dbname ());
516 log_gpasswd_failure (buf);
520 static void log_gpasswd_failure_gshadow (unused void *arg)
523 snprintf (buf, 1023, " in %s", sgr_dbname ());
525 log_gpasswd_failure (buf);
527 #endif /* SHADOWGRP */
529 static void log_gpasswd_success (const char *suffix)
536 "user %s added by %s to group %s%s",
537 user, myname, group, suffix));
540 "user %s added by %s to group %s%s",
541 user, myname, group, suffix);
543 audit_logger (AUDIT_USER_ACCT, Prog,
546 SHADOW_AUDIT_SUCCESS);
550 "user %s removed by %s from group %s%s",
551 user, myname, group, suffix));
554 "user %s removed by %s from group %s%s",
555 user, myname, group, suffix);
557 audit_logger (AUDIT_USER_ACCT, Prog,
560 SHADOW_AUDIT_SUCCESS);
564 "password of group %s removed by %s%s",
565 group, myname, suffix));
568 "password of group %s removed by %s%s",
569 group, myname, suffix);
571 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
574 SHADOW_AUDIT_SUCCESS);
578 "access to group %s restricted by %s%s",
579 group, myname, suffix));
582 "access to group %s restricted by %s%s",
583 group, myname, suffix);
585 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
588 SHADOW_AUDIT_SUCCESS);
590 } else if (Aflg || Mflg) {
594 "administrators of group %s set by %s to %s%s",
595 group, myname, admins, suffix));
598 "administrators of group %s set by %s to %s%s",
599 group, myname, admins, suffix);
601 audit_logger (AUDIT_USER_ACCT, Prog,
604 SHADOW_AUDIT_SUCCESS);
607 #endif /* SHADOWGRP */
610 "members of group %s set by %s to %s%s",
611 group, myname, members, suffix));
614 "members of group %s set by %s to %s%s",
615 group, myname, members, suffix);
617 audit_logger (AUDIT_USER_ACCT, Prog,
620 SHADOW_AUDIT_SUCCESS);
625 "password of group %s changed by %s%s",
626 group, myname, suffix));
629 "password of group %s changed by %s%s",
630 group, myname, suffix);
632 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
635 SHADOW_AUDIT_SUCCESS);
640 static void log_gpasswd_success_system (unused void *arg)
642 log_gpasswd_success ("");
645 static void log_gpasswd_success_group (unused void *arg)
648 snprintf (buf, 1023, " in %s", gr_dbname ());
650 log_gpasswd_success (buf);
654 static void log_gpasswd_success_gshadow (unused void *arg)
657 snprintf (buf, 1023, " in %s", sgr_dbname ());
659 log_gpasswd_success (buf);
661 #endif /* SHADOWGRP */
664 * close_files - close and unlock the group databases
666 * This cause any changes in the databases to be committed.
668 * It will call exit in case of error.
670 static void close_files (void)
672 if (gr_close () == 0) {
674 _("%s: failure while writing changes to %s\n"),
678 add_cleanup (log_gpasswd_success_group, NULL);
679 del_cleanup (log_gpasswd_failure_group);
681 cleanup_unlock_group (NULL);
682 del_cleanup (cleanup_unlock_group);
686 if (sgr_close () == 0) {
688 _("%s: failure while writing changes to %s\n"),
689 Prog, sgr_dbname ());
692 add_cleanup (log_gpasswd_success_gshadow, NULL);
693 del_cleanup (log_gpasswd_failure_gshadow);
695 cleanup_unlock_gshadow (NULL);
696 del_cleanup (cleanup_unlock_gshadow);
698 #endif /* SHADOWGRP */
700 log_gpasswd_success_system (NULL);
701 del_cleanup (log_gpasswd_success_group);
704 del_cleanup (log_gpasswd_success_gshadow);
710 * check_perms - check if the user is allowed to change the password of
711 * the specified group.
713 * It only returns if the user is allowed.
716 static void check_perms (const struct group *gr, const struct sgrp *sg)
718 static void check_perms (const struct group *gr)
722 * Only root can use the -M and -A options.
724 if (!amroot && (Aflg || Mflg)) {
731 * The policy here for changing a group is that
732 * 1) you must be root or
733 * 2) you must be listed as an administrative member.
734 * Administrative members can do anything to a group that
737 if (!amroot && !is_on_list (sg->sg_adm, myname)) {
741 #endif /* SHADOWGRP */
743 #ifdef FIRST_MEMBER_IS_ADMIN
745 * The policy here for changing a group is that
746 * 1) you must be root or
747 * 2) you must be the first listed member of the group.
748 * The first listed member of a group can do anything to
749 * that group that the root user can. The rationale for
750 * this hack is that the FIRST user is probably the most
751 * important user in this entire group.
753 * This feature enabled by default could be a security
754 * problem when installed on existing systems where the
755 * first group member might be just a normal user.
759 if (gr->gr_mem[0] == (char *) 0) {
763 if (strcmp (gr->gr_mem[0], myname) != 0) {
767 #else /* ! FIRST_MEMBER_IS_ADMIN */
776 * update_group - Update the group information in the databases
779 static void update_group (struct group *gr, struct sgrp *sg)
781 static void update_group (struct group *gr)
784 if (gr_update (gr) == 0) {
786 _("%s: failed to prepare the new %s entry '%s'\n"),
787 Prog, gr_dbname (), gr->gr_name);
791 if (is_shadowgrp && (sgr_update (sg) == 0)) {
793 _("%s: failed to prepare the new %s entry '%s'\n"),
794 Prog, sgr_dbname (), sg->sg_name);
797 #endif /* SHADOWGRP */
801 * get_group - get the current information for the group
803 * The information are copied in group structure(s) so that they can be
806 * Note: If !is_shadowgrp, *sg will not be initialized.
809 static void get_group (struct group *gr, struct sgrp *sg)
811 static void get_group (struct group *gr)
814 struct group const*tmpgr = NULL;
816 struct sgrp const*tmpsg = NULL;
819 if (gr_open (O_RDONLY) == 0) {
820 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
821 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
825 tmpgr = gr_locate (group);
828 _("%s: group '%s' does not exist in %s\n"),
829 Prog, group, gr_dbname ());
834 gr->gr_name = xstrdup (tmpgr->gr_name);
835 gr->gr_passwd = xstrdup (tmpgr->gr_passwd);
836 gr->gr_mem = dup_list (tmpgr->gr_mem);
838 if (gr_close () == 0) {
840 _("%s: failure while closing read-only %s\n"),
843 "failure while closing read-only %s",
850 if (sgr_open (O_RDONLY) == 0) {
852 _("%s: cannot open %s\n"),
853 Prog, sgr_dbname ());
854 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
857 tmpsg = sgr_locate (group);
860 sg->sg_name = xstrdup (tmpsg->sg_name);
861 sg->sg_passwd = xstrdup (tmpsg->sg_passwd);
863 sg->sg_mem = dup_list (tmpsg->sg_mem);
864 sg->sg_adm = dup_list (tmpsg->sg_adm);
866 sg->sg_name = xstrdup (group);
867 sg->sg_passwd = gr->gr_passwd;
868 gr->gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
870 sg->sg_mem = dup_list (gr->gr_mem);
872 sg->sg_adm = (char **) xmalloc (sizeof (char *) * 2);
873 #ifdef FIRST_MEMBER_IS_ADMIN
875 sg->sg_adm[0] = xstrdup (sg->sg_mem[0]);
876 sg->sg_adm[1] = NULL;
880 sg->sg_adm[0] = NULL;
884 if (sgr_close () == 0) {
886 _("%s: failure while closing read-only %s\n"),
887 Prog, sgr_dbname ());
889 "failure while closing read-only %s",
894 #endif /* SHADOWGRP */
898 * change_passwd - change the group's password
900 * Get the new password from the user and update the password in the
903 * It will call exit in case of error.
906 static void change_passwd (struct group *gr, struct sgrp *sg)
908 static void change_passwd (struct group *gr)
912 static char pass[BUFSIZ];
916 * A new password is to be entered and it must be encrypted, etc.
917 * The password will be prompted for twice, and both entries must be
918 * identical. There is no need to validate the old password since
919 * the invoker is either the group owner, or root.
921 printf (_("Changing the password for group %s\n"), group);
923 for (retries = 0; retries < RETRIES; retries++) {
924 cp = getpass (_("New Password: "));
931 cp = getpass (_("Re-enter new password: "));
936 if (strcmp (pass, cp) == 0) {
942 memzero (pass, sizeof pass);
944 if (retries + 1 < RETRIES) {
945 puts (_("They don't match; try again"));
949 if (retries == RETRIES) {
950 fprintf (stderr, _("%s: Try again later\n"), Prog);
954 cp = pw_encrypt (pass, crypt_make_salt (NULL, NULL));
955 memzero (pass, sizeof pass);
967 * gpasswd - administer the /etc/group file
969 int main (int argc, char **argv)
975 struct passwd *pw = NULL;
982 (void) setlocale (LC_ALL, "");
983 (void) bindtextdomain (PACKAGE, LOCALEDIR);
984 (void) textdomain (PACKAGE);
987 * Make a note of whether or not this command was invoked by root.
988 * This will be used to bypass certain checks later on. Also, set
989 * the real user ID to match the effective user ID. This will
990 * prevent the invoker from issuing signals which would interfere
994 Prog = Basename (argv[0]);
997 setbuf (stdout, NULL);
998 setbuf (stderr, NULL);
1001 is_shadowgrp = sgr_file_present ();
1005 * Determine the name of the user that invoked this command. This
1006 * is really hit or miss because there are so many ways that command
1007 * can be executed and so many ways to trip up the routines that
1008 * report the user name.
1010 pw = get_my_pwent ();
1012 fprintf (stderr, _("%s: Cannot determine your user name.\n"),
1015 "Cannot determine the user name of the caller (UID %lu)",
1016 (unsigned long) getuid ()));
1019 myname = xstrdup (pw->pw_name);
1022 * Register an exit function to warn for any inconsistency that we
1025 if (atexit (do_cleanups) != 0) {
1026 fprintf(stderr, "%s: cannot set exit function\n", Prog);
1030 /* Parse the options */
1031 process_flags (argc, argv);
1034 * Replicate the group so it can be modified later on.
1037 get_group (&grent, &sgent);
1043 * Check if the user is allowed to change the password of this group.
1046 check_perms (&grent, &sgent);
1048 check_perms (&grent);
1052 * Removing a password is straight forward. Just set the password
1056 grent.gr_passwd = ""; /* XXX warning: const */
1058 sgent.sg_passwd = ""; /* XXX warning: const */
1063 * Same thing for restricting the group. Set the password
1066 grent.gr_passwd = "!"; /* XXX warning: const */
1068 sgent.sg_passwd = "!"; /* XXX warning: const */
1074 * Adding a member to a member list is pretty straightforward as
1075 * well. Call the appropriate routine and split.
1078 printf (_("Adding user %s to group %s\n"), user, group);
1079 grent.gr_mem = add_list (grent.gr_mem, user);
1082 sgent.sg_mem = add_list (sgent.sg_mem, user);
1089 * Removing a member from the member list is the same deal as adding
1090 * one, except the routine is different.
1093 bool removed = false;
1095 printf (_("Removing user %s from group %s\n"), user, group);
1097 if (is_on_list (grent.gr_mem, user)) {
1099 grent.gr_mem = del_list (grent.gr_mem, user);
1103 if (is_on_list (sgent.sg_mem, user)) {
1105 sgent.sg_mem = del_list (sgent.sg_mem, user);
1111 _("%s: user '%s' is not a member of '%s'\n"),
1119 * Replacing the entire list of administrators is simple. Check the
1120 * list to make sure everyone is a real user. Then slap the new list
1124 sgent.sg_adm = comma_to_list (admins);
1129 #endif /* SHADOWGRP */
1132 * Replacing the entire list of members is simple. Check the list to
1133 * make sure everyone is a real user. Then slap the new list in
1138 sgent.sg_mem = comma_to_list (members);
1140 grent.gr_mem = comma_to_list (members);
1145 * If the password is being changed, the input and output must both
1146 * be a tty. The typical keyboard signals are caught so the termio
1147 * modes can be restored.
1149 if ((isatty (0) == 0) || (isatty (1) == 0)) {
1150 fprintf (stderr, _("%s: Not a tty\n"), Prog);
1154 catch_signals (0); /* save tty modes */
1156 (void) signal (SIGHUP, catch_signals);
1157 (void) signal (SIGINT, catch_signals);
1158 (void) signal (SIGQUIT, catch_signals);
1159 (void) signal (SIGTERM, catch_signals);
1161 (void) signal (SIGTSTP, catch_signals);
1164 /* Prompt for the new password */
1166 change_passwd (&grent, &sgent);
1168 change_passwd (&grent);
1172 * This is the common arrival point to output the new group file.
1173 * The freshly crafted entry is in allocated space. The group file
1174 * will be locked and opened for writing. The new entry will be
1178 if (setuid (0) != 0) {
1179 fputs (_("Cannot change ID to root.\n"), stderr);
1180 SYSLOG ((LOG_ERR, "can't setuid(0)"));
1189 update_group (&grent, &sgent);
1191 update_group (&grent);
1196 nscd_flush_cache ("group");