Finish the implementation of the -p switch so that it
actually works. I have no idea why this wasn't finished and happened to try to use it.
This commit is contained in:
parent
9dc9d63d01
commit
ae94787d6d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=115955
@ -456,6 +456,30 @@ getprocname(pid_t pid)
|
||||
return (proc.ki_ocomm);
|
||||
}
|
||||
|
||||
static int
|
||||
check_ports(struct sock *s)
|
||||
{
|
||||
int port;
|
||||
|
||||
if (ports == NULL)
|
||||
return (1);
|
||||
if ((s->family != AF_INET) && (s->family != AF_INET6))
|
||||
return (1);
|
||||
if (s->family == AF_INET)
|
||||
port = ntohs(((struct sockaddr_in *)(&s->laddr))->sin_port);
|
||||
else
|
||||
port = ntohs(((struct sockaddr_in6 *)(&s->laddr))->sin6_port);
|
||||
if (CHK_PORT(port))
|
||||
return (1);
|
||||
if (s->family == AF_INET)
|
||||
port = ntohs(((struct sockaddr_in *)(&s->faddr))->sin_port);
|
||||
else
|
||||
port = ntohs(((struct sockaddr_in6 *)(&s->faddr))->sin6_port);
|
||||
if (CHK_PORT(port))
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
display(void)
|
||||
{
|
||||
@ -476,6 +500,8 @@ display(void)
|
||||
break;
|
||||
if (s == NULL)
|
||||
continue;
|
||||
if (!check_ports(s))
|
||||
continue;
|
||||
pos = 0;
|
||||
if ((pwd = getpwuid(xf->xf_uid)) == NULL)
|
||||
pos += xprintf("%lu", (u_long)xf->xf_uid);
|
||||
|
Loading…
Reference in New Issue
Block a user