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
-static char sccsid[] = "@(#)telnetd.c 4.19 83/05/03";
+static char sccsid[] = "@(#)telnetd.c 4.20 83/05/22";
sigset(SIGCHLD, reapchild);
listen(s, 10);
for (;;) {
sigset(SIGCHLD, reapchild);
listen(s, 10);
for (;;) {
+ 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;
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);
/*
* Get a pty, scan input lines.
*/
/*
* Get a pty, scan input lines.
*/
+doit(f, who)
+ int f;
+ struct sockaddr_in *who;
+ char *cp = line, *host, *ntoa();
int i, p, cc, t;
struct sgttyb b;
int i, p, cc, t;
struct sgttyb b;
for (i = 0; i < 16; i++) {
cp[strlen("/dev/ptyp")] = "0123456789abcdef"[i];
for (i = 0; i < 16; i++) {
cp[strlen("/dev/ptyp")] = "0123456789abcdef"[i];
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)
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*/
}
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++;
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));
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 *)∈
+#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);
+}
-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>
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);
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;
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++;
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));
-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>
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);
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;
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++;
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));
-static char *sccsid = "@(#)halt.c 4.7 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)halt.c 4.8 (Berkeley) %G%";
+#endif
+
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);
-static char *sccsid = "@(#)reboot.c 4.6 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)reboot.c 4.7 (Berkeley) %G%";
+#endif
+
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);
-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>
-static char *sccsid = "@(#)last.c 4.4 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#)last.c 4.5 (Berkeley) %G%";
+#endif
+
#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))
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;
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",
- 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) {