summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorRob Landley2006-01-06 20:59:09 +0000
committerRob Landley2006-01-06 20:59:09 +0000
commit84cb76733f0e5853a6c7c2f64b1c168e61dfd933 (patch)
treee9315133e3d21ea032e5e676ddb3f39e18be5605 /loginutils
parent251161f75c0895a1138f87bd80d9bcc38e567444 (diff)
downloadbusybox-84cb76733f0e5853a6c7c2f64b1c168e61dfd933.zip
busybox-84cb76733f0e5853a6c7c2f64b1c168e61dfd933.tar.gz
patch from tito: consolidate delay functions as bb_do_delay()
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/login.c12
-rw-r--r--loginutils/passwd.c8
-rw-r--r--loginutils/sulogin.c8
-rw-r--r--loginutils/vlock.c2
4 files changed, 4 insertions, 26 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 6632a76..21e8076 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -198,17 +198,7 @@ auth_ok:
if ( !failed)
break;
- { // delay next try
- time_t start, now;
-
- time ( &start );
- now = start;
- while ( difftime ( now, start ) < FAIL_DELAY) {
- sleep ( FAIL_DELAY );
- time ( &now );
- }
- }
-
+ bb_do_delay(FAIL_DELAY);
puts("Login incorrect");
username[0] = 0;
if ( ++count == 3 ) {
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 5d8380d..b60b897 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -323,7 +323,6 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
char *cp;
char orig[200];
char pass[200];
- time_t start, now;
if (!amroot && crypt_passwd[0]) {
if (!(clear = bb_askpass(0, "Old password:"))) {
@@ -334,12 +333,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
if (strcmp(cipher, crypt_passwd) != 0) {
syslog(LOG_WARNING, "incorrect password for `%s'",
pw->pw_name);
- time(&start);
- now = start;
- while (difftime(now, start) < FAIL_DELAY) {
- sleep(FAIL_DELAY);
- time(&now);
- }
+ bb_do_delay(FAIL_DELAY);
fprintf(stderr, "Incorrect password.\n");
/* return -1; */
return 1;
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 4e689ad..f54939e 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -58,7 +58,6 @@ extern int sulogin_main(int argc, char **argv)
struct passwd pwent;
struct passwd *pwd;
- time_t start, now;
const char * const *p;
#ifdef CONFIG_FEATURE_SHADOWPASSWDS
struct spwd *spwd = NULL;
@@ -140,12 +139,7 @@ extern int sulogin_main(int argc, char **argv)
if (strcmp(pw_encrypt(pass, pwent.pw_passwd), pwent.pw_passwd) == 0) {
break;
}
- time(&start);
- now = start;
- while (difftime(now, start) < FAIL_DELAY) {
- sleep(FAIL_DELAY);
- time(&now);
- }
+ bb_do_delay(FAIL_DELAY);
puts("Login incorrect");
fflush(stdout);
syslog(LOG_WARNING, "Incorrect root password\n");
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 141767c..0975b51 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -135,7 +135,7 @@ extern int vlock_main(int argc, char **argv)
if (correct_password (pw)) {
break;
}
- sleep(10);
+ bb_do_delay(FAIL_DELAY);
puts("Password incorrect.");
} while (1);
restore_terminal();