use syslog for error messages
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Fri, 14 Sep 1984 02:33:46 +0000 (18:33 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Fri, 14 Sep 1984 02:33:46 +0000 (18:33 -0800)
SCCS-vsn: libexec/rshd/rshd.c 4.21
SCCS-vsn: libexec/rlogind/rlogind.c 4.22
SCCS-vsn: libexec/telnetd/telnetd.c 4.29
SCCS-vsn: libexec/tftpd/tftpd.c 4.14

usr/src/libexec/rlogind/rlogind.c
usr/src/libexec/rshd/rshd.c
usr/src/libexec/telnetd/telnetd.c
usr/src/libexec/tftpd/tftpd.c

index b8b59ff..00a9a32 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)rlogind.c  4.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)rlogind.c  4.22 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -24,6 +24,7 @@ static        char sccsid[] = "@(#)rlogind.c  4.21 (Berkeley) %G%";
 #include <sgtty.h>
 #include <stdio.h>
 #include <netdb.h>
 #include <sgtty.h>
 #include <stdio.h>
 #include <netdb.h>
+#include <syslog.h>
 
 extern errno;
 int    reapchild();
 
 extern errno;
 int    reapchild();
@@ -44,8 +45,8 @@ main(argc, argv)
                _exit(1);
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
                _exit(1);
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
-               fprintf(stderr, "%s: ", argv[0]);
-               perror("setsockopt (SO_KEEPALIVE)");
+               openlog(argv[0], LOG_PID, 0);
+               syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
        }
        doit(0, &from);
 }
        }
        doit(0, &from);
 }
index 16994df..2410d74 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)rshd.c     4.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)rshd.c     4.21 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -21,10 +21,10 @@ static      char sccsid[] = "@(#)rshd.c     4.20 (Berkeley) %G%";
 #include <pwd.h>
 #include <signal.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <signal.h>
 #include <netdb.h>
+#include <syslog.h>
 
 int    errno;
 
 int    errno;
-struct passwd *getpwnam();
-char   *index(), *rindex(), *sprintf();
+char   *index(), *rindex();
 /* VARARGS 1 */
 int    error();
 
 /* VARARGS 1 */
 int    error();
 
@@ -43,14 +43,14 @@ main(argc, argv)
                _exit(1);
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
                _exit(1);
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
-               fprintf(stderr, "%s: ", argv[0]);
-               perror("setsockopt (SO_KEEPALIVE)");
+               openlog(argv[0], LOG_PID, 0);
+               syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
        }
        linger.l_onoff = 1;
        linger.l_linger = 60;                   /* XXX */
        if (setsockopt(0, SOL_SOCKET, SO_LINGER, &linger, sizeof (linger)) < 0) {
        }
        linger.l_onoff = 1;
        linger.l_linger = 60;                   /* XXX */
        if (setsockopt(0, SOL_SOCKET, SO_LINGER, &linger, sizeof (linger)) < 0) {
-               fprintf(stderr, "%s: ", argv[0]);
-               perror("setsockopt (SO_LINGER)");
+               openlog(argv[0], LOG_PID, 0);
+               syslog(LOG_WARNING, "setsockopt (SO_LINGER): %m");
        }
        doit(dup(0), &from);
 }
        }
        doit(dup(0), &from);
 }
@@ -90,7 +90,8 @@ doit(f, fromp)
        fromp->sin_port = ntohs((u_short)fromp->sin_port);
        if (fromp->sin_family != AF_INET ||
            fromp->sin_port >= IPPORT_RESERVED) {
        fromp->sin_port = ntohs((u_short)fromp->sin_port);
        if (fromp->sin_family != AF_INET ||
            fromp->sin_port >= IPPORT_RESERVED) {
-               fprintf(stderr, "rshd: malformed from address\n");
+               openlog("rshd", LOG_PID, 0);
+               syslog(LOG_ERR, "malformed from address\n");
                exit(1);
        }
        (void) alarm(60);
                exit(1);
        }
        (void) alarm(60);
@@ -98,7 +99,8 @@ doit(f, fromp)
        for (;;) {
                char c;
                if (read(f, &c, 1) != 1) {
        for (;;) {
                char c;
                if (read(f, &c, 1) != 1) {
-                       perror("rshd: read");
+                       openlog("rshd", LOG_PID, 0);
+                       syslog(LOG_ERR, "read: %m");
                        shutdown(f, 1+1);
                        exit(1);
                }
                        shutdown(f, 1+1);
                        exit(1);
                }
@@ -111,16 +113,19 @@ doit(f, fromp)
                int lport = IPPORT_RESERVED - 1, retryshift;
                s = rresvport(&lport);
                if (s < 0) {
                int lport = IPPORT_RESERVED - 1, retryshift;
                s = rresvport(&lport);
                if (s < 0) {
-                       perror("rshd: can't get stderr port");
+                       openlog("rshd", LOG_PID, 0);
+                       syslog(LOG_ERR, "can't get stderr port: %m");
                        exit(1);
                }
                if (port >= IPPORT_RESERVED) {
                        exit(1);
                }
                if (port >= IPPORT_RESERVED) {
-                       fprintf(stderr, "rshd: 2nd port not reserved\n");
+                       openlog("rshd", LOG_PID, 0);
+                       syslog(LOG_ERR, "2nd port not reserved\n");
                        exit(1);
                }
                fromp->sin_port = htons((u_short)port);
                if (connect(s, fromp, sizeof (*fromp), 0) < 0) {
                        exit(1);
                }
                fromp->sin_port = htons((u_short)port);
                if (connect(s, fromp, sizeof (*fromp), 0) < 0) {
-                       perror("rshd: connect");
+                       openlog("rshd", LOG_PID, 0);
+                       syslog(LOG_ERR, "connect: %m");
                        exit(1);
                }
        }
                        exit(1);
                }
        }
index 052efc0..51c274d 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  4.28 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  4.29 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -18,6 +18,7 @@ static        char sccsid[] = "@(#)telnetd.c  4.28 (Berkeley) %G%";
 #include <errno.h>
 #include <sgtty.h>
 #include <netdb.h>
 #include <errno.h>
 #include <sgtty.h>
 #include <netdb.h>
+#include <syslog.h>
 
 #define        BELL    '\07'
 #define BANNER "\r\n\r\n4.2 BSD UNIX (%s)\r\n\r\r\n\r%s"
 
 #define        BELL    '\07'
 #define BANNER "\r\n\r\n4.2 BSD UNIX (%s)\r\n\r\r\n\r%s"
@@ -58,8 +59,8 @@ main(argc, argv)
                _exit(1);
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
                _exit(1);
        }
        if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0) {
-               fprintf(stderr, "%s: ", argv[0]);
-               perror("setsockopt (SO_KEEPALIVE)");
+               openlog(argv[0], LOG_PID, 0);
+               syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
        }
        doit(0, &from);
 }
        }
        doit(0, &from);
 }
index 2c4db82..185ba09 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)tftpd.c    4.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)tftpd.c    4.14 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -21,6 +21,7 @@ static        char sccsid[] = "@(#)tftpd.c    4.13 (Berkeley) %G%";
 #include <ctype.h>
 #include <netdb.h>
 #include <setjmp.h>
 #include <ctype.h>
 #include <netdb.h>
 #include <setjmp.h>
+#include <syslog.h>
 
 #define        TIMEOUT         5
 
 
 #define        TIMEOUT         5
 
@@ -52,15 +53,18 @@ main()
        close(1);
        peer = socket(AF_INET, SOCK_DGRAM, 0);
        if (peer < 0) {
        close(1);
        peer = socket(AF_INET, SOCK_DGRAM, 0);
        if (peer < 0) {
-               perror("tftpd: socket");
+               openlog("tftpd", LOG_PID, 0);
+               syslog(LOG_ERR, "socket: %m");
                exit(1);
        }
        if (bind(peer, (caddr_t)&sin, sizeof (sin)) < 0) {
                exit(1);
        }
        if (bind(peer, (caddr_t)&sin, sizeof (sin)) < 0) {
-               perror("tftpd: bind");
+               openlog("tftpd", LOG_PID, 0);
+               syslog(LOG_ERR, "bind: %m");
                exit(1);
        }
        if (connect(peer, (caddr_t)&from, sizeof(from)) < 0) {
                exit(1);
        }
        if (connect(peer, (caddr_t)&from, sizeof(from)) < 0) {
-               perror("tftpd: connect");
+               openlog("tftpd", LOG_PID, 0);
+               syslog(LOG_ERR, "connect: %m");
                exit(1);
        }
        tp = (struct tftphdr *)buf;
                exit(1);
        }
        tp = (struct tftphdr *)buf;