| 925 | |
| 926 | #ifdef INET |
| 927 | static int |
| 928 | udp_getcred(SYSCTL_HANDLER_ARGS) |
| 929 | { |
| 930 | struct xucred xuc; |
| 931 | struct sockaddr_in addrs[2]; |
| 932 | struct epoch_tracker et; |
| 933 | struct inpcb *inp; |
| 934 | int error; |
| 935 | |
| 936 | error = priv_check(req->td, PRIV_NETINET_GETCRED); |
| 937 | if (error) |
| 938 | return (error); |
| 939 | error = SYSCTL_IN(req, addrs, sizeof(addrs)); |
| 940 | if (error) |
| 941 | return (error); |
| 942 | NET_EPOCH_ENTER(et); |
| 943 | inp = in_pcblookup(&V_udbinfo, addrs[1].sin_addr, addrs[1].sin_port, |
| 944 | addrs[0].sin_addr, addrs[0].sin_port, |
| 945 | INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB, NULL); |
| 946 | NET_EPOCH_EXIT(et); |
| 947 | if (inp != NULL) { |
| 948 | INP_RLOCK_ASSERT(inp); |
| 949 | if (inp->inp_socket == NULL) |
| 950 | error = ENOENT; |
| 951 | if (error == 0) |
| 952 | error = cr_canseeinpcb(req->td->td_ucred, inp); |
| 953 | if (error == 0) |
| 954 | cru2x(inp->inp_cred, &xuc); |
| 955 | INP_RUNLOCK(inp); |
| 956 | } else |
| 957 | error = ENOENT; |
| 958 | if (error == 0) |
| 959 | error = SYSCTL_OUT(req, &xuc, sizeof(struct xucred)); |
| 960 | return (error); |
| 961 | } |
| 962 | |
| 963 | SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred, |
| 964 | CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE, |
nothing calls this directly
no test coverage detected