diff options
author | Miles Bader <miles@gnu.org> | 1996-07-06 04:20:12 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-07-06 04:20:12 +0000 |
commit | 6d0c7f745e0f733d1014e6894a0060c7173bfe33 (patch) | |
tree | 01a3d5207d91cbad19b09fcc66070c6b78f0aa1f /daemons | |
parent | 0dcee3c25fd84fb3dbc4bc28afa4163ce467b4f2 (diff) |
(print_banner): Use localhost instead of grotty loop. Make static.
(main): Use syslog instead of error to report exec failure.
Diffstat (limited to 'daemons')
-rw-r--r-- | daemons/getty.c | 31 |
1 files 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; } |