Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:tsaupe:testpackages
systemd-bsc1218671
1005-logind-keep-backward-compatibility-with-Us...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1005-logind-keep-backward-compatibility-with-UserTasksMax.patch of Package systemd-bsc1218671
From 122fe0fe7f66063a576df553890d2cbb2e125a13 Mon Sep 17 00:00:00 2001 From: Franck Bui <fbui@suse.com> Date: Tue, 6 Nov 2018 11:51:26 +0100 Subject: [PATCH 1005/1016] logind: keep backward compatibility with UserTasksMax= in logind.conf Since commit 284149392755f086d0a71, UserTasksMax= support has been simply dropped. A generator is used to automatically create an appropriate dropin that has the same effect. However since the snippet is generated in /run, sysadmin is encouraged to copy it in /etc to make it persistent. The main advantages to use a generator are: - sysadmin is aware of this backward incompatible change - he will be the one who will fix logind.conf manually (to remove the use of UserTasksMax=) - he will decide how to name the snippet and possibly merge it with an existing one Expect this generator to be dropped in the future. --- meson.build | 9 +++++ src/login/compat-tasks-max-generator.c | 56 ++++++++++++++++++++++++++ src/login/logind-core.c | 2 + src/login/logind-gperf.gperf | 2 +- src/login/logind-user.c | 16 +++++--- src/login/logind.c | 2 + src/login/logind.h | 3 ++ 7 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 src/login/compat-tasks-max-generator.c diff --git a/meson.build b/meson.build index a6286f1531..6fe4860b81 100644 --- a/meson.build +++ b/meson.build @@ -2846,6 +2846,15 @@ if conf.get('ENABLE_LOGIND') == 1 install_rpath : rootpkglibdir, install : true, install_dir : rootlibexecdir) + + executable('logind-compat-tasks-max-generator', + 'src/login/compat-tasks-max-generator.c', + include_directories : includes, + link_with : [libshared, liblogind_core], + dependencies : userspace, + install_rpath : rootpkglibdir, + install : true, + install_dir : systemgeneratordir) endif if conf.get('HAVE_PAM') == 1 diff --git a/src/login/compat-tasks-max-generator.c b/src/login/compat-tasks-max-generator.c new file mode 100644 index 0000000000..2fe1c92ba7 --- /dev/null +++ b/src/login/compat-tasks-max-generator.c @@ -0,0 +1,56 @@ +#include <stdint.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include "alloc-util.h" +#include "dropin.h" +#include "generator.h" +#include "logind.h" +#include "path-util.h" + +static int read_manager_configuration(char **user_tasks_max) { + Manager m = {}; + int r; + + manager_reset_config(&m); + m.user_tasks_max = NULL; + + r = manager_parse_config_file(&m); + if (r < 0) + return log_warning_errno(r, "Failed to parse logind.conf: %m"); + + if (!m.user_tasks_max) + return 0; + + *user_tasks_max = m.user_tasks_max; + return 1; +} + +static int run(const char *dest, const char *dest_early, const char *dest_late) { + _cleanup_free_ char *p = NULL; + char *user_tasks_max; + int r = 0; + + umask(0022); + + r = read_manager_configuration(&user_tasks_max); + if (r == 0) + return EXIT_SUCCESS; + if (r < 0) + return EXIT_FAILURE; + + p = path_join(dest, "user-.slice.d", "50-limits.conf"); + if (!p) + return EXIT_FAILURE; + + log_warning("Creating %s to keep compatibility\n" + "Please copy the snippet in /etc/systemd/system/user-.slice.d/ and remove any uses of UserTasksMax=\n", p); + + r = write_drop_in_format(dest, "user-.slice", 50, "limits", + "# Automatically generated by logind-compat-tasks-max-generator\n\n" + "[Slice]\nTasksMax=%s", user_tasks_max); + + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; +} + +DEFINE_MAIN_GENERATOR_FUNCTION(run); diff --git a/src/login/logind-core.c b/src/login/logind-core.c index af86e92c01..8506744270 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -61,6 +61,8 @@ void manager_reset_config(Manager *m) { m->holdoff_timeout_usec = 30 * USEC_PER_SEC; + m->user_tasks_max = mfree(m->user_tasks_max); + m->idle_action_usec = 30 * USEC_PER_MINUTE; m->idle_action = HANDLE_IGNORE; diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf index c95a3b2dc3..b9473104a7 100644 --- a/src/login/logind-gperf.gperf +++ b/src/login/logind-gperf.gperf @@ -49,5 +49,5 @@ Login.RuntimeDirectoryInodesMax, config_parse_iec_uint64, 0, offse Login.RemoveIPC, config_parse_bool, 0, offsetof(Manager, remove_ipc) Login.InhibitorsMax, config_parse_uint64, 0, offsetof(Manager, inhibitors_max) Login.SessionsMax, config_parse_uint64, 0, offsetof(Manager, sessions_max) -Login.UserTasksMax, config_parse_compat_user_tasks_max, 0, 0 Login.StopIdleSessionSec, config_parse_sec_fix_0, 0, offsetof(Manager, stop_idle_session_usec) +Login.UserTasksMax, config_parse_compat_user_tasks_max, 0, offsetof(Manager, user_tasks_max) diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 7a6056086a..9d3ecf0740 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -925,16 +925,20 @@ int config_parse_compat_user_tasks_max( void *data, void *userdata) { + char **m = data; + int r; + assert(filename); assert(lvalue); assert(rvalue); - log_syntax(unit, LOG_NOTICE, filename, line, 0, - "Support for option %s= has been removed.", + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Support for option %s= is deprecated and will be removed.", lvalue); - log_info("Hint: try creating /etc/systemd/system/user-.slice.d/50-limits.conf with:\n" - " [Slice]\n" - " TasksMax=%s", - rvalue); + + r = free_and_strdup(m, rvalue); + if (r < 0) + return log_oom(); + return 0; } diff --git a/src/login/logind.c b/src/login/logind.c index f30f7f9370..10728a55af 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -178,6 +178,8 @@ static Manager* manager_free(Manager *m) { strv_free(m->kill_only_users); strv_free(m->kill_exclude_users); + free(m->user_tasks_max); + free(m->scheduled_shutdown_tty); free(m->wall_message); free(m->action_job); diff --git a/src/login/logind.h b/src/login/logind.h index e6a04e0834..5ad89af5e0 100644 --- a/src/login/logind.h +++ b/src/login/logind.h @@ -131,6 +131,9 @@ struct Manager { uint64_t runtime_dir_size; uint64_t runtime_dir_inodes; + + char *user_tasks_max; + uint64_t sessions_max; uint64_t inhibitors_max; -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor