2 * Copyright (c) 1990 - 1993, Julianne Frances Haugh
3 * Copyright (c) 1996 - 2000, Marek Michałkiewicz
4 * Copyright (c) 2000 - 2006, Tomasz Kłoczko
5 * Copyright (c) 2007 - 2011, 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.
34 * newusers - create users from a batch file
36 * newusers creates a collection of entries in /etc/passwd
37 * and related files by reading a passwd-format file and
38 * adding entries in the related directories.
45 #include <sys/types.h>
55 #ifdef ACCT_TOOLS_SETUID
59 #endif /* ACCT_TOOLS_SETUID */
60 #include "prototypes.h"
75 static bool rflg = false; /* create a system account */
77 static /*@null@*//*@observer@*/char *crypt_method = NULL;
78 #define cflg (NULL != crypt_method)
80 static bool sflg = false;
81 static long sha_rounds = 5000;
82 #endif /* USE_SHA_CRYPT */
85 static bool is_shadow;
87 static bool is_shadow_grp;
88 static bool sgr_locked = false;
90 static bool pw_locked = false;
91 static bool gr_locked = false;
92 static bool spw_locked = false;
94 /* local function prototypes */
95 static void usage (int status);
96 static void fail_exit (int);
97 static int add_group (const char *, const char *, gid_t *, gid_t);
98 static int get_user_id (const char *, uid_t *);
99 static int add_user (const char *, uid_t, gid_t);
101 static void update_passwd (struct passwd *, const char *);
102 #endif /* !USE_PAM */
103 static int add_passwd (struct passwd *, const char *);
104 static void process_flags (int argc, char **argv);
105 static void check_flags (void);
106 static void check_perms (void);
107 static void open_files (void);
108 static void close_files (void);
111 * usage - display usage message and exit
113 static void usage (int status)
115 FILE *usageout = (EXIT_SUCCESS != status) ? stderr : stdout;
116 (void) fprintf (usageout,
117 _("Usage: %s [options]\n"
122 (void) fprintf (usageout,
123 _(" -c, --crypt-method the crypt method (one of %s)\n"),
124 #ifndef USE_SHA_CRYPT
126 #else /* USE_SHA_CRYPT */
127 "NONE DES MD5 SHA256 SHA512"
128 #endif /* USE_SHA_CRYPT */
130 #endif /* !USE_PAM */
131 (void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
132 (void) fputs (_(" -r, --system create system accounts\n"), usageout);
135 (void) fputs (_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
136 " crypt algorithms\n"),
138 #endif /* USE_SHA_CRYPT */
139 #endif /* !USE_PAM */
140 (void) fputs ("\n", usageout);
146 * fail_exit - undo as much as possible
148 static void fail_exit (int code)
151 if (spw_unlock () == 0) {
152 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
153 SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
158 if (pw_unlock () == 0) {
159 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
160 SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
165 if (gr_unlock () == 0) {
166 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
167 SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
173 if (sgr_unlock () == 0) {
174 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
175 SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
185 * add_group - create a new group or add a user to an existing group
187 static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid)
189 const struct group *grp;
193 const struct sgrp *sg;
197 * Start by seeing if the named group already exists. This will be
198 * very easy to deal with if it does.
200 grp = getgrnam (gid);
202 grp = gr_locate (gid);
205 /* The user will use this ID for her primary group */
207 /* Don't check gshadow */
211 if (isdigit (gid[0])) {
213 * The GID is a number, which means either this is a brand
214 * new group, or an existing group.
217 if (get_gid (gid, &grent.gr_gid) == 0) {
219 _("%s: invalid group ID '%s'\n"),
224 /* Look in both the system database (getgrgid) and in the
225 * internal database (gr_locate_gid), which may contain
226 * uncommitted changes */
227 if ( (getgrgid ((gid_t) grent.gr_gid) != NULL)
228 || (gr_locate_gid ((gid_t) grent.gr_gid) != NULL)) {
229 /* The user will use this ID for her
231 *ngid = (gid_t) grent.gr_gid;
235 /* Do not create groups with GID == (gid_t)-1 */
236 if (grent.gr_gid == (gid_t)-1) {
238 _("%s: invalid group ID '%s'\n"),
243 /* The gid parameter can be "" or a name which is not
244 * already the name of an existing group.
245 * In both cases, figure out what group ID can be used.
247 if (find_new_gid(rflg, &grent.gr_gid, &uid) < 0) {
253 * Now I have all of the fields required to create the new group.
255 if (('\0' != gid[0]) && (!isdigit (gid[0]))) {
256 grent.gr_name = xstrdup (gid);
258 grent.gr_name = xstrdup (name);
259 /* FIXME: check if the group exists */
262 /* Check if this is a valid group name */
263 if (!is_valid_group_name (grent.gr_name)) {
265 _("%s: invalid group name '%s'\n"),
266 Prog, grent.gr_name);
267 free (grent.gr_name);
271 grent.gr_passwd = "*"; /* XXX warning: const */
273 grent.gr_mem = members;
275 *ngid = grent.gr_gid;
279 sg = sgr_locate (grent.gr_name);
283 _("%s: group '%s' is a shadow group, but does not exist in /etc/group\n"),
284 Prog, grent.gr_name);
294 sgrent.sg_name = grent.gr_name;
295 sgrent.sg_passwd = "*"; /* XXX warning: const */
296 grent.gr_passwd = "x"; /* XXX warning: const */
298 sgrent.sg_adm = admins;
299 sgrent.sg_mem = members;
301 if (sgr_update (&sgrent) == 0) {
307 if (gr_update (&grent) == 0) {
314 static int get_user_id (const char *uid, uid_t *nuid) {
317 * The first guess for the UID is either the numerical UID that the
318 * caller provided, or the next available UID.
320 if (isdigit (uid[0])) {
321 if ((get_uid (uid, nuid) == 0) || (*nuid == (uid_t)-1)) {
323 _("%s: invalid user ID '%s'\n"),
328 if ('\0' != uid[0]) {
329 const struct passwd *pwd;
330 /* local, no need for xgetpwnam */
331 pwd = getpwnam (uid);
333 pwd = pw_locate (uid);
340 _("%s: user '%s' does not exist\n"),
345 if (find_new_uid (rflg, nuid, NULL) < 0) {
355 * add_user - create a new user ID
357 static int add_user (const char *name, uid_t uid, gid_t gid)
361 /* Check if this is a valid user name */
362 if (!is_valid_user_name (name)) {
364 _("%s: invalid user name '%s'\n"),
370 * I don't want to fill in the entire password structure members
371 * JUST YET, since there is still more data to be added. So, I fill
372 * in the parts that I have.
374 pwent.pw_name = xstrdup (name);
376 pwent.pw_passwd = "x"; /* XXX warning: const */
378 pwent.pw_gecos = ""; /* XXX warning: const */
379 pwent.pw_dir = ""; /* XXX warning: const */
380 pwent.pw_shell = ""; /* XXX warning: const */
382 return (pw_update (&pwent) == 0) ? -1 : 0;
386 static void update_passwd (struct passwd *pwd, const char *password)
388 void *crypt_arg = NULL;
389 if (crypt_method != NULL) {
392 crypt_arg = &sha_rounds;
397 if ((crypt_method != NULL) && (0 == strcmp(crypt_method, "NONE"))) {
398 pwd->pw_passwd = (char *)password;
400 pwd->pw_passwd = pw_encrypt (password,
401 crypt_make_salt (crypt_method,
405 #endif /* !USE_PAM */
408 * add_passwd - add or update the encrypted password
410 static int add_passwd (struct passwd *pwd, const char *password)
412 const struct spwd *sp;
416 void *crypt_arg = NULL;
417 if (crypt_method != NULL) {
420 crypt_arg = &sha_rounds;
422 #endif /* USE_SHA_CRYPT */
426 * In the case of regular password files, this is real easy - pwd
427 * points to the entry in the password file. Shadow files are
428 * harder since there are zillions of things to do ...
431 update_passwd (pwd, password);
437 * Do the first and easiest shadow file case. The user already
438 * exists in the shadow password file.
440 sp = spw_locate (pwd->pw_name);
444 if ( (NULL != crypt_method)
445 && (0 == strcmp(crypt_method, "NONE"))) {
446 spent.sp_pwdp = (char *)password;
448 const char *salt = crypt_make_salt (crypt_method,
450 spent.sp_pwdp = pw_encrypt (password, salt);
452 spent.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
453 if (0 == spent.sp_lstchg) {
454 /* Better disable aging than requiring a password
456 spent.sp_lstchg = -1;
458 return (spw_update (&spent) == 0);
462 * Pick the next easiest case - the user has an encrypted password
463 * which isn't equal to "x". The password was set to "x" earlier
464 * when the entry was created, so this user would have to have had
465 * the password set someplace else.
467 if (strcmp (pwd->pw_passwd, "x") != 0) {
468 update_passwd (pwd, password);
473 * If there is already a shadow entry, do not touch it.
474 * If there is already a passwd entry with a password, do not
476 * The password will be updated later for all users using PAM.
479 || (strcmp (pwd->pw_passwd, "x") != 0)) {
485 * Now the really hard case - I need to create an entirely new
486 * shadow password file entry.
488 spent.sp_namp = pwd->pw_name;
490 if ((crypt_method != NULL) && (0 == strcmp(crypt_method, "NONE"))) {
491 spent.sp_pwdp = (char *)password;
493 const char *salt = crypt_make_salt (crypt_method, crypt_arg);
494 spent.sp_pwdp = pw_encrypt (password, salt);
499 * The password will be updated later for all users using PAM.
503 spent.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
504 if (0 == spent.sp_lstchg) {
505 /* Better disable aging than requiring a password change */
506 spent.sp_lstchg = -1;
508 spent.sp_min = getdef_num ("PASS_MIN_DAYS", 0);
509 /* 10000 is infinity this week */
510 spent.sp_max = getdef_num ("PASS_MAX_DAYS", 10000);
511 spent.sp_warn = getdef_num ("PASS_WARN_AGE", -1);
513 spent.sp_expire = -1;
514 spent.sp_flag = SHADOW_SP_FLAG_UNSET;
516 return (spw_update (&spent) == 0);
520 * process_flags - parse the command line options
522 * It will not return if an error is encountered.
524 static void process_flags (int argc, char **argv)
527 static struct option long_options[] = {
529 {"crypt-method", required_argument, NULL, 'c'},
531 {"sha-rounds", required_argument, NULL, 's'},
532 #endif /* USE_SHA_CRYPT */
533 #endif /* !USE_PAM */
534 {"help", no_argument, NULL, 'h'},
535 {"system", no_argument, NULL, 'r'},
536 {NULL, 0, NULL, '\0'}
539 while ((c = getopt_long (argc, argv,
543 #else /* !USE_SHA_CRYPT */
545 #endif /* !USE_SHA_CRYPT */
549 long_options, NULL)) != -1) {
552 usage (EXIT_SUCCESS);
559 crypt_method = optarg;
564 if (getlong(optarg, &sha_rounds) == 0) {
566 _("%s: invalid numeric argument '%s'\n"),
568 usage (EXIT_FAILURE);
571 #endif /* USE_SHA_CRYPT */
572 #endif /* !USE_PAM */
574 usage (EXIT_FAILURE);
579 if (argv[optind] != NULL) {
580 if (freopen (argv[optind], "r", stdin) == NULL) {
582 snprintf (buf, sizeof buf, "%s: %s", Prog, argv[1]);
584 fail_exit (EXIT_FAILURE);
588 /* validate options */
593 * check_flags - check flags and parameters consistency
595 * It will not return if an error is encountered.
597 static void check_flags (void)
603 _("%s: %s flag is only allowed with the %s flag\n"),
605 usage (EXIT_FAILURE);
607 #endif /* USE_SHA_CRYPT */
610 if ( (0 != strcmp (crypt_method, "DES"))
611 && (0 != strcmp (crypt_method, "MD5"))
612 && (0 != strcmp (crypt_method, "NONE"))
614 && (0 != strcmp (crypt_method, "SHA256"))
615 && (0 != strcmp (crypt_method, "SHA512"))
616 #endif /* USE_SHA_CRYPT */
619 _("%s: unsupported crypt method: %s\n"),
621 usage (EXIT_FAILURE);
624 #endif /* !USE_PAM */
628 * check_perms - check if the caller is allowed to add a group
630 * With PAM support, the setuid bit can be set on groupadd to allow
631 * non-root users to groups.
632 * Without PAM support, only users who can write in the group databases
635 * It will not return if the user is not allowed.
637 static void check_perms (void)
639 #ifdef ACCT_TOOLS_SETUID
641 pam_handle_t *pamh = NULL;
643 struct passwd *pampw;
645 pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
648 _("%s: Cannot determine your user name.\n"),
650 fail_exit (EXIT_FAILURE);
653 retval = pam_start ("newusers", pampw->pw_name, &conv, &pamh);
655 if (PAM_SUCCESS == retval) {
656 retval = pam_authenticate (pamh, 0);
659 if (PAM_SUCCESS == retval) {
660 retval = pam_acct_mgmt (pamh, 0);
664 (void) pam_end (pamh, retval);
666 if (PAM_SUCCESS != retval) {
667 fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
668 fail_exit (EXIT_FAILURE);
671 #endif /* ACCT_TOOLS_SETUID */
675 * open_files - lock and open the password, group and shadow databases
677 static void open_files (void)
680 * Lock the password files and open them for update. This will bring
681 * all of the entries into memory where they may be searched for an
682 * modified, or new entries added. The password file is the key - if
683 * it gets locked, assume the others can be locked right away.
685 if (pw_lock () == 0) {
687 _("%s: cannot lock %s; try again later.\n"),
689 fail_exit (EXIT_FAILURE);
693 if (spw_lock () == 0) {
695 _("%s: cannot lock %s; try again later.\n"),
696 Prog, spw_dbname ());
697 fail_exit (EXIT_FAILURE);
701 if (gr_lock () == 0) {
703 _("%s: cannot lock %s; try again later.\n"),
705 fail_exit (EXIT_FAILURE);
710 if (sgr_lock () == 0) {
712 _("%s: cannot lock %s; try again later.\n"),
713 Prog, sgr_dbname ());
714 fail_exit (EXIT_FAILURE);
720 if (pw_open (O_RDWR) == 0) {
721 fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
722 fail_exit (EXIT_FAILURE);
724 if (is_shadow && (spw_open (O_RDWR) == 0)) {
725 fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ());
726 fail_exit (EXIT_FAILURE);
728 if (gr_open (O_RDWR) == 0) {
729 fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
730 fail_exit (EXIT_FAILURE);
733 if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) {
734 fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ());
735 fail_exit (EXIT_FAILURE);
741 * close_files - close and unlock the password, group and shadow databases
743 static void close_files (void)
745 if (pw_close () == 0) {
746 fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
747 SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
748 fail_exit (EXIT_FAILURE);
750 if (pw_unlock () == 0) {
751 fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
752 SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
758 if (spw_close () == 0) {
760 _("%s: failure while writing changes to %s\n"),
761 Prog, spw_dbname ());
762 SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_dbname ()));
763 fail_exit (EXIT_FAILURE);
765 if (spw_unlock () == 0) {
767 _("%s: failed to unlock %s\n"),
768 Prog, spw_dbname ());
769 SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
775 if (gr_close () == 0) {
777 _("%s: failure while writing changes to %s\n"),
779 SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
780 fail_exit (EXIT_FAILURE);
782 if (gr_unlock () == 0) {
784 _("%s: failed to unlock %s\n"),
786 SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
793 if (sgr_close () == 0) {
795 _("%s: failure while writing changes to %s\n"),
796 Prog, sgr_dbname ());
797 SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
798 fail_exit (EXIT_FAILURE);
800 if (sgr_unlock () == 0) {
802 _("%s: failed to unlock %s\n"),
803 Prog, sgr_dbname ());
804 SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
812 int main (int argc, char **argv)
818 const struct passwd *pw;
826 char **usernames = NULL;
827 char **passwords = NULL;
828 unsigned int nusers = 0;
831 Prog = Basename (argv[0]);
833 (void) setlocale (LC_ALL, "");
834 (void) bindtextdomain (PACKAGE, LOCALEDIR);
835 (void) textdomain (PACKAGE);
837 OPENLOG ("newusers");
839 process_flags (argc, argv);
843 is_shadow = spw_file_present ();
846 is_shadow_grp = sgr_file_present ();
852 * Read each line. The line has the same format as a password file
853 * entry, except that certain fields are not constrained to be
854 * numerical values. If a group ID is entered which does not already
855 * exist, an attempt is made to allocate the same group ID as the
856 * numerical user ID. Should that fail, the next available group ID
857 * over 100 is allocated. The pw_gid field will be updated with that
860 while (fgets (buf, (int) sizeof buf, stdin) != (char *) 0) {
862 cp = strrchr (buf, '\n');
866 if (feof (stdin) == 0) {
868 _("%s: line %d: line too long\n"),
876 * Break the string into fields and screw around with them.
877 * There MUST be 7 colon separated fields, although the
878 * values aren't that particular.
880 for (cp = buf, nfields = 0; nfields < 7; nfields++) {
881 fields[nfields] = cp;
882 cp = strchr (cp, ':');
891 fprintf (stderr, _("%s: line %d: invalid line\n"),
898 * First check if we have to create or update an user
900 pw = pw_locate (fields[0]);
901 /* local, no need for xgetpwnam */
903 && (getpwnam (fields[0]) != NULL)) {
904 fprintf (stderr, _("%s: cannot update the entry of user %s (not in the passwd database)\n"), Prog, fields[0]);
910 && (get_user_id (fields[2], &uid) != 0)) {
912 _("%s: line %d: can't create user\n"),
919 * Processed is the group name. A new group will be
920 * created if the group name is non-numeric and does not
921 * already exist. If the group name is a number (which is not
922 * an existing GID), a group with the same name as the user
923 * will be created, with the given GID. The given or created
924 * group will be the primary group of the user. If
925 * there is no named group to be a member of, the UID will
926 * be figured out and that value will be a candidate for a
927 * new group, if that group ID exists, a whole new group ID
931 && (add_group (fields[0], fields[3], &gid, uid) != 0)) {
933 _("%s: line %d: can't create group\n"),
940 * Now we work on the user ID. It has to be specified either
941 * as a numerical value, or left blank. If it is a numerical
942 * value, that value will be used, otherwise the next
943 * available user ID is computed and used. After this there
944 * will at least be a (struct passwd) for the user.
947 && (add_user (fields[0], uid, gid) != 0)) {
949 _("%s: line %d: can't create user\n"),
956 * The password, gecos field, directory, and shell fields
959 pw = pw_locate (fields[0]);
962 _("%s: line %d: user '%s' does not exist in %s\n"),
963 Prog, line, fields[0], pw_dbname ());
970 /* keep the list of user/password for later update by PAM */
972 lines = realloc (lines, sizeof (lines[0]) * nusers);
973 usernames = realloc (usernames, sizeof (usernames[0]) * nusers);
974 passwords = realloc (passwords, sizeof (passwords[0]) * nusers);
975 lines[nusers-1] = line;
976 usernames[nusers-1] = strdup (fields[0]);
977 passwords[nusers-1] = strdup (fields[1]);
979 if (add_passwd (&newpw, fields[1]) != 0) {
981 _("%s: line %d: can't update password\n"),
986 if ('\0' != fields[4][0]) {
987 newpw.pw_gecos = fields[4];
990 if ('\0' != fields[5][0]) {
991 newpw.pw_dir = fields[5];
994 if ('\0' != fields[6][0]) {
995 newpw.pw_shell = fields[6];
998 if ( ('\0' != newpw.pw_dir[0])
999 && (access (newpw.pw_dir, F_OK) != 0)) {
1000 /* FIXME: should check for directory */
1001 mode_t msk = 0777 & ~getdef_num ("UMASK",
1002 GETDEF_DEFAULT_UMASK);
1003 if (mkdir (newpw.pw_dir, msk) != 0) {
1005 _("%s: line %d: mkdir %s failed: %s\n"),
1006 Prog, line, newpw.pw_dir,
1008 } else if (chown (newpw.pw_dir,
1010 newpw.pw_gid) != 0) {
1012 _("%s: line %d: chown %s failed: %s\n"),
1013 Prog, line, newpw.pw_dir,
1019 * Update the password entry with the new changes made.
1021 if (pw_update (&newpw) == 0) {
1023 _("%s: line %d: can't update entry\n"),
1031 * Any detected errors will cause the entire set of changes to be
1032 * aborted. Unlocking the password file will cause all of the
1033 * changes to be ignored. Otherwise the file is closed, causing the
1034 * changes to be written out all at once, and then unlocked
1039 _("%s: error detected, changes ignored\n"), Prog);
1040 fail_exit (EXIT_FAILURE);
1045 nscd_flush_cache ("passwd");
1046 nscd_flush_cache ("group");
1050 /* Now update the passwords using PAM */
1051 for (i = 0; i < nusers; i++) {
1052 if (do_pam_passwd_non_interractive ("newusers", usernames[i], passwords[i]) != 0) {
1054 _("%s: (line %d, user %s) password not changed\n"),
1055 Prog, lines[i], usernames[i]);
1059 #endif /* USE_PAM */
1061 return ((0 == errors) ? EXIT_SUCCESS : EXIT_FAILURE);