forked from pool/systemd
Accepting request 646968 from home:fbui:systemd:openSUSE-Factory
- Add 0001-logind-keep-backward-compatibility-with-UserTasksMax.patch We have to keep support for UserTasksMax= for a while before dropping it. This patch is supposed to do that and also to make users aware of this change. It also hints how to configure that differently. - Import commit f39674d6d114d999c50672c7bea8cad21e1eaed9 7d1e04e85 units: use =yes rather than =true everywhere 185ce0d34 units: assign user-runtime-dir@.service to user-%i.slice a051f5e41 units: make sure user-runtime-dir@.service is Type=oneshot 30c6842c3 units: set StopWhenUnneeded= for the user slice units too e74de046e login: fix typo in log message OBS-URL: https://build.opensuse.org/request/show/646968 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=1045
This commit is contained in:
parent
7fe8f43b74
commit
c538c4fc88
185
0001-logind-keep-backward-compatibility-with-UserTasksMax.patch
Normal file
185
0001-logind-keep-backward-compatibility-with-UserTasksMax.patch
Normal file
@ -0,0 +1,185 @@
|
||||
From d3acd5b49a6a321dc3b1512416132b8724b2fd20 Mon Sep 17 00:00:00 2001
|
||||
From: Franck Bui <fbui@suse.com>
|
||||
Date: Tue, 6 Nov 2018 11:51:26 +0100
|
||||
Subject: [PATCH] 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 | 66 ++++++++++++++++++++++++++
|
||||
src/login/logind-user.c | 43 +++++++++++++++--
|
||||
3 files changed, 112 insertions(+), 5 deletions(-)
|
||||
create mode 100644 src/login/compat-tasks-max-generator.c
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 5c7c165ba..7e3e8ca16 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1701,6 +1701,14 @@ if conf.get('ENABLE_LOGIND') == 1
|
||||
endif
|
||||
endif
|
||||
|
||||
+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)
|
||||
+
|
||||
executable('systemd-user-runtime-dir',
|
||||
user_runtime_dir_sources,
|
||||
include_directories : includes,
|
||||
diff --git a/src/login/compat-tasks-max-generator.c b/src/login/compat-tasks-max-generator.c
|
||||
new file mode 100644
|
||||
index 000000000..404ca5f23
|
||||
--- /dev/null
|
||||
+++ b/src/login/compat-tasks-max-generator.c
|
||||
@@ -0,0 +1,66 @@
|
||||
+#include <stdint.h>
|
||||
+
|
||||
+#include "alloc-util.h"
|
||||
+#include "dropin.h"
|
||||
+#include "logind.h"
|
||||
+#include "path-util.h"
|
||||
+
|
||||
+static const char *arg_dest = "/tmp";
|
||||
+
|
||||
+static int read_manager_configuration(uint64_t *user_tasks_max) {
|
||||
+ Manager m = {};
|
||||
+ int r;
|
||||
+
|
||||
+ manager_reset_config(&m);
|
||||
+ m.user_tasks_max = 0;
|
||||
+
|
||||
+ 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 == 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ *user_tasks_max = m.user_tasks_max;
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+int main(int argc, char *argv[]) {
|
||||
+ _cleanup_free_ char *p = NULL;
|
||||
+ uint64_t user_tasks_max;
|
||||
+ int r = 0;
|
||||
+
|
||||
+ if (argc > 1 && argc != 4) {
|
||||
+ log_error("This program takes three or no arguments.");
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (argc > 1)
|
||||
+ arg_dest = argv[1];
|
||||
+
|
||||
+ log_set_prohibit_ipc(true);
|
||||
+ log_set_target(LOG_TARGET_AUTO);
|
||||
+ log_parse_environment();
|
||||
+ log_open();
|
||||
+
|
||||
+ umask(0022);
|
||||
+
|
||||
+ r = read_manager_configuration(&user_tasks_max);
|
||||
+ if (r == 0)
|
||||
+ return EXIT_SUCCESS;
|
||||
+ if (r < 0)
|
||||
+ return EXIT_FAILURE;
|
||||
+
|
||||
+ p = path_join(arg_dest, "user-.slice.d", "50-limits.conf");
|
||||
+ if (!p)
|
||||
+ return EXIT_FAILURE;
|
||||
+
|
||||
+ log_warning("Creating %s to keep compability\n"
|
||||
+ "Consider copying the snippet in /etc/systemd/system/user-.slice.d/\n", p);
|
||||
+
|
||||
+ r = write_drop_in_format(arg_dest, "user-.slice", 50, "limits",
|
||||
+ "# Automatically generated by logind-compat-tasks-max-generator\n\n"
|
||||
+ "[Slice]\nTasksMax=%" PRIu64, user_tasks_max);
|
||||
+
|
||||
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
+}
|
||||
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
|
||||
index 66f5c896d..fe58b0398 100644
|
||||
--- a/src/login/logind-user.c
|
||||
+++ b/src/login/logind-user.c
|
||||
@@ -743,17 +743,50 @@ int config_parse_compat_user_tasks_max(
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
+ uint64_t *m = data;
|
||||
+ uint64_t k;
|
||||
+ int r;
|
||||
+
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
- log_syntax(unit, LOG_NOTICE, filename, line, 0,
|
||||
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Support for option %s= has been removed.",
|
||||
lvalue);
|
||||
- log_info("Hint: try creating /etc/systemd/system/user-.slice.d/50-limits.conf with:\n"
|
||||
- " [Slice]\n"
|
||||
- " TasksMax=%s",
|
||||
- rvalue);
|
||||
+
|
||||
+ if (isempty(rvalue)) {
|
||||
+ *m = system_tasks_max_scale(DEFAULT_USER_TASKS_MAX_PERCENTAGE, 100U);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (streq(rvalue, "infinity")) {
|
||||
+ *m = CGROUP_LIMIT_MAX;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Try to parse as percentage */
|
||||
+ r = parse_percent(rvalue);
|
||||
+ if (r >= 0)
|
||||
+ k = system_tasks_max_scale(r, 100U);
|
||||
+ else {
|
||||
+
|
||||
+ /* If the passed argument was not a percentage, or out of range, parse as byte size */
|
||||
+
|
||||
+ r = safe_atou64(rvalue, &k);
|
||||
+ if (r < 0) {
|
||||
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse tasks maximum, ignoring: %s", rvalue);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (k <= 0 || k >= UINT64_MAX) {
|
||||
+ log_syntax(unit, LOG_ERR, filename, line, 0, "Tasks maximum out of range, ignoring: %s", rvalue);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ *m = k;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.19.0
|
||||
|
@ -1,3 +1,24 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 7 08:45:08 UTC 2018 - Franck Bui <fbui@suse.com>
|
||||
|
||||
- Add 0001-logind-keep-backward-compatibility-with-UserTasksMax.patch
|
||||
|
||||
We have to keep support for UserTasksMax= for a while before
|
||||
dropping it. This patch is supposed to do that and also to make
|
||||
users aware of this change. It also hints how to configure that
|
||||
differently.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 7 07:05:31 UTC 2018 - Franck Bui <fbui@suse.com>
|
||||
|
||||
- Import commit f39674d6d114d999c50672c7bea8cad21e1eaed9
|
||||
|
||||
7d1e04e85 units: use =yes rather than =true everywhere
|
||||
185ce0d34 units: assign user-runtime-dir@.service to user-%i.slice
|
||||
a051f5e41 units: make sure user-runtime-dir@.service is Type=oneshot
|
||||
30c6842c3 units: set StopWhenUnneeded= for the user slice units too
|
||||
e74de046e login: fix typo in log message
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 5 13:10:54 UTC 2018 - Franck Bui <fbui@suse.com>
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
##### WARNING: please do not edit this auto generated spec file. Use the systemd.spec! #####
|
||||
%define mini -mini
|
||||
%define min_kernel_version 4.5
|
||||
%define suse_version +suse.81.gb54f5d7a8
|
||||
%define suse_version +suse.87.gf39674d6d
|
||||
|
||||
%bcond_with gnuefi
|
||||
%if 0%{?bootstrap}
|
||||
@ -165,6 +165,7 @@ Source200: scripts-udev-convert-lib-udev-path.sh
|
||||
# patches are temporary and should be removed as soon as a fix is
|
||||
# merged by upstream.
|
||||
Patch1: 0001-resolved-create-etc-resolv.conf-symlink-at-runtime.patch
|
||||
Patch2: 0001-logind-keep-backward-compatibility-with-UserTasksMax.patch
|
||||
|
||||
%description
|
||||
Systemd is a system and service manager, compatible with SysV and LSB
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:60693bd3616d9b98495a2ab9a29b1fd5fca5c0ae5968a8c2d7e722faa15af772
|
||||
size 4854516
|
3
systemd-v239+suse.87.gf39674d6d.tar.xz
Normal file
3
systemd-v239+suse.87.gf39674d6d.tar.xz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f62d64a099b2cb1fec5146914220d6396777b06c6d5075a479b1dfc22838c2c5
|
||||
size 4854560
|
@ -1,3 +1,24 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 7 08:45:08 UTC 2018 - Franck Bui <fbui@suse.com>
|
||||
|
||||
- Add 0001-logind-keep-backward-compatibility-with-UserTasksMax.patch
|
||||
|
||||
We have to keep support for UserTasksMax= for a while before
|
||||
dropping it. This patch is supposed to do that and also to make
|
||||
users aware of this change. It also hints how to configure that
|
||||
differently.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 7 07:05:31 UTC 2018 - Franck Bui <fbui@suse.com>
|
||||
|
||||
- Import commit f39674d6d114d999c50672c7bea8cad21e1eaed9
|
||||
|
||||
7d1e04e85 units: use =yes rather than =true everywhere
|
||||
185ce0d34 units: assign user-runtime-dir@.service to user-%i.slice
|
||||
a051f5e41 units: make sure user-runtime-dir@.service is Type=oneshot
|
||||
30c6842c3 units: set StopWhenUnneeded= for the user slice units too
|
||||
e74de046e login: fix typo in log message
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 5 13:10:54 UTC 2018 - Franck Bui <fbui@suse.com>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
%define bootstrap 0
|
||||
%define mini %nil
|
||||
%define min_kernel_version 4.5
|
||||
%define suse_version +suse.81.gb54f5d7a8
|
||||
%define suse_version +suse.87.gf39674d6d
|
||||
|
||||
%bcond_with gnuefi
|
||||
%if 0%{?bootstrap}
|
||||
@ -163,6 +163,7 @@ Source200: scripts-udev-convert-lib-udev-path.sh
|
||||
# patches are temporary and should be removed as soon as a fix is
|
||||
# merged by upstream.
|
||||
Patch1: 0001-resolved-create-etc-resolv.conf-symlink-at-runtime.patch
|
||||
Patch2: 0001-logind-keep-backward-compatibility-with-UserTasksMax.patch
|
||||
|
||||
%description
|
||||
Systemd is a system and service manager, compatible with SysV and LSB
|
||||
|
Loading…
Reference in New Issue
Block a user