[BusyBox-cvs] busybox/loginutils getty.c,1.5,1.6 login.c,1.8,1.9

Glenn McGrath bug1 at busybox.net
Tue Jan 21 20:55:59 UTC 2003


Update of /var/cvs/busybox/loginutils
In directory winder:/tmp/cvs-serv29856/loginutils

Modified Files:
	getty.c login.c 
Log Message:
run telnet from inetd, present login prompt if login is configured, 
patch from Bastian Blank


Index: getty.c
===================================================================
RCS file: /var/cvs/busybox/loginutils/getty.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- getty.c	10 Oct 2002 04:20:17 -0000	1.5
+++ getty.c	21 Jan 2003 20:55:55 -0000	1.6
@@ -73,8 +73,6 @@
 #include <time.h>
 #endif
 
-#define LOGIN " login: "		/* login prompt */
-
 /* Some shorthands for control characters. */
 
 #define CTL(x)		(x ^ 0100)	/* Assumes ASCII dialect */
@@ -752,142 +750,10 @@
 /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */
 static void do_prompt(struct options *op, struct termio *tp)
 {
-#ifdef	ISSUE
-	FILE *fd;
-	int oflag;
-	int c;
-	struct utsname uts;
-
-	(void) uname(&uts);
-#endif
-
-	(void) write(1, "\r\n", 2);	/* start a new line */
 #ifdef	ISSUE					/* optional: show /etc/issue */
-	if ((op->flags & F_ISSUE) && (fd = fopen(op->issue, "r"))) {
-		oflag = tp->c_oflag;	/* save current setting */
-		tp->c_oflag |= (ONLCR | OPOST);	/* map NL in output to CR-NL */
-		(void) ioctl(0, TCSETAW, tp);
-
-
-		while ((c = getc(fd)) != EOF) {
-			if (c == '\\') {
-				c = getc(fd);
-
-				switch (c) {
-				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);
-
-					break;
-				}
-
-				case 'l':
-					(void) printf("%s", op->tty);
-					break;
-
-				case 'b':
-				{
-					int i;
-
-					for (i = 0; speedtab[i].speed; i++) {
-						if (speedtab[i].code == (tp->c_cflag & CBAUD)) {
-							printf("%ld", speedtab[i].speed);
-							break;
-						}
-					}
-					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
-				(void) putchar(c);
-		}
-		fflush(stdout);
-
-		tp->c_oflag = oflag;	/* restore settings */
-		(void) ioctl(0, TCSETAW, tp);	/* wait till output is gone */
-		(void) fclose(fd);
-	}
-#endif
-#ifdef __linux__
-	{
-		char hn[MAXHOSTNAMELEN + 1];
-
-		(void) gethostname(hn, MAXHOSTNAMELEN);
-		write(1, hn, strlen(hn));
-	}
+	print_login_issue(op->issue, op->tty);
 #endif
-	(void) write(1, LOGIN, sizeof(LOGIN) - 1);	/* always show login prompt */
+	print_login_prompt();
 }
 
 /* next_speed - select next baud rate */

Index: login.c
===================================================================
RCS file: /var/cvs/busybox/loginutils/login.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- login.c	3 Dec 2002 19:54:12 -0000	1.8
+++ login.c	21 Jan 2003 20:55:55 -0000	1.9
@@ -253,20 +253,18 @@
 	int i;
 
 	for(i=0; i<EMPTY_USERNAME_COUNT; i++) {
-	gethostname ( buf, sizeof( buf ));
-	printf ( "\n%s login: ", buf );
-	fflush ( stdout );
+		print_login_prompt();
+
+		if ( !fgets ( buf, sizeof( buf ) - 1, stdin ))
+			return 0;
 
-	if ( !fgets ( buf, sizeof( buf ) - 1, stdin ))
-		return 0;
-		
 		if ( !strchr ( buf, '\n' ))
-		return 0;
-	
-	for ( sp = buf; isspace ( *sp ); sp++ ) { }
-	for ( ep = sp; isgraph ( *ep ); ep++ ) { }
+			return 0;
 
-	*ep = 0;		
+		for ( sp = buf; isspace ( *sp ); sp++ ) { }
+		for ( ep = sp; isgraph ( *ep ); ep++ ) { }
+
+		*ep = 0;		
 		safe_strncpy(buf_name, sp, USERNAME_SIZE);
 		if(buf_name[0])
 			return 1;




More information about the busybox-cvs mailing list