summaryrefslogtreecommitdiff
path: root/loginutils/passwd.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /loginutils/passwd.c
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
Major coreutils update.
Diffstat (limited to 'loginutils/passwd.c')
-rw-r--r--loginutils/passwd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index e02cc4b81..e8577066a 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -46,13 +46,13 @@ extern int update_passwd(const struct passwd *pw, char *crypt_pw)
46 struct stat sb; 46 struct stat sb;
47 struct flock lock; 47 struct flock lock;
48 48
49 if (access(shadow_file, F_OK) == 0) { 49 if (access(bb_path_shadow_file, F_OK) == 0) {
50 has_shadow = 1; 50 has_shadow = 1;
51 } 51 }
52 if (has_shadow) { 52 if (has_shadow) {
53 snprintf(filename, sizeof filename, "%s", shadow_file); 53 snprintf(filename, sizeof filename, "%s", bb_path_shadow_file);
54 } else { 54 } else {
55 snprintf(filename, sizeof filename, "%s", passwd_file); 55 snprintf(filename, sizeof filename, "%s", bb_path_passwd_file);
56 } 56 }
57 57
58 if (((fp = fopen(filename, "r+")) == 0) || (fstat(fileno(fp), &sb))) { 58 if (((fp = fopen(filename, "r+")) == 0) || (fstat(fileno(fp), &sb))) {
@@ -167,30 +167,30 @@ extern int passwd_main(int argc, char **argv)
167 uflg++; 167 uflg++;
168 break; 168 break;
169 default: 169 default:
170 show_usage(); 170 bb_show_usage();
171 } 171 }
172 } 172 }
173 ruid = getuid(); 173 ruid = getuid();
174 pw = (struct passwd *) getpwuid(ruid); 174 pw = (struct passwd *) getpwuid(ruid);
175 if (!pw) { 175 if (!pw) {
176 error_msg_and_die("Cannot determine your user name."); 176 bb_error_msg_and_die("Cannot determine your user name.");
177 } 177 }
178 myname = (char *) xstrdup(pw->pw_name); 178 myname = (char *) bb_xstrdup(pw->pw_name);
179 if (optind < argc) { 179 if (optind < argc) {
180 name = argv[optind]; 180 name = argv[optind];
181 } else { 181 } else {
182 name = myname; 182 name = myname;
183 } 183 }
184 if ((lflg || uflg || dflg) && (optind >= argc || !amroot)) { 184 if ((lflg || uflg || dflg) && (optind >= argc || !amroot)) {
185 show_usage(); 185 bb_show_usage();
186 } 186 }
187 pw = getpwnam(name); 187 pw = getpwnam(name);
188 if (!pw) { 188 if (!pw) {
189 error_msg_and_die("Unknown user %s\n", name); 189 bb_error_msg_and_die("Unknown user %s\n", name);
190 } 190 }
191 if (!amroot && pw->pw_uid != getuid()) { 191 if (!amroot && pw->pw_uid != getuid()) {
192 syslog(LOG_WARNING, "can't change pwd for `%s'", name); 192 syslog(LOG_WARNING, "can't change pwd for `%s'", name);
193 error_msg_and_die("Permission denied.\n"); 193 bb_error_msg_and_die("Permission denied.\n");
194 } 194 }
195#ifdef CONFIG_FEATURE_SHADOWPASSWDS 195#ifdef CONFIG_FEATURE_SHADOWPASSWDS
196 sp = getspnam(name); 196 sp = getspnam(name);
@@ -209,12 +209,12 @@ extern int passwd_main(int argc, char **argv)
209 if (!amroot) { 209 if (!amroot) {
210 if (cp[0] == '!') { 210 if (cp[0] == '!') {
211 syslog(LOG_WARNING, "password locked for `%s'", np); 211 syslog(LOG_WARNING, "password locked for `%s'", np);
212 error_msg_and_die( "The password for `%s' cannot be changed.\n", np); 212 bb_error_msg_and_die( "The password for `%s' cannot be changed.\n", np);
213 } 213 }
214 } 214 }
215 printf("Changing password for %s\n", name); 215 printf("Changing password for %s\n", name);
216 if (new_password(pw, amroot, algo)) { 216 if (new_password(pw, amroot, algo)) {
217 error_msg_and_die( "The password for %s is unchanged.\n", name); 217 bb_error_msg_and_die( "The password for %s is unchanged.\n", name);
218 } 218 }
219 } else if (lflg) { 219 } else if (lflg) {
220 if (crypt_passwd[0] != '!') { 220 if (crypt_passwd[0] != '!') {
@@ -238,7 +238,7 @@ extern int passwd_main(int argc, char **argv)
238 umask(077); 238 umask(077);
239 if (setuid(0)) { 239 if (setuid(0)) {
240 syslog(LOG_ERR, "can't setuid(0)"); 240 syslog(LOG_ERR, "can't setuid(0)");
241 error_msg_and_die( "Cannot change ID to root.\n"); 241 bb_error_msg_and_die( "Cannot change ID to root.\n");
242 } 242 }
243 if (!update_passwd(pw, crypt_passwd)) { 243 if (!update_passwd(pw, crypt_passwd)) {
244 syslog(LOG_INFO, "password for `%s' changed by user `%s'", name, 244 syslog(LOG_INFO, "password for `%s' changed by user `%s'", name,
@@ -246,7 +246,7 @@ extern int passwd_main(int argc, char **argv)
246 printf("Password changed.\n"); 246 printf("Password changed.\n");
247 } else { 247 } else {
248 syslog(LOG_WARNING, "an error occurred updating the password file"); 248 syslog(LOG_WARNING, "an error occurred updating the password file");
249 error_msg_and_die("An error occurred updating the password file.\n"); 249 bb_error_msg_and_die("An error occurred updating the password file.\n");
250 } 250 }
251 return (0); 251 return (0);
252} 252}