svn commit: trunk/busybox: include libbb loginutils

landley at busybox.net landley at busybox.net
Fri Jan 6 20:59:10 UTC 2006


Author: landley
Date: 2006-01-06 12:59:09 -0800 (Fri, 06 Jan 2006)
New Revision: 13135

Log:
patch from tito: consolidate delay functions as bb_do_delay()


Added:
   trunk/busybox/libbb/bb_do_delay.c

Modified:
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/Makefile.in
   trunk/busybox/loginutils/login.c
   trunk/busybox/loginutils/passwd.c
   trunk/busybox/loginutils/sulogin.c
   trunk/busybox/loginutils/vlock.c


Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/include/libbb.h	2006-01-06 20:59:09 UTC (rev 13135)
@@ -355,7 +355,7 @@
 #define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+6)
 
 
-extern const char bb_path_mtab_file[];
+extern char bb_path_mtab_file[];
 
 extern int bb_default_error_retval;
 
@@ -419,6 +419,7 @@
 char *bb_xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
 
 #define FAIL_DELAY    3
+extern void bb_do_delay(int seconds);
 extern void change_identity ( const struct passwd *pw );
 extern const char *change_identity_e2str ( const struct passwd *pw );
 extern void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args);

Modified: trunk/busybox/libbb/Makefile.in
===================================================================
--- trunk/busybox/libbb/Makefile.in	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/libbb/Makefile.in	2006-01-06 20:59:09 UTC (rev 13135)
@@ -34,7 +34,7 @@
 	getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
 	perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
 	warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
-	bb_echo.c
+	bb_echo.c bb_do_delay.c
 
 LIBBB_SRC-$(CONFIG_FEATURE_SHADOWPASSWDS)+= pwd2spwd.c
 

Added: trunk/busybox/libbb/bb_do_delay.c
===================================================================
--- trunk/busybox/libbb/bb_do_delay.c	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/libbb/bb_do_delay.c	2006-01-06 20:59:09 UTC (rev 13135)
@@ -0,0 +1,31 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Busybox utility routines.
+ *
+ * Copyright (C) 2005 by Tito Ragusa <tito-wolit at tiscali.it>
+ *
+ * Licensed under the GPL v2, see the file LICENSE in this tarball.
+ */
+
+#include <time.h>
+#include <unistd.h>
+
+void bb_do_delay(int seconds)
+{
+	time_t start, now;
+
+	time(&start);
+	now = start;
+	while (difftime(now, start) < seconds) {
+		sleep(seconds);
+		time(&now);
+	}
+}
+
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/

Modified: trunk/busybox/loginutils/login.c
===================================================================
--- trunk/busybox/loginutils/login.c	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/loginutils/login.c	2006-01-06 20:59:09 UTC (rev 13135)
@@ -198,17 +198,7 @@
 		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 ) {

Modified: trunk/busybox/loginutils/passwd.c
===================================================================
--- trunk/busybox/loginutils/passwd.c	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/loginutils/passwd.c	2006-01-06 20:59:09 UTC (rev 13135)
@@ -323,7 +323,6 @@
 	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 @@
 		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;

Modified: trunk/busybox/loginutils/sulogin.c
===================================================================
--- trunk/busybox/loginutils/sulogin.c	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/loginutils/sulogin.c	2006-01-06 20:59:09 UTC (rev 13135)
@@ -58,7 +58,6 @@
 	
 	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 @@
 		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");

Modified: trunk/busybox/loginutils/vlock.c
===================================================================
--- trunk/busybox/loginutils/vlock.c	2006-01-06 20:28:05 UTC (rev 13134)
+++ trunk/busybox/loginutils/vlock.c	2006-01-06 20:59:09 UTC (rev 13135)
@@ -135,7 +135,7 @@
 		if (correct_password (pw)) {
 			break;
 		}
-		sleep(10);
+		bb_do_delay(FAIL_DELAY);
 		puts("Password incorrect.");
 	} while (1);
 	restore_terminal();




More information about the busybox-cvs mailing list