diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
commit | 89963b524d211e1aec12b72b3725be05ee95c8cf (patch) | |
tree | 48590aef62b7ee7686b7898256f29def8d9c50b9 /loginutils | |
parent | 9aa5a829070392c2ac6494d0c4e674c0c2bc7dab (diff) | |
parent | 2b7c1aa92c68524559a2067609d09309d5c09adc (diff) | |
download | busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.gz busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.bz2 busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/chpasswd.c | 10 | ||||
-rw-r--r-- | loginutils/cryptpw.c | 10 | ||||
-rw-r--r-- | loginutils/getty.c | 8 | ||||
-rw-r--r-- | loginutils/login.c | 18 | ||||
-rw-r--r-- | loginutils/passwd.c | 4 | ||||
-rw-r--r-- | loginutils/su.c | 4 | ||||
-rw-r--r-- | loginutils/sulogin.c | 4 | ||||
-rw-r--r-- | loginutils/vlock.c | 2 |
8 files changed, 22 insertions, 38 deletions
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c index 4e70b2557..a032abbed 100644 --- a/loginutils/chpasswd.c +++ b/loginutils/chpasswd.c | |||
@@ -24,21 +24,13 @@ | |||
24 | //kbuild:lib-$(CONFIG_CHPASSWD) += chpasswd.o | 24 | //kbuild:lib-$(CONFIG_CHPASSWD) += chpasswd.o |
25 | 25 | ||
26 | //usage:#define chpasswd_trivial_usage | 26 | //usage:#define chpasswd_trivial_usage |
27 | //usage: IF_LONG_OPTS("[--md5|--encrypted|--crypt-method|--root]") IF_NOT_LONG_OPTS("[-m|-e|-c|-R]") | 27 | //usage: "[-me] [-c ALG] [-R DIR]" |
28 | //usage:#define chpasswd_full_usage "\n\n" | 28 | //usage:#define chpasswd_full_usage "\n\n" |
29 | //usage: "Read user:password from stdin and update /etc/passwd\n" | 29 | //usage: "Read user:password from stdin and update /etc/passwd\n" |
30 | //usage: IF_LONG_OPTS( | ||
31 | //usage: "\n -e,--encrypted Supplied passwords are in encrypted form" | ||
32 | //usage: "\n -m,--md5 Encrypt using md5, not des" | ||
33 | //usage: "\n -c,--crypt-method ALG "CRYPT_METHODS_HELP_STR | ||
34 | //usage: "\n -R,--root DIR Directory to chroot into" | ||
35 | //usage: ) | ||
36 | //usage: IF_NOT_LONG_OPTS( | ||
37 | //usage: "\n -e Supplied passwords are in encrypted form" | 30 | //usage: "\n -e Supplied passwords are in encrypted form" |
38 | //usage: "\n -m Encrypt using md5, not des" | 31 | //usage: "\n -m Encrypt using md5, not des" |
39 | //usage: "\n -c ALG "CRYPT_METHODS_HELP_STR | 32 | //usage: "\n -c ALG "CRYPT_METHODS_HELP_STR |
40 | //usage: "\n -R DIR Directory to chroot into" | 33 | //usage: "\n -R DIR Directory to chroot into" |
41 | //usage: ) | ||
42 | 34 | ||
43 | #include "libbb.h" | 35 | #include "libbb.h" |
44 | 36 | ||
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c index fbb7f0515..645f1bb09 100644 --- a/loginutils/cryptpw.c +++ b/loginutils/cryptpw.c | |||
@@ -32,22 +32,14 @@ | |||
32 | //kbuild:lib-$(CONFIG_MKPASSWD) += cryptpw.o | 32 | //kbuild:lib-$(CONFIG_MKPASSWD) += cryptpw.o |
33 | 33 | ||
34 | //usage:#define cryptpw_trivial_usage | 34 | //usage:#define cryptpw_trivial_usage |
35 | //usage: "[OPTIONS] [PASSWORD] [SALT]" | 35 | //usage: "[-s] [-p N] [-m TYPE] [-S SALT] [PASSWORD] [SALT]" |
36 | /* We do support -s, we just don't mention it */ | 36 | /* We do support -s, we just don't mention it */ |
37 | //usage:#define cryptpw_full_usage "\n\n" | 37 | //usage:#define cryptpw_full_usage "\n\n" |
38 | //usage: "Print crypt(3) hashed PASSWORD\n" | 38 | //usage: "Print crypt(3) hashed PASSWORD\n" |
39 | //usage: IF_LONG_OPTS( | ||
40 | //usage: "\n -P,--password-fd N Read password from fd N" | ||
41 | /* //usage: "\n -s,--stdin Use stdin; like -P0" */ | ||
42 | //usage: "\n -m,--method TYPE "CRYPT_METHODS_HELP_STR | ||
43 | //usage: "\n -S,--salt SALT" | ||
44 | //usage: ) | ||
45 | //usage: IF_NOT_LONG_OPTS( | ||
46 | //usage: "\n -P N Read password from fd N" | 39 | //usage: "\n -P N Read password from fd N" |
47 | /* //usage: "\n -s Use stdin; like -P0" */ | 40 | /* //usage: "\n -s Use stdin; like -P0" */ |
48 | //usage: "\n -m TYPE "CRYPT_METHODS_HELP_STR | 41 | //usage: "\n -m TYPE "CRYPT_METHODS_HELP_STR |
49 | //usage: "\n -S SALT" | 42 | //usage: "\n -S SALT" |
50 | //usage: ) | ||
51 | 43 | ||
52 | #include "libbb.h" | 44 | #include "libbb.h" |
53 | 45 | ||
diff --git a/loginutils/getty.c b/loginutils/getty.c index 7393a3d1c..6c6d409f4 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -404,7 +404,7 @@ static void finalize_tty_attrs(void) | |||
404 | set_tty_attrs(); | 404 | set_tty_attrs(); |
405 | 405 | ||
406 | /* Now the newline character should be properly written */ | 406 | /* Now the newline character should be properly written */ |
407 | full_write(STDOUT_FILENO, "\n", 1); | 407 | full_write1_str("\n"); |
408 | } | 408 | } |
409 | 409 | ||
410 | /* extract baud rate from modem status message */ | 410 | /* extract baud rate from modem status message */ |
@@ -434,7 +434,7 @@ static void auto_baud(void) | |||
434 | * Wait for a while, then read everything the modem has said so far and | 434 | * Wait for a while, then read everything the modem has said so far and |
435 | * try to extract the speed of the dial-in call. | 435 | * try to extract the speed of the dial-in call. |
436 | */ | 436 | */ |
437 | sleep(1); | 437 | sleep1(); |
438 | nread = safe_read(STDIN_FILENO, G.line_buf, sizeof(G.line_buf) - 1); | 438 | nread = safe_read(STDIN_FILENO, G.line_buf, sizeof(G.line_buf) - 1); |
439 | if (nread > 0) { | 439 | if (nread > 0) { |
440 | int speed; | 440 | int speed; |
@@ -498,13 +498,13 @@ static char *get_logname(void) | |||
498 | case 0x7f: | 498 | case 0x7f: |
499 | G.tty_attrs.c_cc[VERASE] = c; | 499 | G.tty_attrs.c_cc[VERASE] = c; |
500 | if (bp > G.line_buf) { | 500 | if (bp > G.line_buf) { |
501 | full_write(STDOUT_FILENO, "\010 \010", 3); | 501 | full_write1_str("\010 \010"); |
502 | bp--; | 502 | bp--; |
503 | } | 503 | } |
504 | break; | 504 | break; |
505 | case CTL('U'): | 505 | case CTL('U'): |
506 | while (bp > G.line_buf) { | 506 | while (bp > G.line_buf) { |
507 | full_write(STDOUT_FILENO, "\010 \010", 3); | 507 | full_write1_str("\010 \010"); |
508 | bp--; | 508 | bp--; |
509 | } | 509 | } |
510 | break; | 510 | break; |
diff --git a/loginutils/login.c b/loginutils/login.c index 4e65b3a19..21c32fc25 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -341,6 +341,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
341 | #if ENABLE_LOGIN_SESSION_AS_CHILD | 341 | #if ENABLE_LOGIN_SESSION_AS_CHILD |
342 | pid_t child_pid; | 342 | pid_t child_pid; |
343 | #endif | 343 | #endif |
344 | IF_FEATURE_UTMP(pid_t my_pid;) | ||
344 | 345 | ||
345 | INIT_G(); | 346 | INIT_G(); |
346 | 347 | ||
@@ -504,16 +505,14 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
504 | #endif /* ENABLE_PAM */ | 505 | #endif /* ENABLE_PAM */ |
505 | auth_failed: | 506 | auth_failed: |
506 | opt &= ~LOGIN_OPT_f; | 507 | opt &= ~LOGIN_OPT_f; |
507 | bb_do_delay(LOGIN_FAIL_DELAY); | 508 | pause_after_failed_login(); |
508 | /* TODO: doesn't sound like correct English phrase to me */ | 509 | /* TODO: doesn't sound like correct English phrase to me */ |
509 | puts("Login incorrect"); | 510 | puts("Login incorrect"); |
511 | syslog(LOG_WARNING, "invalid password for '%s'%s", | ||
512 | username, fromhost); | ||
510 | if (++count == 3) { | 513 | if (++count == 3) { |
511 | syslog(LOG_WARNING, "invalid password for '%s'%s", | ||
512 | username, fromhost); | ||
513 | |||
514 | if (ENABLE_FEATURE_CLEAN_UP) | 514 | if (ENABLE_FEATURE_CLEAN_UP) |
515 | free(fromhost); | 515 | free(fromhost); |
516 | |||
517 | return EXIT_FAILURE; | 516 | return EXIT_FAILURE; |
518 | } | 517 | } |
519 | username[0] = '\0'; | 518 | username[0] = '\0'; |
@@ -525,6 +524,9 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
525 | if (pw->pw_uid != 0) | 524 | if (pw->pw_uid != 0) |
526 | die_if_nologin(); | 525 | die_if_nologin(); |
527 | 526 | ||
527 | IF_FEATURE_UTMP(my_pid = getpid();) | ||
528 | update_utmp(my_pid, USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL); | ||
529 | |||
528 | #if ENABLE_LOGIN_SESSION_AS_CHILD | 530 | #if ENABLE_LOGIN_SESSION_AS_CHILD |
529 | child_pid = vfork(); | 531 | child_pid = vfork(); |
530 | if (child_pid != 0) { | 532 | if (child_pid != 0) { |
@@ -532,8 +534,8 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
532 | bb_simple_perror_msg("vfork"); | 534 | bb_simple_perror_msg("vfork"); |
533 | else { | 535 | else { |
534 | wait_for_exitstatus(child_pid); | 536 | wait_for_exitstatus(child_pid); |
535 | update_utmp_DEAD_PROCESS(child_pid); | ||
536 | } | 537 | } |
538 | update_utmp_DEAD_PROCESS(my_pid); | ||
537 | login_pam_end(pamh); | 539 | login_pam_end(pamh); |
538 | return 0; | 540 | return 0; |
539 | } | 541 | } |
@@ -546,8 +548,6 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
546 | fchown(0, pw->pw_uid, pw->pw_gid); | 548 | fchown(0, pw->pw_uid, pw->pw_gid); |
547 | fchmod(0, 0600); | 549 | fchmod(0, 0600); |
548 | 550 | ||
549 | update_utmp(getpid(), USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL); | ||
550 | |||
551 | /* We trust environment only if we run by root */ | 551 | /* We trust environment only if we run by root */ |
552 | if (ENABLE_LOGIN_SCRIPTS && run_by_root) | 552 | if (ENABLE_LOGIN_SCRIPTS && run_by_root) |
553 | run_login_script(pw, full_tty); | 553 | run_login_script(pw, full_tty); |
@@ -602,7 +602,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
602 | signal(SIGINT, SIG_DFL); | 602 | signal(SIGINT, SIG_DFL); |
603 | 603 | ||
604 | /* Exec login shell with no additional parameters */ | 604 | /* Exec login shell with no additional parameters */ |
605 | run_shell(pw->pw_shell, 1, NULL); | 605 | exec_login_shell(pw->pw_shell); |
606 | 606 | ||
607 | /* return EXIT_FAILURE; - not reached */ | 607 | /* return EXIT_FAILURE; - not reached */ |
608 | } | 608 | } |
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index 6c643d3d0..acc942275 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -28,7 +28,7 @@ | |||
28 | //kbuild:lib-$(CONFIG_PASSWD) += passwd.o | 28 | //kbuild:lib-$(CONFIG_PASSWD) += passwd.o |
29 | 29 | ||
30 | //usage:#define passwd_trivial_usage | 30 | //usage:#define passwd_trivial_usage |
31 | //usage: "[OPTIONS] [USER]" | 31 | //usage: "[-a ALG] [-dlu] [USER]" |
32 | //usage:#define passwd_full_usage "\n\n" | 32 | //usage:#define passwd_full_usage "\n\n" |
33 | //usage: "Change USER's password (default: current user)" | 33 | //usage: "Change USER's password (default: current user)" |
34 | //usage: "\n" | 34 | //usage: "\n" |
@@ -57,7 +57,7 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo | |||
57 | encrypted = pw_encrypt(orig, pw->pw_passwd, 1); /* returns malloced str */ | 57 | encrypted = pw_encrypt(orig, pw->pw_passwd, 1); /* returns malloced str */ |
58 | if (strcmp(encrypted, pw->pw_passwd) != 0) { | 58 | if (strcmp(encrypted, pw->pw_passwd) != 0) { |
59 | syslog(LOG_WARNING, "incorrect password for %s", pw->pw_name); | 59 | syslog(LOG_WARNING, "incorrect password for %s", pw->pw_name); |
60 | bb_do_delay(LOGIN_FAIL_DELAY); | 60 | pause_after_failed_login(); |
61 | puts("Incorrect password"); | 61 | puts("Incorrect password"); |
62 | goto err_ret; | 62 | goto err_ret; |
63 | } | 63 | } |
diff --git a/loginutils/su.c b/loginutils/su.c index 79edbc44a..e46bbf78b 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -147,7 +147,7 @@ int su_main(int argc UNUSED_PARAM, char **argv) | |||
147 | if (ENABLE_FEATURE_SU_SYSLOG) | 147 | if (ENABLE_FEATURE_SU_SYSLOG) |
148 | syslog(LOG_NOTICE, "%c %s %s:%s", | 148 | syslog(LOG_NOTICE, "%c %s %s:%s", |
149 | '-', tty, old_user, opt_username); | 149 | '-', tty, old_user, opt_username); |
150 | bb_do_delay(LOGIN_FAIL_DELAY); | 150 | pause_after_failed_login(); |
151 | bb_simple_error_msg_and_die("incorrect password"); | 151 | bb_simple_error_msg_and_die("incorrect password"); |
152 | } | 152 | } |
153 | 153 | ||
@@ -205,7 +205,7 @@ int su_main(int argc UNUSED_PARAM, char **argv) | |||
205 | */ | 205 | */ |
206 | 206 | ||
207 | /* Never returns */ | 207 | /* Never returns */ |
208 | run_shell(opt_shell, flags & SU_OPT_l, (const char**)argv); | 208 | exec_shell(opt_shell, flags & SU_OPT_l, (const char**)argv); |
209 | 209 | ||
210 | /* return EXIT_FAILURE; - not reached */ | 210 | /* return EXIT_FAILURE; - not reached */ |
211 | } | 211 | } |
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 099085340..69d8b5ec7 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -74,7 +74,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
74 | if (r > 0) { | 74 | if (r > 0) { |
75 | break; | 75 | break; |
76 | } | 76 | } |
77 | bb_do_delay(LOGIN_FAIL_DELAY); | 77 | pause_after_failed_login(); |
78 | bb_simple_info_msg("Login incorrect"); | 78 | bb_simple_info_msg("Login incorrect"); |
79 | } | 79 | } |
80 | 80 | ||
@@ -89,5 +89,5 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
89 | shell = pwd->pw_shell; | 89 | shell = pwd->pw_shell; |
90 | 90 | ||
91 | /* Exec login shell with no additional parameters. Never returns. */ | 91 | /* Exec login shell with no additional parameters. Never returns. */ |
92 | run_shell(shell, 1, NULL); | 92 | exec_login_shell(shell); |
93 | } | 93 | } |
diff --git a/loginutils/vlock.c b/loginutils/vlock.c index 9e319fe61..334b7d2ad 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c | |||
@@ -120,7 +120,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv) | |||
120 | if (ask_and_check_password(pw) > 0) { | 120 | if (ask_and_check_password(pw) > 0) { |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | bb_do_delay(LOGIN_FAIL_DELAY); | 123 | pause_after_failed_login(); |
124 | puts("Incorrect password"); | 124 | puts("Incorrect password"); |
125 | } | 125 | } |
126 | 126 | ||