diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-24 16:06:46 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-24 16:06:46 +0000 |
commit | 769532857560df0cac747a85cdaa31b764cca6c4 (patch) | |
tree | 986aec907c53cebc6c49300ea497bd70677cec4f | |
parent | 219d14d514ca4d31b4319af14e3a64b66fe2c233 (diff) | |
download | busybox-w32-769532857560df0cac747a85cdaa31b764cca6c4.tar.gz busybox-w32-769532857560df0cac747a85cdaa31b764cca6c4.tar.bz2 busybox-w32-769532857560df0cac747a85cdaa31b764cca6c4.zip |
adduser: don't bomb out if shadow password file doesn't exist
(from Tito <farmatito@tiscali.it>)
-rw-r--r-- | loginutils/adduser.c | 24 |
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) | |||
109 | if (putpwent(p, file) == -1) { | 109 | if (putpwent(p, file) == -1) { |
110 | bb_perror_nomsg_and_die(); | 110 | bb_perror_nomsg_and_die(); |
111 | } | 111 | } |
112 | fclose(file); | 112 | if (ENABLE_FEATURE_CLEAN_UP) |
113 | fclose(file); | ||
113 | 114 | ||
114 | #if ENABLE_FEATURE_SHADOWPASSWDS | 115 | #if ENABLE_FEATURE_SHADOWPASSWDS |
115 | /* add to shadow if necessary */ | 116 | /* add to shadow if necessary */ |
116 | file = xfopen(bb_path_shadow_file, "a"); | 117 | file = fopen_or_warn(bb_path_shadow_file, "a"); |
117 | fseek(file, 0, SEEK_END); | 118 | if (file) { |
118 | fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", | 119 | fseek(file, 0, SEEK_END); |
119 | p->pw_name, /* username */ | 120 | fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", |
120 | time(NULL) / 86400, /* sp->sp_lstchg */ | 121 | p->pw_name, /* username */ |
121 | 0, /* sp->sp_min */ | 122 | time(NULL) / 86400, /* sp->sp_lstchg */ |
122 | 99999, /* sp->sp_max */ | 123 | 0, /* sp->sp_min */ |
123 | 7); /* sp->sp_warn */ | 124 | 99999, /* sp->sp_max */ |
124 | fclose(file); | 125 | 7); /* sp->sp_warn */ |
126 | if (ENABLE_FEATURE_CLEAN_UP) | ||
127 | fclose(file); | ||
128 | } | ||
125 | #endif | 129 | #endif |
126 | 130 | ||
127 | /* add to group */ | 131 | /* add to group */ |