Changeset 35307 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Dec 23, 2010 10:10:31 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69158
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
r34701 r35307 649 649 # elif defined(RT_OS_SOLARIS) 650 650 /* 651 * Add net_icmpaccess privilege to permitted, effective and inheritable 652 * privileges before dropping root privileges. Skip this hacky code for 653 * real root, as it removes lots of privileges due to the harcoded set. 654 */ 655 if (getuid() != 0) 656 { 657 priv_set_t *pPrivSet = priv_str_to_set("basic", ",", NULL); 658 if (pPrivSet) 651 * Add net_icmpaccess privilege to effective privileges and limit 652 * permitted privileges before completely dropping root privileges. 653 * This requires dropping root privileges temporarily to get the normal 654 * user's privileges. 655 */ 656 seteuid(g_uid); 657 priv_set_t *pPrivEffective = priv_allocset(); 658 priv_set_t *pPrivNewEffective = priv_allocset(); 659 priv_set_t *pPrivNewPermitted = priv_allocset(); 660 if (pPrivEffective && pPrivNewEffective && pPrivNewPermitted) 661 { 662 int rc = getppriv(PRIV_EFFECTIVE, pPrivEffective); 663 seteuid(0); 664 if (!rc) 659 665 { 660 priv_addset(pPrivSet, PRIV_NET_ICMPACCESS); 661 int rc = setppriv(PRIV_SET, PRIV_INHERITABLE, pPrivSet); 666 priv_copyset(pPrivEffective, pPrivNewEffective); 667 priv_copyset(pPrivEffective, pPrivNewPermitted); 668 rc = priv_addset(pPrivNewEffective, PRIV_NET_ICMPACCESS); 662 669 if (!rc) 663 670 { 664 rc = setppriv(PRIV_SET, PRIV_PERMITTED, pPrivSet);665 if (!rc)666 {667 rc = setppriv(PRIV_SET, PRIV_EFFECTIVE, pPrivSet);668 669 670 }671 else672 supR3HardenedError(rc, false, "SUPR3HardenedMain: failed to set permittedprivilege set.\n");671 /* Order is important, as one can't set a privilege which is 672 * not in the permitted privilege set. We limit ourselves as 673 * much as possible after grabbing the extra privileges. */ 674 rc = setppriv(PRIV_SET, PRIV_EFFECTIVE, pPrivNewEffective); 675 if (rc) 676 supR3HardenedError(rc, false, "SUPR3HardenedMain: failed to set effective privilege set.\n"); 677 rc = setppriv(PRIV_SET, PRIV_PERMITTED, pPrivNewPermitted); 678 if (rc) 679 supR3HardenedError(rc, false, "SUPR3HardenedMain: failed to set effective privilege set.\n"); 673 680 } 674 681 else 675 supR3HardenedError(rc, false, "SUPR3HardenedMain: failed to set inheritable privilege set.\n"); 676 677 priv_freeset(pPrivSet); 682 supR3HardenedError(rc, false, "SUPR3HardenedMain: failed to add NET_ICMPACCESS privilege.\n"); 678 683 } 679 else 680 supR3HardenedError(-1, false, "SUPR3HardenedMain: failed to get basic privilege set.\n"); 684 } 685 else 686 { 687 /* for memory allocation failures just continue */ 688 seteuid(0); 681 689 } 682 690 # endif
Note:
See TracChangeset
for help on using the changeset viewer.