From 6d0c7f745e0f733d1014e6894a0060c7173bfe33 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 6 Jul 1996 04:20:12 +0000 Subject: (print_banner): Use localhost instead of grotty loop. Make static. (main): Use syslog instead of error to report exec failure. --- daemons/getty.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/daemons/getty.c b/daemons/getty.c index 279422c5..60809608 100644 --- a/daemons/getty.c +++ b/daemons/getty.c @@ -31,44 +31,28 @@ /* XXX */ extern int login_tty (int); +extern char *localhost (); #define _PATH_DEV "/dev" #define _PATH_LOGIN "/bin/login" /* Print a suitable welcome banner */ -void +static void print_banner (int fd, char *ttyname) { - struct utsname u; + int cc; char *s; - int len, cc; - char *hostname; + struct utsname u; + char *hostname = localhost (); if (uname (&u)) u.sysname[0] = u.release[0] = '\0'; - - len = 50; - hostname = malloc (len); - cc = gethostname (hostname, len); - if (cc == -1) - hostname[0] = '\0'; - while (cc >= len) - { - hostname = realloc (hostname, len *= 2); - cc = gethostname (hostname, len); - if (cc == -1) - { - hostname[0] = '\0'; - break; - } - } cc = asprintf (&s, "\r\n\n%s %s (%s) (%s)\r\n\n", - u.sysname, u.release, hostname, ttyname); + u.sysname, u.release, hostname ?: "?", ttyname); write (fd, s, cc); } - int main (int argc, char **argv) { @@ -123,6 +107,7 @@ main (int argc, char **argv) /* Hardwired lines don't. */ execl (_PATH_LOGIN, "login", "-e", arg, "-aNOAUTH_TIMEOUT", 0); - error (99, errno, "execl"); + syslog (LOG_ERR, "%s: %m", _PATH_LOGIN); + return 1; } -- cgit v1.2.3