chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
machined,machinectl: add calls for changing container/VM quotas
[elogind.git]
/
src
/
shared
/
capability.c
diff --git
a/src/shared/capability.c
b/src/shared/capability.c
index 57f392a4da887228c616577f63c8b37ca8ad03b5..4840c3ebf4149fc7658e7f3f2c204fb6219f8235 100644
(file)
--- a/
src/shared/capability.c
+++ b/
src/shared/capability.c
@@
-19,14
+19,9
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <assert.h>
-#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
-#include <sys/types.h>
-#include <stdarg.h>
-#include <ctype.h>
#include <sys/capability.h>
#include <sys/prctl.h>
#include "grp.h"
#include <sys/capability.h>
#include <sys/prctl.h>
#include "grp.h"
@@
-275,10
+270,10
@@
int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
if (keep_capabilities & (1ULL << i))
bits[j++] = i;
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) {
if (cap_set_flag(d, CAP_EFFECTIVE, j, bits, CAP_SET) < 0 ||
cap_set_flag(d, CAP_PERMITTED, j, bits, CAP_SET) < 0) {