1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 #include "alloc-util.h"
7 #include "bus-common-errors.h"
9 #include "bus-locator.h"
11 #include "cgroup-util.h"
12 #include "clean-ipc.h"
17 #include "format-util.h"
20 #include "label-util.h"
21 #include "limits-util.h"
22 #include "logind-dbus.h"
23 #include "logind-user-dbus.h"
24 #include "logind-user.h"
25 #include "mkdir-label.h"
26 #include "parse-util.h"
27 #include "path-util.h"
28 #include "percent-util.h"
30 #include "serialize.h"
32 #include "stdio-util.h"
33 #include "string-table.h"
35 #include "tmpfile-util.h"
36 #include "uid-classification.h"
37 #include "unit-name.h"
38 #include "user-util.h"
40 int user_new(User
**ret
,
44 _cleanup_(user_freep
) User
*u
= NULL
;
45 char lu
[DECIMAL_STR_MAX(uid_t
) + 1];
55 if (!uid_is_valid(ur
->uid
))
64 .user_record
= user_record_ref(ur
),
65 .last_session_timestamp
= USEC_INFINITY
,
66 .gc_mode
= USER_GC_BY_ANY
,
69 if (asprintf(&u
->state_file
, "/run/systemd/users/" UID_FMT
, ur
->uid
) < 0)
72 if (asprintf(&u
->runtime_path
, "/run/user/" UID_FMT
, ur
->uid
) < 0)
75 xsprintf(lu
, UID_FMT
, ur
->uid
);
76 r
= slice_build_subslice(SPECIAL_USER_SLICE
, lu
, &u
->slice
);
80 r
= unit_name_build("user", lu
, ".service", &u
->service
);
84 r
= unit_name_build("user-runtime-dir", lu
, ".service", &u
->runtime_dir_service
);
88 r
= hashmap_put(m
->users
, UID_TO_PTR(ur
->uid
), u
);
92 r
= hashmap_put(m
->user_units
, u
->slice
, u
);
96 r
= hashmap_put(m
->user_units
, u
->service
, u
);
100 r
= hashmap_put(m
->user_units
, u
->runtime_dir_service
, u
);
108 User
*user_free(User
*u
) {
113 LIST_REMOVE(gc_queue
, u
->manager
->user_gc_queue
, u
);
116 session_free(u
->sessions
);
119 hashmap_remove_value(u
->manager
->user_units
, u
->service
, u
);
121 if (u
->runtime_dir_service
)
122 hashmap_remove_value(u
->manager
->user_units
, u
->runtime_dir_service
, u
);
125 hashmap_remove_value(u
->manager
->user_units
, u
->slice
, u
);
127 hashmap_remove_value(u
->manager
->users
, UID_TO_PTR(u
->user_record
->uid
), u
);
129 sd_event_source_unref(u
->timer_event_source
);
131 u
->service_job
= mfree(u
->service_job
);
133 u
->service
= mfree(u
->service
);
134 u
->runtime_dir_service
= mfree(u
->runtime_dir_service
);
135 u
->slice
= mfree(u
->slice
);
136 u
->runtime_path
= mfree(u
->runtime_path
);
137 u
->state_file
= mfree(u
->state_file
);
139 user_record_unref(u
->user_record
);
144 static int user_save_internal(User
*u
) {
145 _cleanup_(unlink_and_freep
) char *temp_path
= NULL
;
146 _cleanup_fclose_
FILE *f
= NULL
;
150 assert(u
->state_file
);
152 r
= mkdir_safe_label("/run/systemd/users", 0755, 0, 0, MKDIR_WARN_MODE
);
156 r
= fopen_temporary(u
->state_file
, &f
, &temp_path
);
160 (void) fchmod(fileno(f
), 0644);
163 "# This is private data. Do not parse.\n"
165 "STATE=%s\n" /* friendly user-facing state */
166 "STOPPING=%s\n" /* low-level state */
168 u
->user_record
->user_name
,
169 user_state_to_string(user_get_state(u
)),
171 user_gc_mode_to_string(u
->gc_mode
));
173 /* LEGACY: no-one reads RUNTIME= anymore, drop it at some point */
175 fprintf(f
, "RUNTIME=%s\n", u
->runtime_path
);
178 fprintf(f
, "SERVICE_JOB=%s\n", u
->service_job
);
181 fprintf(f
, "DISPLAY=%s\n", u
->display
->id
);
183 if (dual_timestamp_is_set(&u
->timestamp
))
185 "REALTIME="USEC_FMT
"\n"
186 "MONOTONIC="USEC_FMT
"\n",
187 u
->timestamp
.realtime
,
188 u
->timestamp
.monotonic
);
190 if (u
->last_session_timestamp
!= USEC_INFINITY
)
191 fprintf(f
, "LAST_SESSION_TIMESTAMP=" USEC_FMT
"\n",
192 u
->last_session_timestamp
);
197 fputs("SESSIONS=", f
);
199 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
208 fputs("\nSEATS=", f
);
210 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
219 fputs(i
->seat
->id
, f
);
222 fputs("\nACTIVE_SESSIONS=", f
);
224 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
225 if (!session_is_active(i
))
236 fputs("\nONLINE_SESSIONS=", f
);
238 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
239 if (session_get_state(i
) == SESSION_CLOSING
)
250 fputs("\nACTIVE_SEATS=", f
);
252 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
253 if (!session_is_active(i
) || !i
->seat
)
261 fputs(i
->seat
->id
, f
);
264 fputs("\nONLINE_SEATS=", f
);
266 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
267 if (session_get_state(i
) == SESSION_CLOSING
|| !i
->seat
)
275 fputs(i
->seat
->id
, f
);
280 r
= fflush_and_check(f
);
284 if (rename(temp_path
, u
->state_file
) < 0) {
289 temp_path
= mfree(temp_path
);
293 (void) unlink(u
->state_file
);
295 return log_error_errno(r
, "Failed to save user data %s: %m", u
->state_file
);
298 int user_save(User
*u
) {
304 return user_save_internal(u
);
307 int user_load(User
*u
) {
308 _cleanup_free_
char *realtime
= NULL
, *monotonic
= NULL
, *stopping
= NULL
, *last_session_timestamp
= NULL
, *gc_mode
= NULL
;
313 r
= parse_env_file(NULL
, u
->state_file
,
314 "SERVICE_JOB", &u
->service_job
,
315 "STOPPING", &stopping
,
316 "REALTIME", &realtime
,
317 "MONOTONIC", &monotonic
,
318 "LAST_SESSION_TIMESTAMP", &last_session_timestamp
,
319 "GC_MODE", &gc_mode
);
323 return log_error_errno(r
, "Failed to read %s: %m", u
->state_file
);
326 r
= parse_boolean(stopping
);
328 log_debug_errno(r
, "Failed to parse 'STOPPING' boolean: %s", stopping
);
334 (void) deserialize_usec(realtime
, &u
->timestamp
.realtime
);
336 (void) deserialize_usec(monotonic
, &u
->timestamp
.monotonic
);
337 if (last_session_timestamp
)
338 (void) deserialize_usec(last_session_timestamp
, &u
->last_session_timestamp
);
340 u
->gc_mode
= user_gc_mode_from_string(gc_mode
);
342 u
->gc_mode
= USER_GC_BY_PIN
;
347 static bool user_wants_service_manager(User
*u
) {
350 LIST_FOREACH(sessions_by_user
, s
, u
->sessions
)
351 if (SESSION_CLASS_WANTS_SERVICE_MANAGER(s
->class))
357 void user_start_service_manager(User
*u
) {
358 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
363 /* Start the service containing the "systemd --user" instance (user@.service). Note that we don't explicitly
364 * start the per-user slice or the systemd-runtime-dir@.service instance, as those are pulled in both by
365 * user@.service and the session scopes as dependencies. */
367 if (u
->stopping
) /* Don't try to start this if the user is going down */
370 if (!user_wants_service_manager(u
)) /* Only start user service manager if there's at least one session which wants it */
373 u
->service_job
= mfree(u
->service_job
);
375 r
= manager_start_unit(u
->manager
, u
->service
, &error
, &u
->service_job
);
377 log_full_errno(sd_bus_error_has_name(&error
, BUS_ERROR_UNIT_MASKED
) ? LOG_DEBUG
: LOG_WARNING
, r
,
378 "Failed to start user service '%s', ignoring: %s", u
->service
, bus_error_message(&error
, r
));
381 static int update_slice_callback(sd_bus_message
*m
, void *userdata
, sd_bus_error
*ret_error
) {
382 _cleanup_(user_record_unrefp
) UserRecord
*ur
= ASSERT_PTR(userdata
);
383 const sd_bus_error
*e
;
388 e
= sd_bus_message_get_error(m
);
390 r
= sd_bus_error_get_errno(e
);
392 "Failed to update slice of %s, ignoring: %s",
394 bus_error_message(e
, r
));
399 log_debug("Successfully set slice parameters of %s.", ur
->user_name
);
403 static int user_update_slice(User
*u
) {
404 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*m
= NULL
;
409 if (u
->user_record
->tasks_max
== UINT64_MAX
&&
410 u
->user_record
->memory_high
== UINT64_MAX
&&
411 u
->user_record
->memory_max
== UINT64_MAX
&&
412 u
->user_record
->cpu_weight
== UINT64_MAX
&&
413 u
->user_record
->io_weight
== UINT64_MAX
)
416 r
= bus_message_new_method_call(u
->manager
->bus
, &m
, bus_systemd_mgr
, "SetUnitProperties");
418 return bus_log_create_error(r
);
420 r
= sd_bus_message_append(m
, "sb", u
->slice
, true);
422 return bus_log_create_error(r
);
424 r
= sd_bus_message_open_container(m
, 'a', "(sv)");
426 return bus_log_create_error(r
);
432 { "TasksMax", u
->user_record
->tasks_max
},
433 { "MemoryMax", u
->user_record
->memory_max
},
434 { "MemoryHigh", u
->user_record
->memory_high
},
435 { "CPUWeight", u
->user_record
->cpu_weight
},
436 { "IOWeight", u
->user_record
->io_weight
},
439 FOREACH_ARRAY(st
, settings
, ELEMENTSOF(settings
)) {
440 if (st
->value
== UINT64_MAX
)
443 r
= sd_bus_message_append(m
, "(sv)", st
->name
, "t", st
->value
);
445 return bus_log_create_error(r
);
448 r
= sd_bus_message_close_container(m
);
450 return bus_log_create_error(r
);
452 r
= sd_bus_call_async(u
->manager
->bus
, NULL
, m
, update_slice_callback
, u
->user_record
, 0);
454 return log_error_errno(r
, "Failed to change user slice properties: %m");
456 /* Ref the user record pointer, so that the slot keeps it pinned */
457 user_record_ref(u
->user_record
);
462 int user_start(User
*u
) {
465 if (u
->started
&& !u
->stopping
)
468 /* If u->stopping is set, the user is marked for removal and service stop-jobs are queued. We have to clear
469 * that flag before queueing the start-jobs again. If they succeed, the user object can be re-used just fine
470 * (pid1 takes care of job-ordering and proper restart), but if they fail, we want to force another user_stop()
471 * so possibly pending units are stopped. */
475 log_debug("Tracking new user %s.", u
->user_record
->user_name
);
477 /* Save the user data so far, because pam_systemd will read the XDG_RUNTIME_DIR out of it while starting up
478 * systemd --user. We need to do user_save_internal() because we have not "officially" started yet. */
479 user_save_internal(u
);
481 /* Set slice parameters */
482 (void) user_update_slice(u
);
484 /* Start user@UID.service */
485 user_start_service_manager(u
);
488 if (!dual_timestamp_is_set(&u
->timestamp
))
489 dual_timestamp_now(&u
->timestamp
);
490 user_send_signal(u
, true);
494 /* Save new user data */
500 static void user_stop_service(User
*u
, bool force
) {
501 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
507 /* The reverse of user_start_service(). Note that we only stop user@UID.service here, and let StopWhenUnneeded=
508 * deal with the slice and the user-runtime-dir@.service instance. */
510 u
->service_job
= mfree(u
->service_job
);
512 r
= manager_stop_unit(u
->manager
, u
->service
, force
? "replace" : "fail", &error
, &u
->service_job
);
514 log_warning_errno(r
, "Failed to stop user service '%s', ignoring: %s", u
->service
, bus_error_message(&error
, r
));
517 int user_stop(User
*u
, bool force
) {
522 /* This is called whenever we begin with tearing down a user record. It's called in two cases: explicit API
523 * request to do so via the bus (in which case 'force' is true) and automatically due to GC, if there's no
524 * session left pinning it (in which case 'force' is false). Note that this just initiates tearing down of the
525 * user, the User object will remain in memory until user_finalize() is called, see below. */
530 if (u
->stopping
) { /* Stop jobs have already been queued */
535 LIST_FOREACH(sessions_by_user
, s
, u
->sessions
) {
538 k
= session_stop(s
, force
);
543 user_stop_service(u
, force
);
552 int user_finalize(User
*u
) {
557 /* Called when the user is really ready to be freed, i.e. when all unit stop jobs and suchlike for it are
558 * done. This is called as a result of an earlier user_done() when all jobs are completed. */
561 log_debug("User %s logged out.", u
->user_record
->user_name
);
563 LIST_FOREACH(sessions_by_user
, s
, u
->sessions
) {
564 k
= session_finalize(s
);
569 /* Clean SysV + POSIX IPC objects, but only if this is not a system user. Background: in many setups cronjobs
570 * are run in full PAM and thus logind sessions, even if the code run doesn't belong to actual users but to
571 * system components. Since enable RemoveIPC= globally for all users, we need to be a bit careful with such
572 * cases, as we shouldn't accidentally remove a system service's IPC objects while it is running, just because
573 * a cronjob running as the same user just finished. Hence: exclude system users generally from IPC clean-up,
574 * and do it only for normal users. */
575 if (u
->manager
->remove_ipc
&& !uid_is_system(u
->user_record
->uid
)) {
576 k
= clean_ipc_by_uid(u
->user_record
->uid
);
581 (void) unlink(u
->state_file
);
582 user_add_to_gc_queue(u
);
585 user_send_signal(u
, false);
592 int user_get_idle_hint(User
*u
, dual_timestamp
*t
) {
593 bool idle_hint
= true;
594 dual_timestamp ts
= DUAL_TIMESTAMP_NULL
;
598 LIST_FOREACH(sessions_by_user
, s
, u
->sessions
) {
602 if (!SESSION_CLASS_CAN_IDLE(s
->class))
605 ih
= session_get_idle_hint(s
, &k
);
611 if (k
.monotonic
< ts
.monotonic
)
617 } else if (idle_hint
) {
619 if (k
.monotonic
> ts
.monotonic
)
630 int user_check_linger_file(User
*u
) {
631 _cleanup_free_
char *cc
= NULL
;
634 cc
= cescape(u
->user_record
->user_name
);
638 p
= strjoina("/var/lib/systemd/linger/", cc
);
639 if (access(p
, F_OK
) < 0) {
649 static bool user_unit_active(User
*u
) {
653 assert(u
->runtime_dir_service
);
656 FOREACH_STRING(i
, u
->service
, u
->runtime_dir_service
, u
->slice
) {
657 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
659 r
= manager_unit_is_active(u
->manager
, i
, &error
);
661 log_debug_errno(r
, "Failed to determine whether unit '%s' is active, ignoring: %s", i
, bus_error_message(&error
, r
));
669 static usec_t
user_get_stop_delay(User
*u
) {
672 if (u
->user_record
->stop_delay_usec
!= UINT64_MAX
)
673 return u
->user_record
->stop_delay_usec
;
675 if (user_record_removable(u
->user_record
) > 0)
676 return 0; /* For removable users lower the stop delay to zero */
678 return u
->manager
->user_stop_delay
;
681 static bool user_pinned_by_sessions(User
*u
) {
684 /* Returns true if at least one session exists that shall keep the user tracking alive. That
685 * generally means one session that isn't the service manager still exists. */
687 switch (u
->gc_mode
) {
693 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
)
694 if (SESSION_CLASS_PIN_USER(i
->class))
700 assert_not_reached();
704 bool user_may_gc(User
*u
, bool drop_not_started
) {
709 if (drop_not_started
&& !u
->started
)
712 if (user_pinned_by_sessions(u
))
715 if (u
->last_session_timestamp
!= USEC_INFINITY
) {
716 usec_t user_stop_delay
;
718 /* All sessions have been closed. Let's see if we shall leave the user record around for a bit */
720 user_stop_delay
= user_get_stop_delay(u
);
722 if (user_stop_delay
== USEC_INFINITY
)
723 return false; /* Leave it around forever! */
724 if (user_stop_delay
> 0 &&
725 now(CLOCK_MONOTONIC
) < usec_add(u
->last_session_timestamp
, user_stop_delay
))
726 return false; /* Leave it around for a bit longer. */
729 /* Is this a user that shall stay around forever ("linger")? Before we say "no" to GC'ing for lingering users, let's check
730 * if any of the three units that we maintain for this user is still around. If none of them is,
731 * there's no need to keep this user around even if lingering is enabled. */
732 if (user_check_linger_file(u
) > 0 && user_unit_active(u
))
735 /* Check if our job is still pending */
736 if (u
->service_job
) {
737 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
739 r
= manager_job_is_active(u
->manager
, u
->service_job
, &error
);
741 log_debug_errno(r
, "Failed to determine whether job '%s' is pending, ignoring: %s", u
->service_job
, bus_error_message(&error
, r
));
746 /* Note that we don't care if the three units we manage for each user object are up or not, as we are managing
747 * their state rather than tracking it. */
752 void user_add_to_gc_queue(User
*u
) {
758 LIST_PREPEND(gc_queue
, u
->manager
->user_gc_queue
, u
);
759 u
->in_gc_queue
= true;
762 UserState
user_get_state(User
*u
) {
768 if (!u
->started
|| u
->service_job
)
771 bool any
= false, all_closing
= true;
772 LIST_FOREACH(sessions_by_user
, i
, u
->sessions
) {
775 /* Ignore sessions that don't pin the user, i.e. are not supposed to have an effect on user state */
776 if (!SESSION_CLASS_PIN_USER(i
->class))
779 state
= session_get_state(i
);
780 if (state
== SESSION_ACTIVE
)
782 if (state
!= SESSION_CLOSING
)
789 return all_closing
? USER_CLOSING
: USER_ONLINE
;
791 if (user_check_linger_file(u
) > 0 && user_unit_active(u
))
792 return USER_LINGERING
;
797 int user_kill(User
*u
, int signo
) {
800 return manager_kill_unit(u
->manager
, u
->slice
, KILL_ALL
, signo
, NULL
);
803 static bool elect_display_filter(Session
*s
) {
804 /* Return true if the session is a candidate for the user’s ‘primary session’ or ‘display’. */
807 return SESSION_CLASS_CAN_DISPLAY(s
->class) && s
->started
&& !s
->stopping
;
810 static int elect_display_compare(Session
*s1
, Session
*s2
) {
811 /* Indexed by SessionType. Lower numbers mean more preferred. */
812 static const int type_ranks
[_SESSION_TYPE_MAX
] = {
813 [SESSION_UNSPECIFIED
] = 0,
816 [SESSION_WAYLAND
] = -3,
821 /* Calculate the partial order relationship between s1 and s2,
822 * returning < 0 if s1 is preferred as the user’s ‘primary session’,
823 * 0 if s1 and s2 are equally preferred or incomparable, or > 0 if s2
826 * s1 or s2 may be NULL. */
830 if ((s1
== NULL
) != (s2
== NULL
))
831 return (s1
== NULL
) - (s2
== NULL
);
833 if (s1
->stopping
!= s2
->stopping
)
834 return s1
->stopping
- s2
->stopping
;
836 if ((s1
->class != SESSION_USER
) != (s2
->class != SESSION_USER
))
837 return (s1
->class != SESSION_USER
) - (s2
->class != SESSION_USER
);
839 if ((s1
->class != SESSION_USER_EARLY
) != (s2
->class != SESSION_USER_EARLY
))
840 return (s1
->class != SESSION_USER_EARLY
) - (s2
->class != SESSION_USER_EARLY
);
842 if ((s1
->type
== _SESSION_TYPE_INVALID
) != (s2
->type
== _SESSION_TYPE_INVALID
))
843 return (s1
->type
== _SESSION_TYPE_INVALID
) - (s2
->type
== _SESSION_TYPE_INVALID
);
845 if (s1
->type
!= s2
->type
)
846 return type_ranks
[s1
->type
] - type_ranks
[s2
->type
];
851 void user_elect_display(User
*u
) {
854 /* This elects a primary session for each user, which we call the "display". We try to keep the assignment
855 * stable, but we "upgrade" to better choices. */
856 log_debug("Electing new display for user %s", u
->user_record
->user_name
);
858 LIST_FOREACH(sessions_by_user
, s
, u
->sessions
) {
859 if (!elect_display_filter(s
)) {
860 log_debug("Ignoring session %s", s
->id
);
864 if (elect_display_compare(s
, u
->display
) < 0) {
865 log_debug("Choosing session %s in preference to %s", s
->id
, u
->display
? u
->display
->id
: "-");
871 static int user_stop_timeout_callback(sd_event_source
*es
, uint64_t usec
, void *userdata
) {
872 User
*u
= ASSERT_PTR(userdata
);
874 user_add_to_gc_queue(u
);
879 void user_update_last_session_timer(User
*u
) {
880 usec_t user_stop_delay
;
885 if (user_pinned_by_sessions(u
)) {
886 /* There are sessions, turn off the timer */
887 u
->last_session_timestamp
= USEC_INFINITY
;
888 u
->timer_event_source
= sd_event_source_unref(u
->timer_event_source
);
892 if (u
->last_session_timestamp
!= USEC_INFINITY
)
893 return; /* Timer already started */
895 u
->last_session_timestamp
= now(CLOCK_MONOTONIC
);
897 assert(!u
->timer_event_source
);
899 user_stop_delay
= user_get_stop_delay(u
);
900 if (!timestamp_is_set(user_stop_delay
))
903 if (sd_event_get_state(u
->manager
->event
) == SD_EVENT_FINISHED
) {
904 log_debug("Not allocating user stop timeout, since we are already exiting.");
908 r
= sd_event_add_time(u
->manager
->event
,
909 &u
->timer_event_source
,
911 usec_add(u
->last_session_timestamp
, user_stop_delay
), 0,
912 user_stop_timeout_callback
, u
);
914 log_warning_errno(r
, "Failed to enqueue user stop event source, ignoring: %m");
917 log_debug("Last session of user '%s' logged out, terminating user context in %s.",
918 u
->user_record
->user_name
,
919 FORMAT_TIMESPAN(user_stop_delay
, USEC_PER_MSEC
));
922 static const char* const user_state_table
[_USER_STATE_MAX
] = {
923 [USER_OFFLINE
] = "offline",
924 [USER_OPENING
] = "opening",
925 [USER_LINGERING
] = "lingering",
926 [USER_ONLINE
] = "online",
927 [USER_ACTIVE
] = "active",
928 [USER_CLOSING
] = "closing"
931 DEFINE_STRING_TABLE_LOOKUP(user_state
, UserState
);
933 static const char* const user_gc_mode_table
[_USER_GC_MODE_MAX
] = {
934 [USER_GC_BY_PIN
] = "pin",
935 [USER_GC_BY_ANY
] = "any",
938 DEFINE_STRING_TABLE_LOOKUP(user_gc_mode
, UserGCMode
);
940 int config_parse_tmpfs_size(
942 const char *filename
,
945 unsigned section_line
,
952 uint64_t *sz
= ASSERT_PTR(data
);
959 /* First, try to parse as percentage */
960 r
= parse_permyriad(rvalue
);
962 *sz
= physical_memory_scale(r
, 10000U);
966 /* If the passed argument was not a percentage, or out of range, parse as byte size */
968 r
= parse_size(rvalue
, 1024, &k
);
969 if (r
>= 0 && (k
<= 0 || (uint64_t) (size_t) k
!= k
))
972 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Failed to parse size value '%s', ignoring: %m", rvalue
);
976 *sz
= PAGE_ALIGN((size_t) k
);
982 int config_parse_compat_user_tasks_max(
984 const char *filename
,
987 unsigned section_line
,
998 log_syntax(unit
, LOG_NOTICE
, filename
, line
, 0,
999 "Support for option %s= has been removed.",
1001 log_info("Hint: try creating /etc/systemd/system/user-.slice.d/50-limits.conf with:\n"