1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include <linux/oom.h>
29 #include <sys/prctl.h>
33 #include "conf-parser.h"
34 #include "load-fragment.h"
37 #include "securebits.h"
40 static int config_parse_deps(
49 UnitDependency d
= PTR_TO_UINT(data
);
59 FOREACH_WORD(w
, &l
, rvalue
, state
) {
63 if (!(t
= strndup(w
, l
)))
66 r
= unit_add_dependency_by_name(u
, d
, t
);
76 static int config_parse_names(
95 FOREACH_WORD(w
, &l
, rvalue
, state
) {
100 if (!(t
= strndup(w
, l
)))
103 other
= manager_get_unit(u
->meta
.manager
, t
);
109 if (other
->meta
.load_state
!= UNIT_STUB
) {
114 if ((r
= unit_merge(u
, other
)) < 0) {
121 if ((r
= unit_add_name(u
, t
)) < 0) {
133 static int config_parse_listen(
134 const char *filename
,
153 if (!(p
= new0(SocketPort
, 1)))
156 if (streq(lvalue
, "ListenFIFO")) {
157 p
->type
= SOCKET_FIFO
;
159 if (!(p
->path
= strdup(rvalue
))) {
164 p
->type
= SOCKET_SOCKET
;
166 if ((r
= socket_address_parse(&p
->address
, rvalue
)) < 0) {
167 log_error("[%s:%u] Failed to parse address value: %s", filename
, line
, rvalue
);
172 if (streq(lvalue
, "ListenStream"))
173 p
->address
.type
= SOCK_STREAM
;
174 else if (streq(lvalue
, "ListenDatagram"))
175 p
->address
.type
= SOCK_DGRAM
;
177 assert(streq(lvalue
, "ListenSequentialPacket"));
178 p
->address
.type
= SOCK_SEQPACKET
;
181 if (socket_address_family(&p
->address
) != AF_LOCAL
&& p
->address
.type
== SOCK_SEQPACKET
) {
183 return -EPROTONOSUPPORT
;
188 LIST_PREPEND(SocketPort
, port
, s
->ports
, p
);
193 static int config_parse_socket_bind(
194 const char *filename
,
212 if ((r
= parse_boolean(rvalue
)) < 0) {
213 log_error("[%s:%u] Failed to parse bind IPv6 only value: %s", filename
, line
, rvalue
);
217 s
->bind_ipv6_only
= r
? SOCKET_ADDRESS_IPV6_ONLY
: SOCKET_ADDRESS_BOTH
;
222 static int config_parse_nice(
223 const char *filename
,
231 ExecContext
*c
= data
;
239 if ((r
= safe_atoi(rvalue
, &priority
)) < 0) {
240 log_error("[%s:%u] Failed to parse nice priority: %s", filename
, line
, rvalue
);
244 if (priority
< PRIO_MIN
|| priority
>= PRIO_MAX
) {
245 log_error("[%s:%u] Nice priority out of range: %s", filename
, line
, rvalue
);
255 static int config_parse_oom_adjust(
256 const char *filename
,
264 ExecContext
*c
= data
;
272 if ((r
= safe_atoi(rvalue
, &oa
)) < 0) {
273 log_error("[%s:%u] Failed to parse OOM adjust value: %s", filename
, line
, rvalue
);
277 if (oa
< OOM_DISABLE
|| oa
> OOM_ADJUST_MAX
) {
278 log_error("[%s:%u] OOM adjust value out of range: %s", filename
, line
, rvalue
);
283 c
->oom_adjust_set
= true;
288 static int config_parse_mode(
289 const char *filename
,
307 l
= strtol(rvalue
, &x
, 8);
308 if (!x
|| *x
|| errno
) {
309 log_error("[%s:%u] Failed to parse mode value: %s", filename
, line
, rvalue
);
310 return errno
? -errno
: -EINVAL
;
313 if (l
< 0000 || l
> 07777) {
314 log_error("[%s:%u] mode value out of range: %s", filename
, line
, rvalue
);
322 static int config_parse_exec(
323 const char *filename
,
331 ExecCommand
**e
= data
, *ee
, *nce
= NULL
;
344 FOREACH_WORD_QUOTED(w
, l
, rvalue
, state
)
347 if (!(n
= new(char*, k
+1)))
351 FOREACH_WORD_QUOTED(w
, l
, rvalue
, state
)
352 if (!(n
[k
++] = strndup(w
, l
)))
357 if (!n
[0] || !path_is_absolute(n
[0])) {
358 log_error("[%s:%u] Invalid executable path in command line: %s", filename
, line
, rvalue
);
363 if (!(nce
= new0(ExecCommand
, 1)))
367 if (!(nce
->path
= strdup(n
[0])))
371 /* It's kinda important that we keep the order here */
372 LIST_FIND_TAIL(ExecCommand
, command
, *e
, ee
);
373 LIST_INSERT_AFTER(ExecCommand
, command
, *e
, ee
, nce
);
389 static int config_parse_usec(
390 const char *filename
,
399 unsigned long long u
;
407 if ((r
= safe_atollu(rvalue
, &u
)) < 0) {
408 log_error("[%s:%u] Failed to parse time value: %s", filename
, line
, rvalue
);
412 /* We actually assume the user configures seconds. Later on we
413 * might choose to support suffixes for time values, to
414 * configure bigger or smaller units */
416 *usec
= u
* USEC_PER_SEC
;
421 static int config_parse_service_type(
422 const char *filename
,
438 if ((x
= service_type_from_string(rvalue
)) < 0) {
439 log_error("[%s:%u] Failed to parse service type: %s", filename
, line
, rvalue
);
448 static int config_parse_service_restart(
449 const char *filename
,
465 if ((x
= service_restart_from_string(rvalue
)) < 0) {
466 log_error("[%s:%u] Failed to parse service restart specifier: %s", filename
, line
, rvalue
);
475 static int config_parse_bindtodevice(
476 const char *filename
,
492 if (rvalue
[0] && !streq(rvalue
, "*")) {
493 if (!(n
= strdup(rvalue
)))
498 free(s
->bind_to_device
);
499 s
->bind_to_device
= n
;
504 static int config_parse_output(
505 const char *filename
,
513 ExecOutput
*o
= data
, x
;
520 if ((x
= exec_output_from_string(rvalue
)) < 0) {
521 log_error("[%s:%u] Failed to parse output specifier: %s", filename
, line
, rvalue
);
530 static int config_parse_input(
531 const char *filename
,
539 ExecInput
*i
= data
, x
;
546 if ((x
= exec_input_from_string(rvalue
)) < 0) {
547 log_error("[%s:%u] Failed to parse input specifier: %s", filename
, line
, rvalue
);
556 static int config_parse_facility(
557 const char *filename
,
573 if ((x
= log_facility_from_string(rvalue
)) < 0)
575 /* Second try, let's see if this is a number. */
576 if (safe_atoi(rvalue
, &x
) < 0 || !log_facility_to_string(x
)) {
577 log_error("[%s:%u] Failed to parse log facility: %s", filename
, line
, rvalue
);
581 *o
= LOG_MAKEPRI(x
, LOG_PRI(*o
));
586 static int config_parse_level(
587 const char *filename
,
603 if ((x
= log_level_from_string(rvalue
)) < 0)
605 /* Second try, let's see if this is a number. */
606 if (safe_atoi(rvalue
, &x
) < 0 || !log_level_to_string(x
)) {
607 log_error("[%s:%u] Failed to parse log level: %s", filename
, line
, rvalue
);
611 *o
= LOG_MAKEPRI(LOG_FAC(*o
), x
);
615 static int config_parse_io_class(
616 const char *filename
,
624 ExecContext
*c
= data
;
632 if ((x
= ioprio_class_from_string(rvalue
)) < 0)
634 /* Second try, let's see if this is a number. */
635 if (safe_atoi(rvalue
, &x
) < 0 || !ioprio_class_to_string(x
)) {
636 log_error("[%s:%u] Failed to parse IO scheduling class: %s", filename
, line
, rvalue
);
640 c
->ioprio
= IOPRIO_PRIO_VALUE(x
, IOPRIO_PRIO_DATA(c
->ioprio
));
641 c
->ioprio_set
= true;
646 static int config_parse_io_priority(
647 const char *filename
,
655 ExecContext
*c
= data
;
663 if (safe_atoi(rvalue
, &i
) < 0 || i
< 0 || i
>= IOPRIO_BE_NR
) {
664 log_error("[%s:%u] Failed to parse io priority: %s", filename
, line
, rvalue
);
668 c
->ioprio
= IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c
->ioprio
), i
);
669 c
->ioprio_set
= true;
674 static int config_parse_cpu_sched_policy(
675 const char *filename
,
684 ExecContext
*c
= data
;
692 if ((x
= sched_policy_from_string(rvalue
)) < 0)
694 /* Second try, let's see if this is a number. */
695 if (safe_atoi(rvalue
, &x
) < 0 || !sched_policy_to_string(x
)) {
696 log_error("[%s:%u] Failed to parse CPU scheduling policy: %s", filename
, line
, rvalue
);
700 c
->cpu_sched_policy
= x
;
701 c
->cpu_sched_set
= true;
706 static int config_parse_cpu_sched_prio(
707 const char *filename
,
715 ExecContext
*c
= data
;
723 /* On Linux RR/FIFO have the same range */
724 if (safe_atoi(rvalue
, &i
) < 0 || i
< sched_get_priority_min(SCHED_RR
) || i
> sched_get_priority_max(SCHED_RR
)) {
725 log_error("[%s:%u] Failed to parse CPU scheduling priority: %s", filename
, line
, rvalue
);
729 c
->cpu_sched_priority
= i
;
730 c
->cpu_sched_set
= true;
735 static int config_parse_cpu_affinity(
736 const char *filename
,
744 ExecContext
*c
= data
;
754 FOREACH_WORD(w
, &l
, rvalue
, state
) {
759 if (!(t
= strndup(w
, l
)))
762 r
= safe_atou(t
, &cpu
);
765 if (r
< 0 || cpu
>= CPU_SETSIZE
) {
766 log_error("[%s:%u] Failed to parse CPU affinity: %s", filename
, line
, rvalue
);
770 CPU_SET(cpu
, &c
->cpu_affinity
);
773 c
->cpu_affinity_set
= true;
778 static int config_parse_capabilities(
779 const char *filename
,
787 ExecContext
*c
= data
;
795 if (!(cap
= cap_from_text(rvalue
))) {
799 log_error("[%s:%u] Failed to parse capabilities: %s", filename
, line
, rvalue
);
804 cap_free(c
->capabilities
);
805 c
->capabilities
= cap
;
810 static int config_parse_secure_bits(
811 const char *filename
,
819 ExecContext
*c
= data
;
829 FOREACH_WORD(w
, &l
, rvalue
, state
) {
830 if (first_word(w
, "keep-caps"))
831 c
->secure_bits
|= SECURE_KEEP_CAPS
;
832 else if (first_word(w
, "keep-caps-locked"))
833 c
->secure_bits
|= SECURE_KEEP_CAPS_LOCKED
;
834 else if (first_word(w
, "no-setuid-fixup"))
835 c
->secure_bits
|= SECURE_NO_SETUID_FIXUP
;
836 else if (first_word(w
, "no-setuid-fixup-locked"))
837 c
->secure_bits
|= SECURE_NO_SETUID_FIXUP_LOCKED
;
838 else if (first_word(w
, "noroot"))
839 c
->secure_bits
|= SECURE_NOROOT
;
840 else if (first_word(w
, "noroot-locked"))
841 c
->secure_bits
|= SECURE_NOROOT_LOCKED
;
843 log_error("[%s:%u] Failed to parse secure bits: %s", filename
, line
, rvalue
);
851 static int config_parse_bounding_set(
852 const char *filename
,
860 ExecContext
*c
= data
;
870 FOREACH_WORD(w
, &l
, rvalue
, state
) {
875 if (!(t
= strndup(w
, l
)))
878 r
= cap_from_name(t
, &cap
);
882 log_error("[%s:%u] Failed to parse capability bounding set: %s", filename
, line
, rvalue
);
886 c
->capability_bounding_set_drop
|= 1 << cap
;
892 static int config_parse_timer_slack_ns(
893 const char *filename
,
901 ExecContext
*c
= data
;
910 if ((r
= safe_atolu(rvalue
, &u
)) < 0) {
911 log_error("[%s:%u] Failed to parse time slack value: %s", filename
, line
, rvalue
);
915 c
->timer_slack_ns
= u
;
920 static int config_parse_limit(
921 const char *filename
,
929 struct rlimit
**rl
= data
;
930 unsigned long long u
;
938 if ((r
= safe_atollu(rvalue
, &u
)) < 0) {
939 log_error("[%s:%u] Failed to parse resource value: %s", filename
, line
, rvalue
);
944 if (!(*rl
= new(struct rlimit
, 1)))
947 (*rl
)->rlim_cur
= (*rl
)->rlim_max
= (rlim_t
) u
;
953 static int open_follow(char **filename
, FILE **_f
, Set
*names
, char **_id
) {
964 /* This will update the filename pointer if the loaded file is
965 * reached by a symlink. The old string will be freed. */
968 char *target
, *k
, *name
;
970 if (c
++ >= FOLLOW_MAX
)
973 path_kill_slashes(*filename
);
975 /* Add the file name we are currently looking at to
976 * the names of this unit */
977 name
= file_name_from_path(*filename
);
978 if (!(id
= set_get(names
, name
))) {
980 if (!(id
= strdup(name
)))
983 if ((r
= set_put(names
, id
)) < 0) {
989 /* Try to open the file name, but don't if its a symlink */
990 if ((fd
= open(*filename
, O_RDONLY
|O_CLOEXEC
|O_NOCTTY
|O_NOFOLLOW
)) >= 0)
996 /* Hmm, so this is a symlink. Let's read the name, and follow it manually */
997 if ((r
= readlink_malloc(*filename
, &target
)) < 0)
1000 k
= file_in_same_dir(*filename
, target
);
1010 if (!(f
= fdopen(fd
, "r"))) {
1012 assert(close_nointr(fd
) == 0);
1021 static int load_from_path(Unit
*u
, const char *path
) {
1023 static const char* const section_table
[_UNIT_TYPE_MAX
] = {
1024 [UNIT_SERVICE
] = "Service",
1025 [UNIT_TIMER
] = "Timer",
1026 [UNIT_SOCKET
] = "Socket",
1027 [UNIT_TARGET
] = "Target",
1028 [UNIT_DEVICE
] = "Device",
1029 [UNIT_MOUNT
] = "Mount",
1030 [UNIT_AUTOMOUNT
] = "Automount",
1031 [UNIT_SNAPSHOT
] = "Snapshot"
1034 #define EXEC_CONTEXT_CONFIG_ITEMS(context, section) \
1035 { "WorkingDirectory", config_parse_path, &(context).working_directory, section }, \
1036 { "RootDirectory", config_parse_path, &(context).root_directory, section }, \
1037 { "User", config_parse_string, &(context).user, section }, \
1038 { "Group", config_parse_string, &(context).group, section }, \
1039 { "SupplementaryGroups", config_parse_strv, &(context).supplementary_groups, section }, \
1040 { "Nice", config_parse_nice, &(context), section }, \
1041 { "OOMAdjust", config_parse_oom_adjust, &(context), section }, \
1042 { "IOSchedulingClass", config_parse_io_class, &(context), section }, \
1043 { "IOSchedulingPriority", config_parse_io_priority, &(context), section }, \
1044 { "CPUSchedulingPolicy", config_parse_cpu_sched_policy,&(context), section }, \
1045 { "CPUSchedulingPriority", config_parse_cpu_sched_prio, &(context), section }, \
1046 { "CPUSchedulingResetOnFork", config_parse_bool, &(context).cpu_sched_reset_on_fork, section }, \
1047 { "CPUAffinity", config_parse_cpu_affinity, &(context), section }, \
1048 { "UMask", config_parse_mode, &(context).umask, section }, \
1049 { "Environment", config_parse_strv, &(context).environment, section }, \
1050 { "Output", config_parse_output, &(context).output, section }, \
1051 { "Input", config_parse_input, &(context).input, section }, \
1052 { "SyslogIdentifier", config_parse_string, &(context).syslog_identifier, section }, \
1053 { "SyslogFacility", config_parse_facility, &(context).syslog_priority, section }, \
1054 { "SyslogLevel", config_parse_level, &(context).syslog_priority, section }, \
1055 { "Capabilities", config_parse_capabilities, &(context), section }, \
1056 { "SecureBits", config_parse_secure_bits, &(context), section }, \
1057 { "CapabilityBoundingSetDrop", config_parse_bounding_set, &(context), section }, \
1058 { "TimerSlackNS", config_parse_timer_slack_ns, &(context), section }, \
1059 { "LimitCPU", config_parse_limit, &(context).rlimit[RLIMIT_CPU], section }, \
1060 { "LimitFSIZE", config_parse_limit, &(context).rlimit[RLIMIT_FSIZE], section }, \
1061 { "LimitDATA", config_parse_limit, &(context).rlimit[RLIMIT_DATA], section }, \
1062 { "LimitSTACK", config_parse_limit, &(context).rlimit[RLIMIT_STACK], section }, \
1063 { "LimitCORE", config_parse_limit, &(context).rlimit[RLIMIT_CORE], section }, \
1064 { "LimitRSS", config_parse_limit, &(context).rlimit[RLIMIT_RSS], section }, \
1065 { "LimitNOFILE", config_parse_limit, &(context).rlimit[RLIMIT_NOFILE], section }, \
1066 { "LimitAS", config_parse_limit, &(context).rlimit[RLIMIT_AS], section }, \
1067 { "LimitNPROC", config_parse_limit, &(context).rlimit[RLIMIT_NPROC], section }, \
1068 { "LimitMEMLOCK", config_parse_limit, &(context).rlimit[RLIMIT_MEMLOCK], section }, \
1069 { "LimitLOCKS", config_parse_limit, &(context).rlimit[RLIMIT_LOCKS], section }, \
1070 { "LimitSIGPENDING", config_parse_limit, &(context).rlimit[RLIMIT_SIGPENDING], section }, \
1071 { "LimitMSGQUEUE", config_parse_limit, &(context).rlimit[RLIMIT_MSGQUEUE], section }, \
1072 { "LimitNICE", config_parse_limit, &(context).rlimit[RLIMIT_NICE], section }, \
1073 { "LimitRTPRIO", config_parse_limit, &(context).rlimit[RLIMIT_RTPRIO], section }, \
1074 { "LimitRTTIME", config_parse_limit, &(context).rlimit[RLIMIT_RTTIME], section }, \
1075 { "NonBlocking", config_parse_bool, &(context).non_blocking, section }
1077 const ConfigItem items
[] = {
1078 { "Names", config_parse_names
, u
, "Meta" },
1079 { "Description", config_parse_string
, &u
->meta
.description
, "Meta" },
1080 { "Requires", config_parse_deps
, UINT_TO_PTR(UNIT_REQUIRES
), "Meta" },
1081 { "SoftRequires", config_parse_deps
, UINT_TO_PTR(UNIT_SOFT_REQUIRES
), "Meta" },
1082 { "Wants", config_parse_deps
, UINT_TO_PTR(UNIT_WANTS
), "Meta" },
1083 { "Requisite", config_parse_deps
, UINT_TO_PTR(UNIT_REQUISITE
), "Meta" },
1084 { "SoftRequisite", config_parse_deps
, UINT_TO_PTR(UNIT_SOFT_REQUISITE
), "Meta" },
1085 { "Conflicts", config_parse_deps
, UINT_TO_PTR(UNIT_CONFLICTS
), "Meta" },
1086 { "Before", config_parse_deps
, UINT_TO_PTR(UNIT_BEFORE
), "Meta" },
1087 { "After", config_parse_deps
, UINT_TO_PTR(UNIT_AFTER
), "Meta" },
1088 { "RecursiveStop", config_parse_bool
, &u
->meta
.recursive_stop
, "Meta" },
1089 { "StopWhenUnneeded", config_parse_bool
, &u
->meta
.stop_when_unneeded
, "Meta" },
1091 { "PIDFile", config_parse_path
, &u
->service
.pid_file
, "Service" },
1092 { "ExecStartPre", config_parse_exec
, u
->service
.exec_command
+SERVICE_EXEC_START_PRE
, "Service" },
1093 { "ExecStart", config_parse_exec
, u
->service
.exec_command
+SERVICE_EXEC_START
, "Service" },
1094 { "ExecStartPost", config_parse_exec
, u
->service
.exec_command
+SERVICE_EXEC_START_POST
, "Service" },
1095 { "ExecReload", config_parse_exec
, u
->service
.exec_command
+SERVICE_EXEC_RELOAD
, "Service" },
1096 { "ExecStop", config_parse_exec
, u
->service
.exec_command
+SERVICE_EXEC_STOP
, "Service" },
1097 { "ExecStopPost", config_parse_exec
, u
->service
.exec_command
+SERVICE_EXEC_STOP_POST
, "Service" },
1098 { "RestartSec", config_parse_usec
, &u
->service
.restart_usec
, "Service" },
1099 { "TimeoutSec", config_parse_usec
, &u
->service
.timeout_usec
, "Service" },
1100 { "Type", config_parse_service_type
, &u
->service
, "Service" },
1101 { "Restart", config_parse_service_restart
, &u
->service
, "Service" },
1102 EXEC_CONTEXT_CONFIG_ITEMS(u
->service
.exec_context
, "Service"),
1104 { "ListenStream", config_parse_listen
, &u
->socket
, "Socket" },
1105 { "ListenDatagram", config_parse_listen
, &u
->socket
, "Socket" },
1106 { "ListenSequentialPacket", config_parse_listen
, &u
->socket
, "Socket" },
1107 { "ListenFIFO", config_parse_listen
, &u
->socket
, "Socket" },
1108 { "BindIPv6Only", config_parse_socket_bind
, &u
->socket
, "Socket" },
1109 { "Backlog", config_parse_unsigned
, &u
->socket
.backlog
, "Socket" },
1110 { "BindToDevice", config_parse_bindtodevice
, &u
->socket
, "Socket" },
1111 { "ExecStartPre", config_parse_exec
, u
->socket
.exec_command
+SOCKET_EXEC_START_PRE
, "Socket" },
1112 { "ExecStartPost", config_parse_exec
, u
->socket
.exec_command
+SOCKET_EXEC_START_POST
, "Socket" },
1113 { "ExecStopPre", config_parse_exec
, u
->socket
.exec_command
+SOCKET_EXEC_STOP_PRE
, "Socket" },
1114 { "ExecStopPost", config_parse_exec
, u
->socket
.exec_command
+SOCKET_EXEC_STOP_POST
, "Socket" },
1115 { "DirectoryMode", config_parse_mode
, &u
->socket
.directory_mode
, "Socket" },
1116 { "SocketMode", config_parse_mode
, &u
->socket
.socket_mode
, "Socket" },
1117 EXEC_CONTEXT_CONFIG_ITEMS(u
->socket
.exec_context
, "Socket"),
1119 EXEC_CONTEXT_CONFIG_ITEMS(u
->automount
.exec_context
, "Automount"),
1121 { NULL
, NULL
, NULL
, NULL
}
1124 #undef EXEC_CONTEXT_CONFIG_ITEMS
1126 const char *sections
[3];
1131 char *filename
= NULL
, *id
;
1133 sections
[0] = "Meta";
1134 sections
[1] = section_table
[u
->meta
.type
];
1137 if (!(symlink_names
= set_new(string_hash_func
, string_compare_func
)))
1140 if (path_is_absolute(path
)) {
1142 if (!(filename
= strdup(path
))) {
1147 if ((r
= open_follow(&filename
, &f
, symlink_names
, &id
)) < 0) {
1158 STRV_FOREACH(p
, u
->meta
.manager
->unit_path
) {
1160 /* Instead of opening the path right away, we manually
1161 * follow all symlinks and add their name to our unit
1162 * name set while doing so */
1163 if (!(filename
= path_make_absolute(path
, *p
))) {
1168 if ((r
= open_follow(&filename
, &f
, symlink_names
, &id
)) < 0) {
1177 /* Empty the symlink names for the next run */
1178 while ((sn
= set_steal_first(symlink_names
)))
1189 r
= 0; /* returning 0 means: no suitable config file found */
1193 /* Now, parse the file contents */
1194 r
= config_parse(filename
, f
, sections
, items
, u
);
1198 /* Let's try to add in all symlink names we found */
1199 while ((k
= set_steal_first(symlink_names
))) {
1200 if ((r
= unit_add_name(u
, k
)) < 0)
1205 unit_choose_id(u
, id
);
1210 free(u
->meta
.fragment_path
);
1211 u
->meta
.fragment_path
= filename
;
1214 r
= 1; /* returning 1 means: suitable config file found and loaded */
1217 while ((k
= set_steal_first(symlink_names
)))
1219 set_free(symlink_names
);
1225 int unit_load_fragment(Unit
*u
) {
1230 assert(u
->meta
.load_state
== UNIT_STUB
);
1232 if (u
->meta
.fragment_path
)
1233 r
= load_from_path(u
, u
->meta
.fragment_path
);
1238 /* Try to find a name we can load this with */
1239 SET_FOREACH(t
, u
->meta
.names
, i
)
1240 if ((r
= load_from_path(u
, t
)) != 0)
1244 if (u
->meta
.type
== UNIT_SOCKET
)
1245 c
= &u
->socket
.exec_context
;
1246 else if (u
->meta
.type
== UNIT_SERVICE
)
1247 c
= &u
->service
.exec_context
;
1252 (c
->output
== EXEC_OUTPUT_KERNEL
|| c
->output
== EXEC_OUTPUT_SYSLOG
)) {
1255 /* If syslog or kernel logging is requested, make sure
1256 * our own logging daemon is run first. */
1258 if ((k
= unit_add_dependency_by_name(u
, UNIT_AFTER
, SPECIAL_LOGGER_SOCKET
)) < 0)
1261 if ((k
= unit_add_dependency_by_name(u
, UNIT_REQUIRES
, SPECIAL_LOGGER_SOCKET
)) < 0)