summaryrefslogtreecommitdiff
path: root/daemons/getty.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-07-06 02:02:12 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-07-06 02:02:12 +0000
commit229ed26d6eb768ab12250d73dd3d6e3ede0d3c15 (patch)
tree312027f5f6e35627875a7c677e9db56bc34839ea /daemons/getty.c
parentbf9c208d6942f318ebed4071cd9c20d537acd403 (diff)
(print_banner): New function.
(main): Call print_banner.
Diffstat (limited to 'daemons/getty.c')
-rw-r--r--daemons/getty.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/daemons/getty.c b/daemons/getty.c
index 5714778d..2138df5e 100644
--- a/daemons/getty.c
+++ b/daemons/getty.c
@@ -33,6 +33,40 @@ extern int login_tty (int);
#define _PATH_DEV "/dev"
#define _PATH_LOGIN "/bin/login"
+/* Print a suitable welcome banner */
+void
+print_banner (int fd, char *ttyname)
+{
+ struct utsname u;
+ char *s;
+ int len, cc;
+ char *hostname;
+
+ 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 = hostname (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);
+ write (fd, s, cc);
+}
+
+
int
main (int argc, char **argv)
{
@@ -74,6 +108,8 @@ main (int argc, char **argv)
}
while (tty == -1);
+ print_banner (tty, ttyname);
+
login_tty (tty);
asprintf (&arg, "TERM=%s", tt ? tt->ty_type : "unknown");