[systemd-commits] src/shared

Tom Gundersen tomegun at kemper.freedesktop.org
Tue Jun 3 02:46:33 PDT 2014


 src/shared/capability.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit e5999b46792b859043a62431d426a280f26a16d7
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue Jun 3 11:46:25 2014 +0200

    shared: capability - don't loop over the cap bits if they are all unset

diff --git a/src/shared/capability.c b/src/shared/capability.c
index 58270ad..439aac7 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -264,11 +264,11 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
         if (!d)
                 return log_oom();
 
-        for (i = 0; i < sizeof(keep_capabilities)*8; i++)
-                if (keep_capabilities & (1ULL << i))
-                        bits[j++] = i;
-
         if (keep_capabilities) {
+                for (i = 0; i < sizeof(keep_capabilities)*8; i++)
+                        if (keep_capabilities & (1ULL << i))
+                                bits[j++] = i;
+
                 if (cap_set_flag(d, CAP_EFFECTIVE, j, bits, CAP_SET) < 0 ||
                     cap_set_flag(d, CAP_PERMITTED, j, bits, CAP_SET) < 0) {
                         log_error("Failed to enable capabilities bits: %m");



More information about the systemd-commits mailing list