]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: improve the logic that implies no new privileges
authorDjalal Harouni <tixxdz@opendz.org>
Tue, 15 Nov 2016 09:15:27 +0000 (10:15 +0100)
committerDjalal Harouni <tixxdz@opendz.org>
Tue, 15 Nov 2016 14:04:31 +0000 (15:04 +0100)
The no_new_privileged_set variable is not used any more since commit
9b232d3241fcfbf60af that fixed another thing. So remove it. Also no
need to check if we are under user manager, remove that part too.

src/core/execute.c
src/core/execute.h
src/core/load-fragment.c
src/core/unit.c

index f666f7c6ce0de9373b38666cdfcf42456f2eb087..04c4e511f4de8bbf24949a663d4e7dd05b1a3afb 100644 (file)
@@ -2201,7 +2201,8 @@ static bool context_has_no_new_privileges(const ExecContext *c) {
         if (have_effective_cap(CAP_SYS_ADMIN)) /* if we are privileged, we don't need NNP */
                 return false;
 
-        return context_has_address_families(c) || /* we need NNP if we have any form of seccomp and are unprivileged */
+        /* We need NNP if we have any form of seccomp and are unprivileged */
+        return context_has_address_families(c) ||
                 c->memory_deny_write_execute ||
                 c->restrict_realtime ||
                 exec_context_restrict_namespaces_set(c) ||
index 56f880cffef93993937dbea0b7fbad3961204d33..e52640ee91d0b7f8306c4eb4150fea61d4f906bf 100644 (file)
@@ -216,7 +216,6 @@ struct ExecContext {
         bool nice_set:1;
         bool ioprio_set:1;
         bool cpu_sched_set:1;
-        bool no_new_privileges_set:1;
 };
 
 static inline bool exec_context_restrict_namespaces_set(const ExecContext *c) {
index 52079980d8357f22cacd0e9b773cbeda8e1aecea..970eed27c19498ff67da0c016ec400cb5091a1a2 100644 (file)
@@ -3896,7 +3896,6 @@ int config_parse_no_new_privileges(
         }
 
         c->no_new_privileges = k;
-        c->no_new_privileges_set = true;
 
         return 0;
 }
index bba0f5d357c2c879f5eaaa9e90eab41542179d42..da9bb58a5210e78dde6f5ddb59e14e3c0b38371c 100644 (file)
@@ -3429,14 +3429,6 @@ int unit_patch_contexts(Unit *u) {
                         ec->working_directory_missing_ok = true;
                 }
 
-                if (MANAGER_IS_USER(u->manager) &&
-                    (ec->syscall_whitelist ||
-                     !set_isempty(ec->syscall_filter) ||
-                     !set_isempty(ec->syscall_archs) ||
-                     ec->address_families_whitelist ||
-                     !set_isempty(ec->address_families)))
-                        ec->no_new_privileges = true;
-
                 if (ec->private_devices)
                         ec->capability_bounding_set &= ~((UINT64_C(1) << CAP_MKNOD) | (UINT64_C(1) << CAP_SYS_RAWIO));