summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-12-07 22:25:26 +0100
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commiteb4fb6ebb1b639fceafd729ab1bbc47f4db64873 (patch)
treefd10ff4fc025fd85db4014a6b6152f4ba56dc217
parenta574cd708cec217e8e948b63aa02c082128c4a3e (diff)
Use a dash-truncated drop-in for user-%j.slice configuration
This removes the UserTasksMax= setting in logind.conf. Instead, the generic TasksMax= setting on the slice should be used. Instead of a transient unit we use a drop-in to tweak the default definition of a .slice. It's better to use the normal unit mechanisms instead of creating units on the fly. This will also make it easier to start user@.service independently of logind, or set additional settings like MemoryMax= for user slices. The setting in logind is removed, because otherwise we would have two sources of "truth": the slice on disk and the logind config. Instead of trying to coordinate those two sources of configuration (and maintainer overrides to both), let's just convert to the new one fully. Right now now automatic transition mechanism is provided. logind will emit a hint when it encounters the setting, but otherwise it will be ignored. Fixes #2556.
-rw-r--r--man/logind.conf.xml11
-rw-r--r--src/login/logind-dbus.c20
-rw-r--r--src/login/logind-gperf.gperf48
-rw-r--r--src/login/logind-user.c81
-rw-r--r--src/login/logind-user.h2
-rw-r--r--src/login/logind.conf.in10
-rw-r--r--src/login/logind.h1
7 files changed, 54 insertions, 119 deletions
diff --git a/man/logind.conf.xml b/man/logind.conf.xml
index 82789cdcb..813f22777 100644
--- a/man/logind.conf.xml
+++ b/man/logind.conf.xml
@@ -367,17 +367,6 @@
</varlistentry>
<varlistentry>
- <term><varname>UserTasksMax=</varname></term>
-
- <listitem><para>Sets the maximum number of OS tasks each user may run concurrently. This controls the
- <varname>TasksMax=</varname> setting of the per-user slice unit, see
- <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
- for details. If assigned the special value <literal>infinity</literal>, no tasks limit is applied.
- Defaults to 33%, which equals 10813 with the kernel's defaults on the host, but might be smaller in
- OS containers.</para></listitem>
- </varlistentry>
-
- <varlistentry>
<term><varname>RemoveIPC=</varname></term>
<listitem><para>Controls whether System V and POSIX IPC objects belonging to the user shall be removed when the
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 533206027..cfcbc601d 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -335,6 +335,20 @@ static int property_get_current_inhibitors(
return sd_bus_message_append(reply, "t", (uint64_t) hashmap_size(m->inhibitors));
}
+static int property_get_compat_user_tasks_max(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ assert(reply);
+
+ return sd_bus_message_append(reply, "t", CGROUP_LIMIT_MAX);
+}
+
static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
@@ -1260,7 +1274,7 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
}
static int trigger_device(Manager *m, struct udev_device *d) {
- _cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
+ _cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
struct udev_list_entry *first, *item;
int r;
@@ -1298,7 +1312,7 @@ static int trigger_device(Manager *m, struct udev_device *d) {
}
static int attach_device(Manager *m, const char *seat, const char *sysfs) {
- _cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
+ _cleanup_udev_device_unref_ struct udev_device *d = NULL;
_cleanup_free_ char *rule = NULL, *file = NULL;
const char *id_for_seat;
int r;
@@ -2876,7 +2890,7 @@ const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("NCurrentInhibitors", "t", property_get_current_inhibitors, 0, 0),
SD_BUS_PROPERTY("SessionsMax", "t", NULL, offsetof(Manager, sessions_max), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("NCurrentSessions", "t", property_get_current_sessions, 0, 0),
- SD_BUS_PROPERTY("UserTasksMax", "t", NULL, offsetof(Manager, user_tasks_max), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("UserTasksMax", "t", property_get_compat_user_tasks_max, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
SD_BUS_METHOD("GetSession", "s", "o", method_get_session, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("GetSessionByPID", "u", "o", method_get_session_by_pid, SD_BUS_VTABLE_UNPRIVILEGED),
diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf
index c520cd5ac..90c346b92 100644
--- a/src/login/logind-gperf.gperf
+++ b/src/login/logind-gperf.gperf
@@ -18,31 +18,7 @@ struct ConfigPerfItem;
%includes
%%
#if 0 /// UNNEEDED by elogind
-# Login.NAutoVTs, config_parse_n_autovts, 0, offsetof(Manager, n_autovts)
-# Login.ReserveVT, config_parse_unsigned, 0, offsetof(Manager, reserve_vt)
#endif // 0
-Login.KillUserProcesses, config_parse_bool, 0, offsetof(Manager, kill_user_processes)
-Login.KillOnlyUsers, config_parse_strv, 0, offsetof(Manager, kill_only_users)
-Login.KillExcludeUsers, config_parse_strv, 0, offsetof(Manager, kill_exclude_users)
-Login.InhibitDelayMaxSec, config_parse_sec, 0, offsetof(Manager, inhibit_delay_max)
-Login.HandlePowerKey, config_parse_handle_action, 0, offsetof(Manager, handle_power_key)
-Login.HandleSuspendKey, config_parse_handle_action, 0, offsetof(Manager, handle_suspend_key)
-Login.HandleHibernateKey, config_parse_handle_action, 0, offsetof(Manager, handle_hibernate_key)
-Login.HandleLidSwitch, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch)
-Login.HandleLidSwitchExternalPower,config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_ep)
-Login.HandleLidSwitchDocked, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_docked)
-Login.PowerKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, power_key_ignore_inhibited)
-Login.SuspendKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, suspend_key_ignore_inhibited)
-Login.HibernateKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, hibernate_key_ignore_inhibited)
-Login.LidSwitchIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, lid_switch_ignore_inhibited)
-Login.HoldoffTimeoutSec, config_parse_sec, 0, offsetof(Manager, holdoff_timeout_usec)
-Login.IdleAction, config_parse_handle_action, 0, offsetof(Manager, idle_action)
-Login.IdleActionSec, config_parse_sec, 0, offsetof(Manager, idle_action_usec)
-Login.RuntimeDirectorySize, config_parse_tmpfs_size, 0, offsetof(Manager, runtime_dir_size)
-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_user_tasks_max,0, offsetof(Manager, user_tasks_max)
#if 1 /// Additions for elogind
Sleep.SuspendMode, config_parse_strv, 0, offsetof(Manager, suspend_mode)
Sleep.SuspendState, config_parse_strv, 0, offsetof(Manager, suspend_state)
@@ -51,3 +27,27 @@ Sleep.HibernateState, config_parse_strv, 0, offsetof(Manag
Sleep.HybridSleepMode, config_parse_strv, 0, offsetof(Manager, hybrid_sleep_mode)
Sleep.HybridSleepState, config_parse_strv, 0, offsetof(Manager, hybrid_sleep_state)
#endif // 1
+Login.NAutoVTs, config_parse_n_autovts, 0, offsetof(Manager, n_autovts)
+Login.ReserveVT, config_parse_unsigned, 0, offsetof(Manager, reserve_vt)
+Login.KillUserProcesses, config_parse_bool, 0, offsetof(Manager, kill_user_processes)
+Login.KillOnlyUsers, config_parse_strv, 0, offsetof(Manager, kill_only_users)
+Login.KillExcludeUsers, config_parse_strv, 0, offsetof(Manager, kill_exclude_users)
+Login.InhibitDelayMaxSec, config_parse_sec, 0, offsetof(Manager, inhibit_delay_max)
+Login.HandlePowerKey, config_parse_handle_action, 0, offsetof(Manager, handle_power_key)
+Login.HandleSuspendKey, config_parse_handle_action, 0, offsetof(Manager, handle_suspend_key)
+Login.HandleHibernateKey, config_parse_handle_action, 0, offsetof(Manager, handle_hibernate_key)
+Login.HandleLidSwitch, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch)
+Login.HandleLidSwitchExternalPower, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_ep)
+Login.HandleLidSwitchDocked, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_docked)
+Login.PowerKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, power_key_ignore_inhibited)
+Login.SuspendKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, suspend_key_ignore_inhibited)
+Login.HibernateKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, hibernate_key_ignore_inhibited)
+Login.LidSwitchIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, lid_switch_ignore_inhibited)
+Login.HoldoffTimeoutSec, config_parse_sec, 0, offsetof(Manager, holdoff_timeout_usec)
+Login.IdleAction, config_parse_handle_action, 0, offsetof(Manager, idle_action)
+Login.IdleActionSec, config_parse_sec, 0, offsetof(Manager, idle_action_usec)
+Login.RuntimeDirectorySize, config_parse_tmpfs_size, 0, offsetof(Manager, runtime_dir_size)
+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, offsetof(Manager, user_tasks_max)
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index b1485037b..69ff15f39 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -374,42 +374,12 @@ fail:
return r;
}
-static int user_start_slice(User *u) {
#if 0 /// elogind can not ask systemd via dbus to start user services
- _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- const char *description;
- char *job;
- int r;
-
- assert(u);
-
- u->slice_job = mfree(u->slice_job);
- description = strjoina("User Slice of ", u->name);
-
- r = manager_start_slice(
- u->manager,
- u->slice,
- description,
- "systemd-logind.service",
- "systemd-user-sessions.service",
- u->manager->user_tasks_max,
- &error,
- &job);
- if (r >= 0)
- u->slice_job = job;
- else if (!sd_bus_error_has_name(&error, BUS_ERROR_UNIT_EXISTS))
- /* we don't fail due to this, let's try to continue */
- log_error_errno(r, "Failed to start user slice %s, ignoring: %s (%s)",
- u->slice, bus_error_message(&error, r), error.name);
#else
assert(u);
hashmap_put(u->manager->user_units, u->slice, u);
#endif // 0
-
- return 0;
-}
-
static int user_start_service(User *u) {
#if 0 /// elogind can not ask systemd via dbus to start user services
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -471,11 +441,6 @@ int user_start(User *u) {
return r;
}
- /* Create cgroup */
- r = user_start_slice(u);
- if (r < 0)
- return r;
-
/* Save the user data so far, because pam_systemd will read the
* XDG_RUNTIME_DIR out of it while starting up systemd --user.
* We need to do user_save_internal() because we have not
@@ -904,8 +869,8 @@ int config_parse_tmpfs_size(
return 0;
}
-int config_parse_user_tasks_max(
- const char* unit,
+int config_parse_compat_user_tasks_max(
+ const char *unit,
const char *filename,
unsigned line,
const char *section,
@@ -916,45 +881,17 @@ int config_parse_user_tasks_max(
void *data,
void *userdata) {
- uint64_t *m = data;
- uint64_t k;
- int r;
-
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
- 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;
+ log_syntax(unit, LOG_NOTICE, filename, line, 0,
+ "Support for option %s= has been removed.",
+ lvalue);
+ log_info("Hint: try creating /etc/elogind/system/user-.slice/50-limits.conf with:\n"
+ " [Slice]\n"
+ " TasksMax=%s",
+ rvalue);
return 0;
}
diff --git a/src/login/logind-user.h b/src/login/logind-user.h
index 158288dd2..c80b02271 100644
--- a/src/login/logind-user.h
+++ b/src/login/logind-user.h
@@ -81,3 +81,5 @@ UserState user_state_from_string(const char *s) _pure_;
int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error);
int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error);
+
+int config_parse_compat_user_tasks_max(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
diff --git a/src/login/logind.conf.in b/src/login/logind.conf.in
index 97b408ad7..1794014cc 100644
--- a/src/login/logind.conf.in
+++ b/src/login/logind.conf.in
@@ -12,6 +12,8 @@
# See logind.conf(5) for details.
[Login]
+#NAutoVTs=6
+#ReserveVT=6
#KillUserProcesses=@KILL_USER_PROCESSES@
#KillOnlyUsers=
#KillExcludeUsers=root
@@ -33,11 +35,3 @@
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
-#UserTasksMax=33%
-
-[Sleep]
-#SuspendState=mem standby freeze
-#SuspendMode=
-#HibernateState=disk
-#HibernateMode=platform shutdown
-#HybridSleepState=disk
diff --git a/src/login/logind.h b/src/login/logind.h
index 54bd6ef72..a83e89411 100644
--- a/src/login/logind.h
+++ b/src/login/logind.h
@@ -234,7 +234,6 @@ int manager_set_lid_switch_ignore(Manager *m, usec_t until);
int config_parse_n_autovts(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_user_tasks_max(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);