diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-11-26 11:03:35 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-12-15 13:10:57 -0500 |
commit | 405a8d3fb4884d5e5c5f32881a1a810b733a5aad (patch) | |
tree | 53fbd1b246592d767837236082f44b3a5bf4cba0 /src/common/compat.c | |
parent | fd0c6671d13333f2ddb41e792b40162c841adae6 (diff) | |
download | tor-405a8d3fb4884d5e5c5f32881a1a810b733a5aad.tar.gz tor-405a8d3fb4884d5e5c5f32881a1a810b733a5aad.zip |
Update KeepCapabilities based on comments from asn
* The option is now KeepBindCapabilities
* We now warn if the user specifically asked for KeepBindCapabilities
and we can't deliver.
* The unit tests are willing to start.
* Fewer unused-variable warnings.
* More documentation, fewer misspellings.
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 655193499e..217bc00315 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1997,8 +1997,11 @@ drop_capabilities(int pre_setuid) /** Call setuid and setgid to run as <b>user</b> and switch to their * primary group. Return 0 on success. On failure, log and return -1. * - * If SWITCH_ID_KEEP_BINDLOW is set in 'flags', try to use the capabilitity + * If SWITCH_ID_KEEP_BINDLOW is set in 'flags', try to use the capability * system to retain the abilitity to bind low ports. + * + * If SWITCH_ID_WARN_IF_NO_CAPS is set in flags, also warn if we have + * don't have capability support. */ int switch_id(const char *user, const unsigned flags) @@ -2009,6 +2012,7 @@ switch_id(const char *user, const unsigned flags) gid_t old_gid; static int have_already_switched_id = 0; const int keep_bindlow = !!(flags & SWITCH_ID_KEEP_BINDLOW); + const int warn_if_no_caps = !!(flags & SWITCH_ID_WARN_IF_NO_CAPS); tor_assert(user); @@ -2033,10 +2037,17 @@ switch_id(const char *user, const unsigned flags) } #ifdef HAVE_LINUX_CAPABILITIES + (void) warn_if_no_caps; if (keep_bindlow) { if (drop_capabilities(1)) return -1; } +#else + (void) keep_bindlow; + if (warn_if_no_caps) { + log_warn(LD_CONFIG, "KeepBindCapabilities set, but no capability support " + "on this system."); + } #endif /* Properly switch egid,gid,euid,uid here or bail out */ |