1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright © 2012 Holger Hans Peter Freyther
14 #include <sys/resource.h>
16 #include "sd-messages.h"
19 #include "alloc-util.h"
20 #include "all-units.h"
21 #include "bpf-firewall.h"
22 #include "bus-error.h"
23 #include "bus-internal.h"
26 #include "capability-util.h"
27 #include "cgroup-setup.h"
28 #include "conf-parser.h"
29 #include "cpu-set-util.h"
31 #include "errno-list.h"
36 #include "hexdecoct.h"
39 #include "ip-protocol-list.h"
40 #include "journal-util.h"
41 #include "limits-util.h"
42 #include "load-fragment.h"
44 #include "mountpoint-util.h"
45 #include "nulstr-util.h"
46 #include "parse-util.h"
47 #include "path-util.h"
48 #include "process-util.h"
50 #include "seccomp-util.h"
52 #include "securebits-util.h"
53 #include "signal-util.h"
54 #include "socket-netlink.h"
55 #include "stat-util.h"
56 #include "string-util.h"
58 #include "syslog-util.h"
59 #include "time-util.h"
60 #include "unit-name.h"
61 #include "unit-printf.h"
62 #include "user-util.h"
65 static int parse_socket_protocol(const char *s
) {
68 r
= parse_ip_protocol(s
);
71 if (!IN_SET(r
, IPPROTO_UDPLITE
, IPPROTO_SCTP
))
72 return -EPROTONOSUPPORT
;
77 int parse_crash_chvt(const char *value
, int *data
) {
80 if (safe_atoi(value
, data
) >= 0)
83 b
= parse_boolean(value
);
88 *data
= 0; /* switch to where kmsg goes */
90 *data
= -1; /* turn off switching */
95 int parse_confirm_spawn(const char *value
, char **console
) {
99 r
= value
? parse_boolean(value
) : 1;
103 } else if (r
> 0) /* on with default tty */
104 s
= strdup("/dev/console");
105 else if (is_path(value
)) /* on with fully qualified path */
107 else /* on with only a tty file name, not a fully qualified path */
108 s
= path_join("/dev/", value
);
116 DEFINE_CONFIG_PARSE(config_parse_socket_protocol
, parse_socket_protocol
, "Failed to parse socket protocol");
117 DEFINE_CONFIG_PARSE(config_parse_exec_secure_bits
, secure_bits_from_string
, "Failed to parse secure bits");
118 DEFINE_CONFIG_PARSE_ENUM(config_parse_collect_mode
, collect_mode
, CollectMode
, "Failed to parse garbage collection mode");
119 DEFINE_CONFIG_PARSE_ENUM(config_parse_device_policy
, cgroup_device_policy
, CGroupDevicePolicy
, "Failed to parse device policy");
120 DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_keyring_mode
, exec_keyring_mode
, ExecKeyringMode
, "Failed to parse keyring mode");
121 DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_utmp_mode
, exec_utmp_mode
, ExecUtmpMode
, "Failed to parse utmp mode");
122 DEFINE_CONFIG_PARSE_ENUM(config_parse_job_mode
, job_mode
, JobMode
, "Failed to parse job mode");
123 DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access
, notify_access
, NotifyAccess
, "Failed to parse notify access specifier");
124 DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_home
, protect_home
, ProtectHome
, "Failed to parse protect home value");
125 DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_system
, protect_system
, ProtectSystem
, "Failed to parse protect system value");
126 DEFINE_CONFIG_PARSE_ENUM(config_parse_runtime_preserve_mode
, exec_preserve_mode
, ExecPreserveMode
, "Failed to parse runtime directory preserve mode");
127 DEFINE_CONFIG_PARSE_ENUM(config_parse_service_type
, service_type
, ServiceType
, "Failed to parse service type");
128 DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart
, service_restart
, ServiceRestart
, "Failed to parse service restart specifier");
129 DEFINE_CONFIG_PARSE_ENUM(config_parse_service_timeout_failure_mode
, service_timeout_failure_mode
, ServiceTimeoutFailureMode
, "Failed to parse timeout failure mode");
130 DEFINE_CONFIG_PARSE_ENUM(config_parse_socket_bind
, socket_address_bind_ipv6_only_or_bool
, SocketAddressBindIPv6Only
, "Failed to parse bind IPv6 only value");
131 DEFINE_CONFIG_PARSE_ENUM(config_parse_oom_policy
, oom_policy
, OOMPolicy
, "Failed to parse OOM policy");
132 DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_ip_tos
, ip_tos
, int, -1, "Failed to parse IP TOS value");
133 DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight
, cg_blkio_weight_parse
, uint64_t, "Invalid block IO weight");
134 DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight
, cg_weight_parse
, uint64_t, "Invalid weight");
135 DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares
, cg_cpu_shares_parse
, uint64_t, "Invalid CPU shares");
136 DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags
, mount_propagation_flags_from_string
, unsigned long, "Failed to parse mount flag");
137 DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy
, mpol
, int, -1, "Invalid NUMA policy type");
138 DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format
, status_unit_format
, StatusUnitFormat
, "Failed to parse status unit format");
140 int config_parse_unit_deps(
142 const char *filename
,
145 unsigned section_line
,
152 UnitDependency d
= ltype
;
162 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
165 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_RETAIN_ESCAPE
);
171 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid syntax, ignoring: %s", rvalue
);
175 r
= unit_name_printf(u
, word
, &k
);
177 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", word
);
181 r
= unit_add_dependency_by_name(u
, d
, k
, true, UNIT_DEPENDENCY_FILE
);
183 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to add dependency on %s, ignoring: %m", k
);
189 int config_parse_obsolete_unit_deps(
191 const char *filename
,
194 unsigned section_line
,
201 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
202 "Unit dependency type %s= is obsolete, replacing by %s=, please update your unit file", lvalue
, unit_dependency_to_string(ltype
));
204 return config_parse_unit_deps(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, rvalue
, data
, userdata
);
207 int config_parse_unit_string_printf(
209 const char *filename
,
212 unsigned section_line
,
219 _cleanup_free_
char *k
= NULL
;
220 const Unit
*u
= userdata
;
228 r
= unit_full_printf(u
, rvalue
, &k
);
230 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
234 return config_parse_string(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, k
, data
, userdata
);
237 int config_parse_unit_strv_printf(
239 const char *filename
,
242 unsigned section_line
,
249 const Unit
*u
= userdata
;
250 _cleanup_free_
char *k
= NULL
;
258 r
= unit_full_printf(u
, rvalue
, &k
);
260 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
264 return config_parse_strv(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, k
, data
, userdata
);
267 int config_parse_unit_path_printf(
269 const char *filename
,
272 unsigned section_line
,
279 _cleanup_free_
char *k
= NULL
;
280 const Unit
*u
= userdata
;
289 /* Let's not bother with anything that is too long */
290 if (strlen(rvalue
) >= PATH_MAX
) {
291 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
292 "%s value too long%s.",
293 lvalue
, fatal
? "" : ", ignoring");
294 return fatal
? -ENAMETOOLONG
: 0;
297 r
= unit_full_printf(u
, rvalue
, &k
);
299 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
300 "Failed to resolve unit specifiers in '%s'%s: %m",
301 rvalue
, fatal
? "" : ", ignoring");
302 return fatal
? -ENOEXEC
: 0;
305 return config_parse_path(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, k
, data
, userdata
);
308 int config_parse_unit_path_strv_printf(
310 const char *filename
,
313 unsigned section_line
,
321 const Unit
*u
= userdata
;
330 if (isempty(rvalue
)) {
336 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
338 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
344 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
345 "Invalid syntax, ignoring: %s", rvalue
);
349 r
= unit_full_printf(u
, word
, &k
);
351 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
352 "Failed to resolve unit specifiers in '%s', ignoring: %m", word
);
356 r
= path_simplify_and_warn(k
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
360 r
= strv_consume(x
, TAKE_PTR(k
));
366 static int patch_var_run(
368 const char *filename
,
376 e
= path_startswith(*path
, "/var/run/");
380 z
= path_join("/run/", e
);
384 log_syntax(unit
, LOG_NOTICE
, filename
, line
, 0,
385 "%s= references a path below legacy directory /var/run/, updating %s → %s; "
386 "please update the unit file accordingly.", lvalue
, *path
, z
);
388 free_and_replace(*path
, z
);
393 int config_parse_socket_listen(
395 const char *filename
,
398 unsigned section_line
,
405 _cleanup_free_ SocketPort
*p
= NULL
;
417 if (isempty(rvalue
)) {
418 /* An empty assignment removes all ports */
419 socket_free_ports(s
);
423 p
= new0(SocketPort
, 1);
427 if (ltype
!= SOCKET_SOCKET
) {
428 _cleanup_free_
char *k
= NULL
;
430 r
= unit_full_printf(UNIT(s
), rvalue
, &k
);
432 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
436 r
= path_simplify_and_warn(k
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
440 if (ltype
== SOCKET_FIFO
) {
441 r
= patch_var_run(unit
, filename
, line
, lvalue
, &k
);
446 free_and_replace(p
->path
, k
);
449 } else if (streq(lvalue
, "ListenNetlink")) {
450 _cleanup_free_
char *k
= NULL
;
452 r
= unit_full_printf(UNIT(s
), rvalue
, &k
);
454 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
458 r
= socket_address_parse_netlink(&p
->address
, k
);
460 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse address value in '%s', ignoring: %m", k
);
464 p
->type
= SOCKET_SOCKET
;
467 _cleanup_free_
char *k
= NULL
;
469 r
= unit_full_printf(UNIT(s
), rvalue
, &k
);
471 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
475 if (k
[0] == '/') { /* Only for AF_UNIX file system sockets… */
476 r
= patch_var_run(unit
, filename
, line
, lvalue
, &k
);
481 r
= socket_address_parse_and_warn(&p
->address
, k
);
483 if (r
!= -EAFNOSUPPORT
)
484 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse address value in '%s', ignoring: %m", k
);
488 if (streq(lvalue
, "ListenStream"))
489 p
->address
.type
= SOCK_STREAM
;
490 else if (streq(lvalue
, "ListenDatagram"))
491 p
->address
.type
= SOCK_DGRAM
;
493 assert(streq(lvalue
, "ListenSequentialPacket"));
494 p
->address
.type
= SOCK_SEQPACKET
;
497 if (socket_address_family(&p
->address
) != AF_LOCAL
&& p
->address
.type
== SOCK_SEQPACKET
) {
498 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Address family not supported, ignoring: %s", rvalue
);
502 p
->type
= SOCKET_SOCKET
;
506 p
->auxiliary_fds
= NULL
;
507 p
->n_auxiliary_fds
= 0;
510 LIST_FIND_TAIL(port
, s
->ports
, tail
);
511 LIST_INSERT_AFTER(port
, s
->ports
, tail
, p
);
518 int config_parse_exec_nice(
520 const char *filename
,
523 unsigned section_line
,
530 ExecContext
*c
= data
;
538 if (isempty(rvalue
)) {
543 r
= parse_nice(rvalue
, &priority
);
546 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Nice priority out of range, ignoring: %s", rvalue
);
548 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse nice priority '%s', ignoring: %m", rvalue
);
558 int config_parse_exec_oom_score_adjust(
560 const char *filename
,
563 unsigned section_line
,
570 ExecContext
*c
= data
;
578 if (isempty(rvalue
)) {
579 c
->oom_score_adjust_set
= false;
583 r
= parse_oom_score_adjust(rvalue
, &oa
);
586 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "OOM score adjust value out of range, ignoring: %s", rvalue
);
588 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse the OOM score adjust value '%s', ignoring: %m", rvalue
);
592 c
->oom_score_adjust
= oa
;
593 c
->oom_score_adjust_set
= true;
598 int config_parse_exec_coredump_filter(
600 const char *filename
,
603 unsigned section_line
,
610 ExecContext
*c
= data
;
618 if (isempty(rvalue
)) {
619 c
->coredump_filter
= 0;
620 c
->coredump_filter_set
= false;
625 r
= coredump_filter_mask_from_string(rvalue
, &f
);
627 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
628 "Failed to parse the CoredumpFilter=%s, ignoring: %m", rvalue
);
632 c
->coredump_filter
|= f
;
633 c
->oom_score_adjust_set
= true;
637 int config_parse_kill_mode(
639 const char *filename
,
642 unsigned section_line
,
649 KillMode
*k
= data
, m
;
656 if (isempty(rvalue
)) {
657 *k
= KILL_CONTROL_GROUP
;
661 m
= kill_mode_from_string(rvalue
);
663 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
664 "Failed to parse kill mode specification, ignoring: %s", rvalue
);
669 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
670 "Unit configured to use KillMode=none. "
671 "This is unsafe, as it disables systemd's process lifecycle management for the service. "
672 "Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'. "
673 "Support for KillMode=none is deprecated and will eventually be removed.");
679 int config_parse_exec(
681 const char *filename
,
684 unsigned section_line
,
691 ExecCommand
**e
= data
;
692 const Unit
*u
= userdata
;
704 if (isempty(rvalue
)) {
705 /* An empty assignment resets the list */
706 *e
= exec_command_free_list(*e
);
712 _cleanup_free_
char *path
= NULL
, *firstword
= NULL
;
713 ExecCommandFlags flags
= 0;
714 bool ignore
= false, separate_argv0
= false;
715 _cleanup_free_ ExecCommand
*nce
= NULL
;
716 _cleanup_strv_free_
char **n
= NULL
;
717 size_t nlen
= 0, nbufsize
= 0;
722 r
= extract_first_word_and_warn(&p
, &firstword
, NULL
, EXTRACT_UNQUOTE
|EXTRACT_CUNESCAPE
, unit
, filename
, line
, rvalue
);
728 /* We accept an absolute path as first argument. If it's prefixed with - and the path doesn't
729 * exist, we ignore it instead of erroring out; if it's prefixed with @, we allow overriding of
730 * argv[0]; if it's prefixed with :, we will not do environment variable substitution;
731 * if it's prefixed with +, it will be run with full privileges and no sandboxing; if
732 * it's prefixed with '!' we apply sandboxing, but do not change user/group credentials; if
733 * it's prefixed with '!!', then we apply user/group credentials if the kernel supports ambient
734 * capabilities -- if it doesn't we don't apply the credentials themselves, but do apply most
735 * other sandboxing, with some special exceptions for changing UID.
737 * The idea is that '!!' may be used to write services that can take benefit of systemd's
738 * UID/GID dropping if the kernel supports ambient creds, but provide an automatic fallback to
739 * privilege dropping within the daemon if the kernel does not offer that. */
741 if (*f
== '-' && !(flags
& EXEC_COMMAND_IGNORE_FAILURE
)) {
742 flags
|= EXEC_COMMAND_IGNORE_FAILURE
;
744 } else if (*f
== '@' && !separate_argv0
)
745 separate_argv0
= true;
746 else if (*f
== ':' && !(flags
& EXEC_COMMAND_NO_ENV_EXPAND
))
747 flags
|= EXEC_COMMAND_NO_ENV_EXPAND
;
748 else if (*f
== '+' && !(flags
& (EXEC_COMMAND_FULLY_PRIVILEGED
|EXEC_COMMAND_NO_SETUID
|EXEC_COMMAND_AMBIENT_MAGIC
)))
749 flags
|= EXEC_COMMAND_FULLY_PRIVILEGED
;
750 else if (*f
== '!' && !(flags
& (EXEC_COMMAND_FULLY_PRIVILEGED
|EXEC_COMMAND_NO_SETUID
|EXEC_COMMAND_AMBIENT_MAGIC
)))
751 flags
|= EXEC_COMMAND_NO_SETUID
;
752 else if (*f
== '!' && !(flags
& (EXEC_COMMAND_FULLY_PRIVILEGED
|EXEC_COMMAND_AMBIENT_MAGIC
))) {
753 flags
&= ~EXEC_COMMAND_NO_SETUID
;
754 flags
|= EXEC_COMMAND_AMBIENT_MAGIC
;
760 r
= unit_full_printf(u
, f
, &path
);
762 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
763 "Failed to resolve unit specifiers in '%s'%s: %m",
764 f
, ignore
? ", ignoring" : "");
765 return ignore
? 0 : -ENOEXEC
;
769 /* First word is either "-" or "@" with no command. */
770 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
771 "Empty path in command line%s: '%s'",
772 ignore
? ", ignoring" : "", rvalue
);
773 return ignore
? 0 : -ENOEXEC
;
775 if (!string_is_safe(path
)) {
776 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
777 "Executable name contains special characters%s: %s",
778 ignore
? ", ignoring" : "", path
);
779 return ignore
? 0 : -ENOEXEC
;
781 if (endswith(path
, "/")) {
782 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
783 "Executable path specifies a directory%s: %s",
784 ignore
? ", ignoring" : "", path
);
785 return ignore
? 0 : -ENOEXEC
;
788 if (!path_is_absolute(path
)) {
792 if (!filename_is_valid(path
)) {
793 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
794 "Neither a valid executable name nor an absolute path%s: %s",
795 ignore
? ", ignoring" : "", path
);
796 return ignore
? 0 : -ENOEXEC
;
799 /* Resolve a single-component name to a full path */
800 NULSTR_FOREACH(prefix
, DEFAULT_PATH_NULSTR
) {
801 _cleanup_free_
char *fullpath
= NULL
;
803 fullpath
= path_join(prefix
, path
);
807 if (access(fullpath
, F_OK
) >= 0) {
808 free_and_replace(path
, fullpath
);
815 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
816 "Executable \"%s\" not found in path \"%s\"%s",
817 path
, DEFAULT_PATH
, ignore
? ", ignoring" : "");
818 return ignore
? 0 : -ENOEXEC
;
822 if (!separate_argv0
) {
825 if (!GREEDY_REALLOC(n
, nbufsize
, nlen
+ 2))
835 path_simplify(path
, false);
837 while (!isempty(p
)) {
838 _cleanup_free_
char *word
= NULL
, *resolved
= NULL
;
840 /* Check explicitly for an unquoted semicolon as
841 * command separator token. */
842 if (p
[0] == ';' && (!p
[1] || strchr(WHITESPACE
, p
[1]))) {
844 p
+= strspn(p
, WHITESPACE
);
849 /* Check for \; explicitly, to not confuse it with \\; or "\;" or "\\;" etc.
850 * extract_first_word() would return the same for all of those. */
851 if (p
[0] == '\\' && p
[1] == ';' && (!p
[2] || strchr(WHITESPACE
, p
[2]))) {
855 p
+= strspn(p
, WHITESPACE
);
857 if (!GREEDY_REALLOC(n
, nbufsize
, nlen
+ 2))
868 r
= extract_first_word_and_warn(&p
, &word
, NULL
, EXTRACT_UNQUOTE
|EXTRACT_CUNESCAPE
, unit
, filename
, line
, rvalue
);
872 return ignore
? 0 : -ENOEXEC
;
874 r
= unit_full_printf(u
, word
, &resolved
);
876 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
877 "Failed to resolve unit specifiers in %s%s: %m",
878 word
, ignore
? ", ignoring" : "");
879 return ignore
? 0 : -ENOEXEC
;
882 if (!GREEDY_REALLOC(n
, nbufsize
, nlen
+ 2))
885 n
[nlen
++] = TAKE_PTR(resolved
);
890 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
891 "Empty executable name or zeroeth argument%s: %s",
892 ignore
? ", ignoring" : "", rvalue
);
893 return ignore
? 0 : -ENOEXEC
;
896 nce
= new0(ExecCommand
, 1);
900 nce
->argv
= TAKE_PTR(n
);
901 nce
->path
= TAKE_PTR(path
);
904 exec_command_append_list(e
, nce
);
906 /* Do not _cleanup_free_ these. */
915 int config_parse_socket_bindtodevice(
917 const char *filename
,
920 unsigned section_line
,
934 if (isempty(rvalue
) || streq(rvalue
, "*")) {
935 s
->bind_to_device
= mfree(s
->bind_to_device
);
939 if (!ifname_valid(rvalue
)) {
940 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid interface name, ignoring: %s", rvalue
);
944 if (free_and_strdup(&s
->bind_to_device
, rvalue
) < 0)
950 int config_parse_exec_input(
952 const char *filename
,
955 unsigned section_line
,
962 ExecContext
*c
= data
;
963 const Unit
*u
= userdata
;
973 n
= startswith(rvalue
, "fd:");
975 _cleanup_free_
char *resolved
= NULL
;
977 r
= unit_full_printf(u
, n
, &resolved
);
979 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s': %m", n
);
981 if (isempty(resolved
))
982 resolved
= mfree(resolved
);
983 else if (!fdname_is_valid(resolved
)) {
984 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid file descriptor name: %s", resolved
);
988 free_and_replace(c
->stdio_fdname
[STDIN_FILENO
], resolved
);
990 ei
= EXEC_INPUT_NAMED_FD
;
992 } else if ((n
= startswith(rvalue
, "file:"))) {
993 _cleanup_free_
char *resolved
= NULL
;
995 r
= unit_full_printf(u
, n
, &resolved
);
997 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s': %m", n
);
999 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
| PATH_CHECK_FATAL
, unit
, filename
, line
, lvalue
);
1003 free_and_replace(c
->stdio_file
[STDIN_FILENO
], resolved
);
1005 ei
= EXEC_INPUT_FILE
;
1008 ei
= exec_input_from_string(rvalue
);
1010 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse input specifier, ignoring: %s", rvalue
);
1019 int config_parse_exec_input_text(
1021 const char *filename
,
1023 const char *section
,
1024 unsigned section_line
,
1031 _cleanup_free_
char *unescaped
= NULL
, *resolved
= NULL
;
1032 ExecContext
*c
= data
;
1033 const Unit
*u
= userdata
;
1043 if (isempty(rvalue
)) {
1044 /* Reset if the empty string is assigned */
1045 c
->stdin_data
= mfree(c
->stdin_data
);
1046 c
->stdin_data_size
= 0;
1050 r
= cunescape(rvalue
, 0, &unescaped
);
1052 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to decode C escaped text '%s': %m", rvalue
);
1054 r
= unit_full_printf(u
, unescaped
, &resolved
);
1056 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s': %m", unescaped
);
1058 sz
= strlen(resolved
);
1059 if (c
->stdin_data_size
+ sz
+ 1 < c
->stdin_data_size
|| /* check for overflow */
1060 c
->stdin_data_size
+ sz
+ 1 > EXEC_STDIN_DATA_MAX
) {
1061 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Standard input data too large (%zu), maximum of %zu permitted, ignoring.", c
->stdin_data_size
+ sz
, (size_t) EXEC_STDIN_DATA_MAX
);
1065 p
= realloc(c
->stdin_data
, c
->stdin_data_size
+ sz
+ 1);
1069 *((char*) mempcpy((char*) p
+ c
->stdin_data_size
, resolved
, sz
)) = '\n';
1072 c
->stdin_data_size
+= sz
+ 1;
1077 int config_parse_exec_input_data(
1079 const char *filename
,
1081 const char *section
,
1082 unsigned section_line
,
1089 _cleanup_free_
void *p
= NULL
;
1090 ExecContext
*c
= data
;
1100 if (isempty(rvalue
)) {
1101 /* Reset if the empty string is assigned */
1102 c
->stdin_data
= mfree(c
->stdin_data
);
1103 c
->stdin_data_size
= 0;
1107 r
= unbase64mem(rvalue
, (size_t) -1, &p
, &sz
);
1109 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to decode base64 data, ignoring: %s", rvalue
);
1113 if (c
->stdin_data_size
+ sz
< c
->stdin_data_size
|| /* check for overflow */
1114 c
->stdin_data_size
+ sz
> EXEC_STDIN_DATA_MAX
) {
1115 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Standard input data too large (%zu), maximum of %zu permitted, ignoring.", c
->stdin_data_size
+ sz
, (size_t) EXEC_STDIN_DATA_MAX
);
1119 q
= realloc(c
->stdin_data
, c
->stdin_data_size
+ sz
);
1123 memcpy((uint8_t*) q
+ c
->stdin_data_size
, p
, sz
);
1126 c
->stdin_data_size
+= sz
;
1131 int config_parse_exec_output(
1133 const char *filename
,
1135 const char *section
,
1136 unsigned section_line
,
1143 _cleanup_free_
char *resolved
= NULL
;
1145 ExecContext
*c
= data
;
1146 const Unit
*u
= userdata
;
1147 bool obsolete
= false;
1157 n
= startswith(rvalue
, "fd:");
1159 r
= unit_full_printf(u
, n
, &resolved
);
1161 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", n
);
1163 if (isempty(resolved
))
1164 resolved
= mfree(resolved
);
1165 else if (!fdname_is_valid(resolved
)) {
1166 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid file descriptor name: %s", resolved
);
1170 eo
= EXEC_OUTPUT_NAMED_FD
;
1172 } else if (streq(rvalue
, "syslog")) {
1173 eo
= EXEC_OUTPUT_JOURNAL
;
1176 } else if (streq(rvalue
, "syslog+console")) {
1177 eo
= EXEC_OUTPUT_JOURNAL_AND_CONSOLE
;
1180 } else if ((n
= startswith(rvalue
, "file:"))) {
1182 r
= unit_full_printf(u
, n
, &resolved
);
1184 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", n
);
1186 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
| PATH_CHECK_FATAL
, unit
, filename
, line
, lvalue
);
1190 eo
= EXEC_OUTPUT_FILE
;
1192 } else if ((n
= startswith(rvalue
, "append:"))) {
1194 r
= unit_full_printf(u
, n
, &resolved
);
1196 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", n
);
1198 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
| PATH_CHECK_FATAL
, unit
, filename
, line
, lvalue
);
1202 eo
= EXEC_OUTPUT_FILE_APPEND
;
1204 eo
= exec_output_from_string(rvalue
);
1206 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse output specifier, ignoring: %s", rvalue
);
1212 log_syntax(unit
, LOG_NOTICE
, filename
, line
, 0,
1213 "Standard output type %s is obsolete, automatically updating to %s. Please update your unit file, and consider removing the setting altogether.",
1214 rvalue
, exec_output_to_string(eo
));
1216 if (streq(lvalue
, "StandardOutput")) {
1217 if (eo
== EXEC_OUTPUT_NAMED_FD
)
1218 free_and_replace(c
->stdio_fdname
[STDOUT_FILENO
], resolved
);
1220 free_and_replace(c
->stdio_file
[STDOUT_FILENO
], resolved
);
1225 assert(streq(lvalue
, "StandardError"));
1227 if (eo
== EXEC_OUTPUT_NAMED_FD
)
1228 free_and_replace(c
->stdio_fdname
[STDERR_FILENO
], resolved
);
1230 free_and_replace(c
->stdio_file
[STDERR_FILENO
], resolved
);
1238 int config_parse_exec_io_class(const char *unit
,
1239 const char *filename
,
1241 const char *section
,
1242 unsigned section_line
,
1249 ExecContext
*c
= data
;
1257 if (isempty(rvalue
)) {
1258 c
->ioprio_set
= false;
1259 c
->ioprio
= IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE
, 0);
1263 x
= ioprio_class_from_string(rvalue
);
1265 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse IO scheduling class, ignoring: %s", rvalue
);
1269 c
->ioprio
= IOPRIO_PRIO_VALUE(x
, IOPRIO_PRIO_DATA(c
->ioprio
));
1270 c
->ioprio_set
= true;
1275 int config_parse_exec_io_priority(const char *unit
,
1276 const char *filename
,
1278 const char *section
,
1279 unsigned section_line
,
1286 ExecContext
*c
= data
;
1294 if (isempty(rvalue
)) {
1295 c
->ioprio_set
= false;
1296 c
->ioprio
= IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE
, 0);
1300 r
= ioprio_parse_priority(rvalue
, &i
);
1302 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse IO priority, ignoring: %s", rvalue
);
1306 c
->ioprio
= IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c
->ioprio
), i
);
1307 c
->ioprio_set
= true;
1312 int config_parse_exec_cpu_sched_policy(const char *unit
,
1313 const char *filename
,
1315 const char *section
,
1316 unsigned section_line
,
1323 ExecContext
*c
= data
;
1331 if (isempty(rvalue
)) {
1332 c
->cpu_sched_set
= false;
1333 c
->cpu_sched_policy
= SCHED_OTHER
;
1334 c
->cpu_sched_priority
= 0;
1338 x
= sched_policy_from_string(rvalue
);
1340 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue
);
1344 c
->cpu_sched_policy
= x
;
1345 /* Moving to or from real-time policy? We need to adjust the priority */
1346 c
->cpu_sched_priority
= CLAMP(c
->cpu_sched_priority
, sched_get_priority_min(x
), sched_get_priority_max(x
));
1347 c
->cpu_sched_set
= true;
1352 int config_parse_numa_mask(const char *unit
,
1353 const char *filename
,
1355 const char *section
,
1356 unsigned section_line
,
1363 NUMAPolicy
*p
= data
;
1370 r
= parse_cpu_set_extend(rvalue
, &p
->nodes
, true, unit
, filename
, line
, lvalue
);
1372 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse NUMA node mask, ignoring: %s", rvalue
);
1379 int config_parse_exec_cpu_sched_prio(const char *unit
,
1380 const char *filename
,
1382 const char *section
,
1383 unsigned section_line
,
1390 ExecContext
*c
= data
;
1398 r
= safe_atoi(rvalue
, &i
);
1400 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse CPU scheduling priority, ignoring: %s", rvalue
);
1404 /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0 */
1405 min
= sched_get_priority_min(c
->cpu_sched_policy
);
1406 max
= sched_get_priority_max(c
->cpu_sched_policy
);
1408 if (i
< min
|| i
> max
) {
1409 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "CPU scheduling priority is out of range, ignoring: %s", rvalue
);
1413 c
->cpu_sched_priority
= i
;
1414 c
->cpu_sched_set
= true;
1419 int config_parse_exec_root_hash(
1421 const char *filename
,
1423 const char *section
,
1424 unsigned section_line
,
1431 _cleanup_free_
void *roothash_decoded
= NULL
;
1432 ExecContext
*c
= data
;
1433 size_t roothash_decoded_size
= 0;
1441 if (isempty(rvalue
)) {
1442 /* Reset if the empty string is assigned */
1443 c
->root_hash_path
= mfree(c
->root_hash_path
);
1444 c
->root_hash
= mfree(c
->root_hash
);
1445 c
->root_hash_size
= 0;
1449 if (path_is_absolute(rvalue
)) {
1450 /* We have the path to a roothash to load and decode, eg: RootHash=/foo/bar.roothash */
1451 _cleanup_free_
char *p
= NULL
;
1457 free_and_replace(c
->root_hash_path
, p
);
1458 c
->root_hash
= mfree(c
->root_hash
);
1459 c
->root_hash_size
= 0;
1463 /* We have a roothash to decode, eg: RootHash=012345789abcdef */
1464 r
= unhexmem(rvalue
, strlen(rvalue
), &roothash_decoded
, &roothash_decoded_size
);
1466 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to decode RootHash=, ignoring: %s", rvalue
);
1467 if (roothash_decoded_size
< sizeof(sd_id128_t
))
1468 return log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
), "RootHash= is too short, ignoring: %s", rvalue
);
1470 free_and_replace(c
->root_hash
, roothash_decoded
);
1471 c
->root_hash_size
= roothash_decoded_size
;
1472 c
->root_hash_path
= mfree(c
->root_hash_path
);
1477 int config_parse_exec_root_hash_sig(
1479 const char *filename
,
1481 const char *section
,
1482 unsigned section_line
,
1489 _cleanup_free_
void *roothash_sig_decoded
= NULL
;
1491 ExecContext
*c
= data
;
1492 size_t roothash_sig_decoded_size
= 0;
1500 if (isempty(rvalue
)) {
1501 /* Reset if the empty string is assigned */
1502 c
->root_hash_sig_path
= mfree(c
->root_hash_sig_path
);
1503 c
->root_hash_sig
= mfree(c
->root_hash_sig
);
1504 c
->root_hash_sig_size
= 0;
1508 if (path_is_absolute(rvalue
)) {
1509 /* We have the path to a roothash signature to load and decode, eg: RootHashSignature=/foo/bar.roothash.p7s */
1510 _cleanup_free_
char *p
= NULL
;
1516 free_and_replace(c
->root_hash_sig_path
, p
);
1517 c
->root_hash_sig
= mfree(c
->root_hash_sig
);
1518 c
->root_hash_sig_size
= 0;
1522 if (!(value
= startswith(rvalue
, "base64:")))
1523 return log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
), "Failed to decode RootHashSignature=, not a path but doesn't start with 'base64:', ignoring: %s", rvalue
);
1525 /* We have a roothash signature to decode, eg: RootHashSignature=base64:012345789abcdef */
1526 r
= unbase64mem(value
, strlen(value
), &roothash_sig_decoded
, &roothash_sig_decoded_size
);
1528 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to decode RootHashSignature=, ignoring: %s", rvalue
);
1530 free_and_replace(c
->root_hash_sig
, roothash_sig_decoded
);
1531 c
->root_hash_sig_size
= roothash_sig_decoded_size
;
1532 c
->root_hash_sig_path
= mfree(c
->root_hash_sig_path
);
1537 int config_parse_exec_cpu_affinity(const char *unit
,
1538 const char *filename
,
1540 const char *section
,
1541 unsigned section_line
,
1548 ExecContext
*c
= data
;
1556 if (streq(rvalue
, "numa")) {
1557 c
->cpu_affinity_from_numa
= true;
1558 cpu_set_reset(&c
->cpu_set
);
1563 r
= parse_cpu_set_extend(rvalue
, &c
->cpu_set
, true, unit
, filename
, line
, lvalue
);
1565 c
->cpu_affinity_from_numa
= false;
1570 int config_parse_capability_set(
1572 const char *filename
,
1574 const char *section
,
1575 unsigned section_line
,
1582 uint64_t *capability_set
= data
;
1583 uint64_t sum
= 0, initial
= 0;
1584 bool invert
= false;
1592 if (rvalue
[0] == '~') {
1597 if (streq(lvalue
, "CapabilityBoundingSet"))
1598 initial
= CAP_ALL
; /* initialized to all bits on */
1599 /* else "AmbientCapabilities" initialized to all bits off */
1601 r
= capability_set_from_string(rvalue
, &sum
);
1603 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s= specifier '%s', ignoring: %m", lvalue
, rvalue
);
1607 if (sum
== 0 || *capability_set
== initial
)
1608 /* "", "~" or uninitialized data -> replace */
1609 *capability_set
= invert
? ~sum
: sum
;
1611 /* previous data -> merge */
1613 *capability_set
&= ~sum
;
1615 *capability_set
|= sum
;
1621 int config_parse_exec_selinux_context(
1623 const char *filename
,
1625 const char *section
,
1626 unsigned section_line
,
1633 ExecContext
*c
= data
;
1634 const Unit
*u
= userdata
;
1644 if (isempty(rvalue
)) {
1645 c
->selinux_context
= mfree(c
->selinux_context
);
1646 c
->selinux_context_ignore
= false;
1650 if (rvalue
[0] == '-') {
1656 r
= unit_full_printf(u
, rvalue
, &k
);
1658 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
1659 "Failed to resolve unit specifiers in '%s'%s: %m",
1660 rvalue
, ignore
? ", ignoring" : "");
1661 return ignore
? 0 : -ENOEXEC
;
1664 free_and_replace(c
->selinux_context
, k
);
1665 c
->selinux_context_ignore
= ignore
;
1670 int config_parse_exec_apparmor_profile(
1672 const char *filename
,
1674 const char *section
,
1675 unsigned section_line
,
1682 ExecContext
*c
= data
;
1683 const Unit
*u
= userdata
;
1693 if (isempty(rvalue
)) {
1694 c
->apparmor_profile
= mfree(c
->apparmor_profile
);
1695 c
->apparmor_profile_ignore
= false;
1699 if (rvalue
[0] == '-') {
1705 r
= unit_full_printf(u
, rvalue
, &k
);
1707 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
1708 "Failed to resolve unit specifiers in '%s'%s: %m",
1709 rvalue
, ignore
? ", ignoring" : "");
1710 return ignore
? 0 : -ENOEXEC
;
1713 free_and_replace(c
->apparmor_profile
, k
);
1714 c
->apparmor_profile_ignore
= ignore
;
1719 int config_parse_exec_smack_process_label(
1721 const char *filename
,
1723 const char *section
,
1724 unsigned section_line
,
1731 ExecContext
*c
= data
;
1732 const Unit
*u
= userdata
;
1742 if (isempty(rvalue
)) {
1743 c
->smack_process_label
= mfree(c
->smack_process_label
);
1744 c
->smack_process_label_ignore
= false;
1748 if (rvalue
[0] == '-') {
1754 r
= unit_full_printf(u
, rvalue
, &k
);
1756 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
1757 "Failed to resolve unit specifiers in '%s'%s: %m",
1758 rvalue
, ignore
? ", ignoring" : "");
1759 return ignore
? 0 : -ENOEXEC
;
1762 free_and_replace(c
->smack_process_label
, k
);
1763 c
->smack_process_label_ignore
= ignore
;
1768 int config_parse_timer(
1770 const char *filename
,
1772 const char *section
,
1773 unsigned section_line
,
1780 _cleanup_(calendar_spec_freep
) CalendarSpec
*c
= NULL
;
1781 _cleanup_free_
char *k
= NULL
;
1782 const Unit
*u
= userdata
;
1793 if (isempty(rvalue
)) {
1794 /* Empty assignment resets list */
1795 timer_free_values(t
);
1799 r
= unit_full_printf(u
, rvalue
, &k
);
1801 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
1805 if (ltype
== TIMER_CALENDAR
) {
1806 r
= calendar_spec_from_string(k
, &c
);
1808 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse calendar specification, ignoring: %s", k
);
1812 r
= parse_sec(k
, &usec
);
1814 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse timer value, ignoring: %s", k
);
1819 v
= new(TimerValue
, 1);
1826 .calendar_spec
= TAKE_PTR(c
),
1829 LIST_PREPEND(value
, t
->values
, v
);
1834 int config_parse_trigger_unit(
1836 const char *filename
,
1838 const char *section
,
1839 unsigned section_line
,
1846 _cleanup_free_
char *p
= NULL
;
1856 if (!hashmap_isempty(u
->dependencies
[UNIT_TRIGGERS
])) {
1857 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Multiple units to trigger specified, ignoring: %s", rvalue
);
1861 r
= unit_name_printf(u
, rvalue
, &p
);
1863 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue
);
1867 type
= unit_name_to_type(p
);
1869 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Unit type not valid, ignoring: %s", rvalue
);
1872 if (unit_has_name(u
, p
)) {
1873 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Units cannot trigger themselves, ignoring: %s", rvalue
);
1877 r
= unit_add_two_dependencies_by_name(u
, UNIT_BEFORE
, UNIT_TRIGGERS
, p
, true, UNIT_DEPENDENCY_FILE
);
1879 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to add trigger on %s, ignoring: %m", p
);
1886 int config_parse_path_spec(const char *unit
,
1887 const char *filename
,
1889 const char *section
,
1890 unsigned section_line
,
1900 _cleanup_free_
char *k
= NULL
;
1908 if (isempty(rvalue
)) {
1909 /* Empty assignment clears list */
1914 b
= path_type_from_string(lvalue
);
1916 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse path type, ignoring: %s", lvalue
);
1920 r
= unit_full_printf(UNIT(p
), rvalue
, &k
);
1922 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue
);
1926 r
= path_simplify_and_warn(k
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
1930 s
= new0(PathSpec
, 1);
1935 s
->path
= TAKE_PTR(k
);
1939 LIST_PREPEND(spec
, p
->specs
, s
);
1944 int config_parse_socket_service(
1946 const char *filename
,
1948 const char *section
,
1949 unsigned section_line
,
1956 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
1957 _cleanup_free_
char *p
= NULL
;
1967 r
= unit_name_printf(UNIT(s
), rvalue
, &p
);
1969 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", rvalue
);
1973 if (!endswith(p
, ".service")) {
1974 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Unit must be of type service: %s", rvalue
);
1978 r
= manager_load_unit(UNIT(s
)->manager
, p
, NULL
, &error
, &x
);
1980 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to load unit %s: %s", rvalue
, bus_error_message(&error
, r
));
1984 unit_ref_set(&s
->service
, UNIT(s
), x
);
1989 int config_parse_fdname(
1991 const char *filename
,
1993 const char *section
,
1994 unsigned section_line
,
2001 _cleanup_free_
char *p
= NULL
;
2010 if (isempty(rvalue
)) {
2011 s
->fdname
= mfree(s
->fdname
);
2015 r
= unit_full_printf(UNIT(s
), rvalue
, &p
);
2017 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
2021 if (!fdname_is_valid(p
)) {
2022 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid file descriptor name, ignoring: %s", p
);
2026 return free_and_replace(s
->fdname
, p
);
2029 int config_parse_service_sockets(
2031 const char *filename
,
2033 const char *section
,
2034 unsigned section_line
,
2052 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
2054 r
= extract_first_word(&p
, &word
, NULL
, 0);
2060 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Trailing garbage in sockets, ignoring: %s", rvalue
);
2064 r
= unit_name_printf(UNIT(s
), word
, &k
);
2066 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", word
);
2070 if (!endswith(k
, ".socket")) {
2071 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Unit must be of type socket, ignoring: %s", k
);
2075 r
= unit_add_two_dependencies_by_name(UNIT(s
), UNIT_WANTS
, UNIT_AFTER
, k
, true, UNIT_DEPENDENCY_FILE
);
2077 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to add dependency on %s, ignoring: %m", k
);
2079 r
= unit_add_dependency_by_name(UNIT(s
), UNIT_TRIGGERED_BY
, k
, true, UNIT_DEPENDENCY_FILE
);
2081 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to add dependency on %s, ignoring: %m", k
);
2087 int config_parse_bus_name(
2089 const char *filename
,
2091 const char *section
,
2092 unsigned section_line
,
2099 _cleanup_free_
char *k
= NULL
;
2100 const Unit
*u
= userdata
;
2108 r
= unit_full_printf(u
, rvalue
, &k
);
2110 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue
);
2114 if (!sd_bus_service_name_is_valid(k
)) {
2115 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid bus name, ignoring: %s", k
);
2119 return config_parse_string(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, k
, data
, userdata
);
2122 int config_parse_service_timeout(
2124 const char *filename
,
2126 const char *section
,
2127 unsigned section_line
,
2134 Service
*s
= userdata
;
2143 /* This is called for two cases: TimeoutSec= and TimeoutStartSec=. */
2145 /* Traditionally, these options accepted 0 to disable the timeouts. However, a timeout of 0 suggests it happens
2146 * immediately, hence fix this to become USEC_INFINITY instead. This is in-line with how we internally handle
2147 * all other timeouts. */
2148 r
= parse_sec_fix_0(rvalue
, &usec
);
2150 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s= parameter, ignoring: %s", lvalue
, rvalue
);
2154 s
->start_timeout_defined
= true;
2155 s
->timeout_start_usec
= usec
;
2157 if (streq(lvalue
, "TimeoutSec"))
2158 s
->timeout_stop_usec
= usec
;
2163 int config_parse_timeout_abort(
2165 const char *filename
,
2167 const char *section
,
2168 unsigned section_line
,
2183 /* Note: apart from setting the arg, this returns an extra bit of information in the return value. */
2185 if (isempty(rvalue
)) {
2187 return 0; /* "not set" */
2190 r
= parse_sec(rvalue
, ret
);
2192 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s= setting, ignoring: %s", lvalue
, rvalue
);
2194 return 1; /* "set" */
2197 int config_parse_service_timeout_abort(
2199 const char *filename
,
2201 const char *section
,
2202 unsigned section_line
,
2209 Service
*s
= userdata
;
2214 r
= config_parse_timeout_abort(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, rvalue
,
2215 &s
->timeout_abort_usec
, s
);
2217 s
->timeout_abort_set
= r
;
2221 int config_parse_sec_fix_0(
2223 const char *filename
,
2225 const char *section
,
2226 unsigned section_line
,
2233 usec_t
*usec
= data
;
2241 /* This is pretty much like config_parse_sec(), except that this treats a time of 0 as infinity, for
2242 * compatibility with older versions of systemd where 0 instead of infinity was used as indicator to turn off a
2245 r
= parse_sec_fix_0(rvalue
, usec
);
2247 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s= parameter, ignoring: %s", lvalue
, rvalue
);
2254 int config_parse_user_group_compat(
2256 const char *filename
,
2258 const char *section
,
2259 unsigned section_line
,
2266 _cleanup_free_
char *k
= NULL
;
2268 const Unit
*u
= userdata
;
2276 if (isempty(rvalue
)) {
2277 *user
= mfree(*user
);
2281 r
= unit_full_printf(u
, rvalue
, &k
);
2283 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", rvalue
);
2287 if (!valid_user_group_name(k
, VALID_USER_ALLOW_NUMERIC
|VALID_USER_RELAX
|VALID_USER_WARN
)) {
2288 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid user/group name or numeric ID: %s", k
);
2292 if (strstr(lvalue
, "User") && streq(k
, NOBODY_USER_NAME
))
2293 log_struct(LOG_NOTICE
,
2294 "MESSAGE=%s:%u: Special user %s configured, this is not safe!", filename
, line
, k
,
2296 "MESSAGE_ID=" SD_MESSAGE_NOBODY_USER_UNSUITABLE_STR
,
2297 "OFFENDING_USER=%s", k
,
2298 "CONFIG_FILE=%s", filename
,
2299 "CONFIG_LINE=%u", line
);
2301 return free_and_replace(*user
, k
);
2304 int config_parse_user_group_strv_compat(
2306 const char *filename
,
2308 const char *section
,
2309 unsigned section_line
,
2316 char ***users
= data
;
2317 const Unit
*u
= userdata
;
2318 const char *p
= rvalue
;
2326 if (isempty(rvalue
)) {
2327 *users
= strv_free(*users
);
2332 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
2334 r
= extract_first_word(&p
, &word
, NULL
, 0);
2340 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid syntax: %s", rvalue
);
2344 r
= unit_full_printf(u
, word
, &k
);
2346 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", word
);
2350 if (!valid_user_group_name(k
, VALID_USER_ALLOW_NUMERIC
|VALID_USER_RELAX
|VALID_USER_WARN
)) {
2351 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid user/group name or numeric ID: %s", k
);
2355 r
= strv_push(users
, k
);
2365 int config_parse_working_directory(
2367 const char *filename
,
2369 const char *section
,
2370 unsigned section_line
,
2377 ExecContext
*c
= data
;
2378 const Unit
*u
= userdata
;
2388 if (isempty(rvalue
)) {
2389 c
->working_directory_home
= false;
2390 c
->working_directory
= mfree(c
->working_directory
);
2394 if (rvalue
[0] == '-') {
2400 if (streq(rvalue
, "~")) {
2401 c
->working_directory_home
= true;
2402 c
->working_directory
= mfree(c
->working_directory
);
2404 _cleanup_free_
char *k
= NULL
;
2406 r
= unit_full_printf(u
, rvalue
, &k
);
2408 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2409 "Failed to resolve unit specifiers in working directory path '%s'%s: %m",
2410 rvalue
, missing_ok
? ", ignoring" : "");
2411 return missing_ok
? 0 : -ENOEXEC
;
2414 r
= path_simplify_and_warn(k
, PATH_CHECK_ABSOLUTE
| (missing_ok
? 0 : PATH_CHECK_FATAL
), unit
, filename
, line
, lvalue
);
2416 return missing_ok
? 0 : -ENOEXEC
;
2418 c
->working_directory_home
= false;
2419 free_and_replace(c
->working_directory
, k
);
2422 c
->working_directory_missing_ok
= missing_ok
;
2426 int config_parse_unit_env_file(const char *unit
,
2427 const char *filename
,
2429 const char *section
,
2430 unsigned section_line
,
2438 const Unit
*u
= userdata
;
2439 _cleanup_free_
char *n
= NULL
;
2447 if (isempty(rvalue
)) {
2448 /* Empty assignment frees the list */
2449 *env
= strv_free(*env
);
2453 r
= unit_full_printf(u
, rvalue
, &n
);
2455 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
2459 r
= path_simplify_and_warn(n
[0] == '-' ? n
+ 1 : n
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
2463 r
= strv_push(env
, n
);
2472 int config_parse_environ(
2474 const char *filename
,
2476 const char *section
,
2477 unsigned section_line
,
2484 const Unit
*u
= userdata
;
2494 if (isempty(rvalue
)) {
2495 /* Empty assignment resets the list */
2496 *env
= strv_free(*env
);
2500 for (p
= rvalue
;; ) {
2501 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
2503 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_CUNESCAPE
|EXTRACT_UNQUOTE
);
2509 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2510 "Invalid syntax, ignoring: %s", rvalue
);
2515 r
= unit_full_printf(u
, word
, &k
);
2517 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2518 "Failed to resolve unit specifiers in %s, ignoring: %m", word
);
2524 if (!env_assignment_is_valid(k
)) {
2525 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
2526 "Invalid environment assignment, ignoring: %s", k
);
2530 r
= strv_env_replace(env
, k
);
2538 int config_parse_pass_environ(
2540 const char *filename
,
2542 const char *section
,
2543 unsigned section_line
,
2550 _cleanup_strv_free_
char **n
= NULL
;
2551 size_t nlen
= 0, nbufsize
= 0;
2552 char*** passenv
= data
;
2553 const char *p
= rvalue
;
2554 const Unit
*u
= userdata
;
2562 if (isempty(rvalue
)) {
2563 /* Empty assignment resets the list */
2564 *passenv
= strv_free(*passenv
);
2569 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
2571 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
2577 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2578 "Trailing garbage in %s, ignoring: %s", lvalue
, rvalue
);
2583 r
= unit_full_printf(u
, word
, &k
);
2585 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2586 "Failed to resolve specifiers in %s, ignoring: %m", word
);
2592 if (!env_name_is_valid(k
)) {
2593 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
2594 "Invalid environment name for %s, ignoring: %s", lvalue
, k
);
2598 if (!GREEDY_REALLOC(n
, nbufsize
, nlen
+ 2))
2601 n
[nlen
++] = TAKE_PTR(k
);
2606 r
= strv_extend_strv(passenv
, n
, true);
2614 int config_parse_unset_environ(
2616 const char *filename
,
2618 const char *section
,
2619 unsigned section_line
,
2626 _cleanup_strv_free_
char **n
= NULL
;
2627 size_t nlen
= 0, nbufsize
= 0;
2628 char*** unsetenv
= data
;
2629 const char *p
= rvalue
;
2630 const Unit
*u
= userdata
;
2638 if (isempty(rvalue
)) {
2639 /* Empty assignment resets the list */
2640 *unsetenv
= strv_free(*unsetenv
);
2645 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
2647 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_CUNESCAPE
|EXTRACT_UNQUOTE
);
2653 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2654 "Trailing garbage in %s, ignoring: %s", lvalue
, rvalue
);
2659 r
= unit_full_printf(u
, word
, &k
);
2661 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2662 "Failed to resolve unit specifiers in %s, ignoring: %m", word
);
2668 if (!env_assignment_is_valid(k
) && !env_name_is_valid(k
)) {
2669 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
2670 "Invalid environment name or assignment %s, ignoring: %s", lvalue
, k
);
2674 if (!GREEDY_REALLOC(n
, nbufsize
, nlen
+ 2))
2677 n
[nlen
++] = TAKE_PTR(k
);
2682 r
= strv_extend_strv(unsetenv
, n
, true);
2690 int config_parse_log_extra_fields(
2692 const char *filename
,
2694 const char *section
,
2695 unsigned section_line
,
2702 ExecContext
*c
= data
;
2703 const Unit
*u
= userdata
;
2704 const char *p
= rvalue
;
2712 if (isempty(rvalue
)) {
2713 exec_context_free_log_extra_fields(c
);
2718 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
2722 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_CUNESCAPE
|EXTRACT_UNQUOTE
);
2728 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Invalid syntax, ignoring: %s", rvalue
);
2732 r
= unit_full_printf(u
, word
, &k
);
2734 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", word
);
2738 eq
= strchr(k
, '=');
2740 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Log field lacks '=' character, ignoring: %s", k
);
2744 if (!journal_field_valid(k
, eq
-k
, false)) {
2745 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Log field name is invalid, ignoring: %s", k
);
2749 t
= reallocarray(c
->log_extra_fields
, c
->n_log_extra_fields
+1, sizeof(struct iovec
));
2753 c
->log_extra_fields
= t
;
2754 c
->log_extra_fields
[c
->n_log_extra_fields
++] = IOVEC_MAKE_STRING(k
);
2760 int config_parse_log_namespace(
2762 const char *filename
,
2764 const char *section
,
2765 unsigned section_line
,
2772 _cleanup_free_
char *k
= NULL
;
2773 ExecContext
*c
= data
;
2774 const Unit
*u
= userdata
;
2782 if (isempty(rvalue
)) {
2783 c
->log_namespace
= mfree(c
->log_namespace
);
2787 r
= unit_full_printf(u
, rvalue
, &k
);
2789 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue
);
2793 if (!log_namespace_name_valid(k
)) {
2794 log_syntax(unit
, LOG_ERR
, filename
, line
, SYNTHETIC_ERRNO(EINVAL
), "Specified log namespace name is not valid: %s", k
);
2798 free_and_replace(c
->log_namespace
, k
);
2802 int config_parse_unit_condition_path(
2804 const char *filename
,
2806 const char *section
,
2807 unsigned section_line
,
2814 _cleanup_free_
char *p
= NULL
;
2815 Condition
**list
= data
, *c
;
2816 ConditionType t
= ltype
;
2817 bool trigger
, negate
;
2818 const Unit
*u
= userdata
;
2826 if (isempty(rvalue
)) {
2827 /* Empty assignment resets the list */
2828 *list
= condition_free_list(*list
);
2832 trigger
= rvalue
[0] == '|';
2836 negate
= rvalue
[0] == '!';
2840 r
= unit_full_printf(u
, rvalue
, &p
);
2842 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue
);
2846 r
= path_simplify_and_warn(p
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
2850 c
= condition_new(t
, p
, trigger
, negate
);
2854 LIST_PREPEND(conditions
, *list
, c
);
2858 int config_parse_unit_condition_string(
2860 const char *filename
,
2862 const char *section
,
2863 unsigned section_line
,
2870 _cleanup_free_
char *s
= NULL
;
2871 Condition
**list
= data
, *c
;
2872 ConditionType t
= ltype
;
2873 bool trigger
, negate
;
2874 const Unit
*u
= userdata
;
2882 if (isempty(rvalue
)) {
2883 /* Empty assignment resets the list */
2884 *list
= condition_free_list(*list
);
2888 trigger
= *rvalue
== '|';
2890 rvalue
+= 1 + strspn(rvalue
+ 1, WHITESPACE
);
2892 negate
= *rvalue
== '!';
2894 rvalue
+= 1 + strspn(rvalue
+ 1, WHITESPACE
);
2896 r
= unit_full_printf(u
, rvalue
, &s
);
2898 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
2899 "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
2903 c
= condition_new(t
, s
, trigger
, negate
);
2907 LIST_PREPEND(conditions
, *list
, c
);
2911 int config_parse_unit_condition_null(
2913 const char *filename
,
2915 const char *section
,
2916 unsigned section_line
,
2923 Condition
**list
= data
, *c
;
2924 bool trigger
, negate
;
2932 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0, "%s= is deprecated, please do not use.", lvalue
);
2934 if (isempty(rvalue
)) {
2935 /* Empty assignment resets the list */
2936 *list
= condition_free_list(*list
);
2940 trigger
= rvalue
[0] == '|';
2944 negate
= rvalue
[0] == '!';
2948 b
= parse_boolean(rvalue
);
2950 log_syntax(unit
, LOG_ERR
, filename
, line
, b
, "Failed to parse boolean value in condition, ignoring: %s", rvalue
);
2957 c
= condition_new(CONDITION_NULL
, NULL
, trigger
, negate
);
2961 LIST_PREPEND(conditions
, *list
, c
);
2965 int config_parse_unit_requires_mounts_for(
2967 const char *filename
,
2969 const char *section
,
2970 unsigned section_line
,
2977 const char *p
= rvalue
;
2987 _cleanup_free_
char *word
= NULL
, *resolved
= NULL
;
2989 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
2995 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2996 "Invalid syntax, ignoring: %s", rvalue
);
3000 r
= unit_full_printf(u
, word
, &resolved
);
3002 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", word
);
3006 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
3010 r
= unit_require_mounts_for(u
, resolved
, UNIT_DEPENDENCY_FILE
);
3012 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to add required mount '%s', ignoring: %m", resolved
);
3018 int config_parse_documentation(const char *unit
,
3019 const char *filename
,
3021 const char *section
,
3022 unsigned section_line
,
3038 if (isempty(rvalue
)) {
3039 /* Empty assignment resets the list */
3040 u
->documentation
= strv_free(u
->documentation
);
3044 r
= config_parse_unit_strv_printf(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
,
3045 rvalue
, data
, userdata
);
3049 for (a
= b
= u
->documentation
; a
&& *a
; a
++) {
3051 if (documentation_url_is_valid(*a
))
3054 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid URL, ignoring: %s", *a
);
3065 int config_parse_syscall_filter(
3067 const char *filename
,
3069 const char *section
,
3070 unsigned section_line
,
3077 ExecContext
*c
= data
;
3078 _unused_
const Unit
*u
= userdata
;
3079 bool invert
= false;
3088 if (isempty(rvalue
)) {
3089 /* Empty assignment resets the list */
3090 c
->syscall_filter
= hashmap_free(c
->syscall_filter
);
3091 c
->syscall_allow_list
= false;
3095 if (rvalue
[0] == '~') {
3100 if (!c
->syscall_filter
) {
3101 c
->syscall_filter
= hashmap_new(NULL
);
3102 if (!c
->syscall_filter
)
3106 /* Allow everything but the ones listed */
3107 c
->syscall_allow_list
= false;
3109 /* Allow nothing but the ones listed */
3110 c
->syscall_allow_list
= true;
3112 /* Accept default syscalls if we are on a allow_list */
3113 r
= seccomp_parse_syscall_filter(
3114 "@default", -1, c
->syscall_filter
,
3115 SECCOMP_PARSE_PERMISSIVE
|SECCOMP_PARSE_ALLOW_LIST
,
3125 _cleanup_free_
char *word
= NULL
, *name
= NULL
;
3128 r
= extract_first_word(&p
, &word
, NULL
, 0);
3134 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Invalid syntax, ignoring: %s", rvalue
);
3138 r
= parse_syscall_and_errno(word
, &name
, &num
);
3140 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Failed to parse syscall:errno, ignoring: %s", word
);
3144 r
= seccomp_parse_syscall_filter(
3145 name
, num
, c
->syscall_filter
,
3146 SECCOMP_PARSE_LOG
|SECCOMP_PARSE_PERMISSIVE
|
3147 (invert
? SECCOMP_PARSE_INVERT
: 0)|
3148 (c
->syscall_allow_list
? SECCOMP_PARSE_ALLOW_LIST
: 0),
3149 unit
, filename
, line
);
3155 int config_parse_syscall_archs(
3157 const char *filename
,
3159 const char *section
,
3160 unsigned section_line
,
3167 const char *p
= rvalue
;
3171 if (isempty(rvalue
)) {
3172 *archs
= set_free(*archs
);
3177 _cleanup_free_
char *word
= NULL
;
3180 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
3186 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3187 "Invalid syntax, ignoring: %s", rvalue
);
3191 r
= seccomp_arch_from_string(word
, &a
);
3193 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
3194 "Failed to parse system call architecture \"%s\", ignoring: %m", word
);
3198 r
= set_ensure_put(archs
, NULL
, UINT32_TO_PTR(a
+ 1));
3204 int config_parse_syscall_errno(
3206 const char *filename
,
3208 const char *section
,
3209 unsigned section_line
,
3216 ExecContext
*c
= data
;
3223 if (isempty(rvalue
)) {
3224 /* Empty assignment resets to KILL */
3225 c
->syscall_errno
= 0;
3229 e
= parse_errno(rvalue
);
3231 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse error number, ignoring: %s", rvalue
);
3235 c
->syscall_errno
= e
;
3239 int config_parse_address_families(
3241 const char *filename
,
3243 const char *section
,
3244 unsigned section_line
,
3251 ExecContext
*c
= data
;
3252 bool invert
= false;
3260 if (isempty(rvalue
)) {
3261 /* Empty assignment resets the list */
3262 c
->address_families
= set_free(c
->address_families
);
3263 c
->address_families_allow_list
= false;
3267 if (rvalue
[0] == '~') {
3272 if (!c
->address_families
) {
3273 c
->address_families
= set_new(NULL
);
3274 if (!c
->address_families
)
3277 c
->address_families_allow_list
= !invert
;
3280 for (p
= rvalue
;;) {
3281 _cleanup_free_
char *word
= NULL
;
3284 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
3290 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3291 "Invalid syntax, ignoring: %s", rvalue
);
3295 af
= af_from_name(word
);
3297 log_syntax(unit
, LOG_ERR
, filename
, line
, af
,
3298 "Failed to parse address family, ignoring: %s", word
);
3302 /* If we previously wanted to forbid an address family and now
3303 * we want to allow it, then just remove it from the list.
3305 if (!invert
== c
->address_families_allow_list
) {
3306 r
= set_put(c
->address_families
, INT_TO_PTR(af
));
3310 set_remove(c
->address_families
, INT_TO_PTR(af
));
3314 int config_parse_restrict_namespaces(
3316 const char *filename
,
3318 const char *section
,
3319 unsigned section_line
,
3326 ExecContext
*c
= data
;
3327 unsigned long flags
;
3328 bool invert
= false;
3331 if (isempty(rvalue
)) {
3332 /* Reset to the default. */
3333 c
->restrict_namespaces
= NAMESPACE_FLAGS_INITIAL
;
3337 /* Boolean parameter ignores the previous settings */
3338 r
= parse_boolean(rvalue
);
3340 c
->restrict_namespaces
= 0;
3342 } else if (r
== 0) {
3343 c
->restrict_namespaces
= NAMESPACE_FLAGS_ALL
;
3347 if (rvalue
[0] == '~') {
3352 /* Not a boolean argument, in this case it's a list of namespace types. */
3353 r
= namespace_flags_from_string(rvalue
, &flags
);
3355 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse namespace type string, ignoring: %s", rvalue
);
3359 if (c
->restrict_namespaces
== NAMESPACE_FLAGS_INITIAL
)
3360 /* Initial assignment. Just set the value. */
3361 c
->restrict_namespaces
= invert
? (~flags
) & NAMESPACE_FLAGS_ALL
: flags
;
3363 /* Merge the value with the previous one. */
3364 SET_FLAG(c
->restrict_namespaces
, flags
, !invert
);
3370 int config_parse_unit_slice(
3372 const char *filename
,
3374 const char *section
,
3375 unsigned section_line
,
3382 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
3383 _cleanup_free_
char *k
= NULL
;
3384 Unit
*u
= userdata
, *slice
;
3392 r
= unit_name_printf(u
, rvalue
, &k
);
3394 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue
);
3398 r
= manager_load_unit(u
->manager
, k
, NULL
, &error
, &slice
);
3400 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to load slice unit %s, ignoring: %s", k
, bus_error_message(&error
, r
));
3404 r
= unit_set_slice(u
, slice
);
3406 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to assign slice %s to unit %s, ignoring: %m", slice
->id
, u
->id
);
3413 int config_parse_cpu_quota(
3415 const char *filename
,
3417 const char *section
,
3418 unsigned section_line
,
3425 CGroupContext
*c
= data
;
3432 if (isempty(rvalue
)) {
3433 c
->cpu_quota_per_sec_usec
= USEC_INFINITY
;
3437 r
= parse_permille_unbounded(rvalue
);
3439 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid CPU quota '%s', ignoring.", rvalue
);
3443 c
->cpu_quota_per_sec_usec
= ((usec_t
) r
* USEC_PER_SEC
) / 1000U;
3447 int config_parse_allowed_cpus(
3449 const char *filename
,
3451 const char *section
,
3452 unsigned section_line
,
3459 CGroupContext
*c
= data
;
3461 (void) parse_cpu_set_extend(rvalue
, &c
->cpuset_cpus
, true, unit
, filename
, line
, lvalue
);
3466 int config_parse_allowed_mems(
3468 const char *filename
,
3470 const char *section
,
3471 unsigned section_line
,
3478 CGroupContext
*c
= data
;
3480 (void) parse_cpu_set_extend(rvalue
, &c
->cpuset_mems
, true, unit
, filename
, line
, lvalue
);
3485 int config_parse_memory_limit(
3487 const char *filename
,
3489 const char *section
,
3490 unsigned section_line
,
3497 CGroupContext
*c
= data
;
3498 uint64_t bytes
= CGROUP_LIMIT_MAX
;
3501 if (isempty(rvalue
) && STR_IN_SET(lvalue
, "DefaultMemoryLow",
3505 bytes
= CGROUP_LIMIT_MIN
;
3506 else if (!isempty(rvalue
) && !streq(rvalue
, "infinity")) {
3508 r
= parse_permille(rvalue
);
3510 r
= parse_size(rvalue
, 1024, &bytes
);
3512 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid memory limit '%s', ignoring: %m", rvalue
);
3516 bytes
= physical_memory_scale(r
, 1000U);
3518 if (bytes
>= UINT64_MAX
||
3519 (bytes
<= 0 && !STR_IN_SET(lvalue
, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
3520 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Memory limit '%s' out of range, ignoring.", rvalue
);
3525 if (streq(lvalue
, "DefaultMemoryLow")) {
3526 c
->default_memory_low
= bytes
;
3527 c
->default_memory_low_set
= true;
3528 } else if (streq(lvalue
, "DefaultMemoryMin")) {
3529 c
->default_memory_min
= bytes
;
3530 c
->default_memory_min_set
= true;
3531 } else if (streq(lvalue
, "MemoryMin")) {
3532 c
->memory_min
= bytes
;
3533 c
->memory_min_set
= true;
3534 } else if (streq(lvalue
, "MemoryLow")) {
3535 c
->memory_low
= bytes
;
3536 c
->memory_low_set
= true;
3537 } else if (streq(lvalue
, "MemoryHigh"))
3538 c
->memory_high
= bytes
;
3539 else if (streq(lvalue
, "MemoryMax"))
3540 c
->memory_max
= bytes
;
3541 else if (streq(lvalue
, "MemorySwapMax"))
3542 c
->memory_swap_max
= bytes
;
3543 else if (streq(lvalue
, "MemoryLimit"))
3544 c
->memory_limit
= bytes
;
3551 int config_parse_tasks_max(
3553 const char *filename
,
3555 const char *section
,
3556 unsigned section_line
,
3563 const Unit
*u
= userdata
;
3564 TasksMax
*tasks_max
= data
;
3568 if (isempty(rvalue
)) {
3569 *tasks_max
= u
? u
->manager
->default_tasks_max
: TASKS_MAX_UNSET
;
3573 if (streq(rvalue
, "infinity")) {
3574 *tasks_max
= TASKS_MAX_UNSET
;
3578 r
= parse_permille(rvalue
);
3580 *tasks_max
= (TasksMax
) { r
, 1000U }; /* r‰ */
3582 r
= safe_atou64(rvalue
, &v
);
3584 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid maximum tasks value '%s', ignoring: %m", rvalue
);
3588 if (v
<= 0 || v
>= UINT64_MAX
) {
3589 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Maximum tasks value '%s' out of range, ignoring.", rvalue
);
3593 *tasks_max
= (TasksMax
) { v
};
3599 int config_parse_delegate(
3601 const char *filename
,
3603 const char *section
,
3604 unsigned section_line
,
3611 CGroupContext
*c
= data
;
3615 t
= unit_name_to_type(unit
);
3616 assert(t
!= _UNIT_TYPE_INVALID
);
3618 if (!unit_vtable
[t
]->can_delegate
) {
3619 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Delegate= setting not supported for this unit type, ignoring.");
3623 /* We either accept a boolean value, which may be used to turn on delegation for all controllers, or turn it
3624 * off for all. Or it takes a list of controller names, in which case we add the specified controllers to the
3625 * mask to delegate. */
3627 if (isempty(rvalue
)) {
3628 /* An empty string resets controllers and set Delegate=yes. */
3630 c
->delegate_controllers
= 0;
3634 r
= parse_boolean(rvalue
);
3636 const char *p
= rvalue
;
3637 CGroupMask mask
= 0;
3640 _cleanup_free_
char *word
= NULL
;
3641 CGroupController cc
;
3643 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
3649 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid syntax, ignoring: %s", rvalue
);
3653 cc
= cgroup_controller_from_string(word
);
3655 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid controller name '%s', ignoring", word
);
3659 mask
|= CGROUP_CONTROLLER_TO_MASK(cc
);
3663 c
->delegate_controllers
|= mask
;
3667 c
->delegate_controllers
= _CGROUP_MASK_ALL
;
3669 c
->delegate
= false;
3670 c
->delegate_controllers
= 0;
3676 int config_parse_device_allow(
3678 const char *filename
,
3680 const char *section
,
3681 unsigned section_line
,
3688 _cleanup_free_
char *path
= NULL
, *resolved
= NULL
;
3689 CGroupContext
*c
= data
;
3690 const char *p
= rvalue
;
3693 if (isempty(rvalue
)) {
3694 while (c
->device_allow
)
3695 cgroup_context_free_device_allow(c
, c
->device_allow
);
3700 r
= extract_first_word(&p
, &path
, NULL
, EXTRACT_UNQUOTE
);
3704 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3705 "Invalid syntax, ignoring: %s", rvalue
);
3709 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
3710 "Failed to extract device path and rights from '%s', ignoring.", rvalue
);
3714 r
= unit_full_printf(userdata
, path
, &resolved
);
3716 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3717 "Failed to resolve unit specifiers in '%s', ignoring: %m", path
);
3721 if (!STARTSWITH_SET(resolved
, "block-", "char-")) {
3723 r
= path_simplify_and_warn(resolved
, 0, unit
, filename
, line
, lvalue
);
3727 if (!valid_device_node_path(resolved
)) {
3728 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid device node path '%s', ignoring.", resolved
);
3733 if (!isempty(p
) && !in_charset(p
, "rwm")) {
3734 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid device rights '%s', ignoring.", p
);
3738 return cgroup_add_device_allow(c
, resolved
, p
);
3741 int config_parse_io_device_weight(
3743 const char *filename
,
3745 const char *section
,
3746 unsigned section_line
,
3753 _cleanup_free_
char *path
= NULL
, *resolved
= NULL
;
3754 CGroupIODeviceWeight
*w
;
3755 CGroupContext
*c
= data
;
3756 const char *p
= rvalue
;
3764 if (isempty(rvalue
)) {
3765 while (c
->io_device_weights
)
3766 cgroup_context_free_io_device_weight(c
, c
->io_device_weights
);
3771 r
= extract_first_word(&p
, &path
, NULL
, EXTRACT_UNQUOTE
);
3775 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3776 "Invalid syntax, ignoring: %s", rvalue
);
3779 if (r
== 0 || isempty(p
)) {
3780 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
3781 "Failed to extract device path and weight from '%s', ignoring.", rvalue
);
3785 r
= unit_full_printf(userdata
, path
, &resolved
);
3787 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3788 "Failed to resolve unit specifiers in '%s', ignoring: %m", path
);
3792 r
= path_simplify_and_warn(resolved
, 0, unit
, filename
, line
, lvalue
);
3796 r
= cg_weight_parse(p
, &u
);
3798 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "IO weight '%s' invalid, ignoring: %m", p
);
3802 assert(u
!= CGROUP_WEIGHT_INVALID
);
3804 w
= new0(CGroupIODeviceWeight
, 1);
3808 w
->path
= TAKE_PTR(resolved
);
3811 LIST_PREPEND(device_weights
, c
->io_device_weights
, w
);
3815 int config_parse_io_device_latency(
3817 const char *filename
,
3819 const char *section
,
3820 unsigned section_line
,
3827 _cleanup_free_
char *path
= NULL
, *resolved
= NULL
;
3828 CGroupIODeviceLatency
*l
;
3829 CGroupContext
*c
= data
;
3830 const char *p
= rvalue
;
3838 if (isempty(rvalue
)) {
3839 while (c
->io_device_latencies
)
3840 cgroup_context_free_io_device_latency(c
, c
->io_device_latencies
);
3845 r
= extract_first_word(&p
, &path
, NULL
, EXTRACT_UNQUOTE
);
3849 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3850 "Invalid syntax, ignoring: %s", rvalue
);
3853 if (r
== 0 || isempty(p
)) {
3854 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
3855 "Failed to extract device path and latency from '%s', ignoring.", rvalue
);
3859 r
= unit_full_printf(userdata
, path
, &resolved
);
3861 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3862 "Failed to resolve unit specifiers in '%s', ignoring: %m", path
);
3866 r
= path_simplify_and_warn(resolved
, 0, unit
, filename
, line
, lvalue
);
3870 if (parse_sec(p
, &usec
) < 0) {
3871 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse timer value, ignoring: %s", p
);
3875 l
= new0(CGroupIODeviceLatency
, 1);
3879 l
->path
= TAKE_PTR(resolved
);
3880 l
->target_usec
= usec
;
3882 LIST_PREPEND(device_latencies
, c
->io_device_latencies
, l
);
3886 int config_parse_io_limit(
3888 const char *filename
,
3890 const char *section
,
3891 unsigned section_line
,
3898 _cleanup_free_
char *path
= NULL
, *resolved
= NULL
;
3899 CGroupIODeviceLimit
*l
= NULL
, *t
;
3900 CGroupContext
*c
= data
;
3901 CGroupIOLimitType type
;
3902 const char *p
= rvalue
;
3910 type
= cgroup_io_limit_type_from_string(lvalue
);
3913 if (isempty(rvalue
)) {
3914 LIST_FOREACH(device_limits
, l
, c
->io_device_limits
)
3915 l
->limits
[type
] = cgroup_io_limit_defaults
[type
];
3919 r
= extract_first_word(&p
, &path
, NULL
, EXTRACT_UNQUOTE
);
3923 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3924 "Invalid syntax, ignoring: %s", rvalue
);
3927 if (r
== 0 || isempty(p
)) {
3928 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
3929 "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue
);
3933 r
= unit_full_printf(userdata
, path
, &resolved
);
3935 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
3936 "Failed to resolve unit specifiers in '%s', ignoring: %m", path
);
3940 r
= path_simplify_and_warn(resolved
, 0, unit
, filename
, line
, lvalue
);
3944 if (streq("infinity", p
))
3945 num
= CGROUP_LIMIT_MAX
;
3947 r
= parse_size(p
, 1000, &num
);
3948 if (r
< 0 || num
<= 0) {
3949 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid IO limit '%s', ignoring.", p
);
3954 LIST_FOREACH(device_limits
, t
, c
->io_device_limits
) {
3955 if (path_equal(resolved
, t
->path
)) {
3962 CGroupIOLimitType ttype
;
3964 l
= new0(CGroupIODeviceLimit
, 1);
3968 l
->path
= TAKE_PTR(resolved
);
3969 for (ttype
= 0; ttype
< _CGROUP_IO_LIMIT_TYPE_MAX
; ttype
++)
3970 l
->limits
[ttype
] = cgroup_io_limit_defaults
[ttype
];
3972 LIST_PREPEND(device_limits
, c
->io_device_limits
, l
);
3975 l
->limits
[type
] = num
;
3980 int config_parse_blockio_device_weight(
3982 const char *filename
,
3984 const char *section
,
3985 unsigned section_line
,
3992 _cleanup_free_
char *path
= NULL
, *resolved
= NULL
;
3993 CGroupBlockIODeviceWeight
*w
;
3994 CGroupContext
*c
= data
;
3995 const char *p
= rvalue
;
4003 if (isempty(rvalue
)) {
4004 while (c
->blockio_device_weights
)
4005 cgroup_context_free_blockio_device_weight(c
, c
->blockio_device_weights
);
4010 r
= extract_first_word(&p
, &path
, NULL
, EXTRACT_UNQUOTE
);
4014 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
4015 "Invalid syntax, ignoring: %s", rvalue
);
4018 if (r
== 0 || isempty(p
)) {
4019 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
4020 "Failed to extract device node and weight from '%s', ignoring.", rvalue
);
4024 r
= unit_full_printf(userdata
, path
, &resolved
);
4026 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
4027 "Failed to resolve unit specifiers in '%s', ignoring: %m", path
);
4031 r
= path_simplify_and_warn(resolved
, 0, unit
, filename
, line
, lvalue
);
4035 r
= cg_blkio_weight_parse(p
, &u
);
4037 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid block IO weight '%s', ignoring: %m", p
);
4041 assert(u
!= CGROUP_BLKIO_WEIGHT_INVALID
);
4043 w
= new0(CGroupBlockIODeviceWeight
, 1);
4047 w
->path
= TAKE_PTR(resolved
);
4050 LIST_PREPEND(device_weights
, c
->blockio_device_weights
, w
);
4054 int config_parse_blockio_bandwidth(
4056 const char *filename
,
4058 const char *section
,
4059 unsigned section_line
,
4066 _cleanup_free_
char *path
= NULL
, *resolved
= NULL
;
4067 CGroupBlockIODeviceBandwidth
*b
= NULL
, *t
;
4068 CGroupContext
*c
= data
;
4069 const char *p
= rvalue
;
4078 read
= streq("BlockIOReadBandwidth", lvalue
);
4080 if (isempty(rvalue
)) {
4081 LIST_FOREACH(device_bandwidths
, b
, c
->blockio_device_bandwidths
) {
4082 b
->rbps
= CGROUP_LIMIT_MAX
;
4083 b
->wbps
= CGROUP_LIMIT_MAX
;
4088 r
= extract_first_word(&p
, &path
, NULL
, EXTRACT_UNQUOTE
);
4092 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
4093 "Invalid syntax, ignoring: %s", rvalue
);
4096 if (r
== 0 || isempty(p
)) {
4097 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
4098 "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue
);
4102 r
= unit_full_printf(userdata
, path
, &resolved
);
4104 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
4105 "Failed to resolve unit specifiers in '%s', ignoring: %m", path
);
4109 r
= path_simplify_and_warn(resolved
, 0, unit
, filename
, line
, lvalue
);
4113 r
= parse_size(p
, 1000, &bytes
);
4114 if (r
< 0 || bytes
<= 0) {
4115 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid Block IO Bandwidth '%s', ignoring.", p
);
4119 LIST_FOREACH(device_bandwidths
, t
, c
->blockio_device_bandwidths
) {
4120 if (path_equal(resolved
, t
->path
)) {
4127 b
= new0(CGroupBlockIODeviceBandwidth
, 1);
4131 b
->path
= TAKE_PTR(resolved
);
4132 b
->rbps
= CGROUP_LIMIT_MAX
;
4133 b
->wbps
= CGROUP_LIMIT_MAX
;
4135 LIST_PREPEND(device_bandwidths
, c
->blockio_device_bandwidths
, b
);
4146 int config_parse_job_mode_isolate(
4148 const char *filename
,
4150 const char *section
,
4151 unsigned section_line
,
4165 r
= parse_boolean(rvalue
);
4167 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse boolean, ignoring: %s", rvalue
);
4171 log_notice("%s is deprecated. Please use OnFailureJobMode= instead", lvalue
);
4173 *m
= r
? JOB_ISOLATE
: JOB_REPLACE
;
4177 int config_parse_exec_directories(
4179 const char *filename
,
4181 const char *section
,
4182 unsigned section_line
,
4190 const Unit
*u
= userdata
;
4199 if (isempty(rvalue
)) {
4200 /* Empty assignment resets the list */
4201 *rt
= strv_free(*rt
);
4205 for (p
= rvalue
;;) {
4206 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
4208 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
4212 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
4213 "Invalid syntax, ignoring: %s", rvalue
);
4219 r
= unit_full_printf(u
, word
, &k
);
4221 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
4222 "Failed to resolve unit specifiers in \"%s\", ignoring: %m", word
);
4226 r
= path_simplify_and_warn(k
, PATH_CHECK_RELATIVE
, unit
, filename
, line
, lvalue
);
4230 if (path_startswith(k
, "private")) {
4231 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
4232 "%s= path can't be 'private', ignoring assignment: %s", lvalue
, word
);
4236 r
= strv_push(rt
, k
);
4243 int config_parse_set_status(
4245 const char *filename
,
4247 const char *section
,
4248 unsigned section_line
,
4256 const char *word
, *state
;
4258 ExitStatusSet
*status_set
= data
;
4265 /* Empty assignment resets the list */
4266 if (isempty(rvalue
)) {
4267 exit_status_set_free(status_set
);
4271 FOREACH_WORD(word
, l
, rvalue
, state
) {
4272 _cleanup_free_
char *temp
;
4275 temp
= strndup(word
, l
);
4279 /* We need to call exit_status_from_string() first, because we want
4280 * to parse numbers as exit statuses, not signals. */
4282 r
= exit_status_from_string(temp
);
4284 assert(r
>= 0 && r
< 256);
4285 bitmap
= &status_set
->status
;
4287 r
= signal_from_string(temp
);
4290 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
4291 "Failed to parse value, ignoring: %s", word
);
4294 bitmap
= &status_set
->signal
;
4297 r
= bitmap_set(bitmap
, r
);
4299 return log_error_errno(r
, "Failed to set signal or status %s: %m", word
);
4301 if (!isempty(state
))
4302 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Trailing garbage, ignoring.");
4307 int config_parse_namespace_path_strv(
4309 const char *filename
,
4311 const char *section
,
4312 unsigned section_line
,
4319 const Unit
*u
= userdata
;
4321 const char *p
= rvalue
;
4329 if (isempty(rvalue
)) {
4330 /* Empty assignment resets the list */
4331 *sv
= strv_free(*sv
);
4336 _cleanup_free_
char *word
= NULL
, *resolved
= NULL
, *joined
= NULL
;
4338 bool ignore_enoent
= false, shall_prefix
= false;
4340 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
4346 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract first word, ignoring: %s", rvalue
);
4351 if (startswith(w
, "-")) {
4352 ignore_enoent
= true;
4355 if (startswith(w
, "+")) {
4356 shall_prefix
= true;
4360 r
= unit_full_printf(u
, w
, &resolved
);
4362 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s: %m", w
);
4366 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
4370 joined
= strjoin(ignore_enoent
? "-" : "",
4371 shall_prefix
? "+" : "",
4374 r
= strv_push(sv
, joined
);
4384 int config_parse_temporary_filesystems(
4386 const char *filename
,
4388 const char *section
,
4389 unsigned section_line
,
4396 const Unit
*u
= userdata
;
4397 ExecContext
*c
= data
;
4398 const char *p
= rvalue
;
4406 if (isempty(rvalue
)) {
4407 /* Empty assignment resets the list */
4408 temporary_filesystem_free_many(c
->temporary_filesystems
, c
->n_temporary_filesystems
);
4409 c
->temporary_filesystems
= NULL
;
4410 c
->n_temporary_filesystems
= 0;
4415 _cleanup_free_
char *word
= NULL
, *path
= NULL
, *resolved
= NULL
;
4418 r
= extract_first_word(&p
, &word
, NULL
, EXTRACT_UNQUOTE
);
4424 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract first word, ignoring: %s", rvalue
);
4429 r
= extract_first_word(&w
, &path
, ":", EXTRACT_DONT_COALESCE_SEPARATORS
);
4433 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract first word, ignoring: %s", word
);
4437 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid syntax, ignoring: %s", word
);
4441 r
= unit_full_printf(u
, path
, &resolved
);
4443 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in %s, ignoring: %m", path
);
4447 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
4451 r
= temporary_filesystem_add(&c
->temporary_filesystems
, &c
->n_temporary_filesystems
, resolved
, w
);
4457 int config_parse_bind_paths(
4459 const char *filename
,
4461 const char *section
,
4462 unsigned section_line
,
4469 ExecContext
*c
= data
;
4470 const Unit
*u
= userdata
;
4479 if (isempty(rvalue
)) {
4480 /* Empty assignment resets the list */
4481 bind_mount_free_many(c
->bind_mounts
, c
->n_bind_mounts
);
4482 c
->bind_mounts
= NULL
;
4483 c
->n_bind_mounts
= 0;
4489 _cleanup_free_
char *source
= NULL
, *destination
= NULL
;
4490 _cleanup_free_
char *sresolved
= NULL
, *dresolved
= NULL
;
4491 char *s
= NULL
, *d
= NULL
;
4492 bool rbind
= true, ignore_enoent
= false;
4494 r
= extract_first_word(&p
, &source
, ":" WHITESPACE
, EXTRACT_UNQUOTE
|EXTRACT_DONT_COALESCE_SEPARATORS
);
4500 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s, ignoring: %s", lvalue
, rvalue
);
4504 r
= unit_full_printf(u
, source
, &sresolved
);
4506 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
4507 "Failed to resolved unit specifiers in \"%s\", ignoring: %m", source
);
4513 ignore_enoent
= true;
4517 r
= path_simplify_and_warn(s
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
4521 /* Optionally, the destination is specified. */
4522 if (p
&& p
[-1] == ':') {
4523 r
= extract_first_word(&p
, &destination
, ":" WHITESPACE
, EXTRACT_UNQUOTE
|EXTRACT_DONT_COALESCE_SEPARATORS
);
4527 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s, ignoring: %s", lvalue
, rvalue
);
4531 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Missing argument after ':', ignoring: %s", s
);
4535 r
= unit_full_printf(u
, destination
, &dresolved
);
4537 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
4538 "Failed to resolved specifiers in \"%s\", ignoring: %m", destination
);
4542 r
= path_simplify_and_warn(dresolved
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
4548 /* Optionally, there's also a short option string specified */
4549 if (p
&& p
[-1] == ':') {
4550 _cleanup_free_
char *options
= NULL
;
4552 r
= extract_first_word(&p
, &options
, NULL
, EXTRACT_UNQUOTE
);
4556 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse %s: %s", lvalue
, rvalue
);
4560 if (isempty(options
) || streq(options
, "rbind"))
4562 else if (streq(options
, "norbind"))
4565 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid option string, ignoring setting: %s", options
);
4572 r
= bind_mount_add(&c
->bind_mounts
, &c
->n_bind_mounts
,
4576 .read_only
= !!strstr(lvalue
, "ReadOnly"),
4578 .ignore_enoent
= ignore_enoent
,
4587 int config_parse_job_timeout_sec(
4589 const char *filename
,
4591 const char *section
,
4592 unsigned section_line
,
4608 r
= parse_sec_fix_0(rvalue
, &usec
);
4610 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse JobTimeoutSec= parameter, ignoring: %s", rvalue
);
4614 /* If the user explicitly changed JobTimeoutSec= also change JobRunningTimeoutSec=, for compatibility with old
4615 * versions. If JobRunningTimeoutSec= was explicitly set, avoid this however as whatever the user picked should
4618 if (!u
->job_running_timeout_set
)
4619 u
->job_running_timeout
= usec
;
4621 u
->job_timeout
= usec
;
4626 int config_parse_job_running_timeout_sec(
4628 const char *filename
,
4630 const char *section
,
4631 unsigned section_line
,
4647 r
= parse_sec_fix_0(rvalue
, &usec
);
4649 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse JobRunningTimeoutSec= parameter, ignoring: %s", rvalue
);
4653 u
->job_running_timeout
= usec
;
4654 u
->job_running_timeout_set
= true;
4659 int config_parse_emergency_action(
4661 const char *filename
,
4663 const char *section
,
4664 unsigned section_line
,
4672 EmergencyAction
*x
= data
;
4681 m
= ((Unit
*) userdata
)->manager
;
4685 r
= parse_emergency_action(rvalue
, MANAGER_IS_SYSTEM(m
), x
);
4687 if (r
== -EOPNOTSUPP
&& MANAGER_IS_USER(m
)) {
4688 /* Compat mode: remove for systemd 241. */
4690 log_syntax(unit
, LOG_INFO
, filename
, line
, r
,
4691 "%s= in user mode specified as \"%s\", using \"exit-force\" instead.",
4693 *x
= EMERGENCY_ACTION_EXIT_FORCE
;
4697 if (r
== -EOPNOTSUPP
)
4698 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
4699 "%s= specified as %s mode action, ignoring: %s",
4700 lvalue
, MANAGER_IS_SYSTEM(m
) ? "user" : "system", rvalue
);
4702 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
4703 "Failed to parse %s=, ignoring: %s", lvalue
, rvalue
);
4710 int config_parse_pid_file(
4712 const char *filename
,
4714 const char *section
,
4715 unsigned section_line
,
4722 _cleanup_free_
char *k
= NULL
, *n
= NULL
;
4723 const Unit
*u
= userdata
;
4732 if (isempty(rvalue
)) {
4733 /* An empty assignment removes already set value. */
4738 r
= unit_full_printf(u
, rvalue
, &k
);
4740 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
4744 /* If this is a relative path make it absolute by prefixing the /run */
4745 n
= path_make_absolute(k
, u
->manager
->prefix
[EXEC_DIRECTORY_RUNTIME
]);
4749 /* Check that the result is a sensible path */
4750 r
= path_simplify_and_warn(n
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
4754 r
= patch_var_run(unit
, filename
, line
, lvalue
, &n
);
4758 free_and_replace(*s
, n
);
4762 int config_parse_exit_status(
4764 const char *filename
,
4766 const char *section
,
4767 unsigned section_line
,
4774 int *exit_status
= data
, r
;
4780 assert(exit_status
);
4782 if (isempty(rvalue
)) {
4787 r
= safe_atou8(rvalue
, &u
);
4789 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse exit status '%s', ignoring: %m", rvalue
);
4797 int config_parse_disable_controllers(
4799 const char *filename
,
4801 const char *section
,
4802 unsigned section_line
,
4810 CGroupContext
*c
= data
;
4811 CGroupMask disabled_mask
;
4813 /* 1. If empty, make all controllers eligible for use again.
4814 * 2. If non-empty, merge all listed controllers, space separated. */
4816 if (isempty(rvalue
)) {
4817 c
->disable_controllers
= 0;
4821 r
= cg_mask_from_string(rvalue
, &disabled_mask
);
4822 if (r
< 0 || disabled_mask
<= 0) {
4823 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid cgroup string: %s, ignoring", rvalue
);
4827 c
->disable_controllers
|= disabled_mask
;
4832 int config_parse_ip_filter_bpf_progs(
4834 const char *filename
,
4836 const char *section
,
4837 unsigned section_line
,
4844 _cleanup_free_
char *resolved
= NULL
;
4845 const Unit
*u
= userdata
;
4846 char ***paths
= data
;
4854 if (isempty(rvalue
)) {
4855 *paths
= strv_free(*paths
);
4859 r
= unit_full_printf(u
, rvalue
, &resolved
);
4861 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue
);
4865 r
= path_simplify_and_warn(resolved
, PATH_CHECK_ABSOLUTE
, unit
, filename
, line
, lvalue
);
4869 if (strv_contains(*paths
, resolved
))
4872 r
= strv_extend(paths
, resolved
);
4876 r
= bpf_firewall_supported();
4879 if (r
!= BPF_FIREWALL_SUPPORTED_WITH_MULTI
) {
4880 static bool warned
= false;
4882 log_full(warned
? LOG_DEBUG
: LOG_WARNING
,
4883 "File %s:%u configures an IP firewall with BPF programs (%s=%s), but the local system does not support BPF/cgroup based firewalling with multiple filters.\n"
4884 "Starting this unit will fail! (This warning is only shown for the first loaded unit using IP firewalling.)", filename
, line
, lvalue
, rvalue
);
4892 static int merge_by_names(Unit
**u
, Set
*names
, const char *id
) {
4899 /* Let's try to add in all names that are aliases of this unit */
4900 while ((k
= set_steal_first(names
))) {
4901 _cleanup_free_ _unused_
char *free_k
= k
;
4903 /* First try to merge in the other name into our unit */
4904 r
= unit_merge_by_name(*u
, k
);
4908 /* Hmm, we couldn't merge the other unit into ours? Then let's try it the other way
4911 other
= manager_get_unit((*u
)->manager
, k
);
4913 return r
; /* return previous failure */
4915 r
= unit_merge(other
, *u
);
4920 return merge_by_names(u
, names
, NULL
);
4923 if (streq_ptr(id
, k
))
4924 unit_choose_id(*u
, id
);
4930 int unit_load_fragment(Unit
*u
) {
4931 const char *fragment
;
4932 _cleanup_set_free_free_ Set
*names
= NULL
;
4936 assert(u
->load_state
== UNIT_STUB
);
4940 u
->load_state
= UNIT_LOADED
;
4944 /* Possibly rebuild the fragment map to catch new units */
4945 r
= unit_file_build_name_map(&u
->manager
->lookup_paths
,
4946 &u
->manager
->unit_cache_mtime
,
4947 &u
->manager
->unit_id_map
,
4948 &u
->manager
->unit_name_map
,
4949 &u
->manager
->unit_path_cache
);
4951 return log_error_errno(r
, "Failed to rebuild name map: %m");
4953 r
= unit_file_find_fragment(u
->manager
->unit_id_map
,
4954 u
->manager
->unit_name_map
,
4958 if (r
< 0 && r
!= -ENOENT
)
4962 /* Open the file, check if this is a mask, otherwise read. */
4963 _cleanup_fclose_
FILE *f
= NULL
;
4966 /* Try to open the file name. A symlink is OK, for example for linked files or masks. We
4967 * expect that all symlinks within the lookup paths have been already resolved, but we don't
4968 * verify this here. */
4969 f
= fopen(fragment
, "re");
4971 return log_unit_notice_errno(u
, errno
, "Failed to open %s: %m", fragment
);
4973 if (fstat(fileno(f
), &st
) < 0)
4976 r
= free_and_strdup(&u
->fragment_path
, fragment
);
4980 if (null_or_empty(&st
)) {
4981 /* Unit file is masked */
4983 u
->load_state
= u
->perpetual
? UNIT_LOADED
: UNIT_MASKED
; /* don't allow perpetual units to ever be masked */
4984 u
->fragment_mtime
= 0;
4986 u
->load_state
= UNIT_LOADED
;
4987 u
->fragment_mtime
= timespec_load(&st
.st_mtim
);
4989 /* Now, parse the file contents */
4990 r
= config_parse(u
->id
, fragment
, f
,
4991 UNIT_VTABLE(u
)->sections
,
4992 config_item_perf_lookup
, load_fragment_gperf_lookup
,
4997 log_unit_notice_errno(u
, r
, "Unit configuration has fatal error, unit will not be started.");
5003 /* We do the merge dance here because for some unit types, the unit might have aliases which are not
5004 * declared in the file system. In particular, this is true (and frequent) for device and swap units.
5007 const char *id
= u
->id
;
5008 _cleanup_free_
char *free_id
= NULL
;
5011 id
= basename(fragment
);
5012 if (unit_name_is_valid(id
, UNIT_NAME_TEMPLATE
)) {
5013 assert(u
->instance
); /* If we're not trying to use a template for non-instanced unit,
5014 * this must be set. */
5016 r
= unit_name_replace_instance(id
, u
->instance
, &free_id
);
5018 return log_debug_errno(r
, "Failed to build id (%s + %s): %m", id
, u
->instance
);
5024 r
= merge_by_names(&merged
, names
, id
);
5029 u
->load_state
= UNIT_MERGED
;
5034 void unit_dump_config_items(FILE *f
) {
5035 static const struct {
5036 const ConfigParserCallback callback
;
5039 { config_parse_warn_compat
, "NOTSUPPORTED" },
5040 { config_parse_int
, "INTEGER" },
5041 { config_parse_unsigned
, "UNSIGNED" },
5042 { config_parse_iec_size
, "SIZE" },
5043 { config_parse_iec_uint64
, "SIZE" },
5044 { config_parse_si_uint64
, "SIZE" },
5045 { config_parse_bool
, "BOOLEAN" },
5046 { config_parse_string
, "STRING" },
5047 { config_parse_path
, "PATH" },
5048 { config_parse_unit_path_printf
, "PATH" },
5049 { config_parse_strv
, "STRING [...]" },
5050 { config_parse_exec_nice
, "NICE" },
5051 { config_parse_exec_oom_score_adjust
, "OOMSCOREADJUST" },
5052 { config_parse_exec_io_class
, "IOCLASS" },
5053 { config_parse_exec_io_priority
, "IOPRIORITY" },
5054 { config_parse_exec_cpu_sched_policy
, "CPUSCHEDPOLICY" },
5055 { config_parse_exec_cpu_sched_prio
, "CPUSCHEDPRIO" },
5056 { config_parse_exec_cpu_affinity
, "CPUAFFINITY" },
5057 { config_parse_mode
, "MODE" },
5058 { config_parse_unit_env_file
, "FILE" },
5059 { config_parse_exec_output
, "OUTPUT" },
5060 { config_parse_exec_input
, "INPUT" },
5061 { config_parse_log_facility
, "FACILITY" },
5062 { config_parse_log_level
, "LEVEL" },
5063 { config_parse_exec_secure_bits
, "SECUREBITS" },
5064 { config_parse_capability_set
, "BOUNDINGSET" },
5065 { config_parse_rlimit
, "LIMIT" },
5066 { config_parse_unit_deps
, "UNIT [...]" },
5067 { config_parse_exec
, "PATH [ARGUMENT [...]]" },
5068 { config_parse_service_type
, "SERVICETYPE" },
5069 { config_parse_service_restart
, "SERVICERESTART" },
5070 { config_parse_service_timeout_failure_mode
, "TIMEOUTMODE" },
5071 { config_parse_kill_mode
, "KILLMODE" },
5072 { config_parse_signal
, "SIGNAL" },
5073 { config_parse_socket_listen
, "SOCKET [...]" },
5074 { config_parse_socket_bind
, "SOCKETBIND" },
5075 { config_parse_socket_bindtodevice
, "NETWORKINTERFACE" },
5076 { config_parse_sec
, "SECONDS" },
5077 { config_parse_nsec
, "NANOSECONDS" },
5078 { config_parse_namespace_path_strv
, "PATH [...]" },
5079 { config_parse_bind_paths
, "PATH[:PATH[:OPTIONS]] [...]" },
5080 { config_parse_unit_requires_mounts_for
, "PATH [...]" },
5081 { config_parse_exec_mount_flags
, "MOUNTFLAG [...]" },
5082 { config_parse_unit_string_printf
, "STRING" },
5083 { config_parse_trigger_unit
, "UNIT" },
5084 { config_parse_timer
, "TIMER" },
5085 { config_parse_path_spec
, "PATH" },
5086 { config_parse_notify_access
, "ACCESS" },
5087 { config_parse_ip_tos
, "TOS" },
5088 { config_parse_unit_condition_path
, "CONDITION" },
5089 { config_parse_unit_condition_string
, "CONDITION" },
5090 { config_parse_unit_condition_null
, "CONDITION" },
5091 { config_parse_unit_slice
, "SLICE" },
5092 { config_parse_documentation
, "URL" },
5093 { config_parse_service_timeout
, "SECONDS" },
5094 { config_parse_emergency_action
, "ACTION" },
5095 { config_parse_set_status
, "STATUS" },
5096 { config_parse_service_sockets
, "SOCKETS" },
5097 { config_parse_environ
, "ENVIRON" },
5099 { config_parse_syscall_filter
, "SYSCALLS" },
5100 { config_parse_syscall_archs
, "ARCHS" },
5101 { config_parse_syscall_errno
, "ERRNO" },
5102 { config_parse_address_families
, "FAMILIES" },
5103 { config_parse_restrict_namespaces
, "NAMESPACES" },
5105 { config_parse_cpu_shares
, "SHARES" },
5106 { config_parse_cg_weight
, "WEIGHT" },
5107 { config_parse_memory_limit
, "LIMIT" },
5108 { config_parse_device_allow
, "DEVICE" },
5109 { config_parse_device_policy
, "POLICY" },
5110 { config_parse_io_limit
, "LIMIT" },
5111 { config_parse_io_device_weight
, "DEVICEWEIGHT" },
5112 { config_parse_io_device_latency
, "DEVICELATENCY" },
5113 { config_parse_blockio_bandwidth
, "BANDWIDTH" },
5114 { config_parse_blockio_weight
, "WEIGHT" },
5115 { config_parse_blockio_device_weight
, "DEVICEWEIGHT" },
5116 { config_parse_long
, "LONG" },
5117 { config_parse_socket_service
, "SERVICE" },
5119 { config_parse_exec_selinux_context
, "LABEL" },
5121 { config_parse_job_mode
, "MODE" },
5122 { config_parse_job_mode_isolate
, "BOOLEAN" },
5123 { config_parse_personality
, "PERSONALITY" },
5126 const char *prev
= NULL
;
5131 NULSTR_FOREACH(i
, load_fragment_gperf_nulstr
) {
5132 const char *rvalue
= "OTHER", *lvalue
;
5133 const ConfigPerfItem
*p
;
5138 assert_se(p
= load_fragment_gperf_lookup(i
, strlen(i
)));
5140 /* Hide legacy settings */
5141 if (p
->parse
== config_parse_warn_compat
&&
5142 p
->ltype
== DISABLED_LEGACY
)
5145 for (j
= 0; j
< ELEMENTSOF(table
); j
++)
5146 if (p
->parse
== table
[j
].callback
) {
5147 rvalue
= table
[j
].rvalue
;
5151 dot
= strchr(i
, '.');
5152 lvalue
= dot
? dot
+ 1 : i
;
5156 if (!prev
|| !strneq(prev
, i
, prefix_len
+1)) {
5160 fprintf(f
, "[%.*s]\n", (int) prefix_len
, i
);
5163 fprintf(f
, "%s=%s\n", lvalue
, rvalue
);
5168 int config_parse_cpu_affinity2(
5170 const char *filename
,
5172 const char *section
,
5173 unsigned section_line
,
5180 CPUSet
*affinity
= data
;
5184 (void) parse_cpu_set_extend(rvalue
, affinity
, true, unit
, filename
, line
, lvalue
);
5189 int config_parse_show_status(
5191 const char *filename
,
5193 const char *section
,
5194 unsigned section_line
,
5202 ShowStatus
*b
= data
;
5209 k
= parse_show_status(rvalue
, b
);
5211 log_syntax(unit
, LOG_ERR
, filename
, line
, k
, "Failed to parse show status setting, ignoring: %s", rvalue
);
5218 int config_parse_output_restricted(
5220 const char *filename
,
5222 const char *section
,
5223 unsigned section_line
,
5230 ExecOutput t
, *eo
= data
;
5231 bool obsolete
= false;
5238 if (streq(rvalue
, "syslog")) {
5239 t
= EXEC_OUTPUT_JOURNAL
;
5241 } else if (streq(rvalue
, "syslog+console")) {
5242 t
= EXEC_OUTPUT_JOURNAL_AND_CONSOLE
;
5245 t
= exec_output_from_string(rvalue
);
5247 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse output type, ignoring: %s", rvalue
);
5251 if (IN_SET(t
, EXEC_OUTPUT_SOCKET
, EXEC_OUTPUT_NAMED_FD
, EXEC_OUTPUT_FILE
, EXEC_OUTPUT_FILE_APPEND
)) {
5252 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Standard output types socket, fd:, file:, append: are not supported as defaults, ignoring: %s", rvalue
);
5258 log_syntax(unit
, LOG_NOTICE
, filename
, line
, 0,
5259 "Standard output type %s is obsolete, automatically updating to %s. Please update your configuration.",
5260 rvalue
, exec_output_to_string(t
));
5266 int config_parse_crash_chvt(
5268 const char *filename
,
5270 const char *section
,
5271 unsigned section_line
,
5285 r
= parse_crash_chvt(rvalue
, data
);
5287 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse CrashChangeVT= setting, ignoring: %s", rvalue
);
5294 int config_parse_swap_priority(
5296 const char *filename
,
5298 const char *section
,
5299 unsigned section_line
,
5315 if (isempty(rvalue
)) {
5316 s
->parameters_fragment
.priority
= -1;
5317 s
->parameters_fragment
.priority_set
= false;
5321 r
= safe_atoi(rvalue
, &priority
);
5323 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid swap priority '%s', ignoring.", rvalue
);
5327 if (priority
< -1) {
5328 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Sorry, swap priorities smaller than -1 may only be assigned by the kernel itself, ignoring: %s", rvalue
);
5332 if (priority
> 32767) {
5333 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Swap priority out of range, ignoring: %s", rvalue
);
5337 s
->parameters_fragment
.priority
= priority
;
5338 s
->parameters_fragment
.priority_set
= true;