Initialize for systemd
This commit is contained in:
commit
2de24fe84c
43 changed files with 14931 additions and 0 deletions
200
1006-logind-keep-backward-compatibility-with-UserTasksMax.patch
Normal file
200
1006-logind-keep-backward-compatibility-with-UserTasksMax.patch
Normal file
|
@ -0,0 +1,200 @@
|
|||
From 296e3938b60610679e333ca5c0757d4ceeb23a87 Mon Sep 17 00:00:00 2001
|
||||
From: Franck Bui <fbui@suse.com>
|
||||
Date: Tue, 6 Nov 2018 11:51:26 +0100
|
||||
Subject: [PATCH 1006/1007] 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 | 8 ++++
|
||||
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, 82 insertions(+), 7 deletions(-)
|
||||
create mode 100644 src/login/compat-tasks-max-generator.c
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 0760a793ac..40885a81ae 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -2132,6 +2132,14 @@ if conf.get('ENABLE_LOGIND') == 1
|
||||
install_rpath : rootlibexecdir,
|
||||
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],
|
||||
+ install_rpath : rootlibexecdir,
|
||||
+ 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 22031f485a..585971c738 100644
|
||||
--- a/src/login/logind-core.c
|
||||
+++ b/src/login/logind-core.c
|
||||
@@ -53,6 +53,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 25e429c5a3..0b99c9f58d 100644
|
||||
--- a/src/login/logind-gperf.gperf
|
||||
+++ b/src/login/logind-gperf.gperf
|
||||
@@ -45,4 +45,4 @@ Login.RuntimeDirectoryInodesMax, config_parse_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.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 a2c468e8dd..4b753d8929 100644
|
||||
--- a/src/login/logind-user.c
|
||||
+++ b/src/login/logind-user.c
|
||||
@@ -942,16 +942,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 ec52a57acb..2514e747cd 100644
|
||||
--- a/src/login/logind.c
|
||||
+++ b/src/login/logind.c
|
||||
@@ -164,6 +164,8 @@ static Manager* manager_unref(Manager *m) {
|
||||
strv_free(m->kill_only_users);
|
||||
strv_free(m->kill_exclude_users);
|
||||
|
||||
+ free(m->user_tasks_max);
|
||||
+
|
||||
free(m->scheduled_shutdown_type);
|
||||
free(m->scheduled_shutdown_tty);
|
||||
free(m->wall_message);
|
||||
diff --git a/src/login/logind.h b/src/login/logind.h
|
||||
index 761763a476..eefea7c227 100644
|
||||
--- a/src/login/logind.h
|
||||
+++ b/src/login/logind.h
|
||||
@@ -124,6 +124,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.31.1
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue