traceroute6: Fix Capsicum rights for rcvsock
- Always use distinct sockets for send and recv - Limit rights on the recv socket For ICMP6 we were using the same socket for both send and receive, and we limited rights on the socket such that it's impossible to receive anything. PR: 254623 Diagnosed by: Zhenlei Huang <zlei.huang@gmail.com> Reviewed by: oshogbo MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29523
This commit is contained in:
parent
02f26e98c7
commit
b8ae450f05
@ -578,8 +578,6 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
switch (useproto) {
|
||||
case IPPROTO_ICMPV6:
|
||||
sndsock = rcvsock;
|
||||
break;
|
||||
case IPPROTO_NONE:
|
||||
case IPPROTO_SCTP:
|
||||
case IPPROTO_TCP:
|
||||
@ -928,7 +926,6 @@ main(int argc, char *argv[])
|
||||
* namespaces (e.g filesystem) is restricted (see capsicum(4)).
|
||||
* We must connect(2) our socket before this point.
|
||||
*/
|
||||
|
||||
if (caph_enter_casper() < 0) {
|
||||
fprintf(stderr, "caph_enter_casper: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
@ -940,6 +937,12 @@ main(int argc, char *argv[])
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
cap_rights_init(&rights, CAP_RECV);
|
||||
if (caph_rights_limit(rcvsock, &rights) < 0) {
|
||||
fprintf(stderr, "caph_rights_limit rcvsock: %s\n",
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Main loop
|
||||
|
Loading…
Reference in New Issue
Block a user