diff --git a/src/mute-console/mute-console.c b/src/mute-console/mute-console.c index 4a44498777..40c0839367 100644 --- a/src/mute-console/mute-console.c +++ b/src/mute-console/mute-console.c @@ -167,7 +167,8 @@ static int unmute_pid1(Context *c) { assert(c); if (!c->muted_pid1) { - log_debug("Not restoring PID 1 status console output level."); + if (c->mute_pid1) + log_debug("Not restoring PID 1 status console output level."); return 0; } @@ -185,14 +186,16 @@ static int mute_kernel(Context *c) { assert(c); - if (!arg_mute_kernel) { + if (!c->mute_kernel) { log_debug("Muting of kernel printk() console output disabled."); c->saved_kernel = -1; return 0; } if (detect_container() > 0) { - log_debug("Skipping muting of print() console output, because running in a container."); + log_debug("Skipping muting of printk() console output, because running in a container."); + + c->mute_kernel = false; c->saved_kernel = -1; return 0; } @@ -222,7 +225,8 @@ static int unmute_kernel(Context *c) { assert(c); if (c->saved_kernel < 0) { - log_debug("Not restoring kernel printk() console output level."); + if (c->mute_kernel) + log_debug("Not restoring kernel printk() console output level."); return 0; } @@ -244,28 +248,6 @@ static int unmute_kernel(Context *c) { return 0; } -static void context_done(Context *c) { - assert(c); - - (void) unmute_pid1(c); - (void) unmute_kernel(c); - - if (c->link) { - (void) sd_varlink_set_userdata(c->link, NULL); - c->link = sd_varlink_flush_close_unref(c->link); - } -} - -static Context* context_free(Context *c) { - if (!c) - return NULL; - - context_done(c); - return mfree(c); -} - -DEFINE_TRIVIAL_CLEANUP_FUNC(Context*, context_free); - static void vl_on_disconnect(sd_varlink_server *server, sd_varlink *link, void *userdata) { assert(link); @@ -273,7 +255,13 @@ static void vl_on_disconnect(sd_varlink_server *server, sd_varlink *link, void * if (!c) return; - context_free(c); + (void) unmute_pid1(c); + (void) unmute_kernel(c); + + (void) sd_varlink_set_userdata(c->link, NULL); + sd_varlink_flush_close_unref(c->link); + + free(c); } static int vl_method_mute( @@ -286,7 +274,7 @@ static int vl_method_mute( assert(link); - _cleanup_(context_freep) Context *nc = new(Context, 1); + _cleanup_free_ Context *nc = new(Context, 1); if (!nc) return -ENOMEM; @@ -380,7 +368,7 @@ static int run(int argc, char* argv[]) { if (!arg_mute_pid1 && !arg_mute_kernel) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not asked to mute anything, refusing."); - _cleanup_(context_done) Context c = { + Context c = { .mute_pid1 = arg_mute_pid1, .mute_kernel = arg_mute_kernel, .saved_kernel = -1, @@ -398,7 +386,7 @@ static int run(int argc, char* argv[]) { RET_GATHER(ret, mute_pid1(&c)); RET_GATHER(ret, mute_kernel(&c)); - /* Now tell service manager we area ready to go */ + /* Now tell service manager we are ready to go */ _unused_ _cleanup_(notify_on_cleanup) const char *notify_message = notify_start("READY=1\n" "STATUS=Console status output muted temporarily.", diff --git "a/units/system-systemd\\x2dmute\\x2dconsole.slice" "b/units/system-systemd\\x2dmute\\x2dconsole.slice" index 7819eb91a3..18890cf1b3 100644 --- "a/units/system-systemd\\x2dmute\\x2dconsole.slice" +++ "b/units/system-systemd\\x2dmute\\x2dconsole.slice" @@ -10,9 +10,6 @@ [Unit] Description=Console Output Muting Service Slice Documentation=man:systemd-mute-console(8) -DefaultDependencies=no -Conflicts=shutdown.target -Before=shutdown.target [Slice] # Serialize requests to mute the console. diff --git a/units/systemd-bootctl.socket b/units/systemd-bootctl.socket index 59151ba161..d4071833b6 100644 --- a/units/systemd-bootctl.socket +++ b/units/systemd-bootctl.socket @@ -19,3 +19,4 @@ ListenStream=/run/systemd/io.systemd.BootControl FileDescriptorName=varlink SocketMode=0600 Accept=yes +MaxConnectionsPerSource=16 diff --git a/units/systemd-mute-console.socket b/units/systemd-mute-console.socket index 6223dc033c..16032e94b4 100644 --- a/units/systemd-mute-console.socket +++ b/units/systemd-mute-console.socket @@ -20,3 +20,4 @@ ListenStream=/run/systemd/io.systemd.MuteConsole FileDescriptorName=varlink SocketMode=0600 Accept=yes +MaxConnectionsPerSource=16 diff --git a/units/systemd-pcrlock.socket b/units/systemd-pcrlock.socket index 17a56f7eb3..ca1cd53aea 100644 --- a/units/systemd-pcrlock.socket +++ b/units/systemd-pcrlock.socket @@ -20,6 +20,7 @@ ListenStream=/run/systemd/io.systemd.PCRLock FileDescriptorName=varlink SocketMode=0600 Accept=yes +MaxConnectionsPerSource=16 [Install] WantedBy=sockets.target diff --git a/units/systemd-repart.socket b/units/systemd-repart.socket index 0c77165e1c..c9fc308b1b 100644 --- a/units/systemd-repart.socket +++ b/units/systemd-repart.socket @@ -20,3 +20,4 @@ ListenStream=/run/systemd/io.systemd.Repart FileDescriptorName=varlink SocketMode=0600 Accept=yes +MaxConnectionsPerSource=16