version 1.95, 2013/03/20 15:23:37 |
version 1.96, 2013/10/22 16:40:28 |
|
|
*/ |
*/ |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/file.h> |
|
#include <sys/protosw.h> |
#include <sys/protosw.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
#include <sys/sysctl.h> |
#include <sys/sysctl.h> |
|
|
#include <ctype.h> |
#include <ctype.h> |
#include <err.h> |
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
|
#include <fcntl.h> |
#include <kvm.h> |
#include <kvm.h> |
#include <limits.h> |
#include <limits.h> |
#include <netdb.h> |
#include <netdb.h> |
|
|
u_int tableid; |
u_int tableid; |
int Tflag = 0; |
int Tflag = 0; |
int repeatcount = 0; |
int repeatcount = 0; |
|
int need_nlist; |
|
|
hideroot = getuid(); |
hideroot = getuid(); |
|
|
|
|
} |
} |
#endif |
#endif |
|
|
|
need_nlist = !mflag && (pflag || nlistf != NULL || memf != NULL || |
|
(!iflag && !sflag && (rflag ? Aflag : |
|
(gflag || af != AF_UNIX || Pflag)))); |
|
|
/* |
/* |
* Discard setgid privileges if not the running kernel so that bad |
* Discard setgid privileges if not the running kernel so that bad |
* guys can't print interesting stuff from kernel memory. |
* guys can't print interesting stuff from kernel memory. |
|
|
if (setresgid(gid, gid, gid) == -1) |
if (setresgid(gid, gid, gid) == -1) |
err(1, "setresgid"); |
err(1, "setresgid"); |
|
|
if ((kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, |
if ((kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY | |
buf)) == NULL) { |
(need_nlist ? 0 : KVM_NO_FILES), buf)) == NULL) { |
fprintf(stderr, "%s: kvm_openfiles: %s\n", __progname, buf); |
fprintf(stderr, "%s: kvm_openfiles: %s\n", __progname, buf); |
exit(1); |
exit(1); |
} |
} |
|
|
if (setresgid(gid, gid, gid) == -1) |
if (setresgid(gid, gid, gid) == -1) |
err(1, "setresgid"); |
err(1, "setresgid"); |
|
|
if (kvm_nlist(kvmd, nl) < 0 || nl[0].n_type == 0) { |
if (need_nlist && (kvm_nlist(kvmd, nl) < 0 || nl[0].n_type == 0)) { |
if (nlistf) |
if (nlistf) |
fprintf(stderr, "%s: %s: no namelist\n", __progname, |
fprintf(stderr, "%s: %s: no namelist\n", __progname, |
nlistf); |
nlistf); |
|
|
printproto(tp, tp->pr_name, AF_INET6, tableid, |
printproto(tp, tp->pr_name, AF_INET6, tableid, |
pcbaddr); |
pcbaddr); |
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) |
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) |
unixpr(nl[N_UNIXSW].n_value, pcbaddr); |
unixpr(kvmd, pcbaddr); |
exit(0); |
exit(0); |
} |
} |
|
|