Changeset 16050 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Jan 19, 2009 5:16:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
r16048 r16050 610 610 * keep the cap_net_raw capability for ICMP sockets for the NAT stack. 611 611 */ 612 if (g_uCaps != 0) 613 { 612 614 # ifdef USE_LIB_PCAP 613 /* XXX cap_net_bind_service */614 if (!cap_set_proc(cap_from_text("all-eip cap_net_raw+ep")))615 prctl(PR_SET_KEEPCAPS, /*keep=*/1, 0, 0, 0);615 /* XXX cap_net_bind_service */ 616 if (!cap_set_proc(cap_from_text("all-eip cap_net_raw+ep"))) 617 prctl(PR_SET_KEEPCAPS, /*keep=*/1, 0, 0, 0); 616 618 # else 617 if (g_uCaps != 0)618 {619 619 cap_user_header_t hdr = (cap_user_header_t)alloca(sizeof(*hdr)); 620 620 cap_user_data_t cap = (cap_user_data_t)alloca(sizeof(*cap)); … … 626 626 if (!capset(hdr, cap)) 627 627 prctl(PR_SET_KEEPCAPS, /*keep=*/1, 0, 0, 0); 628 } 629 # endif 628 # endif /* !USE_LIB_PCAP */ 629 } 630 630 631 631 # elif defined(RT_OS_SOLARIS) … … 673 673 674 674 /* 675 * CAP_NET_RAW. 676 * Default: enabled. 677 * Can be disabled with 'export VBOX_HARD_CAP_NET_RAW=0'. 678 */ 679 pszOpt = getenv("VBOX_HARD_CAP_NET_RAW"); 680 if ( !pszOpt 681 || memcmp(pszOpt, "0", sizeof("0")) != 0) 682 g_uCaps = CAP_TO_MASK(CAP_NET_RAW); 683 684 /* 685 * CAP_NET_BIND_SERVICE. 686 * Default: disabled. 687 * Can be enabled with 'export VBOX_HARD_CAP_NET_BIND_SERVICE=1'. 688 */ 689 pszOpt = getenv("VBOX_HARD_CAP_NET_BIND_SERVICE"); 690 if ( pszOpt 691 && memcmp(pszOpt, "0", sizeof("0")) != 0) 692 g_uCaps |= CAP_TO_MASK(CAP_NET_BIND_SERVICE); 675 * Do _not_ perform any capability-related system calls for root processes 676 * (leaving g_uCaps at 0). 677 */ 678 if (getuid() != 0) 679 { 680 /* 681 * CAP_NET_RAW. 682 * Default: enabled. 683 * Can be disabled with 'export VBOX_HARD_CAP_NET_RAW=0'. 684 */ 685 pszOpt = getenv("VBOX_HARD_CAP_NET_RAW"); 686 if ( !pszOpt 687 || memcmp(pszOpt, "0", sizeof("0")) != 0) 688 g_uCaps = CAP_TO_MASK(CAP_NET_RAW); 689 690 /* 691 * CAP_NET_BIND_SERVICE. 692 * Default: disabled. 693 * Can be enabled with 'export VBOX_HARD_CAP_NET_BIND_SERVICE=1'. 694 */ 695 pszOpt = getenv("VBOX_HARD_CAP_NET_BIND_SERVICE"); 696 if ( pszOpt 697 && memcmp(pszOpt, "0", sizeof("0")) != 0) 698 g_uCaps |= CAP_TO_MASK(CAP_NET_BIND_SERVICE); 699 } 693 700 # endif 694 701 } … … 762 769 * Re-enable the cap_net_raw capability which was disabled during setresuid. 763 770 */ 771 if (g_uCaps != 0) 772 { 764 773 # ifdef USE_LIB_PCAP 765 /** @todo Warn if that does not work? */766 /* XXX cap_net_bind_service */767 cap_set_proc(cap_from_text("cap_net_raw+ep"));774 /** @todo Warn if that does not work? */ 775 /* XXX cap_net_bind_service */ 776 cap_set_proc(cap_from_text("cap_net_raw+ep")); 768 777 # else 769 if (g_uCaps != 0)770 {771 778 cap_user_header_t hdr = (cap_user_header_t)alloca(sizeof(*hdr)); 772 779 cap_user_data_t cap = (cap_user_data_t)alloca(sizeof(*cap)); … … 778 785 /** @todo Warn if that does not work? */ 779 786 capset(hdr, cap); 780 } 781 # endif 787 # endif /* !USE_LIB_PCAP */ 788 } 782 789 # endif 783 790 }
Note:
See TracChangeset
for help on using the changeset viewer.