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 = (E_SUCCESS != 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 */
282 case 'M': /* set the list of members */
284 if (!is_valid_user_list (members)) {
289 case 'r': /* remove group password */
292 case 'R': /* restrict group password */
300 /* Get the name of the group that is being affected. */
301 group = argv[optind];
303 check_flags (argc, optind);
307 * check_flags - check the validity of options
309 static void check_flags (int argc, int opt_index)
313 * Make sure exclusive flags are exclusive
335 * Make sure one (and only one) group was provided
337 if ((argc != (opt_index+1)) || (NULL == group)) {
343 * open_files - lock and open the group databases
345 * It will call exit in case of error.
347 static void open_files (void)
349 if (gr_lock () == 0) {
351 _("%s: cannot lock %s; try again later.\n"),
355 add_cleanup (cleanup_unlock_group, NULL);
359 if (sgr_lock () == 0) {
361 _("%s: cannot lock %s; try again later.\n"),
362 Prog, sgr_dbname ());
365 add_cleanup (cleanup_unlock_gshadow, NULL);
367 #endif /* SHADOWGRP */
369 add_cleanup (log_gpasswd_failure_system, NULL);
371 if (gr_open (O_RDWR) == 0) {
373 _("%s: cannot open %s\n"),
375 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
381 if (sgr_open (O_RDWR) == 0) {
383 _("%s: cannot open %s\n"),
384 Prog, sgr_dbname ());
385 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
388 add_cleanup (log_gpasswd_failure_gshadow, NULL);
390 #endif /* SHADOWGRP */
392 add_cleanup (log_gpasswd_failure_group, NULL);
393 del_cleanup (log_gpasswd_failure_system);
396 static void log_gpasswd_failure (const char *suffix)
403 "%s failed to add user %s to group %s%s",
404 myname, user, group, suffix));
407 "%s failed to add user %s to group %s%s",
408 myname, user, group, suffix);
410 audit_logger (AUDIT_USER_ACCT, Prog,
413 SHADOW_AUDIT_FAILURE);
417 "%s failed to remove user %s from group %s%s",
418 myname, user, group, suffix));
421 "%s failed to remove user %s from group %s%s",
422 myname, user, group, suffix);
424 audit_logger (AUDIT_USER_ACCT, Prog,
427 SHADOW_AUDIT_FAILURE);
431 "%s failed to remove password of group %s%s",
432 myname, group, suffix));
435 "%s failed to remove password of group %s%s",
436 myname, group, suffix);
438 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
441 SHADOW_AUDIT_FAILURE);
445 "%s failed to restrict access to group %s%s",
446 myname, group, suffix));
449 "%s failed to restrict access to group %s%s",
450 myname, group, suffix);
452 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
455 SHADOW_AUDIT_FAILURE);
457 } else if (Aflg || Mflg) {
461 "%s failed to set the administrators of group %s to %s%s",
462 myname, group, admins, suffix));
465 "%s failed to set the administrators of group %s to %s%s",
466 myname, group, admins, suffix);
468 audit_logger (AUDIT_USER_ACCT, Prog,
471 SHADOW_AUDIT_FAILURE);
474 #endif /* SHADOWGRP */
477 "%s failed to set the members of group %s to %s%s",
478 myname, group, members, suffix));
481 "%s failed to set the members of group %s to %s%s",
482 myname, group, members, suffix);
484 audit_logger (AUDIT_USER_ACCT, Prog,
487 SHADOW_AUDIT_FAILURE);
492 "%s failed to change password of group %s%s",
493 myname, group, suffix));
496 "%s failed to change password of group %s%s",
497 myname, group, suffix);
499 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
502 SHADOW_AUDIT_FAILURE);
507 static void log_gpasswd_failure_system (unused void *arg)
509 log_gpasswd_failure ("");
512 static void log_gpasswd_failure_group (unused void *arg)
515 snprintf (buf, 1023, " in %s", gr_dbname ());
517 log_gpasswd_failure (buf);
521 static void log_gpasswd_failure_gshadow (unused void *arg)
524 snprintf (buf, 1023, " in %s", sgr_dbname ());
526 log_gpasswd_failure (buf);
528 #endif /* SHADOWGRP */
530 static void log_gpasswd_success (const char *suffix)
537 "user %s added by %s to group %s%s",
538 user, myname, group, suffix));
541 "user %s added by %s to group %s%s",
542 user, myname, group, suffix);
544 audit_logger (AUDIT_USER_ACCT, Prog,
547 SHADOW_AUDIT_SUCCESS);
551 "user %s removed by %s from group %s%s",
552 user, myname, group, suffix));
555 "user %s removed by %s from group %s%s",
556 user, myname, group, suffix);
558 audit_logger (AUDIT_USER_ACCT, Prog,
561 SHADOW_AUDIT_SUCCESS);
565 "password of group %s removed by %s%s",
566 group, myname, suffix));
569 "password of group %s removed by %s%s",
570 group, myname, suffix);
572 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
575 SHADOW_AUDIT_SUCCESS);
579 "access to group %s restricted by %s%s",
580 group, myname, suffix));
583 "access to group %s restricted by %s%s",
584 group, myname, suffix);
586 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
589 SHADOW_AUDIT_SUCCESS);
591 } else if (Aflg || Mflg) {
595 "administrators of group %s set by %s to %s%s",
596 group, myname, admins, suffix));
599 "administrators of group %s set by %s to %s%s",
600 group, myname, admins, suffix);
602 audit_logger (AUDIT_USER_ACCT, Prog,
605 SHADOW_AUDIT_SUCCESS);
608 #endif /* SHADOWGRP */
611 "members of group %s set by %s to %s%s",
612 group, myname, members, suffix));
615 "members of group %s set by %s to %s%s",
616 group, myname, members, suffix);
618 audit_logger (AUDIT_USER_ACCT, Prog,
621 SHADOW_AUDIT_SUCCESS);
626 "password of group %s changed by %s%s",
627 group, myname, suffix));
630 "password of group %s changed by %s%s",
631 group, myname, suffix);
633 audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
636 SHADOW_AUDIT_SUCCESS);
641 static void log_gpasswd_success_system (unused void *arg)
643 log_gpasswd_success ("");
646 static void log_gpasswd_success_group (unused void *arg)
649 snprintf (buf, 1023, " in %s", gr_dbname ());
651 log_gpasswd_success (buf);
655 static void log_gpasswd_success_gshadow (unused void *arg)
658 snprintf (buf, 1023, " in %s", sgr_dbname ());
660 log_gpasswd_success (buf);
662 #endif /* SHADOWGRP */
665 * close_files - close and unlock the group databases
667 * This cause any changes in the databases to be committed.
669 * It will call exit in case of error.
671 static void close_files (void)
673 if (gr_close () == 0) {
675 _("%s: failure while writing changes to %s\n"),
679 add_cleanup (log_gpasswd_success_group, NULL);
680 del_cleanup (log_gpasswd_failure_group);
682 cleanup_unlock_group (NULL);
683 del_cleanup (cleanup_unlock_group);
687 if (sgr_close () == 0) {
689 _("%s: failure while writing changes to %s\n"),
690 Prog, sgr_dbname ());
693 add_cleanup (log_gpasswd_success_gshadow, NULL);
694 del_cleanup (log_gpasswd_failure_gshadow);
696 cleanup_unlock_gshadow (NULL);
697 del_cleanup (cleanup_unlock_gshadow);
699 #endif /* SHADOWGRP */
701 log_gpasswd_success_system (NULL);
702 del_cleanup (log_gpasswd_success_group);
705 del_cleanup (log_gpasswd_success_gshadow);
711 * check_perms - check if the user is allowed to change the password of
712 * the specified group.
714 * It only returns if the user is allowed.
717 static void check_perms (const struct group *gr, const struct sgrp *sg)
719 static void check_perms (const struct group *gr)
723 * Only root can use the -M and -A options.
725 if (!amroot && (Aflg || Mflg)) {
732 * The policy here for changing a group is that
733 * 1) you must be root or
734 * 2) you must be listed as an administrative member.
735 * Administrative members can do anything to a group that
738 if (!amroot && !is_on_list (sg->sg_adm, myname)) {
742 #endif /* SHADOWGRP */
744 #ifdef FIRST_MEMBER_IS_ADMIN
746 * The policy here for changing a group is that
747 * 1) you must be root or
748 * 2) you must be the first listed member of the group.
749 * The first listed member of a group can do anything to
750 * that group that the root user can. The rationale for
751 * this hack is that the FIRST user is probably the most
752 * important user in this entire group.
754 * This feature enabled by default could be a security
755 * problem when installed on existing systems where the
756 * first group member might be just a normal user.
760 if (gr->gr_mem[0] == (char *) 0) {
764 if (strcmp (gr->gr_mem[0], myname) != 0) {
768 #else /* ! FIRST_MEMBER_IS_ADMIN */
777 * update_group - Update the group information in the databases
780 static void update_group (struct group *gr, struct sgrp *sg)
782 static void update_group (struct group *gr)
785 if (gr_update (gr) == 0) {
787 _("%s: failed to prepare the new %s entry '%s'\n"),
788 Prog, gr_dbname (), gr->gr_name);
792 if (is_shadowgrp && (sgr_update (sg) == 0)) {
794 _("%s: failed to prepare the new %s entry '%s'\n"),
795 Prog, sgr_dbname (), sg->sg_name);
798 #endif /* SHADOWGRP */
802 * get_group - get the current information for the group
804 * The information are copied in group structure(s) so that they can be
807 * Note: If !is_shadowgrp, *sg will not be initialized.
810 static void get_group (struct group *gr, struct sgrp *sg)
812 static void get_group (struct group *gr)
815 struct group const*tmpgr = NULL;
817 struct sgrp const*tmpsg = NULL;
820 if (gr_open (O_RDONLY) == 0) {
821 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
822 SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
826 tmpgr = gr_locate (group);
829 _("%s: group '%s' does not exist in %s\n"),
830 Prog, group, gr_dbname ());
835 gr->gr_name = xstrdup (tmpgr->gr_name);
836 gr->gr_passwd = xstrdup (tmpgr->gr_passwd);
837 gr->gr_mem = dup_list (tmpgr->gr_mem);
839 if (gr_close () == 0) {
841 _("%s: failure while closing read-only %s\n"),
844 "failure while closing read-only %s",
851 if (sgr_open (O_RDONLY) == 0) {
853 _("%s: cannot open %s\n"),
854 Prog, sgr_dbname ());
855 SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
858 tmpsg = sgr_locate (group);
861 sg->sg_name = xstrdup (tmpsg->sg_name);
862 sg->sg_passwd = xstrdup (tmpsg->sg_passwd);
864 sg->sg_mem = dup_list (tmpsg->sg_mem);
865 sg->sg_adm = dup_list (tmpsg->sg_adm);
867 sg->sg_name = xstrdup (group);
868 sg->sg_passwd = gr->gr_passwd;
869 gr->gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
871 sg->sg_mem = dup_list (gr->gr_mem);
873 sg->sg_adm = (char **) xmalloc (sizeof (char *) * 2);
874 #ifdef FIRST_MEMBER_IS_ADMIN
876 sg->sg_adm[0] = xstrdup (sg->sg_mem[0]);
877 sg->sg_adm[1] = NULL;
881 sg->sg_adm[0] = NULL;
885 if (sgr_close () == 0) {
887 _("%s: failure while closing read-only %s\n"),
888 Prog, sgr_dbname ());
890 "failure while closing read-only %s",
895 #endif /* SHADOWGRP */
899 * change_passwd - change the group's password
901 * Get the new password from the user and update the password in the
904 * It will call exit in case of error.
907 static void change_passwd (struct group *gr, struct sgrp *sg)
909 static void change_passwd (struct group *gr)
913 static char pass[BUFSIZ];
917 * A new password is to be entered and it must be encrypted, etc.
918 * The password will be prompted for twice, and both entries must be
919 * identical. There is no need to validate the old password since
920 * the invoker is either the group owner, or root.
922 printf (_("Changing the password for group %s\n"), group);
924 for (retries = 0; retries < RETRIES; retries++) {
925 cp = getpass (_("New Password: "));
932 cp = getpass (_("Re-enter new password: "));
937 if (strcmp (pass, cp) == 0) {
943 memzero (pass, sizeof pass);
945 if (retries + 1 < RETRIES) {
946 puts (_("They don't match; try again"));
950 if (retries == RETRIES) {
951 fprintf (stderr, _("%s: Try again later\n"), Prog);
955 cp = pw_encrypt (pass, crypt_make_salt (NULL, NULL));
956 memzero (pass, sizeof pass);
968 * gpasswd - administer the /etc/group file
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");