aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-24 16:06:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-24 16:06:46 +0000
commit769532857560df0cac747a85cdaa31b764cca6c4 (patch)
tree986aec907c53cebc6c49300ea497bd70677cec4f
parent219d14d514ca4d31b4319af14e3a64b66fe2c233 (diff)
downloadbusybox-769532857560df0cac747a85cdaa31b764cca6c4.tar.gz
adduser: don't bomb out if shadow password file doesn't exist
(from Tito <farmatito@tiscali.it>)
-rw-r--r--loginutils/adduser.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 4c03790d8..124e17730 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -109,19 +109,23 @@ static int adduser(struct passwd *p)
if (putpwent(p, file) == -1) {
bb_perror_nomsg_and_die();
}
- fclose(file);
+ if (ENABLE_FEATURE_CLEAN_UP)
+ fclose(file);
#if ENABLE_FEATURE_SHADOWPASSWDS
/* add to shadow if necessary */
- file = xfopen(bb_path_shadow_file, "a");
- fseek(file, 0, SEEK_END);
- fprintf(file, "%s:!:%ld:%d:%d:%d:::\n",
- p->pw_name, /* username */
- time(NULL) / 86400, /* sp->sp_lstchg */
- 0, /* sp->sp_min */
- 99999, /* sp->sp_max */
- 7); /* sp->sp_warn */
- fclose(file);
+ file = fopen_or_warn(bb_path_shadow_file, "a");
+ if (file) {
+ fseek(file, 0, SEEK_END);
+ fprintf(file, "%s:!:%ld:%d:%d:%d:::\n",
+ p->pw_name, /* username */
+ time(NULL) / 86400, /* sp->sp_lstchg */
+ 0, /* sp->sp_min */
+ 99999, /* sp->sp_max */
+ 7); /* sp->sp_warn */
+ if (ENABLE_FEATURE_CLEAN_UP)
+ fclose(file);
+ }
#endif
/* add to group */