diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-02-04 10:24:02 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-02-04 10:27:09 -0500 |
commit | 2c9fc26670ef85a14d16a72bc16e7368f76c28f4 (patch) | |
tree | 41707dbfc974c8e4b3f6d772e721bb1769dc7dca | |
parent | 6295ba8c3d448d993d750c0cc0da44cca77480e7 (diff) |
shared/capabilities: simplify assertions about bits
The assert added in 7d328b5446 was wrong. Also update the comments
and make sure we don't try to shift by type size.
-rw-r--r-- | src/shared/capability.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shared/capability.c b/src/shared/capability.c index 57f392a4da..915ceb9d9b 100644 --- a/src/shared/capability.c +++ b/src/shared/capability.c @@ -275,10 +275,10 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) { if (keep_capabilities & (1ULL << i)) bits[j++] = i; - /* don't keep too many bits */ - assert((keep_capabilities & (~1ULL << i)) == 0); - /* don't throw away too many bits */ - assert(((keep_capabilities >> i) & (~1ULL >> i)) == 0); + /* use enough bits */ + assert(i == 64 || (keep_capabilities >> i) == 0); + /* don't use too many bits */ + assert(keep_capabilities & (1ULL << (i - 1))); if (cap_set_flag(d, CAP_EFFECTIVE, j, bits, CAP_SET) < 0 || cap_set_flag(d, CAP_PERMITTED, j, bits, CAP_SET) < 0) { |