[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] More patches - issue file fixes
From:       Joshua Jackson <busybox () vortech ! net>
Date:       2003-01-31 23:34:03
[Download RAW message or body]

Attached is a patch against the 1/31/2003 busybox CVS code for the following:

- Fixes syslogd to not die when a remote UDP host is unavailable
- Changes default hash to MD5 for passwd utility
- Ports TinyLogin's issue file handling to current busybox tree

The issue file was being dumped with the annoying LF but no CR stepping 
effect. This patch adds the issue file output routines from the original 
TinyLogin. This also adds several additional issue file tokens.

--
Joshua Jackson
http://www.coyotelinux.com
["bb-patch" (text/x-diff)]

diff -uNr busybox.orig/include/libbb.h busybox/include/libbb.h
--- busybox.orig/include/libbb.h	2003-01-21 15:55:53.000000000 -0500
+++ busybox/include/libbb.h	2003-02-01 01:10:56.000000000 -0500
@@ -31,6 +31,8 @@
 
 #include <netdb.h>
 
+#include <termios.h>
+
 #ifdef DMALLOC
 #include <dmalloc.h>
 #endif
@@ -364,7 +366,7 @@
 } llist_t;
 extern llist_t *llist_add_to(llist_t *old_head, char *new_item);
 
-void print_login_issue(const char *issue_file, const char *tty);
+void print_login_issue(const char *issue_file, const char *tty, struct termios *tp);
 void print_login_prompt(void);
 
 #endif /* __LIBCONFIG_H__ */
diff -uNr busybox.orig/libbb/login.c busybox/libbb/login.c
--- busybox.orig/libbb/login.c	2003-01-21 15:59:34.000000000 -0500
+++ busybox/libbb/login.c	2003-02-01 01:11:27.000000000 -0500
@@ -26,25 +26,23 @@
 
 #include <sys/utsname.h>
 #include <time.h>
+#include <termios.h>
+#include <utmp.h>
 
 #define LOGIN " login: "
 
 static char fmtstr_d[] = { "%A, %d %B %Y" };
 static char fmtstr_t[] = { "%H:%M:%S" };
 
-void print_login_issue(const char *issue_file, const char *tty)
+void print_login_issue(const char *issue_file, const char *tty, struct termios *tp)
 {
 	FILE *fd;
 	int c;
-	char buf[256];
-	char *ret;
-	time_t t;
 	struct utsname uts;
 
-	time(&t);
 	uname(&uts);
 
-	puts("");	/* start a new line */
+	(void) write(1, "\r\n", 2);
 
 	if ((fd = fopen(issue_file, "r"))) {
 		while ((c = fgetc(fd)) != EOF) {
@@ -52,62 +50,95 @@
 				c = fgetc(fd);
 
 				switch (c) {
-					case 's':
-						fputs(uts.sysname, stdout);
-						break;
-
-					case 'n':
-						fputs(uts.nodename, stdout);
-						break;
-
-					case 'r':
-						fputs(uts.release, stdout);
-						break;
-
-					case 'v':
-						fputs(uts.version, stdout);
-						break;
-
-					case 'm':
-						fputs(uts.machine, stdout);
-						break;
-
-					case 'D':
-					case 'o':
-						getdomainname(buf, sizeof(buf));
-						buf[sizeof(buf) - 1] = '\0';
-						fputs(buf, stdout);
-						break;
-
-					case 'd':
-						strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
-						fputs(buf, stdout);
-						break;
-
-					case 't':
-						strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
-						fputs(buf, stdout);
-						break;
-
-					case 'h':
-						gethostname(buf, sizeof(buf));
-						fputs(buf, stdout);
-						break;
+				case 's':
+					(void) printf("%s", uts.sysname);
+					break;
+
+				case 'n':
+					(void) printf("%s", uts.nodename);
+					break;
+
+				case 'r':
+					(void) printf("%s", uts.release);
+					break;
+
+				case 'v':
+					(void) printf("%s", uts.version);
+					break;
+
+				case 'm':
+					(void) printf("%s", uts.machine);
+					break;
+
+				case 'o':
+				{
+					char domainname[256];
+
+					getdomainname(domainname, sizeof(domainname));
+					domainname[sizeof(domainname) - 1] = '\0';
+					printf("%s", domainname);
+				}
+					break;
+
+				case 'd':
+				case 't':
+				{
+					char *weekday[] = { "Sun", "Mon", "Tue", "Wed", "Thu",
+						"Fri", "Sat"
+					};
+					char *month[] = { "Jan", "Feb", "Mar", "Apr", "May",
+						"Jun", "Jul", "Aug", "Sep", "Oct",
+						"Nov", "Dec"
+					};
+					time_t now;
+					struct tm *tm;
+
+					(void) time(&now);
+					tm = localtime(&now);
+
+					if (c == 'd')
+						(void) printf("%s %s %d  %d",
+									  weekday[tm->tm_wday],
+									  month[tm->tm_mon], tm->tm_mday,
+									  tm->tm_year <
+									  70 ? tm->tm_year +
+									  2000 : tm->tm_year + 1900);
+					else
+						(void) printf("%02d:%02d:%02d", tm->tm_hour,
+									  tm->tm_min, tm->tm_sec);
 
-					case 'l':
-						printf("%s", tty);
+					break;
+				}
 
-					default:
-						putchar(c);
+				case 'l':
+					(void) printf("%s", tty);
+					break;
+
+				case 'u':
+				case 'U':
+				{
+					int users = 0;
+					struct utmp *ut;
+
+					setutent();
+					while ((ut = getutent()))
+						if (ut->ut_type == USER_PROCESS)
+							users++;
+					endutent();
+					printf("%d ", users);
+					if (c == 'U')
+						printf((users == 1) ? "user" : "users");
+					break;
+				}
+				default:
+					(void) putchar(c);
 				}
 			} else
-				putchar(c);
+				(void) putchar(c);
 		}
-
-		puts("");	/* start a new line */
 		fflush(stdout);
 
-		fclose(fd);
+		(void) fclose(fd);
 	}
 }
 
diff -uNr busybox.orig/loginutils/getty.c busybox/loginutils/getty.c
--- busybox.orig/loginutils/getty.c	2003-01-21 15:55:55.000000000 -0500
+++ busybox/loginutils/getty.c	2003-02-01 01:02:18.000000000 -0500
@@ -6,7 +6,7 @@
 
    -f option added by Eric Rasmussen <ear@usfirst.org> - 12/28/95
    
-   1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
+   1999-02-22 Arkadiusz Mikiewicz <misiek@misiek.eu.org>
    - added Native Language Support
 
    1999-05-05 Thorsten Kranzkowski <dl8bcu@gmx.net>
@@ -751,7 +751,15 @@
 static void do_prompt(struct options *op, struct termio *tp)
 {
 #ifdef	ISSUE					/* optional: show /etc/issue */
-	print_login_issue(op->issue, op->tty);
+	int oflag;
+
+	oflag = tp->c_oflag;	/* save current setting */
+	tp->c_oflag |= (ONLCR | OPOST);	/* map NL in output to CR-NL */
+	(void) ioctl(0, TCSETAW, tp);
+	print_login_issue(op->issue, op->tty, tp);
+	tp->c_oflag = oflag;	/* restore settings */
+	(void) ioctl(0, TCSETAW, tp);	/* wait till output is gone */
+
 #endif
 	print_login_prompt();
 }
diff -uNr busybox.orig/loginutils/passwd.c busybox/loginutils/passwd.c
--- busybox.orig/loginutils/passwd.c	2002-07-18 20:05:46.000000000 -0400
+++ busybox/loginutils/passwd.c	2003-01-31 23:21:18.000000000 -0500
@@ -23,10 +23,10 @@
 
 int get_algo(char *a)
 {
-	int x = 0;					/* standart: DES */
+	int x = 1;					/* standard: MD5 */
 
-	if (strcasecmp(a, "md5") == 0)
-		x = 1;
+	if (strcasecmp(a, "des") == 0)
+		x = 0;
 	return x;
 }
 
@@ -140,7 +140,7 @@
 	char *name;
 	char *myname;
 	int flag;
-	int algo = 0;				/* -a - password algorithm */
+	int algo = 1;				/* -a - password algorithm */
 	int lflg = 0;				/* -l - lock account */
 	int uflg = 0;				/* -u - unlock account */
 	int dflg = 0;				/* -d - delete password */
diff -uNr busybox.orig/networking/telnetd.c busybox/networking/telnetd.c
--- busybox.orig/networking/telnetd.c	2003-01-22 16:09:48.000000000 -0500
+++ busybox/networking/telnetd.c	2003-02-01 01:13:07.000000000 -0500
@@ -297,7 +297,7 @@
 		/*termbuf.c_lflag &= ~ICANON;*/
 		tcsetattr(0, TCSANOW, &termbuf);
 
-		print_login_issue(issuefile, NULL);
+		print_login_issue(issuefile, NULL, &termbuf);
 
 		/* exec shell, with correct argv and env */
 		execv(loginpath, (char *const *)argv_init);
diff -uNr busybox.orig/sysklogd/syslogd.c busybox/sysklogd/syslogd.c
--- busybox.orig/sysklogd/syslogd.c	2002-12-12 05:54:48.000000000 -0500
+++ busybox/sysklogd/syslogd.c	2003-01-31 23:21:06.000000000 -0500
@@ -386,12 +386,8 @@
 		v->iov_base = msg;
 		v->iov_len = strlen(msg);
 	  writev_retry:
-		if (-1 == writev(remotefd, iov, IOV_COUNT)) {
-			if (errno == EINTR) {
-				goto writev_retry;
-			}
-			error_msg_and_die("cannot write to remote file handle on %s:%d",
-							  RemoteHost, RemotePort);
+		if ((-1 == writev(remotefd, iov, IOV_COUNT)) && (errno == EINTR)) {
+			goto writev_retry;
 		}
 	}
 	if (local_logging == TRUE)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic