X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/0be6ec503b4c6cd3c31a0e00bf8dd1004e9e17ab..1233d419e4b7d9b574e905f94d808c601d6d9d34:/usr/src/sbin/mount_portal/pt_tcp.c diff --git a/usr/src/sbin/mount_portal/pt_tcp.c b/usr/src/sbin/mount_portal/pt_tcp.c index 32f401083a..bc2cd66ecc 100644 --- a/usr/src/sbin/mount_portal/pt_tcp.c +++ b/usr/src/sbin/mount_portal/pt_tcp.c @@ -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 @@ -8,7 +8,7 @@ * * %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 $ */ @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "portald.h" @@ -51,6 +52,7 @@ int *fdp; struct in_addr *ip[2]; struct in_addr ina; int s_port; + int priv = 0; struct sockaddr_in sain; q = strchr(p, '/'); @@ -58,14 +60,25 @@ int *fdp; return (EINVAL); *q = '\0'; strcpy(host, p); - p = q++; + p = q + 1; q = strchr(p, '/'); - if (q == 0 || q - p >= sizeof(port)) + if (q) + *q = '\0'; + if (strlen(p) >= sizeof(port)) return (EINVAL); - *q = '\0'; 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) { @@ -96,7 +109,10 @@ int *fdp; 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);