utmp changed format
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 23 May 1983 14:58:50 +0000 (06:58 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 23 May 1983 14:58:50 +0000 (06:58 -0800)
SCCS-vsn: sbin/shutdown/shutdown.c 4.17
SCCS-vsn: sbin/reboot/reboot.c 4.7
SCCS-vsn: sbin/reboot/halt.c 4.8
SCCS-vsn: old/init/init.c 4.11
SCCS-vsn: sbin/init/init.c 4.11
SCCS-vsn: libexec/telnetd/telnetd.c 4.20
SCCS-vsn: usr.bin/last/last.c 4.5

usr/src/libexec/telnetd/telnetd.c
usr/src/old/init/init.c
usr/src/sbin/init/init.c
usr/src/sbin/reboot/halt.c
usr/src/sbin/reboot/reboot.c
usr/src/sbin/shutdown/shutdown.c
usr/src/usr.bin/last/last.c

index 1015310..e5a040d 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  4.19 83/05/03";
+static char sccsid[] = "@(#)telnetd.c  4.20 83/05/22";
 #endif
 
 /*
 #endif
 
 /*
@@ -105,9 +105,10 @@ again:
        sigset(SIGCHLD, reapchild);
        listen(s, 10);
        for (;;) {
        sigset(SIGCHLD, reapchild);
        listen(s, 10);
        for (;;) {
-               int s2;
+               struct sockaddr_in from;
+               int s2, fromlen = sizeof (from);
 
 
-               s2 = accept(s, (caddr_t)0, 0, 0);
+               s2 = accept(s, (caddr_t)&from, &fromlen);
                if (s2 < 0) {
                        if (errno == EINTR)
                                continue;
                if (s2 < 0) {
                        if (errno == EINTR)
                                continue;
@@ -119,7 +120,7 @@ again:
                        printf("Out of processes\n");
                else if (pid == 0) {
                        signal(SIGCHLD, SIG_IGN);
                        printf("Out of processes\n");
                else if (pid == 0) {
                        signal(SIGCHLD, SIG_IGN);
-                       doit(s2);
+                       doit(s2, &from);
                }
                close(s2);
        }
                }
                close(s2);
        }
@@ -139,11 +140,14 @@ int       cleanup();
 /*
  * Get a pty, scan input lines.
  */
 /*
  * Get a pty, scan input lines.
  */
-doit(f)
+doit(f, who)
+       int f;
+       struct sockaddr_in *who;
 {
 {
-       char *cp = line;
+       char *cp = line, *host, *ntoa();
        int i, p, cc, t;
        struct sgttyb b;
        int i, p, cc, t;
        struct sgttyb b;
+       struct hostent *hp;
 
        for (i = 0; i < 16; i++) {
                cp[strlen("/dev/ptyp")] = "0123456789abcdef"[i];
 
        for (i = 0; i < 16; i++) {
                cp[strlen("/dev/ptyp")] = "0123456789abcdef"[i];
@@ -170,6 +174,12 @@ gotpty:
        ioctl(p, TIOCGETP, &b);
        b.sg_flags &= ~ECHO;
        ioctl(p, TIOCSETP, &b);
        ioctl(p, TIOCGETP, &b);
        b.sg_flags &= ~ECHO;
        ioctl(p, TIOCSETP, &b);
+       hp = gethostbyaddr(&who->sin_addr, sizeof (struct in_addr),
+               who->sin_family);
+       if (hp)
+               host = hp->h_name;
+       else
+               host = ntoa(who->sin_addr);
        if ((i = fork()) < 0)
                fatalperror(f, "fork", errno);
        if (i)
        if ((i = fork()) < 0)
                fatalperror(f, "fork", errno);
        if (i)
@@ -180,7 +190,7 @@ gotpty:
        dup2(t, 1);
        dup2(t, 2);
        close(t);
        dup2(t, 1);
        dup2(t, 2);
        close(t);
-       execl("/bin/login", "telnet-login", 0);
+       execl("/bin/login", "telnet-login", "-h", host, 0);
        fatalperror(f, "/bin/login", errno);
        /*NOTREACHED*/
 }
        fatalperror(f, "/bin/login", errno);
        /*NOTREACHED*/
 }
@@ -627,6 +637,7 @@ rmut()
                                continue;
                        lseek(f, -(long)sizeof (wtmp), 1);
                        SCPYN(wtmp.ut_name, "");
                                continue;
                        lseek(f, -(long)sizeof (wtmp), 1);
                        SCPYN(wtmp.ut_name, "");
+                       SCPYN(wtmp.ut_host, "");
                        time(&wtmp.ut_time);
                        write(f, (char *)&wtmp, sizeof (wtmp));
                        found++;
                        time(&wtmp.ut_time);
                        write(f, (char *)&wtmp, sizeof (wtmp));
                        found++;
@@ -638,6 +649,7 @@ rmut()
                if (f >= 0) {
                        SCPYN(wtmp.ut_line, line+5);
                        SCPYN(wtmp.ut_name, "");
                if (f >= 0) {
                        SCPYN(wtmp.ut_line, line+5);
                        SCPYN(wtmp.ut_name, "");
+                       SCPYN(wtmp.ut_host, "");
                        time(&wtmp.ut_time);
                        lseek(f, (long)0, 2);
                        write(f, (char *)&wtmp, sizeof (wtmp));
                        time(&wtmp.ut_time);
                        lseek(f, (long)0, 2);
                        write(f, (char *)&wtmp, sizeof (wtmp));
@@ -650,3 +662,20 @@ rmut()
        chmod(line, 0666);
        chown(line, 0, 0);
 }
        chmod(line, 0666);
        chown(line, 0, 0);
 }
+
+/*
+ * Convert network-format internet address
+ * to base 256 d.d.d.d representation.
+ */
+char *
+ntoa(in)
+       struct in_addr in;
+{
+       static char b[18];
+       register char *p;
+
+       p = (char *)&in;
+#define        UC(b)   (((int)b)&0xff)
+       sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
+       return (b);
+}
index 89ccfff..1a1b4c4 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid = "@(#)init.c      4.10 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)init.c      4.11 (Berkeley) %G%";
+#endif
+
 #include <signal.h>
 #include <sys/types.h>
 #include <utmp.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <utmp.h>
@@ -156,6 +159,7 @@ shutend()
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
+               SCPYN(wtmp.ut_host, "");
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
@@ -216,6 +220,7 @@ runcom(oldhowto)
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "reboot");
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "reboot");
+               SCPYN(wtmp.ut_host, "");
                if (time0) {
                        wtmp.ut_time = time0;
                        time0 = 0;
                if (time0) {
                        wtmp.ut_time = time0;
                        time0 = 0;
@@ -457,6 +462,7 @@ register struct tab *p;
                                continue;
                        lseek(f, -(long)sizeof(wtmp), 1);
                        SCPYN(wtmp.ut_name, "");
                                continue;
                        lseek(f, -(long)sizeof(wtmp), 1);
                        SCPYN(wtmp.ut_name, "");
+                       SCPYN(wtmp.ut_host, "");
                        time(&wtmp.ut_time);
                        write(f, (char *)&wtmp, sizeof(wtmp));
                        found++;
                        time(&wtmp.ut_time);
                        write(f, (char *)&wtmp, sizeof(wtmp));
                        found++;
@@ -468,6 +474,7 @@ register struct tab *p;
                if (f >= 0) {
                        SCPYN(wtmp.ut_line, p->line);
                        SCPYN(wtmp.ut_name, "");
                if (f >= 0) {
                        SCPYN(wtmp.ut_line, p->line);
                        SCPYN(wtmp.ut_name, "");
+                       SCPYN(wtmp.ut_host, "");
                        time(&wtmp.ut_time);
                        lseek(f, (long)0, 2);
                        write(f, (char *)&wtmp, sizeof(wtmp));
                        time(&wtmp.ut_time);
                        lseek(f, (long)0, 2);
                        write(f, (char *)&wtmp, sizeof(wtmp));
index 89ccfff..1a1b4c4 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid = "@(#)init.c      4.10 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)init.c      4.11 (Berkeley) %G%";
+#endif
+
 #include <signal.h>
 #include <sys/types.h>
 #include <utmp.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <utmp.h>
@@ -156,6 +159,7 @@ shutend()
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
+               SCPYN(wtmp.ut_host, "");
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
@@ -216,6 +220,7 @@ runcom(oldhowto)
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "reboot");
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "reboot");
+               SCPYN(wtmp.ut_host, "");
                if (time0) {
                        wtmp.ut_time = time0;
                        time0 = 0;
                if (time0) {
                        wtmp.ut_time = time0;
                        time0 = 0;
@@ -457,6 +462,7 @@ register struct tab *p;
                                continue;
                        lseek(f, -(long)sizeof(wtmp), 1);
                        SCPYN(wtmp.ut_name, "");
                                continue;
                        lseek(f, -(long)sizeof(wtmp), 1);
                        SCPYN(wtmp.ut_name, "");
+                       SCPYN(wtmp.ut_host, "");
                        time(&wtmp.ut_time);
                        write(f, (char *)&wtmp, sizeof(wtmp));
                        found++;
                        time(&wtmp.ut_time);
                        write(f, (char *)&wtmp, sizeof(wtmp));
                        found++;
@@ -468,6 +474,7 @@ register struct tab *p;
                if (f >= 0) {
                        SCPYN(wtmp.ut_line, p->line);
                        SCPYN(wtmp.ut_name, "");
                if (f >= 0) {
                        SCPYN(wtmp.ut_line, p->line);
                        SCPYN(wtmp.ut_name, "");
+                       SCPYN(wtmp.ut_host, "");
                        time(&wtmp.ut_time);
                        lseek(f, (long)0, 2);
                        write(f, (char *)&wtmp, sizeof(wtmp));
                        time(&wtmp.ut_time);
                        lseek(f, (long)0, 2);
                        write(f, (char *)&wtmp, sizeof(wtmp));
index 9683a2c..786fd6b 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid = "@(#)halt.c      4.7 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)halt.c      4.8 (Berkeley) %G%";
+#endif
+
 /*
  * Halt
  */
 /*
  * Halt
  */
@@ -103,6 +106,7 @@ markdown()
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
+               SCPYN(wtmp.ut_host, "");
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
index e04f556..511764f 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid = "@(#)reboot.c    4.6 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)reboot.c    4.7 (Berkeley) %G%";
+#endif
+
 /*
  * Reboot
  */
 /*
  * Reboot
  */
@@ -101,6 +104,7 @@ markdown()
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
                lseek(f, 0L, 2);
                SCPYN(wtmp.ut_line, "~");
                SCPYN(wtmp.ut_name, "shutdown");
+               SCPYN(wtmp.ut_host, "");
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
                time(&wtmp.ut_time);
                write(f, (char *)&wtmp, sizeof(wtmp));
                close(f);
index f79f4b7..9a575a7 100644 (file)
@@ -1,4 +1,6 @@
-static char *sccsid = "@(#)shutdown.c  4.16 (Berkeley) 83/04/29";
+#ifndef lint
+static char *sccsid = "@(#)shutdown.c  4.17 (Berkeley) 83/05/22";
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
index 9eed415..bc12e33 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid = "@(#)last.c      4.4 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)last.c      4.5 (Berkeley) %G%";
+#endif
+
 /*
  * last
  */
 /*
  * last
  */
@@ -10,10 +13,12 @@ static      char *sccsid = "@(#)last.c      4.4 (Berkeley) %G%";
 
 #define NMAX   sizeof(buf[0].ut_name)
 #define LMAX   sizeof(buf[0].ut_line)
 
 #define NMAX   sizeof(buf[0].ut_name)
 #define LMAX   sizeof(buf[0].ut_line)
+#define        HMAX    sizeof(buf[0].ut_host)
 #define        SECDAY  (24*60*60)
 
 #define        lineq(a,b)      (!strncmp(a,b,LMAX))
 #define        nameq(a,b)      (!strncmp(a,b,NMAX))
 #define        SECDAY  (24*60*60)
 
 #define        lineq(a,b)      (!strncmp(a,b,LMAX))
 #define        nameq(a,b)      (!strncmp(a,b,NMAX))
+#define        hosteq(a,b)     (!strncmp(a,b,HMAX))
 
 #define MAXTTYS 256
 
 
 #define MAXTTYS 256
 
@@ -48,8 +53,8 @@ main(ac, av)
        nameargs = argc = ac;
        argv = av;
        for (i = 0; i < argc; i++) {
        nameargs = argc = ac;
        argv = av;
        for (i = 0; i < argc; i++) {
-               if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9')
-               {
+               if (argv[i][0] == '-' &&
+                   argv[i][1] >= '0' && argv[i][1] <= '9') {
                        maxrec = atoi(argv[i]+1);
                        nameargs--;
                        continue;
                        maxrec = atoi(argv[i]+1);
                        nameargs--;
                        continue;
@@ -80,9 +85,11 @@ main(ac, av)
                        print = want(bp);
                        if (print) {
                                ct = ctime(&bp->ut_time);
                        print = want(bp);
                        if (print) {
                                ct = ctime(&bp->ut_time);
-                               printf("%-*.*s  %-*.*s  %10.10s %5.5s ",
+                               printf("%-*.*s  %-*.*s %-*.*s %10.10s %5.5s",
                                    NMAX, NMAX, bp->ut_name,
                                    NMAX, NMAX, bp->ut_name,
-                                   LMAX, LMAX, bp->ut_line, ct, 11+ct);
+                                   LMAX, LMAX, bp->ut_line,
+                                   HMAX, HMAX, bp->ut_host,
+                                   ct, 11+ct);
                        }
                        for (i = 0; i < MAXTTYS; i++) {
                                if (ttnames[i][0] == 0) {
                        }
                        for (i = 0; i < MAXTTYS; i++) {
                                if (ttnames[i][0] == 0) {