missing #includes
[unix-history] / usr / src / sbin / mount_portal / pt_tcp.c
index 32f4010..bc2cd66 100644 (file)
@@ -1,6 +1,6 @@
 /*
 /*
- * Copyright (c) 1992 The Regents of the University of California
- * Copyright (c) 1990, 1992 Jan-Simon Pendry
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
  * All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
  * All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pt_tcp.c    5.2 (Berkeley) %G%
+ *     @(#)pt_tcp.c    8.3 (Berkeley) %G%
  *
  * $Id: pt_tcp.c,v 1.1 1992/05/25 21:43:09 jsp Exp jsp $
  */
  *
  * $Id: pt_tcp.c,v 1.1 1992/05/25 21:43:09 jsp Exp jsp $
  */
@@ -23,6 +23,7 @@
 #include <sys/syslog.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/syslog.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 #include <netdb.h>
 
 #include "portald.h"
 #include <netdb.h>
 
 #include "portald.h"
@@ -51,6 +52,7 @@ int *fdp;
        struct in_addr *ip[2];
        struct in_addr ina;
        int s_port;
        struct in_addr *ip[2];
        struct in_addr ina;
        int s_port;
+       int priv = 0;
        struct sockaddr_in sain;
 
        q = strchr(p, '/');
        struct sockaddr_in sain;
 
        q = strchr(p, '/');
@@ -58,14 +60,25 @@ int *fdp;
                return (EINVAL);
        *q = '\0';
        strcpy(host, p);
                return (EINVAL);
        *q = '\0';
        strcpy(host, p);
-       p = q++;
+       p = q + 1;
 
        q = strchr(p, '/');
 
        q = strchr(p, '/');
-       if (q == 0 || q - p >= sizeof(port))
+       if (q)
+               *q = '\0';
+       if (strlen(p) >= sizeof(port))
                return (EINVAL);
                return (EINVAL);
-       *q = '\0';
        strcpy(port, p);
        strcpy(port, p);
-       p = q++;
+       if (q) {
+               p = q + 1;
+               if (strcmp(p, "priv") == 0) {
+                       if (pcr->pcr_uid == 0)
+                               priv = 1;
+                       else
+                               return (EPERM);
+               } else {
+                       return (EINVAL);
+               }
+       }
 
        hp = gethostbyname(host);
        if (hp != 0) {
 
        hp = gethostbyname(host);
        if (hp != 0) {
@@ -96,7 +109,10 @@ int *fdp;
        while (ipp[0]) {
                int so;
 
        while (ipp[0]) {
                int so;
 
-               so = socket(AF_INET, SOCK_STREAM, 0);
+               if (priv)
+                       so = rresvport((int *) 0);
+               else
+                       so = socket(AF_INET, SOCK_STREAM, 0);
                if (so < 0) {
                        syslog(LOG_ERR, "socket: %m");
                        return (errno);
                if (so < 0) {
                        syslog(LOG_ERR, "socket: %m");
                        return (errno);