summaryrefslogtreecommitdiff
path: root/loginutils/passwd.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-01-31 17:57:48 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-01-31 17:57:48 +0000
commit3038557649ae04860213ab264ff0f647103e5083 (patch)
tree129ac6598e5dc72b75062249ce7b78725c85c388 /loginutils/passwd.c
parent87be316149604ca18613acb1a776ea4ea9f07929 (diff)
downloadbusybox-w32-3038557649ae04860213ab264ff0f647103e5083.tar.gz
busybox-w32-3038557649ae04860213ab264ff0f647103e5083.tar.bz2
busybox-w32-3038557649ae04860213ab264ff0f647103e5083.zip
- bzero -> memset
text data bss dec hex filename 1652855 14444 1215616 2882915 2bfd63 busybox.oorig.gcc-3.3 1652823 14444 1215616 2882883 2bfd43 busybox.gcc-3.3 1603655 14412 1215552 2833619 2b3cd3 busybox.oorig.gcc-3.4 1603655 14412 1215552 2833619 2b3cd3 busybox.gcc-3.4 1609755 14508 1215744 2840007 2b55c7 busybox.oorig.gcc-4.0 1609755 14508 1215744 2840007 2b55c7 busybox.gcc-4.0 1590495 13516 1215392 2819403 2b054b busybox.oorig.gcc-4.1-HEAD 1590495 13516 1215392 2819403 2b054b busybox.gcc-4.1-HEAD 1589079 13036 1213248 2815363 2af583 busybox.oorig.gcc-4.2-HEAD 1589079 13036 1213248 2815363 2af583 busybox.gcc-4.2-HEAD
Diffstat (limited to 'loginutils/passwd.c')
-rw-r--r--loginutils/passwd.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index d18cc1e12..c6920ffe7 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -45,7 +45,7 @@ static int update_passwd(const struct passwd *pw, const char *crypt_pw)
45 struct stat sb; 45 struct stat sb;
46 struct flock lock; 46 struct flock lock;
47 47
48#ifdef CONFIG_FEATURE_SHADOWPASSWDS 48#if ENABLE_FEATURE_SHADOWPASSWDS
49 if (access(bb_path_shadow_file, F_OK) == 0) { 49 if (access(bb_path_shadow_file, F_OK) == 0) {
50 snprintf(filename, sizeof filename, "%s", bb_path_shadow_file); 50 snprintf(filename, sizeof filename, "%s", bb_path_shadow_file);
51 } else 51 } else
@@ -93,8 +93,9 @@ static int update_passwd(const struct passwd *pw, const char *crypt_pw)
93 rewind(fp); 93 rewind(fp);
94 while (!feof(fp)) { 94 while (!feof(fp)) {
95 fgets(buffer, sizeof buffer, fp); 95 fgets(buffer, sizeof buffer, fp);
96 if (!continued) { // Check to see if we're updating this line. 96 if (!continued) { /* Check to see if we're updating this line. */
97 if (strncmp(username, buffer, strlen(username)) == 0) { // we have a match. 97 if (strncmp(username, buffer, strlen(username)) == 0) {
98 /* we have a match. */
98 pw_rest = strchr(buffer, ':'); 99 pw_rest = strchr(buffer, ':');
99 *pw_rest++ = '\0'; 100 *pw_rest++ = '\0';
100 pw_rest = strchr(pw_rest, ':'); 101 pw_rest = strchr(pw_rest, ':');
@@ -110,7 +111,7 @@ static int update_passwd(const struct passwd *pw, const char *crypt_pw)
110 } else { 111 } else {
111 continued = 1; 112 continued = 1;
112 } 113 }
113 bzero(buffer, sizeof buffer); 114 memset(buffer, 0, sizeof buffer);
114 } 115 }
115 116
116 if (fflush(out_fp) || fsync(fileno(out_fp)) || fclose(out_fp)) { 117 if (fflush(out_fp) || fsync(fileno(out_fp)) || fclose(out_fp)) {
@@ -145,9 +146,9 @@ extern int passwd_main(int argc, char **argv)
145 int dflg = 0; /* -d - delete password */ 146 int dflg = 0; /* -d - delete password */
146 const struct passwd *pw; 147 const struct passwd *pw;
147 148
148#ifdef CONFIG_FEATURE_SHADOWPASSWDS 149#if ENABLE_FEATURE_SHADOWPASSWDS
149 const struct spwd *sp; 150 const struct spwd *sp;
150#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ 151#endif
151 amroot = (getuid() == 0); 152 amroot = (getuid() == 0);
152 openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); 153 openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
153 while ((flag = getopt(argc, argv, "a:dlu")) != EOF) { 154 while ((flag = getopt(argc, argv, "a:dlu")) != EOF) {
@@ -186,7 +187,7 @@ extern int passwd_main(int argc, char **argv)
186 syslog(LOG_WARNING, "can't change pwd for `%s'", name); 187 syslog(LOG_WARNING, "can't change pwd for `%s'", name);
187 bb_error_msg_and_die("Permission denied.\n"); 188 bb_error_msg_and_die("Permission denied.\n");
188 } 189 }
189#ifdef CONFIG_FEATURE_SHADOWPASSWDS 190#if ENABLE_FEATURE_SHADOWPASSWDS
190 sp = getspnam(name); 191 sp = getspnam(name);
191 if (!sp) { 192 if (!sp) {
192 sp = (struct spwd *) pwd_to_spwd(pw); 193 sp = (struct spwd *) pwd_to_spwd(pw);
@@ -196,7 +197,7 @@ extern int passwd_main(int argc, char **argv)
196#else 197#else
197 cp = pw->pw_passwd; 198 cp = pw->pw_passwd;
198 np = name; 199 np = name;
199#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ 200#endif
200 201
201 safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); 202 safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd));
202 if (!(dflg || lflg || uflg)) { 203 if (!(dflg || lflg || uflg)) {
@@ -339,8 +340,8 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
339 return 1; 340 return 1;
340 } 341 }
341 safe_strncpy(orig, clear, sizeof(orig)); 342 safe_strncpy(orig, clear, sizeof(orig));
342 bzero(clear, strlen(clear)); 343 memset(clear, 0, strlen(clear));
343 bzero(cipher, strlen(cipher)); 344 memset(cipher, 0, strlen(cipher));
344 } else { 345 } else {
345 orig[0] = '\0'; 346 orig[0] = '\0';
346 } 347 }
@@ -348,12 +349,12 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
348 "Please use a combination of upper and lower case letters and numbers.\n" 349 "Please use a combination of upper and lower case letters and numbers.\n"
349 "Enter new password: "))) 350 "Enter new password: ")))
350 { 351 {
351 bzero(orig, sizeof orig); 352 memset(orig, 0, sizeof orig);
352 /* return -1; */ 353 /* return -1; */
353 return 1; 354 return 1;
354 } 355 }
355 safe_strncpy(pass, cp, sizeof(pass)); 356 safe_strncpy(pass, cp, sizeof(pass));
356 bzero(cp, strlen(cp)); 357 memset(cp, 0, strlen(cp));
357 /* if (!obscure(orig, pass, pw)) { */ 358 /* if (!obscure(orig, pass, pw)) { */
358 if (obscure(orig, pass, pw)) { 359 if (obscure(orig, pass, pw)) {
359 if (amroot) { 360 if (amroot) {
@@ -364,7 +365,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
364 } 365 }
365 } 366 }
366 if (!(cp = bb_askpass(0, "Re-enter new password: "))) { 367 if (!(cp = bb_askpass(0, "Re-enter new password: "))) {
367 bzero(orig, sizeof orig); 368 memset(orig, 0, sizeof orig);
368 /* return -1; */ 369 /* return -1; */
369 return 1; 370 return 1;
370 } 371 }
@@ -373,14 +374,14 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
373 /* return -1; */ 374 /* return -1; */
374 return 1; 375 return 1;
375 } 376 }
376 bzero(cp, strlen(cp)); 377 memset(cp, 0, strlen(cp));
377 bzero(orig, sizeof(orig)); 378 memset(orig, 0, sizeof(orig));
378 379
379 if (algo == 1) { 380 if (algo == 1) {
380 cp = pw_encrypt(pass, "$1$"); 381 cp = pw_encrypt(pass, "$1$");
381 } else 382 } else
382 cp = pw_encrypt(pass, crypt_make_salt()); 383 cp = pw_encrypt(pass, crypt_make_salt());
383 bzero(pass, sizeof pass); 384 memset(pass, 0, sizeof pass);
384 safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); 385 safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd));
385 return 0; 386 return 0;
386} 387}