char *cp;
const struct passwd *pw;
struct passwd newpw;
- int errors = 0;
int line = 0;
uid_t uid;
gid_t gid;
fprintf (stderr,
_("%s: line %d: line too long\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
}
if (nfields != 6) {
fprintf (stderr, _("%s: line %d: invalid line\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
/*
/* local, no need for xgetpwnam */
if ( (NULL == pw)
&& (getpwnam (fields[0]) != NULL)) {
- fprintf (stderr, _("%s: cannot update the entry of user %s (not in the passwd database)\n"), Prog, fields[0]);
- errors++;
- continue;
+ fprintf (stderr,
+ _("%s: cannot update the entry of user %s (not in the passwd database)\n"),
+ Prog, fields[0]);
+ fail_exit (EXIT_FAILURE);
}
if ( (NULL == pw)
fprintf (stderr,
_("%s: line %d: can't create user\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
/*
fprintf (stderr,
_("%s: line %d: can't create group\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
/*
fprintf (stderr,
_("%s: line %d: can't create user\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
/*
fprintf (stderr,
_("%s: line %d: user '%s' does not exist in %s\n"),
Prog, line, fields[0], pw_dbname ());
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
newpw = *pw;
fprintf (stderr,
_("%s: line %d: %s\n"),
Prog, line, strerror(errno));
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
lines[nusers-1] = line;
usernames[nusers-1] = strdup (fields[0]);
fprintf (stderr,
_("%s: line %d: can't update password\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
if ('\0' != fields[4][0]) {
newpw.pw_gecos = fields[4];
fprintf(stderr,
_("%s: line %d: homedir must be an absolute path\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
};
if (mkdir (newpw.pw_dir, mode) != 0) {
fprintf (stderr,
Prog, line, newpw.pw_dir,
strerror (errno));
if (errno != EEXIST) {
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
}
if (chown (newpw.pw_dir,
_("%s: line %d: chown %s failed: %s\n"),
Prog, line, newpw.pw_dir,
strerror (errno));
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
}
fprintf (stderr,
_("%s: line %d: can't update entry\n"),
Prog, line);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
#ifdef ENABLE_SUBIDS
fprintf (stderr,
_("%s: failed to prepare new %s entry\n"),
Prog, sub_uid_dbname ());
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
} else {
fprintf (stderr,
_("%s: can't find subordinate user range\n"),
Prog);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
}
fprintf (stderr,
_("%s: failed to prepare new %s entry\n"),
Prog, sub_uid_dbname ());
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
} else {
fprintf (stderr,
_("%s: can't find subordinate group range\n"),
Prog);
- errors++;
- continue;
+ fail_exit (EXIT_FAILURE);
}
}
#endif /* ENABLE_SUBIDS */
* changes to be written out all at once, and then unlocked
* afterwards.
*/
- if (0 != errors) {
- fprintf (stderr,
- _("%s: error detected, changes ignored\n"), Prog);
- fail_exit (EXIT_FAILURE);
- }
-
close_files ();
nscd_flush_cache ("passwd");
fprintf (stderr,
_("%s: (line %d, user %s) password not changed\n"),
Prog, lines[i], usernames[i]);
- errors++;
+ exit (EXIT_FAILURE);
}
}
#endif /* USE_PAM */
- return ((0 == errors) ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (EXIT_SUCCESS);
}