adduser: don't bomb out if shadow password file doesn't exist

(from Tito <farmatito@tiscali.it>)
This commit is contained in:
Denis Vlasenko 2007-03-24 16:06:46 +00:00
parent 219d14d514
commit 7695328575

View File

@ -109,19 +109,23 @@ static int adduser(struct passwd *p)
if (putpwent(p, file) == -1) { if (putpwent(p, file) == -1) {
bb_perror_nomsg_and_die(); bb_perror_nomsg_and_die();
} }
fclose(file); if (ENABLE_FEATURE_CLEAN_UP)
fclose(file);
#if ENABLE_FEATURE_SHADOWPASSWDS #if ENABLE_FEATURE_SHADOWPASSWDS
/* add to shadow if necessary */ /* add to shadow if necessary */
file = xfopen(bb_path_shadow_file, "a"); file = fopen_or_warn(bb_path_shadow_file, "a");
fseek(file, 0, SEEK_END); if (file) {
fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", fseek(file, 0, SEEK_END);
p->pw_name, /* username */ fprintf(file, "%s:!:%ld:%d:%d:%d:::\n",
time(NULL) / 86400, /* sp->sp_lstchg */ p->pw_name, /* username */
0, /* sp->sp_min */ time(NULL) / 86400, /* sp->sp_lstchg */
99999, /* sp->sp_max */ 0, /* sp->sp_min */
7); /* sp->sp_warn */ 99999, /* sp->sp_max */
fclose(file); 7); /* sp->sp_warn */
if (ENABLE_FEATURE_CLEAN_UP)
fclose(file);
}
#endif #endif
/* add to group */ /* add to group */