BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / libc / net / rcmd.c
index d60d5c7..d0cd180 100644 (file)
@@ -2,46 +2,58 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that: (1) source distributions retain this entire copyright
- * notice and comment, and (2) distributions including binaries display
- * the following acknowledgement:  ``This product includes software
- * developed by the University of California, Berkeley and its contributors''
- * in the documentation or other materials provided with the distribution
- * and in all advertising materials mentioning features or use of this
- * software. Neither the name of the University nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rcmd.c     5.22 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)rcmd.c     5.24 (Berkeley) 2/24/91";
 #endif /* LIBC_SCCS and not lint */
 
 #endif /* LIBC_SCCS and not lint */
 
-#include <stdio.h>
-#include <ctype.h>
-#include <pwd.h>
 #include <sys/param.h>
 #include <sys/param.h>
-#include <sys/file.h>
-#include <sys/signal.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-
 #include <netinet/in.h>
 #include <netinet/in.h>
-
+#include <arpa/inet.h>
+#include <signal.h>
+#include <fcntl.h>
 #include <netdb.h>
 #include <netdb.h>
+#include <pwd.h>
 #include <errno.h>
 #include <errno.h>
-
-extern errno;
-char   *index();
+#include <stdio.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
 
 rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
        char **ahost;
        u_short rport;
 
 rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
        char **ahost;
        u_short rport;
-       char *locuser, *remuser, *cmd;
+       const char *locuser, *remuser, *cmd;
        int *fd2p;
 {
        int s, timo = 1, pid;
        int *fd2p;
 {
        int s, timo = 1, pid;
@@ -74,7 +86,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
                sin.sin_family = hp->h_addrtype;
                bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length);
                sin.sin_port = rport;
                sin.sin_family = hp->h_addrtype;
                bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length);
                sin.sin_port = rport;
-               if (connect(s, (caddr_t)&sin, sizeof (sin), 0) >= 0)
+               if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
                        break;
                (void) close(s);
                if (errno == EADDRINUSE) {
                        break;
                (void) close(s);
                if (errno == EADDRINUSE) {
@@ -136,7 +148,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
                        (void) close(s2);
                        goto bad;
                }
                        (void) close(s2);
                        goto bad;
                }
-               s3 = accept(s2, &from, &len, 0);
+               s3 = accept(s2, (struct sockaddr *)&from, &len);
                (void) close(s2);
                if (s3 < 0) {
                        perror("accept");
                (void) close(s2);
                if (s3 < 0) {
                        perror("accept");
@@ -192,7 +204,7 @@ rresvport(alport)
                return (-1);
        for (;;) {
                sin.sin_port = htons((u_short)*alport);
                return (-1);
        for (;;) {
                sin.sin_port = htons((u_short)*alport);
-               if (bind(s, (caddr_t)&sin, sizeof (sin)) >= 0)
+               if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0)
                        return (s);
                if (errno != EADDRINUSE) {
                        (void) close(s);
                        return (s);
                if (errno != EADDRINUSE) {
                        (void) close(s);
@@ -210,9 +222,8 @@ rresvport(alport)
 int    _check_rhosts_file = 1;
 
 ruserok(rhost, superuser, ruser, luser)
 int    _check_rhosts_file = 1;
 
 ruserok(rhost, superuser, ruser, luser)
-       char *rhost;
+       const char *rhost, *ruser, *luser;
        int superuser;
        int superuser;
-       char *ruser, *luser;
 {
        FILE *hostf;
        char fhost[MAXHOSTNAMELEN];
 {
        FILE *hostf;
        char fhost[MAXHOSTNAMELEN];
@@ -220,7 +231,7 @@ ruserok(rhost, superuser, ruser, luser)
        register char *sp, *p;
        int baselen = -1;
 
        register char *sp, *p;
        int baselen = -1;
 
-       sp = rhost;
+       sp = (char *)rhost;
        p = fhost;
        while (*sp) {
                if (*sp == '.') {
        p = fhost;
        while (*sp) {
                if (*sp == '.') {
@@ -274,9 +285,9 @@ _validuser(hostf, rhost, luser, ruser, baselen)
        FILE *hostf;
        int baselen;
 {
        FILE *hostf;
        int baselen;
 {
-       char *user;
-       char ahost[MAXHOSTNAMELEN];
        register char *p;
        register char *p;
+       char *user, ahost[MAXHOSTNAMELEN];
+       static int _checkhost();
 
        while (fgets(ahost, sizeof (ahost), hostf)) {
                p = ahost;
 
        while (fgets(ahost, sizeof (ahost), hostf)) {
                p = ahost;