update from jsp; add 'priv' keyword to get privileged ports

This commit is contained in:
cgd 1994-01-14 19:47:02 +00:00
parent b53b616201
commit 6de18bb07c
1 changed files with 22 additions and 5 deletions

View File

@ -35,8 +35,8 @@
* SUCH DAMAGE.
*
* from: Id: pt_tcp.c,v 1.1 1992/05/25 21:43:09 jsp Exp jsp
* from: @(#)pt_tcp.c 8.1 (Berkeley) 6/5/93
* $Id: pt_tcp.c,v 1.2 1994/01/13 17:43:39 mycroft Exp $
* from: @(#)pt_tcp.c 8.2 (Berkeley) 1/14/94
* $Id: pt_tcp.c,v 1.3 1994/01/14 19:47:02 cgd Exp $
*/
#include <stdio.h>
@ -77,6 +77,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, '/');
@ -84,12 +85,25 @@ int *fdp;
return (EINVAL);
*q = '\0';
strcpy(host, p);
p = ++q;
p = q + 1;
q = strchr(p, '/');
if (q != 0 || strlen(p) >= sizeof(port))
if (q)
*q = '\0';
if (strlen(p) >= sizeof(port))
return (EINVAL);
strcpy(port, p);
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) {
@ -120,7 +134,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);