diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-01-31 17:57:48 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-01-31 17:57:48 +0000 |
commit | 3038557649ae04860213ab264ff0f647103e5083 (patch) | |
tree | 129ac6598e5dc72b75062249ce7b78725c85c388 /loginutils | |
parent | 87be316149604ca18613acb1a776ea4ea9f07929 (diff) | |
download | busybox-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')
-rw-r--r-- | loginutils/passwd.c | 33 | ||||
-rw-r--r-- | loginutils/sulogin.c | 17 |
2 files changed, 25 insertions, 25 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 | } |
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 434683299..cecfa905a 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include "busybox.h" | 17 | #include "busybox.h" |
18 | 18 | ||
19 | 19 | ||
20 | // sulogin defines | ||
21 | #define SULOGIN_PROMPT "\nGive root password for system maintenance\n" \ | 20 | #define SULOGIN_PROMPT "\nGive root password for system maintenance\n" \ |
22 | "(or type Control-D for normal startup):" | 21 | "(or type Control-D for normal startup):" |
23 | 22 | ||
@@ -41,7 +40,7 @@ static const char * const forbid[] = { | |||
41 | 40 | ||
42 | 41 | ||
43 | 42 | ||
44 | static void catchalarm(int junk) | 43 | static void catchalarm(int ATTRIBUTE_UNUSED junk) |
45 | { | 44 | { |
46 | exit(EXIT_FAILURE); | 45 | exit(EXIT_FAILURE); |
47 | } | 46 | } |
@@ -59,9 +58,9 @@ extern int sulogin_main(int argc, char **argv) | |||
59 | struct passwd pwent; | 58 | struct passwd pwent; |
60 | struct passwd *pwd; | 59 | struct passwd *pwd; |
61 | const char * const *p; | 60 | const char * const *p; |
62 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS | 61 | #if ENABLE_FEATURE_SHADOWPASSWDS |
63 | struct spwd *spwd = NULL; | 62 | struct spwd *spwd = NULL; |
64 | #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ | 63 | #endif |
65 | 64 | ||
66 | openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); | 65 | openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); |
67 | if (argc > 1) { | 66 | if (argc > 1) { |
@@ -114,7 +113,7 @@ extern int sulogin_main(int argc, char **argv) | |||
114 | bb_error_msg_and_die("No password entry for `root'\n"); | 113 | bb_error_msg_and_die("No password entry for `root'\n"); |
115 | } | 114 | } |
116 | pwent = *pwd; | 115 | pwent = *pwd; |
117 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS | 116 | #if ENABLE_FEATURE_SHADOWPASSWDS |
118 | spwd = NULL; | 117 | spwd = NULL; |
119 | if (pwd && ((strcmp(pwd->pw_passwd, "x") == 0) | 118 | if (pwd && ((strcmp(pwd->pw_passwd, "x") == 0) |
120 | || (strcmp(pwd->pw_passwd, "*") == 0))) { | 119 | || (strcmp(pwd->pw_passwd, "*") == 0))) { |
@@ -124,7 +123,7 @@ extern int sulogin_main(int argc, char **argv) | |||
124 | pwent.pw_passwd = spwd->sp_pwdp; | 123 | pwent.pw_passwd = spwd->sp_pwdp; |
125 | } | 124 | } |
126 | } | 125 | } |
127 | #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ | 126 | #endif |
128 | while (1) { | 127 | while (1) { |
129 | cp = bb_askpass(timeout, SULOGIN_PROMPT); | 128 | cp = bb_askpass(timeout, SULOGIN_PROMPT); |
130 | if (!cp || !*cp) { | 129 | if (!cp || !*cp) { |
@@ -134,7 +133,7 @@ extern int sulogin_main(int argc, char **argv) | |||
134 | exit(EXIT_SUCCESS); | 133 | exit(EXIT_SUCCESS); |
135 | } else { | 134 | } else { |
136 | safe_strncpy(pass, cp, sizeof(pass)); | 135 | safe_strncpy(pass, cp, sizeof(pass)); |
137 | bzero(cp, strlen(cp)); | 136 | memset(cp, 0, strlen(cp)); |
138 | } | 137 | } |
139 | if (strcmp(pw_encrypt(pass, pwent.pw_passwd), pwent.pw_passwd) == 0) { | 138 | if (strcmp(pw_encrypt(pass, pwent.pw_passwd), pwent.pw_passwd) == 0) { |
140 | break; | 139 | break; |
@@ -144,13 +143,13 @@ extern int sulogin_main(int argc, char **argv) | |||
144 | fflush(stdout); | 143 | fflush(stdout); |
145 | syslog(LOG_WARNING, "Incorrect root password\n"); | 144 | syslog(LOG_WARNING, "Incorrect root password\n"); |
146 | } | 145 | } |
147 | bzero(pass, strlen(pass)); | 146 | memset(pass, 0, strlen(pass)); |
148 | signal(SIGALRM, SIG_DFL); | 147 | signal(SIGALRM, SIG_DFL); |
149 | puts("Entering System Maintenance Mode\n"); | 148 | puts("Entering System Maintenance Mode\n"); |
150 | fflush(stdout); | 149 | fflush(stdout); |
151 | syslog(LOG_INFO, "System Maintenance Mode\n"); | 150 | syslog(LOG_INFO, "System Maintenance Mode\n"); |
152 | 151 | ||
153 | #ifdef CONFIG_SELINUX | 152 | #if ENABLE_SELINUX |
154 | renew_current_security_context(); | 153 | renew_current_security_context(); |
155 | #endif | 154 | #endif |
156 | 155 | ||