]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: don't insist on ProtectHostname= if unshare() is blocked 14090/head
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Nov 2019 11:27:28 +0000 (12:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Nov 2019 11:49:06 +0000 (12:49 +0100)
Previously we'd only skip ProtectHostname= if kernel support for
namespaces was lacking. With this change we also accept if unshare()
fails because it is blocked.

src/core/execute.c

index def73977fc1878f4cb25f4c8ae4dc8cc390a2927..abc164ff5befb1f76536cd094c93cbdf7cf02d53 100644 (file)
@@ -3448,8 +3448,12 @@ static int exec_child(
         if (context->protect_hostname) {
                 if (ns_type_supported(NAMESPACE_UTS)) {
                         if (unshare(CLONE_NEWUTS) < 0) {
-                                *exit_status = EXIT_NAMESPACE;
-                                return log_unit_error_errno(unit, errno, "Failed to set up UTS namespacing: %m");
+                                if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) {
+                                        *exit_status = EXIT_NAMESPACE;
+                                        return log_unit_error_errno(unit, errno, "Failed to set up UTS namespacing: %m");
+                                }
+
+                                log_unit_warning(unit, "ProtectHostname=yes is configured, but UTS namespace setup is prohibited (container manager?), ignoring namespace setup.");
                         }
                 } else
                         log_unit_warning(unit, "ProtectHostname=yes is configured, but the kernel does not support UTS namespaces, ignoring namespace setup.");