File: | build-scan/../src/core/load-fragment.c |
Warning: | line 3879, column 29 Potential leak of memory pointed to by 'temp' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |||
2 | /*** | |||
3 | Copyright © 2012 Holger Hans Peter Freyther | |||
4 | ***/ | |||
5 | ||||
6 | #include <errno(*__errno_location ()).h> | |||
7 | #include <fcntl.h> | |||
8 | #include <linux1/fs.h> | |||
9 | #include <linux1/oom.h> | |||
10 | #if HAVE_SECCOMP1 | |||
11 | #include <seccomp.h> | |||
12 | #endif | |||
13 | #include <sched.h> | |||
14 | #include <string.h> | |||
15 | #include <sys/resource.h> | |||
16 | #include <sys/stat.h> | |||
17 | ||||
18 | #include "af-list.h" | |||
19 | #include "alloc-util.h" | |||
20 | #include "all-units.h" | |||
21 | #include "bus-error.h" | |||
22 | #include "bus-internal.h" | |||
23 | #include "bus-util.h" | |||
24 | #include "cap-list.h" | |||
25 | #include "capability-util.h" | |||
26 | #include "cgroup.h" | |||
27 | #include "conf-parser.h" | |||
28 | #include "cpu-set-util.h" | |||
29 | #include "env-util.h" | |||
30 | #include "errno-list.h" | |||
31 | #include "escape.h" | |||
32 | #include "fd-util.h" | |||
33 | #include "fs-util.h" | |||
34 | #include "hexdecoct.h" | |||
35 | #include "io-util.h" | |||
36 | #include "ioprio.h" | |||
37 | #include "journal-util.h" | |||
38 | #include "load-fragment.h" | |||
39 | #include "log.h" | |||
40 | #include "missing.h" | |||
41 | #include "mount-util.h" | |||
42 | #include "parse-util.h" | |||
43 | #include "path-util.h" | |||
44 | #include "process-util.h" | |||
45 | #if HAVE_SECCOMP1 | |||
46 | #include "seccomp-util.h" | |||
47 | #endif | |||
48 | #include "securebits.h" | |||
49 | #include "securebits-util.h" | |||
50 | #include "signal-util.h" | |||
51 | #include "socket-protocol-list.h" | |||
52 | #include "stat-util.h" | |||
53 | #include "string-util.h" | |||
54 | #include "strv.h" | |||
55 | #include "unit-name.h" | |||
56 | #include "unit-printf.h" | |||
57 | #include "user-util.h" | |||
58 | #include "time-util.h" | |||
59 | #include "web-util.h" | |||
60 | ||||
61 | static int supported_socket_protocol_from_string(const char *s) { | |||
62 | int r; | |||
63 | ||||
64 | if (isempty(s)) | |||
65 | return IPPROTO_IPIPPROTO_IP; | |||
66 | ||||
67 | r = socket_protocol_from_name(s); | |||
68 | if (r < 0) | |||
69 | return -EINVAL22; | |||
70 | if (!IN_SET(r, IPPROTO_UDPLITE, IPPROTO_SCTP)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){IPPROTO_UDPLITE, IPPROTO_SCTP})/sizeof(int )]; switch(r) { case IPPROTO_UDPLITE: case IPPROTO_SCTP: _found = 1; break; default: break; } _found; })) | |||
71 | return -EPROTONOSUPPORT93; | |||
72 | ||||
73 | return r; | |||
74 | } | |||
75 | ||||
76 | DEFINE_CONFIG_PARSE(config_parse_socket_protocol, supported_socket_protocol_from_string, "Failed to parse socket protocol")int config_parse_socket_protocol(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { int *i = data, r; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 76, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 76, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 76, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 76 , __PRETTY_FUNCTION__); } while (0); r = supported_socket_protocol_from_string (rvalue); if (r < 0) { ({ int _level = (3), _e = (r); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 76, __func__, "Failed to parse socket protocol" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = r; return 0; }; | |||
77 | DEFINE_CONFIG_PARSE(config_parse_exec_secure_bits, secure_bits_from_string, "Failed to parse secure bits")int config_parse_exec_secure_bits(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { int *i = data, r; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 77, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 77, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 77, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 77 , __PRETTY_FUNCTION__); } while (0); r = secure_bits_from_string (rvalue); if (r < 0) { ({ int _level = (3), _e = (r); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 77, __func__, "Failed to parse secure bits" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = r; return 0; }; | |||
78 | DEFINE_CONFIG_PARSE_ENUM(config_parse_collect_mode, collect_mode, CollectMode, "Failed to parse garbage collection mode")int config_parse_collect_mode(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { CollectMode *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 78, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 78, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 78, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 78 , __PRETTY_FUNCTION__); } while (0); x = collect_mode_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 78, __func__, "Failed to parse garbage collection mode" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
79 | DEFINE_CONFIG_PARSE_ENUM(config_parse_device_policy, cgroup_device_policy, CGroupDevicePolicy, "Failed to parse device policy")int config_parse_device_policy(const char *unit, const char * filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { CGroupDevicePolicy *i = data, x; do { if ( (__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 79, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("lvalue"), "../src/core/load-fragment.c", 79, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 79, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/load-fragment.c", 79, __PRETTY_FUNCTION__ ); } while (0); x = cgroup_device_policy_from_string(rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 79, __func__, "Failed to parse device policy" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
80 | DEFINE_CONFIG_PARSE_ENUM(config_parse_emergency_action, emergency_action, EmergencyAction, "Failed to parse failure action specifier")int config_parse_emergency_action(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { EmergencyAction *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 80, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 80, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 80, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 80 , __PRETTY_FUNCTION__); } while (0); x = emergency_action_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 80, __func__, "Failed to parse failure action specifier" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
81 | DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_keyring_mode, exec_keyring_mode, ExecKeyringMode, "Failed to parse keyring mode")int config_parse_exec_keyring_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { ExecKeyringMode *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 81, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 81, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 81, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 81 , __PRETTY_FUNCTION__); } while (0); x = exec_keyring_mode_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 81, __func__, "Failed to parse keyring mode" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
82 | DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_utmp_mode, exec_utmp_mode, ExecUtmpMode, "Failed to parse utmp mode")int config_parse_exec_utmp_mode(const char *unit, const char * filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { ExecUtmpMode *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 82, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 82, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 82, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 82 , __PRETTY_FUNCTION__); } while (0); x = exec_utmp_mode_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 82, __func__, "Failed to parse utmp mode" ", ignoring: %s", rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
83 | DEFINE_CONFIG_PARSE_ENUM(config_parse_job_mode, job_mode, JobMode, "Failed to parse job mode")int config_parse_job_mode(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { JobMode *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 83, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 83, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 83, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 83 , __PRETTY_FUNCTION__); } while (0); x = job_mode_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 83, __func__, "Failed to parse job mode" ", ignoring: %s", rvalue ) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
84 | DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode")int config_parse_kill_mode(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { KillMode *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 84, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 84, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 84, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 84 , __PRETTY_FUNCTION__); } while (0); x = kill_mode_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 84, __func__, "Failed to parse kill mode" ", ignoring: %s", rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
85 | DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier")int config_parse_notify_access(const char *unit, const char * filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { NotifyAccess *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 85, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 85, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 85, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 85 , __PRETTY_FUNCTION__); } while (0); x = notify_access_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 85, __func__, "Failed to parse notify access specifier" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
86 | DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_home, protect_home, ProtectHome, "Failed to parse protect home value")int config_parse_protect_home(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { ProtectHome *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 86, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 86, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 86, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 86 , __PRETTY_FUNCTION__); } while (0); x = protect_home_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 86, __func__, "Failed to parse protect home value" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
87 | DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_system, protect_system, ProtectSystem, "Failed to parse protect system value")int config_parse_protect_system(const char *unit, const char * filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { ProtectSystem *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 87, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 87, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 87, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 87 , __PRETTY_FUNCTION__); } while (0); x = protect_system_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 87, __func__, "Failed to parse protect system value" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
88 | DEFINE_CONFIG_PARSE_ENUM(config_parse_runtime_preserve_mode, exec_preserve_mode, ExecPreserveMode, "Failed to parse runtime directory preserve mode")int config_parse_runtime_preserve_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue , void *data, void *userdata) { ExecPreserveMode *i = data, x ; do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 88, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("lvalue"), "../src/core/load-fragment.c", 88, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 88, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/load-fragment.c", 88, __PRETTY_FUNCTION__ ); } while (0); x = exec_preserve_mode_from_string(rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 88, __func__, "Failed to parse runtime directory preserve mode" ", ignoring: %s", rvalue) : -abs(_e); }); return 0; } *i = x ; return 0; }; | |||
89 | DEFINE_CONFIG_PARSE_ENUM(config_parse_service_type, service_type, ServiceType, "Failed to parse service type")int config_parse_service_type(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { ServiceType *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 89, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 89, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 89, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 89 , __PRETTY_FUNCTION__); } while (0); x = service_type_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 89, __func__, "Failed to parse service type" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
90 | DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart, service_restart, ServiceRestart, "Failed to parse service restart specifier")int config_parse_service_restart(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { ServiceRestart *i = data, x; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 90, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 90, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 90, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 90 , __PRETTY_FUNCTION__); } while (0); x = service_restart_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 90, __func__, "Failed to parse service restart specifier" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
91 | DEFINE_CONFIG_PARSE_ENUM(config_parse_socket_bind, socket_address_bind_ipv6_only_or_bool, SocketAddressBindIPv6Only, "Failed to parse bind IPv6 only value")int config_parse_socket_bind(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { SocketAddressBindIPv6Only *i = data, x; do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 91, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("lvalue"), "../src/core/load-fragment.c", 91, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 91, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/load-fragment.c", 91, __PRETTY_FUNCTION__ ); } while (0); x = socket_address_bind_ipv6_only_or_bool_from_string (rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 91, __func__, "Failed to parse bind IPv6 only value" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
92 | DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_ip_tos, ip_tos, int, -1, "Failed to parse IP TOS value")int config_parse_ip_tos(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { int *i = data, x; do { if ((__builtin_expect(!! (!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c", 92, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 92, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 92, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 92 , __PRETTY_FUNCTION__); } while (0); if (isempty(rvalue)) { * i = -1; return 0; } x = ip_tos_from_string(rvalue); if (x < 0) { ({ int _level = (3), _e = (0); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 92, __func__, "Failed to parse IP TOS value" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; } *i = x; return 0; }; | |||
93 | DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint64_t, "Invalid block IO weight")int config_parse_blockio_weight(const char *unit, const char * filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { uint64_t *i = data; int r; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 93, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 93, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 93, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 93 , __PRETTY_FUNCTION__); } while (0); r = cg_blkio_weight_parse (rvalue, i); if (r < 0) ({ int _level = (3), _e = (r); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 93, __func__, "Invalid block IO weight" ", ignoring: %s", rvalue ) : -abs(_e); }); return 0; }; | |||
94 | DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight")int config_parse_cg_weight(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { uint64_t *i = data; int r; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 94, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 94, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 94, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 94 , __PRETTY_FUNCTION__); } while (0); r = cg_weight_parse(rvalue , i); if (r < 0) ({ int _level = (3), _e = (r); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 94, __func__, "Invalid weight" ", ignoring: %s", rvalue) : - abs(_e); }); return 0; }; | |||
95 | DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares")int config_parse_cpu_shares(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { uint64_t *i = data; int r; do { if ((__builtin_expect (!!(!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("filename"), "../src/core/load-fragment.c", 95, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 95, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 95, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 95 , __PRETTY_FUNCTION__); } while (0); r = cg_cpu_shares_parse( rvalue, i); if (r < 0) ({ int _level = (3), _e = (r); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 95, __func__, "Invalid CPU shares" ", ignoring: %s", rvalue ) : -abs(_e); }); return 0; }; | |||
96 | DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flags_from_string, unsigned long, "Failed to parse mount flag")int config_parse_exec_mount_flags(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line , const char *lvalue, int ltype, const char *rvalue, void *data , void *userdata) { unsigned long *i = data; int r; do { if ( (__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 96, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("lvalue"), "../src/core/load-fragment.c", 96, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 96, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/load-fragment.c", 96, __PRETTY_FUNCTION__ ); } while (0); r = mount_propagation_flags_from_string(rvalue , i); if (r < 0) ({ int _level = (3), _e = (r); (log_get_max_level_realm (LOG_REALM_SYSTEMD) >= ((_level) & 0x07)) ? log_syntax_internal (unit, _level, filename, line, _e, "../src/core/load-fragment.c" , 96, __func__, "Failed to parse mount flag" ", ignoring: %s" , rvalue) : -abs(_e); }); return 0; }; | |||
97 | DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1, "Invalid NUMA policy type")int config_parse_numa_policy(const char *unit, const char *filename , unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) { int *i = data, x; do { if ((__builtin_expect(!! (!(filename)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c", 97, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 97, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(rvalue)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("rvalue"), "../src/core/load-fragment.c", 97, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 97 , __PRETTY_FUNCTION__); } while (0); if (isempty(rvalue)) { * i = -1; return 0; } x = mpol_from_string(rvalue); if (x < 0 ) { ({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 97, __func__ , "Invalid NUMA policy type" ", ignoring: %s", rvalue) : -abs (_e); }); return 0; } *i = x; return 0; }; | |||
98 | ||||
99 | int config_parse_unit_deps( | |||
100 | const char *unit, | |||
101 | const char *filename, | |||
102 | unsigned line, | |||
103 | const char *section, | |||
104 | unsigned section_line, | |||
105 | const char *lvalue, | |||
106 | int ltype, | |||
107 | const char *rvalue, | |||
108 | void *data, | |||
109 | void *userdata) { | |||
110 | ||||
111 | UnitDependency d = ltype; | |||
112 | Unit *u = userdata; | |||
113 | const char *p; | |||
114 | ||||
115 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 115, __PRETTY_FUNCTION__); } while (0); | |||
116 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 116, __PRETTY_FUNCTION__); } while (0); | |||
117 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 117, __PRETTY_FUNCTION__); } while (0); | |||
118 | ||||
119 | p = rvalue; | |||
120 | for (;;) { | |||
121 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
122 | int r; | |||
123 | ||||
124 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_RETAIN_ESCAPE); | |||
125 | if (r == 0) | |||
126 | break; | |||
127 | if (r == -ENOMEM12) | |||
128 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 128, __func__); | |||
129 | if (r < 0) { | |||
130 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 130, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
131 | break; | |||
132 | } | |||
133 | ||||
134 | r = unit_name_printf(u, word, &k); | |||
135 | if (r < 0) { | |||
136 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 136, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", word ) : -abs(_e); }); | |||
137 | continue; | |||
138 | } | |||
139 | ||||
140 | r = unit_add_dependency_by_name(u, d, k, NULL((void*)0), true1, UNIT_DEPENDENCY_FILE); | |||
141 | if (r < 0) | |||
142 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 142, __func__ , "Failed to add dependency on %s, ignoring: %m", k) : -abs(_e ); }); | |||
143 | } | |||
144 | ||||
145 | return 0; | |||
146 | } | |||
147 | ||||
148 | int config_parse_obsolete_unit_deps( | |||
149 | const char *unit, | |||
150 | const char *filename, | |||
151 | unsigned line, | |||
152 | const char *section, | |||
153 | unsigned section_line, | |||
154 | const char *lvalue, | |||
155 | int ltype, | |||
156 | const char *rvalue, | |||
157 | void *data, | |||
158 | void *userdata) { | |||
159 | ||||
160 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 161, __func__ , "Unit dependency type %s= is obsolete, replacing by %s=, please update your unit file" , lvalue, unit_dependency_to_string(ltype)) : -abs(_e); }) | |||
161 | "Unit dependency type %s= is obsolete, replacing by %s=, please update your unit file", lvalue, unit_dependency_to_string(ltype))({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 161, __func__ , "Unit dependency type %s= is obsolete, replacing by %s=, please update your unit file" , lvalue, unit_dependency_to_string(ltype)) : -abs(_e); }); | |||
162 | ||||
163 | return config_parse_unit_deps(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata); | |||
164 | } | |||
165 | ||||
166 | int config_parse_unit_string_printf( | |||
167 | const char *unit, | |||
168 | const char *filename, | |||
169 | unsigned line, | |||
170 | const char *section, | |||
171 | unsigned section_line, | |||
172 | const char *lvalue, | |||
173 | int ltype, | |||
174 | const char *rvalue, | |||
175 | void *data, | |||
176 | void *userdata) { | |||
177 | ||||
178 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
179 | Unit *u = userdata; | |||
180 | int r; | |||
181 | ||||
182 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 182, __PRETTY_FUNCTION__); } while (0); | |||
183 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 183, __PRETTY_FUNCTION__); } while (0); | |||
184 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 184, __PRETTY_FUNCTION__); } while (0); | |||
185 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 185 , __PRETTY_FUNCTION__); } while (0); | |||
186 | ||||
187 | r = unit_full_printf(u, rvalue, &k); | |||
188 | if (r < 0) { | |||
189 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 189, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
190 | return 0; | |||
191 | } | |||
192 | ||||
193 | return config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, k, data, userdata); | |||
194 | } | |||
195 | ||||
196 | int config_parse_unit_strv_printf( | |||
197 | const char *unit, | |||
198 | const char *filename, | |||
199 | unsigned line, | |||
200 | const char *section, | |||
201 | unsigned section_line, | |||
202 | const char *lvalue, | |||
203 | int ltype, | |||
204 | const char *rvalue, | |||
205 | void *data, | |||
206 | void *userdata) { | |||
207 | ||||
208 | Unit *u = userdata; | |||
209 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
210 | int r; | |||
211 | ||||
212 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 212, __PRETTY_FUNCTION__); } while (0); | |||
213 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 213, __PRETTY_FUNCTION__); } while (0); | |||
214 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 214, __PRETTY_FUNCTION__); } while (0); | |||
215 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 215 , __PRETTY_FUNCTION__); } while (0); | |||
216 | ||||
217 | r = unit_full_printf(u, rvalue, &k); | |||
218 | if (r < 0) { | |||
219 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 219, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
220 | return 0; | |||
221 | } | |||
222 | ||||
223 | return config_parse_strv(unit, filename, line, section, section_line, lvalue, ltype, k, data, userdata); | |||
224 | } | |||
225 | ||||
226 | int config_parse_unit_path_printf( | |||
227 | const char *unit, | |||
228 | const char *filename, | |||
229 | unsigned line, | |||
230 | const char *section, | |||
231 | unsigned section_line, | |||
232 | const char *lvalue, | |||
233 | int ltype, | |||
234 | const char *rvalue, | |||
235 | void *data, | |||
236 | void *userdata) { | |||
237 | ||||
238 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
239 | Unit *u = userdata; | |||
240 | int r; | |||
241 | bool_Bool fatal = ltype; | |||
242 | ||||
243 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 243, __PRETTY_FUNCTION__); } while (0); | |||
244 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 244, __PRETTY_FUNCTION__); } while (0); | |||
245 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 245, __PRETTY_FUNCTION__); } while (0); | |||
246 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 246 , __PRETTY_FUNCTION__); } while (0); | |||
247 | ||||
248 | /* Let's not bother with anything that is too long */ | |||
249 | if (strlen(rvalue) >= PATH_MAX4096) { | |||
250 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 252, __func__ , "%s value too long%s.", lvalue, fatal ? "" : ", ignoring") : -abs(_e); }) | |||
251 | "%s value too long%s.",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 252, __func__ , "%s value too long%s.", lvalue, fatal ? "" : ", ignoring") : -abs(_e); }) | |||
252 | lvalue, fatal ? "" : ", ignoring")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 252, __func__ , "%s value too long%s.", lvalue, fatal ? "" : ", ignoring") : -abs(_e); }); | |||
253 | return fatal ? -ENAMETOOLONG36 : 0; | |||
254 | } | |||
255 | ||||
256 | r = unit_full_printf(u, rvalue, &k); | |||
257 | if (r < 0) { | |||
258 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 260, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, fatal ? "" : ", ignoring") : -abs(_e); }) | |||
259 | "Failed to resolve unit specifiers in '%s'%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 260, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, fatal ? "" : ", ignoring") : -abs(_e); }) | |||
260 | rvalue, fatal ? "" : ", ignoring")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 260, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, fatal ? "" : ", ignoring") : -abs(_e); }); | |||
261 | return fatal ? -ENOEXEC8 : 0; | |||
262 | } | |||
263 | ||||
264 | return config_parse_path(unit, filename, line, section, section_line, lvalue, ltype, k, data, userdata); | |||
265 | } | |||
266 | ||||
267 | int config_parse_unit_path_strv_printf( | |||
268 | const char *unit, | |||
269 | const char *filename, | |||
270 | unsigned line, | |||
271 | const char *section, | |||
272 | unsigned section_line, | |||
273 | const char *lvalue, | |||
274 | int ltype, | |||
275 | const char *rvalue, | |||
276 | void *data, | |||
277 | void *userdata) { | |||
278 | ||||
279 | char ***x = data; | |||
280 | Unit *u = userdata; | |||
281 | int r; | |||
282 | const char *p; | |||
283 | ||||
284 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 284, __PRETTY_FUNCTION__); } while (0); | |||
285 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 285, __PRETTY_FUNCTION__); } while (0); | |||
286 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 286, __PRETTY_FUNCTION__); } while (0); | |||
287 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 287 , __PRETTY_FUNCTION__); } while (0); | |||
288 | ||||
289 | if (isempty(rvalue)) { | |||
290 | *x = strv_free(*x); | |||
291 | return 0; | |||
292 | } | |||
293 | ||||
294 | for (p = rvalue;;) { | |||
295 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
296 | ||||
297 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
298 | if (r == 0) | |||
299 | return 0; | |||
300 | if (r == -ENOMEM12) | |||
301 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 301, __func__); | |||
302 | if (r < 0) { | |||
303 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 304, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
304 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 304, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
305 | return 0; | |||
306 | } | |||
307 | ||||
308 | r = unit_full_printf(u, word, &k); | |||
309 | if (r < 0) { | |||
310 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 311, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", word ) : -abs(_e); }) | |||
311 | "Failed to resolve unit specifiers in '%s', ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 311, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", word ) : -abs(_e); }); | |||
312 | return 0; | |||
313 | } | |||
314 | ||||
315 | r = path_simplify_and_warn(k, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
316 | if (r < 0) | |||
317 | return 0; | |||
318 | ||||
319 | r = strv_push(x, k); | |||
320 | if (r < 0) | |||
321 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 321, __func__); | |||
322 | k = NULL((void*)0); | |||
323 | } | |||
324 | } | |||
325 | ||||
326 | int config_parse_socket_listen(const char *unit, | |||
327 | const char *filename, | |||
328 | unsigned line, | |||
329 | const char *section, | |||
330 | unsigned section_line, | |||
331 | const char *lvalue, | |||
332 | int ltype, | |||
333 | const char *rvalue, | |||
334 | void *data, | |||
335 | void *userdata) { | |||
336 | ||||
337 | _cleanup_free___attribute__((cleanup(freep))) SocketPort *p = NULL((void*)0); | |||
338 | SocketPort *tail; | |||
339 | Socket *s; | |||
340 | int r; | |||
341 | ||||
342 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 342, __PRETTY_FUNCTION__); } while (0); | |||
343 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 343, __PRETTY_FUNCTION__); } while (0); | |||
344 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 344, __PRETTY_FUNCTION__); } while (0); | |||
345 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 345 , __PRETTY_FUNCTION__); } while (0); | |||
346 | ||||
347 | s = SOCKET(data); | |||
348 | ||||
349 | if (isempty(rvalue)) { | |||
350 | /* An empty assignment removes all ports */ | |||
351 | socket_free_ports(s); | |||
352 | return 0; | |||
353 | } | |||
354 | ||||
355 | p = new0(SocketPort, 1)((SocketPort*) calloc((1), sizeof(SocketPort))); | |||
356 | if (!p) | |||
357 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 357, __func__); | |||
358 | ||||
359 | if (ltype != SOCKET_SOCKET) { | |||
360 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
361 | ||||
362 | r = unit_full_printf(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), rvalue, &k); | |||
363 | if (r < 0) { | |||
364 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 364, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
365 | return 0; | |||
366 | } | |||
367 | ||||
368 | r = path_simplify_and_warn(k, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
369 | if (r < 0) | |||
370 | return 0; | |||
371 | ||||
372 | free_and_replace(p->path, k)({ free(p->path); (p->path) = (k); (k) = ((void*)0); 0; }); | |||
373 | p->type = ltype; | |||
374 | ||||
375 | } else if (streq(lvalue, "ListenNetlink")(strcmp((lvalue),("ListenNetlink")) == 0)) { | |||
376 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
377 | ||||
378 | r = unit_full_printf(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), rvalue, &k); | |||
379 | if (r < 0) { | |||
380 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 380, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
381 | return 0; | |||
382 | } | |||
383 | ||||
384 | r = socket_address_parse_netlink(&p->address, k); | |||
385 | if (r < 0) { | |||
386 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address value in '%s', ignoring: %m", k)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 386, __func__ , "Failed to parse address value in '%s', ignoring: %m", k) : -abs(_e); }); | |||
387 | return 0; | |||
388 | } | |||
389 | ||||
390 | p->type = SOCKET_SOCKET; | |||
391 | ||||
392 | } else { | |||
393 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
394 | ||||
395 | r = unit_full_printf(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), rvalue, &k); | |||
396 | if (r < 0) { | |||
397 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 397, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
398 | return 0; | |||
399 | } | |||
400 | ||||
401 | r = socket_address_parse_and_warn(&p->address, k); | |||
402 | if (r < 0) { | |||
403 | if (r != -EAFNOSUPPORT97) | |||
404 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address value in '%s', ignoring: %m", k)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 404, __func__ , "Failed to parse address value in '%s', ignoring: %m", k) : -abs(_e); }); | |||
405 | return 0; | |||
406 | } | |||
407 | ||||
408 | if (streq(lvalue, "ListenStream")(strcmp((lvalue),("ListenStream")) == 0)) | |||
409 | p->address.type = SOCK_STREAMSOCK_STREAM; | |||
410 | else if (streq(lvalue, "ListenDatagram")(strcmp((lvalue),("ListenDatagram")) == 0)) | |||
411 | p->address.type = SOCK_DGRAMSOCK_DGRAM; | |||
412 | else { | |||
413 | assert(streq(lvalue, "ListenSequentialPacket"))do { if ((__builtin_expect(!!(!((strcmp((lvalue),("ListenSequentialPacket" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(lvalue, \"ListenSequentialPacket\")" ), "../src/core/load-fragment.c", 413, __PRETTY_FUNCTION__); } while (0); | |||
414 | p->address.type = SOCK_SEQPACKETSOCK_SEQPACKET; | |||
415 | } | |||
416 | ||||
417 | if (socket_address_family(&p->address)((&p->address)->sockaddr.sa.sa_family) != AF_LOCAL1 && p->address.type == SOCK_SEQPACKETSOCK_SEQPACKET) { | |||
418 | log_syntax(unit, LOG_ERR, filename, line, 0, "Address family not supported, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 418, __func__ , "Address family not supported, ignoring: %s", rvalue) : -abs (_e); }); | |||
419 | return 0; | |||
420 | } | |||
421 | ||||
422 | p->type = SOCKET_SOCKET; | |||
423 | } | |||
424 | ||||
425 | p->fd = -1; | |||
426 | p->auxiliary_fds = NULL((void*)0); | |||
427 | p->n_auxiliary_fds = 0; | |||
428 | p->socket = s; | |||
429 | ||||
430 | LIST_FIND_TAIL(port, s->ports, tail)do { typeof(*(s->ports)) *_item = (s->ports); if (!_item ) (tail) = ((void*)0); else { while (_item->port_next) _item = _item->port_next; (tail) = _item; } } while (0); | |||
431 | LIST_INSERT_AFTER(port, s->ports, tail, p)do { typeof(*(s->ports)) **_head = &(s->ports), *_a = (tail), *_b = (p); do { if ((__builtin_expect(!!(!(_b)),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_b"), "../src/core/load-fragment.c" , 431, __PRETTY_FUNCTION__); } while (0); if (!_a) { if ((_b-> port_next = *_head)) _b->port_next->port_prev = _b; _b-> port_prev = ((void*)0); *_head = _b; } else { if ((_b->port_next = _a->port_next)) _b->port_next->port_prev = _b; _b ->port_prev = _a; _a->port_next = _b; } } while (0); | |||
432 | ||||
433 | p = NULL((void*)0); | |||
434 | ||||
435 | return 0; | |||
436 | } | |||
437 | ||||
438 | int config_parse_exec_nice( | |||
439 | const char *unit, | |||
440 | const char *filename, | |||
441 | unsigned line, | |||
442 | const char *section, | |||
443 | unsigned section_line, | |||
444 | const char *lvalue, | |||
445 | int ltype, | |||
446 | const char *rvalue, | |||
447 | void *data, | |||
448 | void *userdata) { | |||
449 | ||||
450 | ExecContext *c = data; | |||
451 | int priority, r; | |||
452 | ||||
453 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 453, __PRETTY_FUNCTION__); } while (0); | |||
454 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 454, __PRETTY_FUNCTION__); } while (0); | |||
455 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 455, __PRETTY_FUNCTION__); } while (0); | |||
456 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 456 , __PRETTY_FUNCTION__); } while (0); | |||
457 | ||||
458 | if (isempty(rvalue)) { | |||
459 | c->nice_set = false0; | |||
460 | return 0; | |||
461 | } | |||
462 | ||||
463 | r = parse_nice(rvalue, &priority); | |||
464 | if (r < 0) { | |||
465 | if (r == -ERANGE34) | |||
466 | log_syntax(unit, LOG_ERR, filename, line, r, "Nice priority out of range, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 466, __func__ , "Nice priority out of range, ignoring: %s", rvalue) : -abs( _e); }); | |||
467 | else | |||
468 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse nice priority '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 468, __func__ , "Failed to parse nice priority '%s', ignoring: %m", rvalue) : -abs(_e); }); | |||
469 | return 0; | |||
470 | } | |||
471 | ||||
472 | c->nice = priority; | |||
473 | c->nice_set = true1; | |||
474 | ||||
475 | return 0; | |||
476 | } | |||
477 | ||||
478 | int config_parse_exec_oom_score_adjust( | |||
479 | const char* unit, | |||
480 | const char *filename, | |||
481 | unsigned line, | |||
482 | const char *section, | |||
483 | unsigned section_line, | |||
484 | const char *lvalue, | |||
485 | int ltype, | |||
486 | const char *rvalue, | |||
487 | void *data, | |||
488 | void *userdata) { | |||
489 | ||||
490 | ExecContext *c = data; | |||
491 | int oa, r; | |||
492 | ||||
493 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 493, __PRETTY_FUNCTION__); } while (0); | |||
494 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 494, __PRETTY_FUNCTION__); } while (0); | |||
495 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 495, __PRETTY_FUNCTION__); } while (0); | |||
496 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 496 , __PRETTY_FUNCTION__); } while (0); | |||
497 | ||||
498 | if (isempty(rvalue)) { | |||
499 | c->oom_score_adjust_set = false0; | |||
500 | return 0; | |||
501 | } | |||
502 | ||||
503 | r = parse_oom_score_adjust(rvalue, &oa); | |||
504 | if (r < 0) { | |||
505 | if (r == -ERANGE34) | |||
506 | log_syntax(unit, LOG_ERR, filename, line, r, "OOM score adjust value out of range, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 506, __func__ , "OOM score adjust value out of range, ignoring: %s", rvalue ) : -abs(_e); }); | |||
507 | else | |||
508 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse the OOM score adjust value '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 508, __func__ , "Failed to parse the OOM score adjust value '%s', ignoring: %m" , rvalue) : -abs(_e); }); | |||
509 | return 0; | |||
510 | } | |||
511 | ||||
512 | c->oom_score_adjust = oa; | |||
513 | c->oom_score_adjust_set = true1; | |||
514 | ||||
515 | return 0; | |||
516 | } | |||
517 | ||||
518 | int config_parse_exec( | |||
519 | const char *unit, | |||
520 | const char *filename, | |||
521 | unsigned line, | |||
522 | const char *section, | |||
523 | unsigned section_line, | |||
524 | const char *lvalue, | |||
525 | int ltype, | |||
526 | const char *rvalue, | |||
527 | void *data, | |||
528 | void *userdata) { | |||
529 | ||||
530 | ExecCommand **e = data; | |||
531 | Unit *u = userdata; | |||
532 | const char *p; | |||
533 | bool_Bool semicolon; | |||
534 | int r; | |||
535 | ||||
536 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 536, __PRETTY_FUNCTION__); } while (0); | |||
537 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 537, __PRETTY_FUNCTION__); } while (0); | |||
538 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 538, __PRETTY_FUNCTION__); } while (0); | |||
539 | assert(e)do { if ((__builtin_expect(!!(!(e)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("e"), "../src/core/load-fragment.c", 539 , __PRETTY_FUNCTION__); } while (0); | |||
540 | ||||
541 | e += ltype; | |||
542 | rvalue += strspn(rvalue, WHITESPACE" \t\n\r"); | |||
543 | ||||
544 | if (isempty(rvalue)) { | |||
545 | /* An empty assignment resets the list */ | |||
546 | *e = exec_command_free_list(*e); | |||
547 | return 0; | |||
548 | } | |||
549 | ||||
550 | p = rvalue; | |||
551 | do { | |||
552 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *firstword = NULL((void*)0); | |||
553 | ExecCommandFlags flags = 0; | |||
554 | bool_Bool ignore = false0, separate_argv0 = false0; | |||
555 | _cleanup_free___attribute__((cleanup(freep))) ExecCommand *nce = NULL((void*)0); | |||
556 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **n = NULL((void*)0); | |||
557 | size_t nlen = 0, nbufsize = 0; | |||
558 | const char *f; | |||
559 | ||||
560 | semicolon = false0; | |||
561 | ||||
562 | r = extract_first_word_and_warn(&p, &firstword, NULL((void*)0), EXTRACT_QUOTES|EXTRACT_CUNESCAPE, unit, filename, line, rvalue); | |||
563 | if (r <= 0) | |||
564 | return 0; | |||
565 | ||||
566 | f = firstword; | |||
567 | for (;;) { | |||
568 | /* We accept an absolute path as first argument. If it's prefixed with - and the path doesn't | |||
569 | * exist, we ignore it instead of erroring out; if it's prefixed with @, we allow overriding of | |||
570 | * argv[0]; if it's prefixed with +, it will be run with full privileges and no sandboxing; if | |||
571 | * it's prefixed with '!' we apply sandboxing, but do not change user/group credentials; if | |||
572 | * it's prefixed with '!!', then we apply user/group credentials if the kernel supports ambient | |||
573 | * capabilities -- if it doesn't we don't apply the credentials themselves, but do apply most | |||
574 | * other sandboxing, with some special exceptions for changing UID. | |||
575 | * | |||
576 | * The idea is that '!!' may be used to write services that can take benefit of systemd's | |||
577 | * UID/GID dropping if the kernel supports ambient creds, but provide an automatic fallback to | |||
578 | * privilege dropping within the daemon if the kernel does not offer that. */ | |||
579 | ||||
580 | if (*f == '-' && !(flags & EXEC_COMMAND_IGNORE_FAILURE)) { | |||
581 | flags |= EXEC_COMMAND_IGNORE_FAILURE; | |||
582 | ignore = true1; | |||
583 | } else if (*f == '@' && !separate_argv0) | |||
584 | separate_argv0 = true1; | |||
585 | else if (*f == '+' && !(flags & (EXEC_COMMAND_FULLY_PRIVILEGED|EXEC_COMMAND_NO_SETUID|EXEC_COMMAND_AMBIENT_MAGIC))) | |||
586 | flags |= EXEC_COMMAND_FULLY_PRIVILEGED; | |||
587 | else if (*f == '!' && !(flags & (EXEC_COMMAND_FULLY_PRIVILEGED|EXEC_COMMAND_NO_SETUID|EXEC_COMMAND_AMBIENT_MAGIC))) | |||
588 | flags |= EXEC_COMMAND_NO_SETUID; | |||
589 | else if (*f == '!' && !(flags & (EXEC_COMMAND_FULLY_PRIVILEGED|EXEC_COMMAND_AMBIENT_MAGIC))) { | |||
590 | flags &= ~EXEC_COMMAND_NO_SETUID; | |||
591 | flags |= EXEC_COMMAND_AMBIENT_MAGIC; | |||
592 | } else | |||
593 | break; | |||
594 | f++; | |||
595 | } | |||
596 | ||||
597 | r = unit_full_printf(u, f, &path); | |||
598 | if (r < 0) { | |||
599 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 601, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", f, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
600 | "Failed to resolve unit specifiers in '%s'%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 601, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", f, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
601 | f, ignore ? ", ignoring" : "")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 601, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", f, ignore ? ", ignoring" : "") : -abs(_e); }); | |||
602 | return ignore ? 0 : -ENOEXEC8; | |||
603 | } | |||
604 | ||||
605 | if (isempty(path)) { | |||
606 | /* First word is either "-" or "@" with no command. */ | |||
607 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 609, __func__ , "Empty path in command line%s: '%s'", ignore ? ", ignoring" : "", rvalue) : -abs(_e); }) | |||
608 | "Empty path in command line%s: '%s'",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 609, __func__ , "Empty path in command line%s: '%s'", ignore ? ", ignoring" : "", rvalue) : -abs(_e); }) | |||
609 | ignore ? ", ignoring" : "", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 609, __func__ , "Empty path in command line%s: '%s'", ignore ? ", ignoring" : "", rvalue) : -abs(_e); }); | |||
610 | return ignore ? 0 : -ENOEXEC8; | |||
611 | } | |||
612 | if (!string_is_safe(path)) { | |||
613 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 615, __func__ , "Executable name contains special characters%s: %s", ignore ? ", ignoring" : "", path) : -abs(_e); }) | |||
614 | "Executable name contains special characters%s: %s",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 615, __func__ , "Executable name contains special characters%s: %s", ignore ? ", ignoring" : "", path) : -abs(_e); }) | |||
615 | ignore ? ", ignoring" : "", path)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 615, __func__ , "Executable name contains special characters%s: %s", ignore ? ", ignoring" : "", path) : -abs(_e); }); | |||
616 | return ignore ? 0 : -ENOEXEC8; | |||
617 | } | |||
618 | if (endswith(path, "/")) { | |||
619 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 621, __func__ , "Executable path specifies a directory%s: %s", ignore ? ", ignoring" : "", path) : -abs(_e); }) | |||
620 | "Executable path specifies a directory%s: %s",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 621, __func__ , "Executable path specifies a directory%s: %s", ignore ? ", ignoring" : "", path) : -abs(_e); }) | |||
621 | ignore ? ", ignoring" : "", path)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 621, __func__ , "Executable path specifies a directory%s: %s", ignore ? ", ignoring" : "", path) : -abs(_e); }); | |||
622 | return ignore ? 0 : -ENOEXEC8; | |||
623 | } | |||
624 | ||||
625 | if (!path_is_absolute(path)) { | |||
626 | const char *prefix; | |||
627 | bool_Bool found = false0; | |||
628 | ||||
629 | if (!filename_is_valid(path)) { | |||
630 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 632, __func__ , "Neither a valid executable name nor an absolute path%s: %s" , ignore ? ", ignoring" : "", path) : -abs(_e); }) | |||
631 | "Neither a valid executable name nor an absolute path%s: %s",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 632, __func__ , "Neither a valid executable name nor an absolute path%s: %s" , ignore ? ", ignoring" : "", path) : -abs(_e); }) | |||
632 | ignore ? ", ignoring" : "", path)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 632, __func__ , "Neither a valid executable name nor an absolute path%s: %s" , ignore ? ", ignoring" : "", path) : -abs(_e); }); | |||
633 | return ignore ? 0 : -ENOEXEC8; | |||
634 | } | |||
635 | ||||
636 | /* Resolve a single-component name to a full path */ | |||
637 | NULSTR_FOREACH(prefix, DEFAULT_PATH_NULSTR)for ((prefix) = ("/usr/local/" "sbin\0" "/usr/local/" "bin\0" "/usr/" "sbin\0" "/usr/" "bin\0"); (prefix) && *(prefix ); (prefix) = strchr((prefix), 0)+1) { | |||
638 | _cleanup_free___attribute__((cleanup(freep))) char *fullpath = NULL((void*)0); | |||
639 | ||||
640 | fullpath = strjoin(prefix, "/", path)strjoin_real((prefix), "/", path, ((void*)0)); | |||
641 | if (!fullpath) | |||
642 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 642, __func__); | |||
643 | ||||
644 | if (access(fullpath, F_OK0) >= 0) { | |||
645 | free_and_replace(path, fullpath)({ free(path); (path) = (fullpath); (fullpath) = ((void*)0); 0 ; }); | |||
646 | found = true1; | |||
647 | break; | |||
648 | } | |||
649 | } | |||
650 | ||||
651 | if (!found) { | |||
652 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 654, __func__ , "Executable \"%s\" not found in path \"%s\"%s", path, "/usr/local/" "sbin:" "/usr/local/" "bin" ":" "/usr/" "sbin:" "/usr/" "bin" , ignore ? ", ignoring" : "") : -abs(_e); }) | |||
653 | "Executable \"%s\" not found in path \"%s\"%s",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 654, __func__ , "Executable \"%s\" not found in path \"%s\"%s", path, "/usr/local/" "sbin:" "/usr/local/" "bin" ":" "/usr/" "sbin:" "/usr/" "bin" , ignore ? ", ignoring" : "") : -abs(_e); }) | |||
654 | path, DEFAULT_PATH, ignore ? ", ignoring" : "")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 654, __func__ , "Executable \"%s\" not found in path \"%s\"%s", path, "/usr/local/" "sbin:" "/usr/local/" "bin" ":" "/usr/" "sbin:" "/usr/" "bin" , ignore ? ", ignoring" : "") : -abs(_e); }); | |||
655 | return ignore ? 0 : -ENOEXEC8; | |||
656 | } | |||
657 | } | |||
658 | ||||
659 | if (!separate_argv0) { | |||
660 | char *w = NULL((void*)0); | |||
661 | ||||
662 | if (!GREEDY_REALLOC(n, nbufsize, nlen + 2)greedy_realloc((void**) &(n), &(nbufsize), (nlen + 2) , sizeof((n)[0]))) | |||
663 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 663, __func__); | |||
664 | ||||
665 | w = strdup(path); | |||
666 | if (!w) | |||
667 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 667, __func__); | |||
668 | n[nlen++] = w; | |||
669 | n[nlen] = NULL((void*)0); | |||
670 | } | |||
671 | ||||
672 | path_simplify(path, false0); | |||
673 | ||||
674 | while (!isempty(p)) { | |||
675 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *resolved = NULL((void*)0); | |||
676 | ||||
677 | /* Check explicitly for an unquoted semicolon as | |||
678 | * command separator token. */ | |||
679 | if (p[0] == ';' && (!p[1] || strchr(WHITESPACE" \t\n\r", p[1]))) { | |||
680 | p++; | |||
681 | p += strspn(p, WHITESPACE" \t\n\r"); | |||
682 | semicolon = true1; | |||
683 | break; | |||
684 | } | |||
685 | ||||
686 | /* Check for \; explicitly, to not confuse it with \\; or "\;" or "\\;" etc. | |||
687 | * extract_first_word() would return the same for all of those. */ | |||
688 | if (p[0] == '\\' && p[1] == ';' && (!p[2] || strchr(WHITESPACE" \t\n\r", p[2]))) { | |||
689 | char *w; | |||
690 | ||||
691 | p += 2; | |||
692 | p += strspn(p, WHITESPACE" \t\n\r"); | |||
693 | ||||
694 | if (!GREEDY_REALLOC(n, nbufsize, nlen + 2)greedy_realloc((void**) &(n), &(nbufsize), (nlen + 2) , sizeof((n)[0]))) | |||
695 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 695, __func__); | |||
696 | ||||
697 | w = strdup(";"); | |||
698 | if (!w) | |||
699 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 699, __func__); | |||
700 | n[nlen++] = w; | |||
701 | n[nlen] = NULL((void*)0); | |||
702 | continue; | |||
703 | } | |||
704 | ||||
705 | r = extract_first_word_and_warn(&p, &word, NULL((void*)0), EXTRACT_QUOTES|EXTRACT_CUNESCAPE, unit, filename, line, rvalue); | |||
706 | if (r == 0) | |||
707 | break; | |||
708 | if (r < 0) | |||
709 | return ignore ? 0 : -ENOEXEC8; | |||
710 | ||||
711 | r = unit_full_printf(u, word, &resolved); | |||
712 | if (r < 0) { | |||
713 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 715, __func__ , "Failed to resolve unit specifiers in %s%s: %m", word, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
714 | "Failed to resolve unit specifiers in %s%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 715, __func__ , "Failed to resolve unit specifiers in %s%s: %m", word, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
715 | word, ignore ? ", ignoring" : "")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 715, __func__ , "Failed to resolve unit specifiers in %s%s: %m", word, ignore ? ", ignoring" : "") : -abs(_e); }); | |||
716 | return ignore ? 0 : -ENOEXEC8; | |||
717 | } | |||
718 | ||||
719 | if (!GREEDY_REALLOC(n, nbufsize, nlen + 2)greedy_realloc((void**) &(n), &(nbufsize), (nlen + 2) , sizeof((n)[0]))) | |||
720 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 720, __func__); | |||
721 | ||||
722 | n[nlen++] = TAKE_PTR(resolved)({ typeof(resolved) _ptr_ = (resolved); (resolved) = ((void*) 0); _ptr_; }); | |||
723 | n[nlen] = NULL((void*)0); | |||
724 | } | |||
725 | ||||
726 | if (!n || !n[0]) { | |||
727 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 729, __func__ , "Empty executable name or zeroeth argument%s: %s", ignore ? ", ignoring" : "", rvalue) : -abs(_e); }) | |||
728 | "Empty executable name or zeroeth argument%s: %s",({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 729, __func__ , "Empty executable name or zeroeth argument%s: %s", ignore ? ", ignoring" : "", rvalue) : -abs(_e); }) | |||
729 | ignore ? ", ignoring" : "", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 729, __func__ , "Empty executable name or zeroeth argument%s: %s", ignore ? ", ignoring" : "", rvalue) : -abs(_e); }); | |||
730 | return ignore ? 0 : -ENOEXEC8; | |||
731 | } | |||
732 | ||||
733 | nce = new0(ExecCommand, 1)((ExecCommand*) calloc((1), sizeof(ExecCommand))); | |||
734 | if (!nce) | |||
735 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 735, __func__); | |||
736 | ||||
737 | nce->argv = TAKE_PTR(n)({ typeof(n) _ptr_ = (n); (n) = ((void*)0); _ptr_; }); | |||
738 | nce->path = TAKE_PTR(path)({ typeof(path) _ptr_ = (path); (path) = ((void*)0); _ptr_; } ); | |||
739 | nce->flags = flags; | |||
740 | ||||
741 | exec_command_append_list(e, nce); | |||
742 | ||||
743 | /* Do not _cleanup_free_ these. */ | |||
744 | nce = NULL((void*)0); | |||
745 | ||||
746 | rvalue = p; | |||
747 | } while (semicolon); | |||
748 | ||||
749 | return 0; | |||
750 | } | |||
751 | ||||
752 | int config_parse_socket_bindtodevice( | |||
753 | const char* unit, | |||
754 | const char *filename, | |||
755 | unsigned line, | |||
756 | const char *section, | |||
757 | unsigned section_line, | |||
758 | const char *lvalue, | |||
759 | int ltype, | |||
760 | const char *rvalue, | |||
761 | void *data, | |||
762 | void *userdata) { | |||
763 | ||||
764 | Socket *s = data; | |||
765 | ||||
766 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 766, __PRETTY_FUNCTION__); } while (0); | |||
767 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 767, __PRETTY_FUNCTION__); } while (0); | |||
768 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 768, __PRETTY_FUNCTION__); } while (0); | |||
769 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 769 , __PRETTY_FUNCTION__); } while (0); | |||
770 | ||||
771 | if (isempty(rvalue) || streq(rvalue, "*")(strcmp((rvalue),("*")) == 0)) { | |||
772 | s->bind_to_device = mfree(s->bind_to_device); | |||
773 | return 0; | |||
774 | } | |||
775 | ||||
776 | if (!ifname_valid(rvalue)) { | |||
777 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid interface name, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 777, __func__ , "Invalid interface name, ignoring: %s", rvalue) : -abs(_e); }); | |||
778 | return 0; | |||
779 | } | |||
780 | ||||
781 | if (free_and_strdup(&s->bind_to_device, rvalue) < 0) | |||
782 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 782, __func__); | |||
783 | ||||
784 | return 0; | |||
785 | } | |||
786 | ||||
787 | int config_parse_exec_input( | |||
788 | const char *unit, | |||
789 | const char *filename, | |||
790 | unsigned line, | |||
791 | const char *section, | |||
792 | unsigned section_line, | |||
793 | const char *lvalue, | |||
794 | int ltype, | |||
795 | const char *rvalue, | |||
796 | void *data, | |||
797 | void *userdata) { | |||
798 | ||||
799 | ExecContext *c = data; | |||
800 | Unit *u = userdata; | |||
801 | const char *n; | |||
802 | ExecInput ei; | |||
803 | int r; | |||
804 | ||||
805 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 805 , __PRETTY_FUNCTION__); } while (0); | |||
806 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 806, __PRETTY_FUNCTION__); } while (0); | |||
807 | assert(line)do { if ((__builtin_expect(!!(!(line)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("line"), "../src/core/load-fragment.c", 807 , __PRETTY_FUNCTION__); } while (0); | |||
808 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 808, __PRETTY_FUNCTION__); } while (0); | |||
809 | ||||
810 | n = startswith(rvalue, "fd:"); | |||
811 | if (n) { | |||
812 | _cleanup_free___attribute__((cleanup(freep))) char *resolved = NULL((void*)0); | |||
813 | ||||
814 | r = unit_full_printf(u, n, &resolved); | |||
815 | if (r < 0) | |||
816 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s': %m", n)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 816, __func__ , "Failed to resolve unit specifiers in '%s': %m", n) : -abs( _e); }); | |||
817 | ||||
818 | if (isempty(resolved)) | |||
819 | resolved = mfree(resolved); | |||
820 | else if (!fdname_is_valid(resolved)) { | |||
821 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid file descriptor name: %s", resolved)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 821, __func__ , "Invalid file descriptor name: %s", resolved) : -abs(_e); } ); | |||
822 | return -ENOEXEC8; | |||
823 | } | |||
824 | ||||
825 | free_and_replace(c->stdio_fdname[STDIN_FILENO], resolved)({ free(c->stdio_fdname[0]); (c->stdio_fdname[0]) = (resolved ); (resolved) = ((void*)0); 0; }); | |||
826 | ||||
827 | ei = EXEC_INPUT_NAMED_FD; | |||
828 | ||||
829 | } else if ((n = startswith(rvalue, "file:"))) { | |||
830 | _cleanup_free___attribute__((cleanup(freep))) char *resolved = NULL((void*)0); | |||
831 | ||||
832 | r = unit_full_printf(u, n, &resolved); | |||
833 | if (r < 0) | |||
834 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s': %m", n)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 834, __func__ , "Failed to resolve unit specifiers in '%s': %m", n) : -abs( _e); }); | |||
835 | ||||
836 | r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE | PATH_CHECK_FATAL, unit, filename, line, lvalue); | |||
837 | if (r < 0) | |||
838 | return -ENOEXEC8; | |||
839 | ||||
840 | free_and_replace(c->stdio_file[STDIN_FILENO], resolved)({ free(c->stdio_file[0]); (c->stdio_file[0]) = (resolved ); (resolved) = ((void*)0); 0; }); | |||
841 | ||||
842 | ei = EXEC_INPUT_FILE; | |||
843 | ||||
844 | } else { | |||
845 | ei = exec_input_from_string(rvalue); | |||
846 | if (ei < 0) { | |||
847 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse input specifier, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 847, __func__ , "Failed to parse input specifier, ignoring: %s", rvalue) : - abs(_e); }); | |||
848 | return 0; | |||
849 | } | |||
850 | } | |||
851 | ||||
852 | c->std_input = ei; | |||
853 | return 0; | |||
854 | } | |||
855 | ||||
856 | int config_parse_exec_input_text( | |||
857 | const char *unit, | |||
858 | const char *filename, | |||
859 | unsigned line, | |||
860 | const char *section, | |||
861 | unsigned section_line, | |||
862 | const char *lvalue, | |||
863 | int ltype, | |||
864 | const char *rvalue, | |||
865 | void *data, | |||
866 | void *userdata) { | |||
867 | ||||
868 | _cleanup_free___attribute__((cleanup(freep))) char *unescaped = NULL((void*)0), *resolved = NULL((void*)0); | |||
869 | ExecContext *c = data; | |||
870 | Unit *u = userdata; | |||
871 | size_t sz; | |||
872 | void *p; | |||
873 | int r; | |||
874 | ||||
875 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 875 , __PRETTY_FUNCTION__); } while (0); | |||
876 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 876, __PRETTY_FUNCTION__); } while (0); | |||
877 | assert(line)do { if ((__builtin_expect(!!(!(line)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("line"), "../src/core/load-fragment.c", 877 , __PRETTY_FUNCTION__); } while (0); | |||
878 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 878, __PRETTY_FUNCTION__); } while (0); | |||
879 | ||||
880 | if (isempty(rvalue)) { | |||
881 | /* Reset if the empty string is assigned */ | |||
882 | c->stdin_data = mfree(c->stdin_data); | |||
883 | c->stdin_data_size = 0; | |||
884 | return 0; | |||
885 | } | |||
886 | ||||
887 | r = cunescape(rvalue, 0, &unescaped); | |||
888 | if (r < 0) | |||
889 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to decode C escaped text '%s': %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 889, __func__ , "Failed to decode C escaped text '%s': %m", rvalue) : -abs( _e); }); | |||
890 | ||||
891 | r = unit_full_printf(u, unescaped, &resolved); | |||
892 | if (r < 0) | |||
893 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s': %m", unescaped)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 893, __func__ , "Failed to resolve unit specifiers in '%s': %m", unescaped) : -abs(_e); }); | |||
894 | ||||
895 | sz = strlen(resolved); | |||
896 | if (c->stdin_data_size + sz + 1 < c->stdin_data_size || /* check for overflow */ | |||
897 | c->stdin_data_size + sz + 1 > EXEC_STDIN_DATA_MAX(64U*1024U*1024U)) { | |||
898 | 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)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 898, __func__ , "Standard input data too large (%zu), maximum of %zu permitted, ignoring." , c->stdin_data_size + sz, (size_t) (64U*1024U*1024U)) : - abs(_e); }); | |||
899 | return -E2BIG7; | |||
900 | } | |||
901 | ||||
902 | p = realloc(c->stdin_data, c->stdin_data_size + sz + 1); | |||
903 | if (!p) | |||
904 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 904, __func__); | |||
905 | ||||
906 | *((char*) mempcpy((char*) p + c->stdin_data_size, resolved, sz)) = '\n'; | |||
907 | ||||
908 | c->stdin_data = p; | |||
909 | c->stdin_data_size += sz + 1; | |||
910 | ||||
911 | return 0; | |||
912 | } | |||
913 | ||||
914 | int config_parse_exec_input_data( | |||
915 | const char *unit, | |||
916 | const char *filename, | |||
917 | unsigned line, | |||
918 | const char *section, | |||
919 | unsigned section_line, | |||
920 | const char *lvalue, | |||
921 | int ltype, | |||
922 | const char *rvalue, | |||
923 | void *data, | |||
924 | void *userdata) { | |||
925 | ||||
926 | _cleanup_free___attribute__((cleanup(freep))) void *p = NULL((void*)0); | |||
927 | ExecContext *c = data; | |||
928 | size_t sz; | |||
929 | void *q; | |||
930 | int r; | |||
931 | ||||
932 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 932 , __PRETTY_FUNCTION__); } while (0); | |||
933 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 933, __PRETTY_FUNCTION__); } while (0); | |||
934 | assert(line)do { if ((__builtin_expect(!!(!(line)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("line"), "../src/core/load-fragment.c", 934 , __PRETTY_FUNCTION__); } while (0); | |||
935 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 935, __PRETTY_FUNCTION__); } while (0); | |||
936 | ||||
937 | if (isempty(rvalue)) { | |||
938 | /* Reset if the empty string is assigned */ | |||
939 | c->stdin_data = mfree(c->stdin_data); | |||
940 | c->stdin_data_size = 0; | |||
941 | return 0; | |||
942 | } | |||
943 | ||||
944 | r = unbase64mem(rvalue, (size_t) -1, &p, &sz); | |||
945 | if (r < 0) | |||
946 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to decode base64 data, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 946, __func__ , "Failed to decode base64 data, ignoring: %s", rvalue) : -abs (_e); }); | |||
947 | ||||
948 | assert(sz > 0)do { if ((__builtin_expect(!!(!(sz > 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("sz > 0"), "../src/core/load-fragment.c" , 948, __PRETTY_FUNCTION__); } while (0); | |||
949 | ||||
950 | if (c->stdin_data_size + sz < c->stdin_data_size || /* check for overflow */ | |||
951 | c->stdin_data_size + sz > EXEC_STDIN_DATA_MAX(64U*1024U*1024U)) { | |||
952 | 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)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 952, __func__ , "Standard input data too large (%zu), maximum of %zu permitted, ignoring." , c->stdin_data_size + sz, (size_t) (64U*1024U*1024U)) : - abs(_e); }); | |||
953 | return -E2BIG7; | |||
954 | } | |||
955 | ||||
956 | q = realloc(c->stdin_data, c->stdin_data_size + sz); | |||
957 | if (!q) | |||
958 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 958, __func__); | |||
959 | ||||
960 | memcpy((uint8_t*) q + c->stdin_data_size, p, sz); | |||
961 | ||||
962 | c->stdin_data = q; | |||
963 | c->stdin_data_size += sz; | |||
964 | ||||
965 | return 0; | |||
966 | } | |||
967 | ||||
968 | int config_parse_exec_output( | |||
969 | const char *unit, | |||
970 | const char *filename, | |||
971 | unsigned line, | |||
972 | const char *section, | |||
973 | unsigned section_line, | |||
974 | const char *lvalue, | |||
975 | int ltype, | |||
976 | const char *rvalue, | |||
977 | void *data, | |||
978 | void *userdata) { | |||
979 | ||||
980 | _cleanup_free___attribute__((cleanup(freep))) char *resolved = NULL((void*)0); | |||
981 | const char *n; | |||
982 | ExecContext *c = data; | |||
983 | Unit *u = userdata; | |||
984 | ExecOutput eo; | |||
985 | int r; | |||
986 | ||||
987 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 987 , __PRETTY_FUNCTION__); } while (0); | |||
988 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 988, __PRETTY_FUNCTION__); } while (0); | |||
989 | assert(line)do { if ((__builtin_expect(!!(!(line)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("line"), "../src/core/load-fragment.c", 989 , __PRETTY_FUNCTION__); } while (0); | |||
990 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 990, __PRETTY_FUNCTION__); } while (0); | |||
991 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 991, __PRETTY_FUNCTION__); } while (0); | |||
992 | ||||
993 | n = startswith(rvalue, "fd:"); | |||
994 | if (n) { | |||
995 | r = unit_full_printf(u, n, &resolved); | |||
996 | if (r < 0) | |||
997 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 997, __func__ , "Failed to resolve unit specifiers in %s: %m", n) : -abs(_e ); }); | |||
998 | ||||
999 | if (isempty(resolved)) | |||
1000 | resolved = mfree(resolved); | |||
1001 | else if (!fdname_is_valid(resolved)) { | |||
1002 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid file descriptor name: %s", resolved)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1002, __func__ , "Invalid file descriptor name: %s", resolved) : -abs(_e); } ); | |||
1003 | return -ENOEXEC8; | |||
1004 | } | |||
1005 | ||||
1006 | eo = EXEC_OUTPUT_NAMED_FD; | |||
1007 | ||||
1008 | } else if ((n = startswith(rvalue, "file:"))) { | |||
1009 | ||||
1010 | r = unit_full_printf(u, n, &resolved); | |||
1011 | if (r < 0) | |||
1012 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1012, __func__ , "Failed to resolve unit specifiers in %s: %m", n) : -abs(_e ); }); | |||
1013 | ||||
1014 | r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE | PATH_CHECK_FATAL, unit, filename, line, lvalue); | |||
1015 | if (r < 0) | |||
1016 | return -ENOEXEC8; | |||
1017 | ||||
1018 | eo = EXEC_OUTPUT_FILE; | |||
1019 | ||||
1020 | } else if ((n = startswith(rvalue, "append:"))) { | |||
1021 | ||||
1022 | r = unit_full_printf(u, n, &resolved); | |||
1023 | if (r < 0) | |||
1024 | return log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", n)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1024, __func__ , "Failed to resolve unit specifiers in %s: %m", n) : -abs(_e ); }); | |||
1025 | ||||
1026 | r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE | PATH_CHECK_FATAL, unit, filename, line, lvalue); | |||
1027 | if (r < 0) | |||
1028 | return -ENOEXEC8; | |||
1029 | ||||
1030 | eo = EXEC_OUTPUT_FILE_APPEND; | |||
1031 | } else { | |||
1032 | eo = exec_output_from_string(rvalue); | |||
1033 | if (eo < 0) { | |||
1034 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse output specifier, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1034, __func__ , "Failed to parse output specifier, ignoring: %s", rvalue) : -abs(_e); }); | |||
1035 | return 0; | |||
1036 | } | |||
1037 | } | |||
1038 | ||||
1039 | if (streq(lvalue, "StandardOutput")(strcmp((lvalue),("StandardOutput")) == 0)) { | |||
1040 | if (eo == EXEC_OUTPUT_NAMED_FD) | |||
1041 | free_and_replace(c->stdio_fdname[STDOUT_FILENO], resolved)({ free(c->stdio_fdname[1]); (c->stdio_fdname[1]) = (resolved ); (resolved) = ((void*)0); 0; }); | |||
1042 | else | |||
1043 | free_and_replace(c->stdio_file[STDOUT_FILENO], resolved)({ free(c->stdio_file[1]); (c->stdio_file[1]) = (resolved ); (resolved) = ((void*)0); 0; }); | |||
1044 | ||||
1045 | c->std_output = eo; | |||
1046 | ||||
1047 | } else { | |||
1048 | assert(streq(lvalue, "StandardError"))do { if ((__builtin_expect(!!(!((strcmp((lvalue),("StandardError" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(lvalue, \"StandardError\")" ), "../src/core/load-fragment.c", 1048, __PRETTY_FUNCTION__); } while (0); | |||
1049 | ||||
1050 | if (eo == EXEC_OUTPUT_NAMED_FD) | |||
1051 | free_and_replace(c->stdio_fdname[STDERR_FILENO], resolved)({ free(c->stdio_fdname[2]); (c->stdio_fdname[2]) = (resolved ); (resolved) = ((void*)0); 0; }); | |||
1052 | else | |||
1053 | free_and_replace(c->stdio_file[STDERR_FILENO], resolved)({ free(c->stdio_file[2]); (c->stdio_file[2]) = (resolved ); (resolved) = ((void*)0); 0; }); | |||
1054 | ||||
1055 | c->std_error = eo; | |||
1056 | } | |||
1057 | ||||
1058 | return 0; | |||
1059 | } | |||
1060 | ||||
1061 | int config_parse_exec_io_class(const char *unit, | |||
1062 | const char *filename, | |||
1063 | unsigned line, | |||
1064 | const char *section, | |||
1065 | unsigned section_line, | |||
1066 | const char *lvalue, | |||
1067 | int ltype, | |||
1068 | const char *rvalue, | |||
1069 | void *data, | |||
1070 | void *userdata) { | |||
1071 | ||||
1072 | ExecContext *c = data; | |||
1073 | int x; | |||
1074 | ||||
1075 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1075, __PRETTY_FUNCTION__); } while (0); | |||
1076 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1076, __PRETTY_FUNCTION__); } while (0); | |||
1077 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1077, __PRETTY_FUNCTION__); } while (0); | |||
1078 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1078 , __PRETTY_FUNCTION__); } while (0); | |||
1079 | ||||
1080 | if (isempty(rvalue)) { | |||
1081 | c->ioprio_set = false0; | |||
1082 | c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0)(((IOPRIO_CLASS_BE) << 13) | 0); | |||
1083 | return 0; | |||
1084 | } | |||
1085 | ||||
1086 | x = ioprio_class_from_string(rvalue); | |||
1087 | if (x < 0) { | |||
1088 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IO scheduling class, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1088, __func__ , "Failed to parse IO scheduling class, ignoring: %s", rvalue ) : -abs(_e); }); | |||
1089 | return 0; | |||
1090 | } | |||
1091 | ||||
1092 | c->ioprio = IOPRIO_PRIO_VALUE(x, IOPRIO_PRIO_DATA(c->ioprio))(((x) << 13) | ((c->ioprio) & ((1UL << 13) - 1))); | |||
1093 | c->ioprio_set = true1; | |||
1094 | ||||
1095 | return 0; | |||
1096 | } | |||
1097 | ||||
1098 | int config_parse_exec_io_priority(const char *unit, | |||
1099 | const char *filename, | |||
1100 | unsigned line, | |||
1101 | const char *section, | |||
1102 | unsigned section_line, | |||
1103 | const char *lvalue, | |||
1104 | int ltype, | |||
1105 | const char *rvalue, | |||
1106 | void *data, | |||
1107 | void *userdata) { | |||
1108 | ||||
1109 | ExecContext *c = data; | |||
1110 | int i, r; | |||
1111 | ||||
1112 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1112, __PRETTY_FUNCTION__); } while (0); | |||
1113 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1113, __PRETTY_FUNCTION__); } while (0); | |||
1114 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1114, __PRETTY_FUNCTION__); } while (0); | |||
1115 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1115 , __PRETTY_FUNCTION__); } while (0); | |||
1116 | ||||
1117 | if (isempty(rvalue)) { | |||
1118 | c->ioprio_set = false0; | |||
1119 | c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0)(((IOPRIO_CLASS_BE) << 13) | 0); | |||
1120 | return 0; | |||
1121 | } | |||
1122 | ||||
1123 | r = ioprio_parse_priority(rvalue, &i); | |||
1124 | if (r < 0) { | |||
1125 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse IO priority, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1125, __func__ , "Failed to parse IO priority, ignoring: %s", rvalue) : -abs (_e); }); | |||
1126 | return 0; | |||
1127 | } | |||
1128 | ||||
1129 | c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c->ioprio), i)(((((c->ioprio) >> 13)) << 13) | i); | |||
1130 | c->ioprio_set = true1; | |||
1131 | ||||
1132 | return 0; | |||
1133 | } | |||
1134 | ||||
1135 | int config_parse_exec_cpu_sched_policy(const char *unit, | |||
1136 | const char *filename, | |||
1137 | unsigned line, | |||
1138 | const char *section, | |||
1139 | unsigned section_line, | |||
1140 | const char *lvalue, | |||
1141 | int ltype, | |||
1142 | const char *rvalue, | |||
1143 | void *data, | |||
1144 | void *userdata) { | |||
1145 | ||||
1146 | ExecContext *c = data; | |||
1147 | int x; | |||
1148 | ||||
1149 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1149, __PRETTY_FUNCTION__); } while (0); | |||
1150 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1150, __PRETTY_FUNCTION__); } while (0); | |||
1151 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1151, __PRETTY_FUNCTION__); } while (0); | |||
1152 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1152 , __PRETTY_FUNCTION__); } while (0); | |||
1153 | ||||
1154 | if (isempty(rvalue)) { | |||
1155 | c->cpu_sched_set = false0; | |||
1156 | c->cpu_sched_policy = SCHED_OTHER0; | |||
1157 | c->cpu_sched_priority = 0; | |||
1158 | return 0; | |||
1159 | } | |||
1160 | ||||
1161 | x = sched_policy_from_string(rvalue); | |||
1162 | if (x < 0) { | |||
1163 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse CPU scheduling policy, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1163, __func__ , "Failed to parse CPU scheduling policy, ignoring: %s", rvalue ) : -abs(_e); }); | |||
1164 | return 0; | |||
1165 | } | |||
1166 | ||||
1167 | c->cpu_sched_policy = x; | |||
1168 | /* Moving to or from real-time policy? We need to adjust the priority */ | |||
1169 | c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min(x), sched_get_priority_max(x))__extension__ ({ const typeof((c->cpu_sched_priority)) __unique_prefix_X25 = ((c->cpu_sched_priority)); const typeof((sched_get_priority_min (x))) __unique_prefix_LOW26 = ((sched_get_priority_min(x))); const typeof((sched_get_priority_max(x))) __unique_prefix_HIGH27 = ((sched_get_priority_max(x))); __unique_prefix_X25 > __unique_prefix_HIGH27 ? __unique_prefix_HIGH27 : __unique_prefix_X25 < __unique_prefix_LOW26 ? __unique_prefix_LOW26 : __unique_prefix_X25; }); | |||
1170 | c->cpu_sched_set = true1; | |||
1171 | ||||
1172 | return 0; | |||
1173 | } | |||
1174 | ||||
1175 | int config_parse_numa_mask(const char *unit, | |||
1176 | const char *filename, | |||
1177 | unsigned line, | |||
1178 | const char *section, | |||
1179 | unsigned section_line, | |||
1180 | const char *lvalue, | |||
1181 | int ltype, | |||
1182 | const char *rvalue, | |||
1183 | void *data, | |||
1184 | void *userdata) { | |||
1185 | int r; | |||
1186 | NUMAPolicy *p = data; | |||
1187 | ||||
1188 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1188, __PRETTY_FUNCTION__); } while (0); | |||
1189 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1189, __PRETTY_FUNCTION__); } while (0); | |||
1190 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1190, __PRETTY_FUNCTION__); } while (0); | |||
1191 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1191 , __PRETTY_FUNCTION__); } while (0); | |||
1192 | ||||
1193 | r = parse_cpu_set_extend(rvalue, &p->nodes, true1, unit, filename, line, lvalue); | |||
1194 | if (r < 0) { | |||
1195 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse NUMA node mask, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1195, __func__ , "Failed to parse NUMA node mask, ignoring: %s", rvalue) : - abs(_e); }); | |||
1196 | return 0; | |||
1197 | } | |||
1198 | ||||
1199 | return r; | |||
1200 | } | |||
1201 | ||||
1202 | int config_parse_exec_cpu_sched_prio(const char *unit, | |||
1203 | const char *filename, | |||
1204 | unsigned line, | |||
1205 | const char *section, | |||
1206 | unsigned section_line, | |||
1207 | const char *lvalue, | |||
1208 | int ltype, | |||
1209 | const char *rvalue, | |||
1210 | void *data, | |||
1211 | void *userdata) { | |||
1212 | ||||
1213 | ExecContext *c = data; | |||
1214 | int i, min, max, r; | |||
1215 | ||||
1216 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1216, __PRETTY_FUNCTION__); } while (0); | |||
1217 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1217, __PRETTY_FUNCTION__); } while (0); | |||
1218 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1218, __PRETTY_FUNCTION__); } while (0); | |||
1219 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1219 , __PRETTY_FUNCTION__); } while (0); | |||
1220 | ||||
1221 | r = safe_atoi(rvalue, &i); | |||
1222 | if (r < 0) { | |||
1223 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse CPU scheduling priority, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1223, __func__ , "Failed to parse CPU scheduling priority, ignoring: %s", rvalue ) : -abs(_e); }); | |||
1224 | return 0; | |||
1225 | } | |||
1226 | ||||
1227 | /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0 */ | |||
1228 | min = sched_get_priority_min(c->cpu_sched_policy); | |||
1229 | max = sched_get_priority_max(c->cpu_sched_policy); | |||
1230 | ||||
1231 | if (i < min || i > max) { | |||
1232 | log_syntax(unit, LOG_ERR, filename, line, 0, "CPU scheduling priority is out of range, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1232, __func__ , "CPU scheduling priority is out of range, ignoring: %s", rvalue ) : -abs(_e); }); | |||
1233 | return 0; | |||
1234 | } | |||
1235 | ||||
1236 | c->cpu_sched_priority = i; | |||
1237 | c->cpu_sched_set = true1; | |||
1238 | ||||
1239 | return 0; | |||
1240 | } | |||
1241 | ||||
1242 | int config_parse_exec_cpu_affinity(const char *unit, | |||
1243 | const char *filename, | |||
1244 | unsigned line, | |||
1245 | const char *section, | |||
1246 | unsigned section_line, | |||
1247 | const char *lvalue, | |||
1248 | int ltype, | |||
1249 | const char *rvalue, | |||
1250 | void *data, | |||
1251 | void *userdata) { | |||
1252 | ||||
1253 | ExecContext *c = data; | |||
1254 | int r; | |||
1255 | ||||
1256 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1256, __PRETTY_FUNCTION__); } while (0); | |||
1257 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1257, __PRETTY_FUNCTION__); } while (0); | |||
1258 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1258, __PRETTY_FUNCTION__); } while (0); | |||
1259 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1259 , __PRETTY_FUNCTION__); } while (0); | |||
1260 | ||||
1261 | if (streq(rvalue, "numa")(strcmp((rvalue),("numa")) == 0)) { | |||
1262 | c->cpu_affinity_from_numa = true1; | |||
1263 | cpu_set_reset(&c->cpu_set); | |||
1264 | ||||
1265 | return 0; | |||
1266 | } | |||
1267 | ||||
1268 | r = parse_cpu_set_extend(rvalue, &c->cpu_set, true1, unit, filename, line, lvalue); | |||
1269 | if (r >= 0) | |||
1270 | c->cpu_affinity_from_numa = false0; | |||
1271 | ||||
1272 | return r; | |||
1273 | } | |||
1274 | ||||
1275 | int config_parse_capability_set( | |||
1276 | const char *unit, | |||
1277 | const char *filename, | |||
1278 | unsigned line, | |||
1279 | const char *section, | |||
1280 | unsigned section_line, | |||
1281 | const char *lvalue, | |||
1282 | int ltype, | |||
1283 | const char *rvalue, | |||
1284 | void *data, | |||
1285 | void *userdata) { | |||
1286 | ||||
1287 | uint64_t *capability_set = data; | |||
1288 | uint64_t sum = 0, initial = 0; | |||
1289 | bool_Bool invert = false0; | |||
1290 | int r; | |||
1291 | ||||
1292 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1292, __PRETTY_FUNCTION__); } while (0); | |||
1293 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1293, __PRETTY_FUNCTION__); } while (0); | |||
1294 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1294, __PRETTY_FUNCTION__); } while (0); | |||
1295 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1295 , __PRETTY_FUNCTION__); } while (0); | |||
1296 | ||||
1297 | if (rvalue[0] == '~') { | |||
1298 | invert = true1; | |||
1299 | rvalue++; | |||
1300 | } | |||
1301 | ||||
1302 | if (streq(lvalue, "CapabilityBoundingSet")(strcmp((lvalue),("CapabilityBoundingSet")) == 0)) | |||
1303 | initial = CAP_ALL(uint64_t) -1; /* initialized to all bits on */ | |||
1304 | /* else "AmbientCapabilities" initialized to all bits off */ | |||
1305 | ||||
1306 | r = capability_set_from_string(rvalue, &sum); | |||
1307 | if (r < 0) { | |||
1308 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= specifier '%s', ignoring: %m", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1308, __func__ , "Failed to parse %s= specifier '%s', ignoring: %m", lvalue, rvalue) : -abs(_e); }); | |||
1309 | return 0; | |||
1310 | } | |||
1311 | ||||
1312 | if (sum == 0 || *capability_set == initial) | |||
1313 | /* "", "~" or uninitialized data -> replace */ | |||
1314 | *capability_set = invert ? ~sum : sum; | |||
1315 | else { | |||
1316 | /* previous data -> merge */ | |||
1317 | if (invert) | |||
1318 | *capability_set &= ~sum; | |||
1319 | else | |||
1320 | *capability_set |= sum; | |||
1321 | } | |||
1322 | ||||
1323 | return 0; | |||
1324 | } | |||
1325 | ||||
1326 | int config_parse_exec_selinux_context( | |||
1327 | const char *unit, | |||
1328 | const char *filename, | |||
1329 | unsigned line, | |||
1330 | const char *section, | |||
1331 | unsigned section_line, | |||
1332 | const char *lvalue, | |||
1333 | int ltype, | |||
1334 | const char *rvalue, | |||
1335 | void *data, | |||
1336 | void *userdata) { | |||
1337 | ||||
1338 | ExecContext *c = data; | |||
1339 | Unit *u = userdata; | |||
1340 | bool_Bool ignore; | |||
1341 | char *k; | |||
1342 | int r; | |||
1343 | ||||
1344 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1344, __PRETTY_FUNCTION__); } while (0); | |||
1345 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1345, __PRETTY_FUNCTION__); } while (0); | |||
1346 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1346, __PRETTY_FUNCTION__); } while (0); | |||
1347 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1347 , __PRETTY_FUNCTION__); } while (0); | |||
1348 | ||||
1349 | if (isempty(rvalue)) { | |||
1350 | c->selinux_context = mfree(c->selinux_context); | |||
1351 | c->selinux_context_ignore = false0; | |||
1352 | return 0; | |||
1353 | } | |||
1354 | ||||
1355 | if (rvalue[0] == '-') { | |||
1356 | ignore = true1; | |||
1357 | rvalue++; | |||
1358 | } else | |||
1359 | ignore = false0; | |||
1360 | ||||
1361 | r = unit_full_printf(u, rvalue, &k); | |||
1362 | if (r < 0) { | |||
1363 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1365, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
1364 | "Failed to resolve unit specifiers in '%s'%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1365, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
1365 | rvalue, ignore ? ", ignoring" : "")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1365, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }); | |||
1366 | return ignore ? 0 : -ENOEXEC8; | |||
1367 | } | |||
1368 | ||||
1369 | free_and_replace(c->selinux_context, k)({ free(c->selinux_context); (c->selinux_context) = (k) ; (k) = ((void*)0); 0; }); | |||
1370 | c->selinux_context_ignore = ignore; | |||
1371 | ||||
1372 | return 0; | |||
1373 | } | |||
1374 | ||||
1375 | int config_parse_exec_apparmor_profile( | |||
1376 | const char *unit, | |||
1377 | const char *filename, | |||
1378 | unsigned line, | |||
1379 | const char *section, | |||
1380 | unsigned section_line, | |||
1381 | const char *lvalue, | |||
1382 | int ltype, | |||
1383 | const char *rvalue, | |||
1384 | void *data, | |||
1385 | void *userdata) { | |||
1386 | ||||
1387 | ExecContext *c = data; | |||
1388 | Unit *u = userdata; | |||
1389 | bool_Bool ignore; | |||
1390 | char *k; | |||
1391 | int r; | |||
1392 | ||||
1393 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1393, __PRETTY_FUNCTION__); } while (0); | |||
1394 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1394, __PRETTY_FUNCTION__); } while (0); | |||
1395 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1395, __PRETTY_FUNCTION__); } while (0); | |||
1396 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1396 , __PRETTY_FUNCTION__); } while (0); | |||
1397 | ||||
1398 | if (isempty(rvalue)) { | |||
1399 | c->apparmor_profile = mfree(c->apparmor_profile); | |||
1400 | c->apparmor_profile_ignore = false0; | |||
1401 | return 0; | |||
1402 | } | |||
1403 | ||||
1404 | if (rvalue[0] == '-') { | |||
1405 | ignore = true1; | |||
1406 | rvalue++; | |||
1407 | } else | |||
1408 | ignore = false0; | |||
1409 | ||||
1410 | r = unit_full_printf(u, rvalue, &k); | |||
1411 | if (r < 0) { | |||
1412 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1414, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
1413 | "Failed to resolve unit specifiers in '%s'%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1414, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
1414 | rvalue, ignore ? ", ignoring" : "")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1414, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }); | |||
1415 | return ignore ? 0 : -ENOEXEC8; | |||
1416 | } | |||
1417 | ||||
1418 | free_and_replace(c->apparmor_profile, k)({ free(c->apparmor_profile); (c->apparmor_profile) = ( k); (k) = ((void*)0); 0; }); | |||
1419 | c->apparmor_profile_ignore = ignore; | |||
1420 | ||||
1421 | return 0; | |||
1422 | } | |||
1423 | ||||
1424 | int config_parse_exec_smack_process_label( | |||
1425 | const char *unit, | |||
1426 | const char *filename, | |||
1427 | unsigned line, | |||
1428 | const char *section, | |||
1429 | unsigned section_line, | |||
1430 | const char *lvalue, | |||
1431 | int ltype, | |||
1432 | const char *rvalue, | |||
1433 | void *data, | |||
1434 | void *userdata) { | |||
1435 | ||||
1436 | ExecContext *c = data; | |||
1437 | Unit *u = userdata; | |||
1438 | bool_Bool ignore; | |||
1439 | char *k; | |||
1440 | int r; | |||
1441 | ||||
1442 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1442, __PRETTY_FUNCTION__); } while (0); | |||
1443 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1443, __PRETTY_FUNCTION__); } while (0); | |||
1444 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1444, __PRETTY_FUNCTION__); } while (0); | |||
1445 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1445 , __PRETTY_FUNCTION__); } while (0); | |||
1446 | ||||
1447 | if (isempty(rvalue)) { | |||
1448 | c->smack_process_label = mfree(c->smack_process_label); | |||
1449 | c->smack_process_label_ignore = false0; | |||
1450 | return 0; | |||
1451 | } | |||
1452 | ||||
1453 | if (rvalue[0] == '-') { | |||
1454 | ignore = true1; | |||
1455 | rvalue++; | |||
1456 | } else | |||
1457 | ignore = false0; | |||
1458 | ||||
1459 | r = unit_full_printf(u, rvalue, &k); | |||
1460 | if (r < 0) { | |||
1461 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1463, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
1462 | "Failed to resolve unit specifiers in '%s'%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1463, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }) | |||
1463 | rvalue, ignore ? ", ignoring" : "")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1463, __func__ , "Failed to resolve unit specifiers in '%s'%s: %m", rvalue, ignore ? ", ignoring" : "") : -abs(_e); }); | |||
1464 | return ignore ? 0 : -ENOEXEC8; | |||
1465 | } | |||
1466 | ||||
1467 | free_and_replace(c->smack_process_label, k)({ free(c->smack_process_label); (c->smack_process_label ) = (k); (k) = ((void*)0); 0; }); | |||
1468 | c->smack_process_label_ignore = ignore; | |||
1469 | ||||
1470 | return 0; | |||
1471 | } | |||
1472 | ||||
1473 | int config_parse_timer(const char *unit, | |||
1474 | const char *filename, | |||
1475 | unsigned line, | |||
1476 | const char *section, | |||
1477 | unsigned section_line, | |||
1478 | const char *lvalue, | |||
1479 | int ltype, | |||
1480 | const char *rvalue, | |||
1481 | void *data, | |||
1482 | void *userdata) { | |||
1483 | ||||
1484 | Timer *t = data; | |||
1485 | usec_t usec = 0; | |||
1486 | TimerValue *v; | |||
1487 | TimerBase b; | |||
1488 | _cleanup_(calendar_spec_freep)__attribute__((cleanup(calendar_spec_freep))) CalendarSpec *c = NULL((void*)0); | |||
1489 | Unit *u = userdata; | |||
1490 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
1491 | int r; | |||
1492 | ||||
1493 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1493, __PRETTY_FUNCTION__); } while (0); | |||
1494 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1494, __PRETTY_FUNCTION__); } while (0); | |||
1495 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1495, __PRETTY_FUNCTION__); } while (0); | |||
1496 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1496 , __PRETTY_FUNCTION__); } while (0); | |||
1497 | ||||
1498 | if (isempty(rvalue)) { | |||
1499 | /* Empty assignment resets list */ | |||
1500 | timer_free_values(t); | |||
1501 | return 0; | |||
1502 | } | |||
1503 | ||||
1504 | b = timer_base_from_string(lvalue); | |||
1505 | if (b < 0) { | |||
1506 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse timer base, ignoring: %s", lvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1506, __func__ , "Failed to parse timer base, ignoring: %s", lvalue) : -abs( _e); }); | |||
1507 | return 0; | |||
1508 | } | |||
1509 | ||||
1510 | r = unit_full_printf(u, rvalue, &k); | |||
1511 | if (r < 0) { | |||
1512 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1512, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
1513 | return 0; | |||
1514 | } | |||
1515 | ||||
1516 | if (b == TIMER_CALENDAR) { | |||
1517 | if (calendar_spec_from_string(k, &c) < 0) { | |||
1518 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse calendar specification, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1518, __func__ , "Failed to parse calendar specification, ignoring: %s", k) : -abs(_e); }); | |||
1519 | return 0; | |||
1520 | } | |||
1521 | } else | |||
1522 | if (parse_sec(k, &usec) < 0) { | |||
1523 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse timer value, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1523, __func__ , "Failed to parse timer value, ignoring: %s", k) : -abs(_e); }); | |||
1524 | return 0; | |||
1525 | } | |||
1526 | ||||
1527 | v = new0(TimerValue, 1)((TimerValue*) calloc((1), sizeof(TimerValue))); | |||
1528 | if (!v) | |||
1529 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 1529, __func__); | |||
1530 | ||||
1531 | v->base = b; | |||
1532 | v->value = usec; | |||
1533 | v->calendar_spec = TAKE_PTR(c)({ typeof(c) _ptr_ = (c); (c) = ((void*)0); _ptr_; }); | |||
1534 | ||||
1535 | LIST_PREPEND(value, t->values, v)do { typeof(*(t->values)) **_head = &(t->values), * _item = (v); do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 1535, __PRETTY_FUNCTION__); } while (0); if ((_item->value_next = *_head)) _item->value_next->value_prev = _item; _item ->value_prev = ((void*)0); *_head = _item; } while (0); | |||
1536 | ||||
1537 | return 0; | |||
1538 | } | |||
1539 | ||||
1540 | int config_parse_trigger_unit( | |||
1541 | const char *unit, | |||
1542 | const char *filename, | |||
1543 | unsigned line, | |||
1544 | const char *section, | |||
1545 | unsigned section_line, | |||
1546 | const char *lvalue, | |||
1547 | int ltype, | |||
1548 | const char *rvalue, | |||
1549 | void *data, | |||
1550 | void *userdata) { | |||
1551 | ||||
1552 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); | |||
1553 | Unit *u = data; | |||
1554 | UnitType type; | |||
1555 | int r; | |||
1556 | ||||
1557 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1557, __PRETTY_FUNCTION__); } while (0); | |||
1558 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1558, __PRETTY_FUNCTION__); } while (0); | |||
1559 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1559, __PRETTY_FUNCTION__); } while (0); | |||
1560 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1560 , __PRETTY_FUNCTION__); } while (0); | |||
1561 | ||||
1562 | if (!hashmap_isempty(u->dependencies[UNIT_TRIGGERS])) { | |||
1563 | log_syntax(unit, LOG_ERR, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1563, __func__ , "Multiple units to trigger specified, ignoring: %s", rvalue ) : -abs(_e); }); | |||
1564 | return 0; | |||
1565 | } | |||
1566 | ||||
1567 | r = unit_name_printf(u, rvalue, &p); | |||
1568 | if (r < 0) { | |||
1569 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1569, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue ) : -abs(_e); }); | |||
1570 | return 0; | |||
1571 | } | |||
1572 | ||||
1573 | type = unit_name_to_type(p); | |||
1574 | if (type < 0) { | |||
1575 | log_syntax(unit, LOG_ERR, filename, line, 0, "Unit type not valid, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1575, __func__ , "Unit type not valid, ignoring: %s", rvalue) : -abs(_e); }); | |||
1576 | return 0; | |||
1577 | } | |||
1578 | if (unit_has_name(u, p)) { | |||
1579 | log_syntax(unit, LOG_ERR, filename, line, 0, "Units cannot trigger themselves, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1579, __func__ , "Units cannot trigger themselves, ignoring: %s", rvalue) : - abs(_e); }); | |||
1580 | return 0; | |||
1581 | } | |||
1582 | ||||
1583 | r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_TRIGGERS, p, NULL((void*)0), true1, UNIT_DEPENDENCY_FILE); | |||
1584 | if (r < 0) { | |||
1585 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add trigger on %s, ignoring: %m", p)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1585, __func__ , "Failed to add trigger on %s, ignoring: %m", p) : -abs(_e); }); | |||
1586 | return 0; | |||
1587 | } | |||
1588 | ||||
1589 | return 0; | |||
1590 | } | |||
1591 | ||||
1592 | int config_parse_path_spec(const char *unit, | |||
1593 | const char *filename, | |||
1594 | unsigned line, | |||
1595 | const char *section, | |||
1596 | unsigned section_line, | |||
1597 | const char *lvalue, | |||
1598 | int ltype, | |||
1599 | const char *rvalue, | |||
1600 | void *data, | |||
1601 | void *userdata) { | |||
1602 | ||||
1603 | Path *p = data; | |||
1604 | PathSpec *s; | |||
1605 | PathType b; | |||
1606 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
1607 | int r; | |||
1608 | ||||
1609 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1609, __PRETTY_FUNCTION__); } while (0); | |||
1610 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1610, __PRETTY_FUNCTION__); } while (0); | |||
1611 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1611, __PRETTY_FUNCTION__); } while (0); | |||
1612 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1612 , __PRETTY_FUNCTION__); } while (0); | |||
1613 | ||||
1614 | if (isempty(rvalue)) { | |||
1615 | /* Empty assignment clears list */ | |||
1616 | path_free_specs(p); | |||
1617 | return 0; | |||
1618 | } | |||
1619 | ||||
1620 | b = path_type_from_string(lvalue); | |||
1621 | if (b < 0) { | |||
1622 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse path type, ignoring: %s", lvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1622, __func__ , "Failed to parse path type, ignoring: %s", lvalue) : -abs(_e ); }); | |||
1623 | return 0; | |||
1624 | } | |||
1625 | ||||
1626 | r = unit_full_printf(UNIT(p)({ typeof(p) _u_ = (p); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), rvalue, &k); | |||
1627 | if (r < 0) { | |||
1628 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1628, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue ) : -abs(_e); }); | |||
1629 | return 0; | |||
1630 | } | |||
1631 | ||||
1632 | r = path_simplify_and_warn(k, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
1633 | if (r < 0) | |||
1634 | return 0; | |||
1635 | ||||
1636 | s = new0(PathSpec, 1)((PathSpec*) calloc((1), sizeof(PathSpec))); | |||
1637 | if (!s) | |||
1638 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 1638, __func__); | |||
1639 | ||||
1640 | s->unit = UNIT(p)({ typeof(p) _u_ = (p); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }); | |||
1641 | s->path = TAKE_PTR(k)({ typeof(k) _ptr_ = (k); (k) = ((void*)0); _ptr_; }); | |||
1642 | s->type = b; | |||
1643 | s->inotify_fd = -1; | |||
1644 | ||||
1645 | LIST_PREPEND(spec, p->specs, s)do { typeof(*(p->specs)) **_head = &(p->specs), *_item = (s); do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 1645, __PRETTY_FUNCTION__); } while (0); if ((_item->spec_next = *_head)) _item->spec_next->spec_prev = _item; _item-> spec_prev = ((void*)0); *_head = _item; } while (0); | |||
1646 | ||||
1647 | return 0; | |||
1648 | } | |||
1649 | ||||
1650 | int config_parse_socket_service( | |||
1651 | const char *unit, | |||
1652 | const char *filename, | |||
1653 | unsigned line, | |||
1654 | const char *section, | |||
1655 | unsigned section_line, | |||
1656 | const char *lvalue, | |||
1657 | int ltype, | |||
1658 | const char *rvalue, | |||
1659 | void *data, | |||
1660 | void *userdata) { | |||
1661 | ||||
1662 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
1663 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); | |||
1664 | Socket *s = data; | |||
1665 | Unit *x; | |||
1666 | int r; | |||
1667 | ||||
1668 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1668, __PRETTY_FUNCTION__); } while (0); | |||
1669 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1669, __PRETTY_FUNCTION__); } while (0); | |||
1670 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1670, __PRETTY_FUNCTION__); } while (0); | |||
1671 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1671 , __PRETTY_FUNCTION__); } while (0); | |||
1672 | ||||
1673 | r = unit_name_printf(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), rvalue, &p); | |||
1674 | if (r < 0) { | |||
1675 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1675, __func__ , "Failed to resolve unit specifiers in %s: %m", rvalue) : -abs (_e); }); | |||
1676 | return -ENOEXEC8; | |||
1677 | } | |||
1678 | ||||
1679 | if (!endswith(p, ".service")) { | |||
1680 | log_syntax(unit, LOG_ERR, filename, line, 0, "Unit must be of type service: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1680, __func__ , "Unit must be of type service: %s", rvalue) : -abs(_e); }); | |||
1681 | return -ENOEXEC8; | |||
1682 | } | |||
1683 | ||||
1684 | r = manager_load_unit(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; })->manager, p, NULL((void*)0), &error, &x); | |||
1685 | if (r < 0) { | |||
1686 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load unit %s: %s", rvalue, bus_error_message(&error, r))({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1686, __func__ , "Failed to load unit %s: %s", rvalue, bus_error_message(& error, r)) : -abs(_e); }); | |||
1687 | return -ENOEXEC8; | |||
1688 | } | |||
1689 | ||||
1690 | unit_ref_set(&s->service, UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), x); | |||
1691 | ||||
1692 | return 0; | |||
1693 | } | |||
1694 | ||||
1695 | int config_parse_fdname( | |||
1696 | const char *unit, | |||
1697 | const char *filename, | |||
1698 | unsigned line, | |||
1699 | const char *section, | |||
1700 | unsigned section_line, | |||
1701 | const char *lvalue, | |||
1702 | int ltype, | |||
1703 | const char *rvalue, | |||
1704 | void *data, | |||
1705 | void *userdata) { | |||
1706 | ||||
1707 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); | |||
1708 | Socket *s = data; | |||
1709 | int r; | |||
1710 | ||||
1711 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1711, __PRETTY_FUNCTION__); } while (0); | |||
1712 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1712, __PRETTY_FUNCTION__); } while (0); | |||
1713 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1713, __PRETTY_FUNCTION__); } while (0); | |||
1714 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1714 , __PRETTY_FUNCTION__); } while (0); | |||
1715 | ||||
1716 | if (isempty(rvalue)) { | |||
1717 | s->fdname = mfree(s->fdname); | |||
1718 | return 0; | |||
1719 | } | |||
1720 | ||||
1721 | r = unit_full_printf(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), rvalue, &p); | |||
1722 | if (r < 0) { | |||
1723 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1723, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
1724 | return 0; | |||
1725 | } | |||
1726 | ||||
1727 | if (!fdname_is_valid(p)) { | |||
1728 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid file descriptor name, ignoring: %s", p)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1728, __func__ , "Invalid file descriptor name, ignoring: %s", p) : -abs(_e) ; }); | |||
1729 | return 0; | |||
1730 | } | |||
1731 | ||||
1732 | return free_and_replace(s->fdname, p)({ free(s->fdname); (s->fdname) = (p); (p) = ((void*)0) ; 0; }); | |||
1733 | } | |||
1734 | ||||
1735 | int config_parse_service_sockets( | |||
1736 | const char *unit, | |||
1737 | const char *filename, | |||
1738 | unsigned line, | |||
1739 | const char *section, | |||
1740 | unsigned section_line, | |||
1741 | const char *lvalue, | |||
1742 | int ltype, | |||
1743 | const char *rvalue, | |||
1744 | void *data, | |||
1745 | void *userdata) { | |||
1746 | ||||
1747 | Service *s = data; | |||
1748 | const char *p; | |||
1749 | int r; | |||
1750 | ||||
1751 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1751, __PRETTY_FUNCTION__); } while (0); | |||
1752 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1752, __PRETTY_FUNCTION__); } while (0); | |||
1753 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1753, __PRETTY_FUNCTION__); } while (0); | |||
1754 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 1754 , __PRETTY_FUNCTION__); } while (0); | |||
1755 | ||||
1756 | p = rvalue; | |||
1757 | for (;;) { | |||
1758 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
1759 | ||||
1760 | r = extract_first_word(&p, &word, NULL((void*)0), 0); | |||
1761 | if (r == 0) | |||
1762 | break; | |||
1763 | if (r == -ENOMEM12) | |||
1764 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 1764, __func__); | |||
1765 | if (r < 0) { | |||
1766 | log_syntax(unit, LOG_ERR, filename, line, r, "Trailing garbage in sockets, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1766, __func__ , "Trailing garbage in sockets, ignoring: %s", rvalue) : -abs (_e); }); | |||
1767 | break; | |||
1768 | } | |||
1769 | ||||
1770 | r = unit_name_printf(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), word, &k); | |||
1771 | if (r < 0) { | |||
1772 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1772, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", word ) : -abs(_e); }); | |||
1773 | continue; | |||
1774 | } | |||
1775 | ||||
1776 | if (!endswith(k, ".socket")) { | |||
1777 | log_syntax(unit, LOG_ERR, filename, line, 0, "Unit must be of type socket, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1777, __func__ , "Unit must be of type socket, ignoring: %s", k) : -abs(_e); }); | |||
1778 | continue; | |||
1779 | } | |||
1780 | ||||
1781 | r = unit_add_two_dependencies_by_name(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), UNIT_WANTS, UNIT_AFTER, k, NULL((void*)0), true1, UNIT_DEPENDENCY_FILE); | |||
1782 | if (r < 0) | |||
1783 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1783, __func__ , "Failed to add dependency on %s, ignoring: %m", k) : -abs(_e ); }); | |||
1784 | ||||
1785 | r = unit_add_dependency_by_name(UNIT(s)({ typeof(s) _u_ = (s); Unit *_w_ = _u_ ? &(_u_)->meta : ((void*)0); _w_; }), UNIT_TRIGGERED_BY, k, NULL((void*)0), true1, UNIT_DEPENDENCY_FILE); | |||
1786 | if (r < 0) | |||
1787 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1787, __func__ , "Failed to add dependency on %s, ignoring: %m", k) : -abs(_e ); }); | |||
1788 | } | |||
1789 | ||||
1790 | return 0; | |||
1791 | } | |||
1792 | ||||
1793 | int config_parse_bus_name( | |||
1794 | const char *unit, | |||
1795 | const char *filename, | |||
1796 | unsigned line, | |||
1797 | const char *section, | |||
1798 | unsigned section_line, | |||
1799 | const char *lvalue, | |||
1800 | int ltype, | |||
1801 | const char *rvalue, | |||
1802 | void *data, | |||
1803 | void *userdata) { | |||
1804 | ||||
1805 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
1806 | Unit *u = userdata; | |||
1807 | int r; | |||
1808 | ||||
1809 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1809, __PRETTY_FUNCTION__); } while (0); | |||
1810 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1810, __PRETTY_FUNCTION__); } while (0); | |||
1811 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1811, __PRETTY_FUNCTION__); } while (0); | |||
1812 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 1812 , __PRETTY_FUNCTION__); } while (0); | |||
1813 | ||||
1814 | r = unit_full_printf(u, rvalue, &k); | |||
1815 | if (r < 0) { | |||
1816 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1816, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue ) : -abs(_e); }); | |||
1817 | return 0; | |||
1818 | } | |||
1819 | ||||
1820 | if (!service_name_is_valid(k)) { | |||
1821 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid bus name, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1821, __func__ , "Invalid bus name, ignoring: %s", k) : -abs(_e); }); | |||
1822 | return 0; | |||
1823 | } | |||
1824 | ||||
1825 | return config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, k, data, userdata); | |||
1826 | } | |||
1827 | ||||
1828 | int config_parse_service_timeout( | |||
1829 | const char *unit, | |||
1830 | const char *filename, | |||
1831 | unsigned line, | |||
1832 | const char *section, | |||
1833 | unsigned section_line, | |||
1834 | const char *lvalue, | |||
1835 | int ltype, | |||
1836 | const char *rvalue, | |||
1837 | void *data, | |||
1838 | void *userdata) { | |||
1839 | ||||
1840 | Service *s = userdata; | |||
1841 | usec_t usec; | |||
1842 | int r; | |||
1843 | ||||
1844 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1844, __PRETTY_FUNCTION__); } while (0); | |||
1845 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1845, __PRETTY_FUNCTION__); } while (0); | |||
1846 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1846, __PRETTY_FUNCTION__); } while (0); | |||
1847 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/core/load-fragment.c", 1847 , __PRETTY_FUNCTION__); } while (0); | |||
1848 | ||||
1849 | /* This is called for two cases: TimeoutSec= and TimeoutStartSec=. */ | |||
1850 | ||||
1851 | /* Traditionally, these options accepted 0 to disable the timeouts. However, a timeout of 0 suggests it happens | |||
1852 | * immediately, hence fix this to become USEC_INFINITY instead. This is in-line with how we internally handle | |||
1853 | * all other timeouts. */ | |||
1854 | r = parse_sec_fix_0(rvalue, &usec); | |||
1855 | if (r < 0) { | |||
1856 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1856, __func__ , "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue ) : -abs(_e); }); | |||
1857 | return 0; | |||
1858 | } | |||
1859 | ||||
1860 | s->start_timeout_defined = true1; | |||
1861 | s->timeout_start_usec = usec; | |||
1862 | ||||
1863 | if (streq(lvalue, "TimeoutSec")(strcmp((lvalue),("TimeoutSec")) == 0)) | |||
1864 | s->timeout_stop_usec = usec; | |||
1865 | ||||
1866 | return 0; | |||
1867 | } | |||
1868 | ||||
1869 | int config_parse_sec_fix_0( | |||
1870 | const char *unit, | |||
1871 | const char *filename, | |||
1872 | unsigned line, | |||
1873 | const char *section, | |||
1874 | unsigned section_line, | |||
1875 | const char *lvalue, | |||
1876 | int ltype, | |||
1877 | const char *rvalue, | |||
1878 | void *data, | |||
1879 | void *userdata) { | |||
1880 | ||||
1881 | usec_t *usec = data; | |||
1882 | int r; | |||
1883 | ||||
1884 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1884, __PRETTY_FUNCTION__); } while (0); | |||
1885 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1885, __PRETTY_FUNCTION__); } while (0); | |||
1886 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1886, __PRETTY_FUNCTION__); } while (0); | |||
1887 | assert(usec)do { if ((__builtin_expect(!!(!(usec)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("usec"), "../src/core/load-fragment.c", 1887 , __PRETTY_FUNCTION__); } while (0); | |||
1888 | ||||
1889 | /* This is pretty much like config_parse_sec(), except that this treats a time of 0 as infinity, for | |||
1890 | * compatibility with older versions of systemd where 0 instead of infinity was used as indicator to turn off a | |||
1891 | * timeout. */ | |||
1892 | ||||
1893 | r = parse_sec_fix_0(rvalue, usec); | |||
1894 | if (r < 0) { | |||
1895 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1895, __func__ , "Failed to parse %s= parameter, ignoring: %s", lvalue, rvalue ) : -abs(_e); }); | |||
1896 | return 0; | |||
1897 | } | |||
1898 | ||||
1899 | return 0; | |||
1900 | } | |||
1901 | ||||
1902 | int config_parse_user_group_compat( | |||
1903 | const char *unit, | |||
1904 | const char *filename, | |||
1905 | unsigned line, | |||
1906 | const char *section, | |||
1907 | unsigned section_line, | |||
1908 | const char *lvalue, | |||
1909 | int ltype, | |||
1910 | const char *rvalue, | |||
1911 | void *data, | |||
1912 | void *userdata) { | |||
1913 | ||||
1914 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
1915 | char **user = data; | |||
1916 | Unit *u = userdata; | |||
1917 | int r; | |||
1918 | ||||
1919 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1919, __PRETTY_FUNCTION__); } while (0); | |||
1920 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1920, __PRETTY_FUNCTION__); } while (0); | |||
1921 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1921, __PRETTY_FUNCTION__); } while (0); | |||
1922 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 1922 , __PRETTY_FUNCTION__); } while (0); | |||
1923 | ||||
1924 | if (isempty(rvalue)) { | |||
1925 | *user = mfree(*user); | |||
1926 | return 0; | |||
1927 | } | |||
1928 | ||||
1929 | r = unit_full_printf(u, rvalue, &k); | |||
1930 | if (r < 0) { | |||
1931 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1931, __func__ , "Failed to resolve unit specifiers in %s: %m", rvalue) : -abs (_e); }); | |||
1932 | return -ENOEXEC8; | |||
1933 | } | |||
1934 | ||||
1935 | if (!valid_user_group_name(k, VALID_USER_ALLOW_NUMERIC|VALID_USER_RELAX|VALID_USER_WARN)) { | |||
1936 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid user/group name or numeric ID: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1936, __func__ , "Invalid user/group name or numeric ID: %s", k) : -abs(_e); }); | |||
1937 | return -ENOEXEC8; | |||
1938 | } | |||
1939 | ||||
1940 | return free_and_replace(*user, k)({ free(*user); (*user) = (k); (k) = ((void*)0); 0; }); | |||
1941 | } | |||
1942 | ||||
1943 | int config_parse_user_group_strv_compat( | |||
1944 | const char *unit, | |||
1945 | const char *filename, | |||
1946 | unsigned line, | |||
1947 | const char *section, | |||
1948 | unsigned section_line, | |||
1949 | const char *lvalue, | |||
1950 | int ltype, | |||
1951 | const char *rvalue, | |||
1952 | void *data, | |||
1953 | void *userdata) { | |||
1954 | ||||
1955 | char ***users = data; | |||
1956 | Unit *u = userdata; | |||
1957 | const char *p = rvalue; | |||
1958 | int r; | |||
1959 | ||||
1960 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 1960, __PRETTY_FUNCTION__); } while (0); | |||
1961 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 1961, __PRETTY_FUNCTION__); } while (0); | |||
1962 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 1962, __PRETTY_FUNCTION__); } while (0); | |||
1963 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 1963 , __PRETTY_FUNCTION__); } while (0); | |||
1964 | ||||
1965 | if (isempty(rvalue)) { | |||
1966 | *users = strv_free(*users); | |||
1967 | return 0; | |||
1968 | } | |||
1969 | ||||
1970 | for (;;) { | |||
1971 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
1972 | ||||
1973 | r = extract_first_word(&p, &word, NULL((void*)0), 0); | |||
1974 | if (r == 0) | |||
1975 | break; | |||
1976 | if (r == -ENOMEM12) | |||
1977 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 1977, __func__); | |||
1978 | if (r < 0) { | |||
1979 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1979, __func__ , "Invalid syntax: %s", rvalue) : -abs(_e); }); | |||
1980 | return -ENOEXEC8; | |||
1981 | } | |||
1982 | ||||
1983 | r = unit_full_printf(u, word, &k); | |||
1984 | if (r < 0) { | |||
1985 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1985, __func__ , "Failed to resolve unit specifiers in %s: %m", word) : -abs (_e); }); | |||
1986 | return -ENOEXEC8; | |||
1987 | } | |||
1988 | ||||
1989 | if (!valid_user_group_name(k, VALID_USER_ALLOW_NUMERIC|VALID_USER_RELAX|VALID_USER_WARN)) { | |||
1990 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid user/group name or numeric ID: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 1990, __func__ , "Invalid user/group name or numeric ID: %s", k) : -abs(_e); }); | |||
1991 | return -ENOEXEC8; | |||
1992 | } | |||
1993 | ||||
1994 | r = strv_push(users, k); | |||
1995 | if (r < 0) | |||
1996 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 1996, __func__); | |||
1997 | ||||
1998 | k = NULL((void*)0); | |||
1999 | } | |||
2000 | ||||
2001 | return 0; | |||
2002 | } | |||
2003 | ||||
2004 | int config_parse_working_directory( | |||
2005 | const char *unit, | |||
2006 | const char *filename, | |||
2007 | unsigned line, | |||
2008 | const char *section, | |||
2009 | unsigned section_line, | |||
2010 | const char *lvalue, | |||
2011 | int ltype, | |||
2012 | const char *rvalue, | |||
2013 | void *data, | |||
2014 | void *userdata) { | |||
2015 | ||||
2016 | ExecContext *c = data; | |||
2017 | Unit *u = userdata; | |||
2018 | bool_Bool missing_ok; | |||
2019 | int r; | |||
2020 | ||||
2021 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2021, __PRETTY_FUNCTION__); } while (0); | |||
2022 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2022, __PRETTY_FUNCTION__); } while (0); | |||
2023 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2023, __PRETTY_FUNCTION__); } while (0); | |||
2024 | assert(c)do { if ((__builtin_expect(!!(!(c)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("c"), "../src/core/load-fragment.c", 2024 , __PRETTY_FUNCTION__); } while (0); | |||
2025 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 2025 , __PRETTY_FUNCTION__); } while (0); | |||
2026 | ||||
2027 | if (isempty(rvalue)) { | |||
2028 | c->working_directory_home = false0; | |||
2029 | c->working_directory = mfree(c->working_directory); | |||
2030 | return 0; | |||
2031 | } | |||
2032 | ||||
2033 | if (rvalue[0] == '-') { | |||
2034 | missing_ok = true1; | |||
2035 | rvalue++; | |||
2036 | } else | |||
2037 | missing_ok = false0; | |||
2038 | ||||
2039 | if (streq(rvalue, "~")(strcmp((rvalue),("~")) == 0)) { | |||
2040 | c->working_directory_home = true1; | |||
2041 | c->working_directory = mfree(c->working_directory); | |||
2042 | } else { | |||
2043 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
2044 | ||||
2045 | r = unit_full_printf(u, rvalue, &k); | |||
2046 | if (r < 0) { | |||
2047 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2049, __func__ , "Failed to resolve unit specifiers in working directory path '%s'%s: %m" , rvalue, missing_ok ? ", ignoring" : "") : -abs(_e); }) | |||
2048 | "Failed to resolve unit specifiers in working directory path '%s'%s: %m",({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2049, __func__ , "Failed to resolve unit specifiers in working directory path '%s'%s: %m" , rvalue, missing_ok ? ", ignoring" : "") : -abs(_e); }) | |||
2049 | rvalue, missing_ok ? ", ignoring" : "")({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2049, __func__ , "Failed to resolve unit specifiers in working directory path '%s'%s: %m" , rvalue, missing_ok ? ", ignoring" : "") : -abs(_e); }); | |||
2050 | return missing_ok ? 0 : -ENOEXEC8; | |||
2051 | } | |||
2052 | ||||
2053 | r = path_simplify_and_warn(k, PATH_CHECK_ABSOLUTE | (missing_ok ? 0 : PATH_CHECK_FATAL), unit, filename, line, lvalue); | |||
2054 | if (r < 0) | |||
2055 | return missing_ok ? 0 : -ENOEXEC8; | |||
2056 | ||||
2057 | c->working_directory_home = false0; | |||
2058 | free_and_replace(c->working_directory, k)({ free(c->working_directory); (c->working_directory) = (k); (k) = ((void*)0); 0; }); | |||
2059 | } | |||
2060 | ||||
2061 | c->working_directory_missing_ok = missing_ok; | |||
2062 | return 0; | |||
2063 | } | |||
2064 | ||||
2065 | int config_parse_unit_env_file(const char *unit, | |||
2066 | const char *filename, | |||
2067 | unsigned line, | |||
2068 | const char *section, | |||
2069 | unsigned section_line, | |||
2070 | const char *lvalue, | |||
2071 | int ltype, | |||
2072 | const char *rvalue, | |||
2073 | void *data, | |||
2074 | void *userdata) { | |||
2075 | ||||
2076 | char ***env = data; | |||
2077 | Unit *u = userdata; | |||
2078 | _cleanup_free___attribute__((cleanup(freep))) char *n = NULL((void*)0); | |||
2079 | int r; | |||
2080 | ||||
2081 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2081, __PRETTY_FUNCTION__); } while (0); | |||
2082 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2082, __PRETTY_FUNCTION__); } while (0); | |||
2083 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2083, __PRETTY_FUNCTION__); } while (0); | |||
2084 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2084 , __PRETTY_FUNCTION__); } while (0); | |||
2085 | ||||
2086 | if (isempty(rvalue)) { | |||
2087 | /* Empty assignment frees the list */ | |||
2088 | *env = strv_free(*env); | |||
2089 | return 0; | |||
2090 | } | |||
2091 | ||||
2092 | r = unit_full_printf(u, rvalue, &n); | |||
2093 | if (r < 0) { | |||
2094 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2094, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
2095 | return 0; | |||
2096 | } | |||
2097 | ||||
2098 | r = path_simplify_and_warn(n[0] == '-' ? n + 1 : n, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
2099 | if (r < 0) | |||
2100 | return 0; | |||
2101 | ||||
2102 | r = strv_push(env, n); | |||
2103 | if (r < 0) | |||
2104 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2104, __func__); | |||
2105 | ||||
2106 | n = NULL((void*)0); | |||
2107 | ||||
2108 | return 0; | |||
2109 | } | |||
2110 | ||||
2111 | int config_parse_environ( | |||
2112 | const char *unit, | |||
2113 | const char *filename, | |||
2114 | unsigned line, | |||
2115 | const char *section, | |||
2116 | unsigned section_line, | |||
2117 | const char *lvalue, | |||
2118 | int ltype, | |||
2119 | const char *rvalue, | |||
2120 | void *data, | |||
2121 | void *userdata) { | |||
2122 | ||||
2123 | Unit *u = userdata; | |||
2124 | char ***env = data; | |||
2125 | const char *p; | |||
2126 | int r; | |||
2127 | ||||
2128 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2128, __PRETTY_FUNCTION__); } while (0); | |||
2129 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2129, __PRETTY_FUNCTION__); } while (0); | |||
2130 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2130, __PRETTY_FUNCTION__); } while (0); | |||
2131 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2131 , __PRETTY_FUNCTION__); } while (0); | |||
2132 | ||||
2133 | if (isempty(rvalue)) { | |||
2134 | /* Empty assignment resets the list */ | |||
2135 | *env = strv_free(*env); | |||
2136 | return 0; | |||
2137 | } | |||
2138 | ||||
2139 | for (p = rvalue;; ) { | |||
2140 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
2141 | ||||
2142 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_CUNESCAPE|EXTRACT_QUOTES); | |||
2143 | if (r == 0) | |||
2144 | return 0; | |||
2145 | if (r == -ENOMEM12) | |||
2146 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2146, __func__); | |||
2147 | if (r < 0) { | |||
2148 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2149, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
2149 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2149, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
2150 | return 0; | |||
2151 | } | |||
2152 | ||||
2153 | if (u) { | |||
2154 | r = unit_full_printf(u, word, &k); | |||
2155 | if (r < 0) { | |||
2156 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2157, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", word ) : -abs(_e); }) | |||
2157 | "Failed to resolve unit specifiers in %s, ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2157, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", word ) : -abs(_e); }); | |||
2158 | continue; | |||
2159 | } | |||
2160 | } else | |||
2161 | k = TAKE_PTR(word)({ typeof(word) _ptr_ = (word); (word) = ((void*)0); _ptr_; } ); | |||
2162 | ||||
2163 | if (!env_assignment_is_valid(k)) { | |||
2164 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2165, __func__ , "Invalid environment assignment, ignoring: %s", k) : -abs(_e ); }) | |||
2165 | "Invalid environment assignment, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2165, __func__ , "Invalid environment assignment, ignoring: %s", k) : -abs(_e ); }); | |||
2166 | continue; | |||
2167 | } | |||
2168 | ||||
2169 | r = strv_env_replace(env, k); | |||
2170 | if (r < 0) | |||
2171 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2171, __func__); | |||
2172 | ||||
2173 | k = NULL((void*)0); | |||
2174 | } | |||
2175 | } | |||
2176 | ||||
2177 | int config_parse_pass_environ( | |||
2178 | const char *unit, | |||
2179 | const char *filename, | |||
2180 | unsigned line, | |||
2181 | const char *section, | |||
2182 | unsigned section_line, | |||
2183 | const char *lvalue, | |||
2184 | int ltype, | |||
2185 | const char *rvalue, | |||
2186 | void *data, | |||
2187 | void *userdata) { | |||
2188 | ||||
2189 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **n = NULL((void*)0); | |||
2190 | size_t nlen = 0, nbufsize = 0; | |||
2191 | char*** passenv = data; | |||
2192 | const char *p = rvalue; | |||
2193 | Unit *u = userdata; | |||
2194 | int r; | |||
2195 | ||||
2196 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2196, __PRETTY_FUNCTION__); } while (0); | |||
2197 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2197, __PRETTY_FUNCTION__); } while (0); | |||
2198 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2198, __PRETTY_FUNCTION__); } while (0); | |||
2199 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2199 , __PRETTY_FUNCTION__); } while (0); | |||
2200 | ||||
2201 | if (isempty(rvalue)) { | |||
2202 | /* Empty assignment resets the list */ | |||
2203 | *passenv = strv_free(*passenv); | |||
2204 | return 0; | |||
2205 | } | |||
2206 | ||||
2207 | for (;;) { | |||
2208 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
2209 | ||||
2210 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
2211 | if (r == 0) | |||
2212 | break; | |||
2213 | if (r == -ENOMEM12) | |||
2214 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2214, __func__); | |||
2215 | if (r < 0) { | |||
2216 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2217, __func__ , "Trailing garbage in %s, ignoring: %s", lvalue, rvalue) : - abs(_e); }) | |||
2217 | "Trailing garbage in %s, ignoring: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2217, __func__ , "Trailing garbage in %s, ignoring: %s", lvalue, rvalue) : - abs(_e); }); | |||
2218 | break; | |||
2219 | } | |||
2220 | ||||
2221 | if (u) { | |||
2222 | r = unit_full_printf(u, word, &k); | |||
2223 | if (r < 0) { | |||
2224 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2225, __func__ , "Failed to resolve specifiers in %s, ignoring: %m", word) : -abs(_e); }) | |||
2225 | "Failed to resolve specifiers in %s, ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2225, __func__ , "Failed to resolve specifiers in %s, ignoring: %m", word) : -abs(_e); }); | |||
2226 | continue; | |||
2227 | } | |||
2228 | } else | |||
2229 | k = TAKE_PTR(word)({ typeof(word) _ptr_ = (word); (word) = ((void*)0); _ptr_; } ); | |||
2230 | ||||
2231 | if (!env_name_is_valid(k)) { | |||
2232 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2233, __func__ , "Invalid environment name for %s, ignoring: %s", lvalue, k) : -abs(_e); }) | |||
2233 | "Invalid environment name for %s, ignoring: %s", lvalue, k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2233, __func__ , "Invalid environment name for %s, ignoring: %s", lvalue, k) : -abs(_e); }); | |||
2234 | continue; | |||
2235 | } | |||
2236 | ||||
2237 | if (!GREEDY_REALLOC(n, nbufsize, nlen + 2)greedy_realloc((void**) &(n), &(nbufsize), (nlen + 2) , sizeof((n)[0]))) | |||
2238 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2238, __func__); | |||
2239 | ||||
2240 | n[nlen++] = TAKE_PTR(k)({ typeof(k) _ptr_ = (k); (k) = ((void*)0); _ptr_; }); | |||
2241 | n[nlen] = NULL((void*)0); | |||
2242 | } | |||
2243 | ||||
2244 | if (n) { | |||
2245 | r = strv_extend_strv(passenv, n, true1); | |||
2246 | if (r < 0) | |||
2247 | return r; | |||
2248 | } | |||
2249 | ||||
2250 | return 0; | |||
2251 | } | |||
2252 | ||||
2253 | int config_parse_unset_environ( | |||
2254 | const char *unit, | |||
2255 | const char *filename, | |||
2256 | unsigned line, | |||
2257 | const char *section, | |||
2258 | unsigned section_line, | |||
2259 | const char *lvalue, | |||
2260 | int ltype, | |||
2261 | const char *rvalue, | |||
2262 | void *data, | |||
2263 | void *userdata) { | |||
2264 | ||||
2265 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **n = NULL((void*)0); | |||
2266 | size_t nlen = 0, nbufsize = 0; | |||
2267 | char*** unsetenv = data; | |||
2268 | const char *p = rvalue; | |||
2269 | Unit *u = userdata; | |||
2270 | int r; | |||
2271 | ||||
2272 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2272, __PRETTY_FUNCTION__); } while (0); | |||
2273 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2273, __PRETTY_FUNCTION__); } while (0); | |||
2274 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2274, __PRETTY_FUNCTION__); } while (0); | |||
2275 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2275 , __PRETTY_FUNCTION__); } while (0); | |||
2276 | ||||
2277 | if (isempty(rvalue)) { | |||
2278 | /* Empty assignment resets the list */ | |||
2279 | *unsetenv = strv_free(*unsetenv); | |||
2280 | return 0; | |||
2281 | } | |||
2282 | ||||
2283 | for (;;) { | |||
2284 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
2285 | ||||
2286 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_CUNESCAPE|EXTRACT_QUOTES); | |||
2287 | if (r == 0) | |||
2288 | break; | |||
2289 | if (r == -ENOMEM12) | |||
2290 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2290, __func__); | |||
2291 | if (r < 0) { | |||
2292 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2293, __func__ , "Trailing garbage in %s, ignoring: %s", lvalue, rvalue) : - abs(_e); }) | |||
2293 | "Trailing garbage in %s, ignoring: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2293, __func__ , "Trailing garbage in %s, ignoring: %s", lvalue, rvalue) : - abs(_e); }); | |||
2294 | break; | |||
2295 | } | |||
2296 | ||||
2297 | if (u) { | |||
2298 | r = unit_full_printf(u, word, &k); | |||
2299 | if (r < 0) { | |||
2300 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2301, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", word ) : -abs(_e); }) | |||
2301 | "Failed to resolve unit specifiers in %s, ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2301, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", word ) : -abs(_e); }); | |||
2302 | continue; | |||
2303 | } | |||
2304 | } else | |||
2305 | k = TAKE_PTR(word)({ typeof(word) _ptr_ = (word); (word) = ((void*)0); _ptr_; } ); | |||
2306 | ||||
2307 | if (!env_assignment_is_valid(k) && !env_name_is_valid(k)) { | |||
2308 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2309, __func__ , "Invalid environment name or assignment %s, ignoring: %s", lvalue , k) : -abs(_e); }) | |||
2309 | "Invalid environment name or assignment %s, ignoring: %s", lvalue, k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2309, __func__ , "Invalid environment name or assignment %s, ignoring: %s", lvalue , k) : -abs(_e); }); | |||
2310 | continue; | |||
2311 | } | |||
2312 | ||||
2313 | if (!GREEDY_REALLOC(n, nbufsize, nlen + 2)greedy_realloc((void**) &(n), &(nbufsize), (nlen + 2) , sizeof((n)[0]))) | |||
2314 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2314, __func__); | |||
2315 | ||||
2316 | n[nlen++] = TAKE_PTR(k)({ typeof(k) _ptr_ = (k); (k) = ((void*)0); _ptr_; }); | |||
2317 | n[nlen] = NULL((void*)0); | |||
2318 | } | |||
2319 | ||||
2320 | if (n) { | |||
2321 | r = strv_extend_strv(unsetenv, n, true1); | |||
2322 | if (r < 0) | |||
2323 | return r; | |||
2324 | } | |||
2325 | ||||
2326 | return 0; | |||
2327 | } | |||
2328 | ||||
2329 | int config_parse_log_extra_fields( | |||
2330 | const char *unit, | |||
2331 | const char *filename, | |||
2332 | unsigned line, | |||
2333 | const char *section, | |||
2334 | unsigned section_line, | |||
2335 | const char *lvalue, | |||
2336 | int ltype, | |||
2337 | const char *rvalue, | |||
2338 | void *data, | |||
2339 | void *userdata) { | |||
2340 | ||||
2341 | ExecContext *c = data; | |||
2342 | Unit *u = userdata; | |||
2343 | const char *p = rvalue; | |||
2344 | int r; | |||
2345 | ||||
2346 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2346, __PRETTY_FUNCTION__); } while (0); | |||
2347 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2347, __PRETTY_FUNCTION__); } while (0); | |||
2348 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2348, __PRETTY_FUNCTION__); } while (0); | |||
2349 | assert(c)do { if ((__builtin_expect(!!(!(c)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("c"), "../src/core/load-fragment.c", 2349 , __PRETTY_FUNCTION__); } while (0); | |||
2350 | ||||
2351 | if (isempty(rvalue)) { | |||
2352 | exec_context_free_log_extra_fields(c); | |||
2353 | return 0; | |||
2354 | } | |||
2355 | ||||
2356 | for (;;) { | |||
2357 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
2358 | struct iovec *t; | |||
2359 | const char *eq; | |||
2360 | ||||
2361 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_CUNESCAPE|EXTRACT_QUOTES); | |||
2362 | if (r == 0) | |||
2363 | return 0; | |||
2364 | if (r == -ENOMEM12) | |||
2365 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2365, __func__); | |||
2366 | if (r < 0) { | |||
2367 | log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2367, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
2368 | return 0; | |||
2369 | } | |||
2370 | ||||
2371 | r = unit_full_printf(u, word, &k); | |||
2372 | if (r < 0) { | |||
2373 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2373, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", word ) : -abs(_e); }); | |||
2374 | continue; | |||
2375 | } | |||
2376 | ||||
2377 | eq = strchr(k, '='); | |||
2378 | if (!eq) { | |||
2379 | log_syntax(unit, LOG_ERR, filename, line, 0, "Log field lacks '=' character, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2379, __func__ , "Log field lacks '=' character, ignoring: %s", k) : -abs(_e ); }); | |||
2380 | continue; | |||
2381 | } | |||
2382 | ||||
2383 | if (!journal_field_valid(k, eq-k, false0)) { | |||
2384 | log_syntax(unit, LOG_ERR, filename, line, 0, "Log field name is invalid, ignoring: %s", k)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2384, __func__ , "Log field name is invalid, ignoring: %s", k) : -abs(_e); } ); | |||
2385 | continue; | |||
2386 | } | |||
2387 | ||||
2388 | t = reallocarray(c->log_extra_fields, c->n_log_extra_fields+1, sizeof(struct iovec)); | |||
2389 | if (!t) | |||
2390 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2390, __func__); | |||
2391 | ||||
2392 | c->log_extra_fields = t; | |||
2393 | c->log_extra_fields[c->n_log_extra_fields++] = IOVEC_MAKE_STRING(k)(struct iovec) { .iov_base = ((char*) k), .iov_len = (strlen( k)) }; | |||
2394 | ||||
2395 | k = NULL((void*)0); | |||
2396 | } | |||
2397 | } | |||
2398 | ||||
2399 | int config_parse_unit_condition_path( | |||
2400 | const char *unit, | |||
2401 | const char *filename, | |||
2402 | unsigned line, | |||
2403 | const char *section, | |||
2404 | unsigned section_line, | |||
2405 | const char *lvalue, | |||
2406 | int ltype, | |||
2407 | const char *rvalue, | |||
2408 | void *data, | |||
2409 | void *userdata) { | |||
2410 | ||||
2411 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); | |||
2412 | Condition **list = data, *c; | |||
2413 | ConditionType t = ltype; | |||
2414 | bool_Bool trigger, negate; | |||
2415 | Unit *u = userdata; | |||
2416 | int r; | |||
2417 | ||||
2418 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2418, __PRETTY_FUNCTION__); } while (0); | |||
2419 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2419, __PRETTY_FUNCTION__); } while (0); | |||
2420 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2420, __PRETTY_FUNCTION__); } while (0); | |||
2421 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2421 , __PRETTY_FUNCTION__); } while (0); | |||
2422 | ||||
2423 | if (isempty(rvalue)) { | |||
2424 | /* Empty assignment resets the list */ | |||
2425 | *list = condition_free_list(*list); | |||
2426 | return 0; | |||
2427 | } | |||
2428 | ||||
2429 | trigger = rvalue[0] == '|'; | |||
2430 | if (trigger) | |||
2431 | rvalue++; | |||
2432 | ||||
2433 | negate = rvalue[0] == '!'; | |||
2434 | if (negate) | |||
2435 | rvalue++; | |||
2436 | ||||
2437 | r = unit_full_printf(u, rvalue, &p); | |||
2438 | if (r < 0) { | |||
2439 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2439, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue ) : -abs(_e); }); | |||
2440 | return 0; | |||
2441 | } | |||
2442 | ||||
2443 | r = path_simplify_and_warn(p, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
2444 | if (r < 0) | |||
2445 | return 0; | |||
2446 | ||||
2447 | c = condition_new(t, p, trigger, negate); | |||
2448 | if (!c) | |||
2449 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2449, __func__); | |||
2450 | ||||
2451 | LIST_PREPEND(conditions, *list, c)do { typeof(*(*list)) **_head = &(*list), *_item = (c); do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 2451, __PRETTY_FUNCTION__); } while (0); if ((_item->conditions_next = *_head)) _item->conditions_next->conditions_prev = _item ; _item->conditions_prev = ((void*)0); *_head = _item; } while (0); | |||
2452 | return 0; | |||
2453 | } | |||
2454 | ||||
2455 | int config_parse_unit_condition_string( | |||
2456 | const char *unit, | |||
2457 | const char *filename, | |||
2458 | unsigned line, | |||
2459 | const char *section, | |||
2460 | unsigned section_line, | |||
2461 | const char *lvalue, | |||
2462 | int ltype, | |||
2463 | const char *rvalue, | |||
2464 | void *data, | |||
2465 | void *userdata) { | |||
2466 | ||||
2467 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); | |||
2468 | Condition **list = data, *c; | |||
2469 | ConditionType t = ltype; | |||
2470 | bool_Bool trigger, negate; | |||
2471 | Unit *u = userdata; | |||
2472 | int r; | |||
2473 | ||||
2474 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2474, __PRETTY_FUNCTION__); } while (0); | |||
2475 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2475, __PRETTY_FUNCTION__); } while (0); | |||
2476 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2476, __PRETTY_FUNCTION__); } while (0); | |||
2477 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2477 , __PRETTY_FUNCTION__); } while (0); | |||
2478 | ||||
2479 | if (isempty(rvalue)) { | |||
2480 | /* Empty assignment resets the list */ | |||
2481 | *list = condition_free_list(*list); | |||
2482 | return 0; | |||
2483 | } | |||
2484 | ||||
2485 | trigger = rvalue[0] == '|'; | |||
2486 | if (trigger) | |||
2487 | rvalue++; | |||
2488 | ||||
2489 | negate = rvalue[0] == '!'; | |||
2490 | if (negate) | |||
2491 | rvalue++; | |||
2492 | ||||
2493 | r = unit_full_printf(u, rvalue, &s); | |||
2494 | if (r < 0) { | |||
2495 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2495, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue ) : -abs(_e); }); | |||
2496 | return 0; | |||
2497 | } | |||
2498 | ||||
2499 | c = condition_new(t, s, trigger, negate); | |||
2500 | if (!c) | |||
2501 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2501, __func__); | |||
2502 | ||||
2503 | LIST_PREPEND(conditions, *list, c)do { typeof(*(*list)) **_head = &(*list), *_item = (c); do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 2503, __PRETTY_FUNCTION__); } while (0); if ((_item->conditions_next = *_head)) _item->conditions_next->conditions_prev = _item ; _item->conditions_prev = ((void*)0); *_head = _item; } while (0); | |||
2504 | return 0; | |||
2505 | } | |||
2506 | ||||
2507 | int config_parse_unit_condition_null( | |||
2508 | const char *unit, | |||
2509 | const char *filename, | |||
2510 | unsigned line, | |||
2511 | const char *section, | |||
2512 | unsigned section_line, | |||
2513 | const char *lvalue, | |||
2514 | int ltype, | |||
2515 | const char *rvalue, | |||
2516 | void *data, | |||
2517 | void *userdata) { | |||
2518 | ||||
2519 | Condition **list = data, *c; | |||
2520 | bool_Bool trigger, negate; | |||
2521 | int b; | |||
2522 | ||||
2523 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2523, __PRETTY_FUNCTION__); } while (0); | |||
2524 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2524, __PRETTY_FUNCTION__); } while (0); | |||
2525 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2525, __PRETTY_FUNCTION__); } while (0); | |||
2526 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2526 , __PRETTY_FUNCTION__); } while (0); | |||
2527 | ||||
2528 | if (isempty(rvalue)) { | |||
2529 | /* Empty assignment resets the list */ | |||
2530 | *list = condition_free_list(*list); | |||
2531 | return 0; | |||
2532 | } | |||
2533 | ||||
2534 | trigger = rvalue[0] == '|'; | |||
2535 | if (trigger) | |||
2536 | rvalue++; | |||
2537 | ||||
2538 | negate = rvalue[0] == '!'; | |||
2539 | if (negate) | |||
2540 | rvalue++; | |||
2541 | ||||
2542 | b = parse_boolean(rvalue); | |||
2543 | if (b < 0) { | |||
2544 | log_syntax(unit, LOG_ERR, filename, line, b, "Failed to parse boolean value in condition, ignoring: %s", rvalue)({ int _level = (3), _e = (b); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2544, __func__ , "Failed to parse boolean value in condition, ignoring: %s", rvalue) : -abs(_e); }); | |||
2545 | return 0; | |||
2546 | } | |||
2547 | ||||
2548 | if (!b) | |||
2549 | negate = !negate; | |||
2550 | ||||
2551 | c = condition_new(CONDITION_NULL, NULL((void*)0), trigger, negate); | |||
2552 | if (!c) | |||
2553 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2553, __func__); | |||
2554 | ||||
2555 | LIST_PREPEND(conditions, *list, c)do { typeof(*(*list)) **_head = &(*list), *_item = (c); do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 2555, __PRETTY_FUNCTION__); } while (0); if ((_item->conditions_next = *_head)) _item->conditions_next->conditions_prev = _item ; _item->conditions_prev = ((void*)0); *_head = _item; } while (0); | |||
2556 | return 0; | |||
2557 | } | |||
2558 | ||||
2559 | int config_parse_unit_requires_mounts_for( | |||
2560 | const char *unit, | |||
2561 | const char *filename, | |||
2562 | unsigned line, | |||
2563 | const char *section, | |||
2564 | unsigned section_line, | |||
2565 | const char *lvalue, | |||
2566 | int ltype, | |||
2567 | const char *rvalue, | |||
2568 | void *data, | |||
2569 | void *userdata) { | |||
2570 | ||||
2571 | const char *p = rvalue; | |||
2572 | Unit *u = userdata; | |||
2573 | int r; | |||
2574 | ||||
2575 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2575, __PRETTY_FUNCTION__); } while (0); | |||
2576 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2576, __PRETTY_FUNCTION__); } while (0); | |||
2577 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2577, __PRETTY_FUNCTION__); } while (0); | |||
2578 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 2578 , __PRETTY_FUNCTION__); } while (0); | |||
2579 | ||||
2580 | for (;;) { | |||
2581 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *resolved = NULL((void*)0); | |||
2582 | ||||
2583 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
2584 | if (r == 0) | |||
2585 | return 0; | |||
2586 | if (r == -ENOMEM12) | |||
2587 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2587, __func__); | |||
2588 | if (r < 0) { | |||
2589 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2590, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
2590 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2590, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
2591 | return 0; | |||
2592 | } | |||
2593 | ||||
2594 | r = unit_full_printf(u, word, &resolved); | |||
2595 | if (r < 0) { | |||
2596 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2596, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", word ) : -abs(_e); }); | |||
2597 | continue; | |||
2598 | } | |||
2599 | ||||
2600 | r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
2601 | if (r < 0) | |||
2602 | continue; | |||
2603 | ||||
2604 | r = unit_require_mounts_for(u, resolved, UNIT_DEPENDENCY_FILE); | |||
2605 | if (r < 0) { | |||
2606 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add required mount '%s', ignoring: %m", resolved)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2606, __func__ , "Failed to add required mount '%s', ignoring: %m", resolved ) : -abs(_e); }); | |||
2607 | continue; | |||
2608 | } | |||
2609 | } | |||
2610 | } | |||
2611 | ||||
2612 | int config_parse_documentation(const char *unit, | |||
2613 | const char *filename, | |||
2614 | unsigned line, | |||
2615 | const char *section, | |||
2616 | unsigned section_line, | |||
2617 | const char *lvalue, | |||
2618 | int ltype, | |||
2619 | const char *rvalue, | |||
2620 | void *data, | |||
2621 | void *userdata) { | |||
2622 | ||||
2623 | Unit *u = userdata; | |||
2624 | int r; | |||
2625 | char **a, **b; | |||
2626 | ||||
2627 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2627, __PRETTY_FUNCTION__); } while (0); | |||
2628 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2628, __PRETTY_FUNCTION__); } while (0); | |||
2629 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2629, __PRETTY_FUNCTION__); } while (0); | |||
2630 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 2630 , __PRETTY_FUNCTION__); } while (0); | |||
2631 | ||||
2632 | if (isempty(rvalue)) { | |||
2633 | /* Empty assignment resets the list */ | |||
2634 | u->documentation = strv_free(u->documentation); | |||
2635 | return 0; | |||
2636 | } | |||
2637 | ||||
2638 | r = config_parse_unit_strv_printf(unit, filename, line, section, section_line, lvalue, ltype, | |||
2639 | rvalue, data, userdata); | |||
2640 | if (r < 0) | |||
2641 | return r; | |||
2642 | ||||
2643 | for (a = b = u->documentation; a && *a; a++) { | |||
2644 | ||||
2645 | if (documentation_url_is_valid(*a)) | |||
2646 | *(b++) = *a; | |||
2647 | else { | |||
2648 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid URL, ignoring: %s", *a)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2648, __func__ , "Invalid URL, ignoring: %s", *a) : -abs(_e); }); | |||
2649 | free(*a); | |||
2650 | } | |||
2651 | } | |||
2652 | if (b) | |||
2653 | *b = NULL((void*)0); | |||
2654 | ||||
2655 | return r; | |||
2656 | } | |||
2657 | ||||
2658 | #if HAVE_SECCOMP1 | |||
2659 | int config_parse_syscall_filter( | |||
2660 | const char *unit, | |||
2661 | const char *filename, | |||
2662 | unsigned line, | |||
2663 | const char *section, | |||
2664 | unsigned section_line, | |||
2665 | const char *lvalue, | |||
2666 | int ltype, | |||
2667 | const char *rvalue, | |||
2668 | void *data, | |||
2669 | void *userdata) { | |||
2670 | ||||
2671 | ExecContext *c = data; | |||
2672 | Unit *u = userdata; | |||
2673 | bool_Bool invert = false0; | |||
2674 | const char *p; | |||
2675 | int r; | |||
2676 | ||||
2677 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2677, __PRETTY_FUNCTION__); } while (0); | |||
2678 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2678, __PRETTY_FUNCTION__); } while (0); | |||
2679 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2679, __PRETTY_FUNCTION__); } while (0); | |||
2680 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 2680 , __PRETTY_FUNCTION__); } while (0); | |||
2681 | ||||
2682 | if (isempty(rvalue)) { | |||
2683 | /* Empty assignment resets the list */ | |||
2684 | c->syscall_filter = hashmap_free(c->syscall_filter); | |||
2685 | c->syscall_whitelist = false0; | |||
2686 | return 0; | |||
2687 | } | |||
2688 | ||||
2689 | if (rvalue[0] == '~') { | |||
2690 | invert = true1; | |||
2691 | rvalue++; | |||
2692 | } | |||
2693 | ||||
2694 | if (!c->syscall_filter) { | |||
2695 | c->syscall_filter = hashmap_new(NULL)internal_hashmap_new(((void*)0) ); | |||
2696 | if (!c->syscall_filter) | |||
2697 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2697, __func__); | |||
2698 | ||||
2699 | if (invert) | |||
2700 | /* Allow everything but the ones listed */ | |||
2701 | c->syscall_whitelist = false0; | |||
2702 | else { | |||
2703 | /* Allow nothing but the ones listed */ | |||
2704 | c->syscall_whitelist = true1; | |||
2705 | ||||
2706 | /* Accept default syscalls if we are on a whitelist */ | |||
2707 | r = seccomp_parse_syscall_filter("@default", -1, c->syscall_filter, SECCOMP_PARSE_WHITELIST); | |||
2708 | if (r < 0) | |||
2709 | return r; | |||
2710 | } | |||
2711 | } | |||
2712 | ||||
2713 | p = rvalue; | |||
2714 | for (;;) { | |||
2715 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *name = NULL((void*)0); | |||
2716 | int num; | |||
2717 | ||||
2718 | r = extract_first_word(&p, &word, NULL((void*)0), 0); | |||
2719 | if (r == 0) | |||
2720 | return 0; | |||
2721 | if (r == -ENOMEM12) | |||
2722 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2722, __func__); | |||
2723 | if (r < 0) { | |||
2724 | log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2724, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
2725 | return 0; | |||
2726 | } | |||
2727 | ||||
2728 | r = parse_syscall_and_errno(word, &name, &num); | |||
2729 | if (r < 0) { | |||
2730 | log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse syscall:errno, ignoring: %s", word)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2730, __func__ , "Failed to parse syscall:errno, ignoring: %s", word) : -abs (_e); }); | |||
2731 | continue; | |||
2732 | } | |||
2733 | ||||
2734 | r = seccomp_parse_syscall_filter_full(name, num, c->syscall_filter, | |||
2735 | SECCOMP_PARSE_LOG|SECCOMP_PARSE_PERMISSIVE|(invert ? SECCOMP_PARSE_INVERT : 0)|(c->syscall_whitelist ? SECCOMP_PARSE_WHITELIST : 0), | |||
2736 | unit, filename, line); | |||
2737 | if (r < 0) | |||
2738 | return r; | |||
2739 | } | |||
2740 | } | |||
2741 | ||||
2742 | int config_parse_syscall_archs( | |||
2743 | const char *unit, | |||
2744 | const char *filename, | |||
2745 | unsigned line, | |||
2746 | const char *section, | |||
2747 | unsigned section_line, | |||
2748 | const char *lvalue, | |||
2749 | int ltype, | |||
2750 | const char *rvalue, | |||
2751 | void *data, | |||
2752 | void *userdata) { | |||
2753 | ||||
2754 | const char *p = rvalue; | |||
2755 | Set **archs = data; | |||
2756 | int r; | |||
2757 | ||||
2758 | if (isempty(rvalue)) { | |||
2759 | *archs = set_free(*archs); | |||
2760 | return 0; | |||
2761 | } | |||
2762 | ||||
2763 | r = set_ensure_allocated(archs, NULL)internal_set_ensure_allocated(archs, ((void*)0) ); | |||
2764 | if (r < 0) | |||
2765 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2765, __func__); | |||
2766 | ||||
2767 | for (;;) { | |||
2768 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); | |||
2769 | uint32_t a; | |||
2770 | ||||
2771 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
2772 | if (r == 0) | |||
2773 | return 0; | |||
2774 | if (r == -ENOMEM12) | |||
2775 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2775, __func__); | |||
2776 | if (r < 0) { | |||
2777 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2778, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
2778 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2778, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
2779 | return 0; | |||
2780 | } | |||
2781 | ||||
2782 | r = seccomp_arch_from_string(word, &a); | |||
2783 | if (r < 0) { | |||
2784 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2785, __func__ , "Failed to parse system call architecture \"%s\", ignoring: %m" , word) : -abs(_e); }) | |||
2785 | "Failed to parse system call architecture \"%s\", ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2785, __func__ , "Failed to parse system call architecture \"%s\", ignoring: %m" , word) : -abs(_e); }); | |||
2786 | continue; | |||
2787 | } | |||
2788 | ||||
2789 | r = set_put(*archs, UINT32_TO_PTR(a + 1)((void *) ((uintptr_t) (a + 1)))); | |||
2790 | if (r < 0) | |||
2791 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2791, __func__); | |||
2792 | } | |||
2793 | } | |||
2794 | ||||
2795 | int config_parse_syscall_errno( | |||
2796 | const char *unit, | |||
2797 | const char *filename, | |||
2798 | unsigned line, | |||
2799 | const char *section, | |||
2800 | unsigned section_line, | |||
2801 | const char *lvalue, | |||
2802 | int ltype, | |||
2803 | const char *rvalue, | |||
2804 | void *data, | |||
2805 | void *userdata) { | |||
2806 | ||||
2807 | ExecContext *c = data; | |||
2808 | int e; | |||
2809 | ||||
2810 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2810, __PRETTY_FUNCTION__); } while (0); | |||
2811 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2811, __PRETTY_FUNCTION__); } while (0); | |||
2812 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2812, __PRETTY_FUNCTION__); } while (0); | |||
2813 | ||||
2814 | if (isempty(rvalue)) { | |||
2815 | /* Empty assignment resets to KILL */ | |||
2816 | c->syscall_errno = 0; | |||
2817 | return 0; | |||
2818 | } | |||
2819 | ||||
2820 | e = parse_errno(rvalue); | |||
2821 | if (e <= 0) { | |||
2822 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse error number, ignoring: %s", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2822, __func__ , "Failed to parse error number, ignoring: %s", rvalue) : -abs (_e); }); | |||
2823 | return 0; | |||
2824 | } | |||
2825 | ||||
2826 | c->syscall_errno = e; | |||
2827 | return 0; | |||
2828 | } | |||
2829 | ||||
2830 | int config_parse_address_families( | |||
2831 | const char *unit, | |||
2832 | const char *filename, | |||
2833 | unsigned line, | |||
2834 | const char *section, | |||
2835 | unsigned section_line, | |||
2836 | const char *lvalue, | |||
2837 | int ltype, | |||
2838 | const char *rvalue, | |||
2839 | void *data, | |||
2840 | void *userdata) { | |||
2841 | ||||
2842 | ExecContext *c = data; | |||
2843 | bool_Bool invert = false0; | |||
2844 | const char *p; | |||
2845 | int r; | |||
2846 | ||||
2847 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2847, __PRETTY_FUNCTION__); } while (0); | |||
2848 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2848, __PRETTY_FUNCTION__); } while (0); | |||
2849 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2849, __PRETTY_FUNCTION__); } while (0); | |||
2850 | ||||
2851 | if (isempty(rvalue)) { | |||
2852 | /* Empty assignment resets the list */ | |||
2853 | c->address_families = set_free(c->address_families); | |||
2854 | c->address_families_whitelist = false0; | |||
2855 | return 0; | |||
2856 | } | |||
2857 | ||||
2858 | if (rvalue[0] == '~') { | |||
2859 | invert = true1; | |||
2860 | rvalue++; | |||
2861 | } | |||
2862 | ||||
2863 | if (!c->address_families) { | |||
2864 | c->address_families = set_new(NULL)internal_set_new(((void*)0) ); | |||
2865 | if (!c->address_families) | |||
2866 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2866, __func__); | |||
2867 | ||||
2868 | c->address_families_whitelist = !invert; | |||
2869 | } | |||
2870 | ||||
2871 | for (p = rvalue;;) { | |||
2872 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); | |||
2873 | int af; | |||
2874 | ||||
2875 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
2876 | if (r == 0) | |||
2877 | return 0; | |||
2878 | if (r == -ENOMEM12) | |||
2879 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2879, __func__); | |||
2880 | if (r < 0) { | |||
2881 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2882, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
2882 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2882, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
2883 | return 0; | |||
2884 | } | |||
2885 | ||||
2886 | af = af_from_name(word); | |||
2887 | if (af <= 0) { | |||
2888 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2889, __func__ , "Failed to parse address family, ignoring: %s", word) : -abs (_e); }) | |||
2889 | "Failed to parse address family, ignoring: %s", word)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2889, __func__ , "Failed to parse address family, ignoring: %s", word) : -abs (_e); }); | |||
2890 | continue; | |||
2891 | } | |||
2892 | ||||
2893 | /* If we previously wanted to forbid an address family and now | |||
2894 | * we want to allow it, then just remove it from the list. | |||
2895 | */ | |||
2896 | if (!invert == c->address_families_whitelist) { | |||
2897 | r = set_put(c->address_families, INT_TO_PTR(af)((void *) ((intptr_t) (af)))); | |||
2898 | if (r < 0) | |||
2899 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 2899, __func__); | |||
2900 | } else | |||
2901 | set_remove(c->address_families, INT_TO_PTR(af)((void *) ((intptr_t) (af)))); | |||
2902 | } | |||
2903 | } | |||
2904 | ||||
2905 | int config_parse_restrict_namespaces( | |||
2906 | const char *unit, | |||
2907 | const char *filename, | |||
2908 | unsigned line, | |||
2909 | const char *section, | |||
2910 | unsigned section_line, | |||
2911 | const char *lvalue, | |||
2912 | int ltype, | |||
2913 | const char *rvalue, | |||
2914 | void *data, | |||
2915 | void *userdata) { | |||
2916 | ||||
2917 | ExecContext *c = data; | |||
2918 | unsigned long flags; | |||
2919 | bool_Bool invert = false0; | |||
2920 | int r; | |||
2921 | ||||
2922 | if (isempty(rvalue)) { | |||
2923 | /* Reset to the default. */ | |||
2924 | c->restrict_namespaces = NAMESPACE_FLAGS_INITIAL((unsigned long) -1); | |||
2925 | return 0; | |||
2926 | } | |||
2927 | ||||
2928 | /* Boolean parameter ignores the previous settings */ | |||
2929 | r = parse_boolean(rvalue); | |||
2930 | if (r > 0) { | |||
2931 | c->restrict_namespaces = 0; | |||
2932 | return 0; | |||
2933 | } else if (r == 0) { | |||
2934 | c->restrict_namespaces = NAMESPACE_FLAGS_ALL((unsigned long) (0x02000000| 0x08000000| 0x40000000| 0x00020000 | 0x20000000| 0x10000000| 0x04000000)); | |||
2935 | return 0; | |||
2936 | } | |||
2937 | ||||
2938 | if (rvalue[0] == '~') { | |||
2939 | invert = true1; | |||
2940 | rvalue++; | |||
2941 | } | |||
2942 | ||||
2943 | /* Not a boolean argument, in this case it's a list of namespace types. */ | |||
2944 | r = namespace_flags_from_string(rvalue, &flags); | |||
2945 | if (r < 0) { | |||
2946 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse namespace type string, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2946, __func__ , "Failed to parse namespace type string, ignoring: %s", rvalue ) : -abs(_e); }); | |||
2947 | return 0; | |||
2948 | } | |||
2949 | ||||
2950 | if (c->restrict_namespaces == NAMESPACE_FLAGS_INITIAL((unsigned long) -1)) | |||
2951 | /* Initial assignment. Just set the value. */ | |||
2952 | c->restrict_namespaces = invert ? (~flags) & NAMESPACE_FLAGS_ALL((unsigned long) (0x02000000| 0x08000000| 0x40000000| 0x00020000 | 0x20000000| 0x10000000| 0x04000000)) : flags; | |||
2953 | else | |||
2954 | /* Merge the value with the previous one. */ | |||
2955 | SET_FLAG(c->restrict_namespaces, flags, !invert)(c->restrict_namespaces) = (!invert) ? ((c->restrict_namespaces ) | (flags)) : ((c->restrict_namespaces) & ~(flags)); | |||
2956 | ||||
2957 | return 0; | |||
2958 | } | |||
2959 | #endif | |||
2960 | ||||
2961 | int config_parse_unit_slice( | |||
2962 | const char *unit, | |||
2963 | const char *filename, | |||
2964 | unsigned line, | |||
2965 | const char *section, | |||
2966 | unsigned section_line, | |||
2967 | const char *lvalue, | |||
2968 | int ltype, | |||
2969 | const char *rvalue, | |||
2970 | void *data, | |||
2971 | void *userdata) { | |||
2972 | ||||
2973 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error error = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); | |||
2974 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
2975 | Unit *u = userdata, *slice = NULL((void*)0); | |||
2976 | int r; | |||
2977 | ||||
2978 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 2978, __PRETTY_FUNCTION__); } while (0); | |||
2979 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 2979, __PRETTY_FUNCTION__); } while (0); | |||
2980 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 2980, __PRETTY_FUNCTION__); } while (0); | |||
2981 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 2981 , __PRETTY_FUNCTION__); } while (0); | |||
2982 | ||||
2983 | r = unit_name_printf(u, rvalue, &k); | |||
2984 | if (r < 0) { | |||
2985 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2985, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", rvalue ) : -abs(_e); }); | |||
2986 | return 0; | |||
2987 | } | |||
2988 | ||||
2989 | r = manager_load_unit(u->manager, k, NULL((void*)0), &error, &slice); | |||
2990 | if (r < 0) { | |||
2991 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load slice unit %s, ignoring: %s", k, bus_error_message(&error, r))({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2991, __func__ , "Failed to load slice unit %s, ignoring: %s", k, bus_error_message (&error, r)) : -abs(_e); }); | |||
2992 | return 0; | |||
2993 | } | |||
2994 | ||||
2995 | r = unit_set_slice(u, slice); | |||
2996 | if (r < 0) { | |||
2997 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to assign slice %s to unit %s, ignoring: %m", slice->id, u->id)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 2997, __func__ , "Failed to assign slice %s to unit %s, ignoring: %m", slice ->id, u->id) : -abs(_e); }); | |||
2998 | return 0; | |||
2999 | } | |||
3000 | ||||
3001 | return 0; | |||
3002 | } | |||
3003 | ||||
3004 | int config_parse_cpu_quota( | |||
3005 | const char *unit, | |||
3006 | const char *filename, | |||
3007 | unsigned line, | |||
3008 | const char *section, | |||
3009 | unsigned section_line, | |||
3010 | const char *lvalue, | |||
3011 | int ltype, | |||
3012 | const char *rvalue, | |||
3013 | void *data, | |||
3014 | void *userdata) { | |||
3015 | ||||
3016 | CGroupContext *c = data; | |||
3017 | int r; | |||
3018 | ||||
3019 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3019, __PRETTY_FUNCTION__); } while (0); | |||
3020 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3020, __PRETTY_FUNCTION__); } while (0); | |||
3021 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3021, __PRETTY_FUNCTION__); } while (0); | |||
3022 | ||||
3023 | if (isempty(rvalue)) { | |||
3024 | c->cpu_quota_per_sec_usec = USEC_INFINITY((usec_t) -1); | |||
3025 | return 0; | |||
3026 | } | |||
3027 | ||||
3028 | r = parse_percent_unbounded(rvalue); | |||
3029 | if (r <= 0) { | |||
3030 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid CPU quota '%s', ignoring.", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3030, __func__ , "Invalid CPU quota '%s', ignoring.", rvalue) : -abs(_e); }); | |||
3031 | return 0; | |||
3032 | } | |||
3033 | ||||
3034 | c->cpu_quota_per_sec_usec = ((usec_t) r * USEC_PER_SEC((usec_t) 1000000ULL)) / 100U; | |||
3035 | return 0; | |||
3036 | } | |||
3037 | ||||
3038 | int config_parse_allowed_cpus( | |||
3039 | const char *unit, | |||
3040 | const char *filename, | |||
3041 | unsigned line, | |||
3042 | const char *section, | |||
3043 | unsigned section_line, | |||
3044 | const char *lvalue, | |||
3045 | int ltype, | |||
3046 | const char *rvalue, | |||
3047 | void *data, | |||
3048 | void *userdata) { | |||
3049 | ||||
3050 | CGroupContext *c = data; | |||
3051 | ||||
3052 | (void) parse_cpu_set_extend(rvalue, &c->cpuset_cpus, true1, unit, filename, line, lvalue); | |||
3053 | ||||
3054 | return 0; | |||
3055 | } | |||
3056 | ||||
3057 | int config_parse_allowed_mems( | |||
3058 | const char *unit, | |||
3059 | const char *filename, | |||
3060 | unsigned line, | |||
3061 | const char *section, | |||
3062 | unsigned section_line, | |||
3063 | const char *lvalue, | |||
3064 | int ltype, | |||
3065 | const char *rvalue, | |||
3066 | void *data, | |||
3067 | void *userdata) { | |||
3068 | ||||
3069 | CGroupContext *c = data; | |||
3070 | ||||
3071 | (void) parse_cpu_set_extend(rvalue, &c->cpuset_mems, true1, unit, filename, line, lvalue); | |||
3072 | ||||
3073 | return 0; | |||
3074 | } | |||
3075 | ||||
3076 | int config_parse_memory_limit( | |||
3077 | const char *unit, | |||
3078 | const char *filename, | |||
3079 | unsigned line, | |||
3080 | const char *section, | |||
3081 | unsigned section_line, | |||
3082 | const char *lvalue, | |||
3083 | int ltype, | |||
3084 | const char *rvalue, | |||
3085 | void *data, | |||
3086 | void *userdata) { | |||
3087 | ||||
3088 | CGroupContext *c = data; | |||
3089 | uint64_t bytes = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3090 | int r; | |||
3091 | ||||
3092 | if (!isempty(rvalue) && !streq(rvalue, "infinity")(strcmp((rvalue),("infinity")) == 0)) { | |||
3093 | ||||
3094 | r = parse_percent(rvalue); | |||
3095 | if (r < 0) { | |||
3096 | r = parse_size(rvalue, 1024, &bytes); | |||
3097 | if (r < 0) { | |||
3098 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid memory limit '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3098, __func__ , "Invalid memory limit '%s', ignoring: %m", rvalue) : -abs(_e ); }); | |||
3099 | return 0; | |||
3100 | } | |||
3101 | } else | |||
3102 | bytes = physical_memory_scale(r, 100U); | |||
3103 | ||||
3104 | if (bytes >= UINT64_MAX(18446744073709551615UL) || | |||
3105 | (bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin")(!!strv_find((((char**) ((const char*[]) { "MemorySwapMax", "MemoryLow" , "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin", ((void *)0) }))), (lvalue))))) { | |||
3106 | log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3106, __func__ , "Memory limit '%s' out of range, ignoring.", rvalue) : -abs (_e); }); | |||
3107 | return 0; | |||
3108 | } | |||
3109 | } | |||
3110 | ||||
3111 | if (streq(lvalue, "DefaultMemoryLow")(strcmp((lvalue),("DefaultMemoryLow")) == 0)) { | |||
3112 | c->default_memory_low_set = true1; | |||
3113 | if (isempty(rvalue)) | |||
3114 | c->default_memory_low = CGROUP_LIMIT_MIN0UL; | |||
3115 | else | |||
3116 | c->default_memory_low = bytes; | |||
3117 | } else if (streq(lvalue, "DefaultMemoryMin")(strcmp((lvalue),("DefaultMemoryMin")) == 0)) { | |||
3118 | c->default_memory_min_set = true1; | |||
3119 | if (isempty(rvalue)) | |||
3120 | c->default_memory_min = CGROUP_LIMIT_MIN0UL; | |||
3121 | else | |||
3122 | c->default_memory_min = bytes; | |||
3123 | } else if (streq(lvalue, "MemoryMin")(strcmp((lvalue),("MemoryMin")) == 0)) { | |||
3124 | c->memory_min = bytes; | |||
3125 | c->memory_min_set = true1; | |||
3126 | } else if (streq(lvalue, "MemoryLow")(strcmp((lvalue),("MemoryLow")) == 0)) { | |||
3127 | c->memory_low = bytes; | |||
3128 | c->memory_low_set = true1; | |||
3129 | } else if (streq(lvalue, "MemoryHigh")(strcmp((lvalue),("MemoryHigh")) == 0)) | |||
3130 | c->memory_high = bytes; | |||
3131 | else if (streq(lvalue, "MemoryMax")(strcmp((lvalue),("MemoryMax")) == 0)) | |||
3132 | c->memory_max = bytes; | |||
3133 | else if (streq(lvalue, "MemorySwapMax")(strcmp((lvalue),("MemorySwapMax")) == 0)) | |||
3134 | c->memory_swap_max = bytes; | |||
3135 | else if (streq(lvalue, "MemoryLimit")(strcmp((lvalue),("MemoryLimit")) == 0)) | |||
3136 | c->memory_limit = bytes; | |||
3137 | else | |||
3138 | return -EINVAL22; | |||
3139 | ||||
3140 | return 0; | |||
3141 | } | |||
3142 | ||||
3143 | int config_parse_tasks_max( | |||
3144 | const char *unit, | |||
3145 | const char *filename, | |||
3146 | unsigned line, | |||
3147 | const char *section, | |||
3148 | unsigned section_line, | |||
3149 | const char *lvalue, | |||
3150 | int ltype, | |||
3151 | const char *rvalue, | |||
3152 | void *data, | |||
3153 | void *userdata) { | |||
3154 | ||||
3155 | uint64_t *tasks_max = data, v; | |||
3156 | Unit *u = userdata; | |||
3157 | int r; | |||
3158 | ||||
3159 | if (isempty(rvalue)) { | |||
3160 | *tasks_max = u->manager->default_tasks_max; | |||
3161 | return 0; | |||
3162 | } | |||
3163 | ||||
3164 | if (streq(rvalue, "infinity")(strcmp((rvalue),("infinity")) == 0)) { | |||
3165 | *tasks_max = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3166 | return 0; | |||
3167 | } | |||
3168 | ||||
3169 | r = parse_percent(rvalue); | |||
3170 | if (r < 0) { | |||
3171 | r = safe_atou64(rvalue, &v); | |||
3172 | if (r < 0) { | |||
3173 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid maximum tasks value '%s', ignoring: %m", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3173, __func__ , "Invalid maximum tasks value '%s', ignoring: %m", rvalue) : -abs(_e); }); | |||
3174 | return 0; | |||
3175 | } | |||
3176 | } else | |||
3177 | v = system_tasks_max_scale(r, 100U); | |||
3178 | ||||
3179 | if (v <= 0 || v >= UINT64_MAX(18446744073709551615UL)) { | |||
3180 | log_syntax(unit, LOG_ERR, filename, line, 0, "Maximum tasks value '%s' out of range, ignoring.", rvalue)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3180, __func__ , "Maximum tasks value '%s' out of range, ignoring.", rvalue) : -abs(_e); }); | |||
3181 | return 0; | |||
3182 | } | |||
3183 | ||||
3184 | *tasks_max = v; | |||
3185 | return 0; | |||
3186 | } | |||
3187 | ||||
3188 | int config_parse_delegate( | |||
3189 | const char *unit, | |||
3190 | const char *filename, | |||
3191 | unsigned line, | |||
3192 | const char *section, | |||
3193 | unsigned section_line, | |||
3194 | const char *lvalue, | |||
3195 | int ltype, | |||
3196 | const char *rvalue, | |||
3197 | void *data, | |||
3198 | void *userdata) { | |||
3199 | ||||
3200 | CGroupContext *c = data; | |||
3201 | UnitType t; | |||
3202 | int r; | |||
3203 | ||||
3204 | t = unit_name_to_type(unit); | |||
3205 | assert(t != _UNIT_TYPE_INVALID)do { if ((__builtin_expect(!!(!(t != _UNIT_TYPE_INVALID)),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("t != _UNIT_TYPE_INVALID" ), "../src/core/load-fragment.c", 3205, __PRETTY_FUNCTION__); } while (0); | |||
3206 | ||||
3207 | if (!unit_vtable[t]->can_delegate) { | |||
3208 | log_syntax(unit, LOG_ERR, filename, line, 0, "Delegate= setting not supported for this unit type, ignoring.")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3208, __func__ , "Delegate= setting not supported for this unit type, ignoring." ) : -abs(_e); }); | |||
3209 | return 0; | |||
3210 | } | |||
3211 | ||||
3212 | /* We either accept a boolean value, which may be used to turn on delegation for all controllers, or turn it | |||
3213 | * off for all. Or it takes a list of controller names, in which case we add the specified controllers to the | |||
3214 | * mask to delegate. */ | |||
3215 | ||||
3216 | if (isempty(rvalue)) { | |||
3217 | /* An empty string resets controllers and set Delegate=yes. */ | |||
3218 | c->delegate = true1; | |||
3219 | c->delegate_controllers = 0; | |||
3220 | return 0; | |||
3221 | } | |||
3222 | ||||
3223 | r = parse_boolean(rvalue); | |||
3224 | if (r < 0) { | |||
3225 | const char *p = rvalue; | |||
3226 | CGroupMask mask = 0; | |||
3227 | ||||
3228 | for (;;) { | |||
3229 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0); | |||
3230 | CGroupController cc; | |||
3231 | ||||
3232 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
3233 | if (r == 0) | |||
3234 | break; | |||
3235 | if (r == -ENOMEM12) | |||
3236 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3236, __func__); | |||
3237 | if (r < 0) { | |||
3238 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3238, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3239 | return 0; | |||
3240 | } | |||
3241 | ||||
3242 | cc = cgroup_controller_from_string(word); | |||
3243 | if (cc < 0) { | |||
3244 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid controller name '%s', ignoring", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3244, __func__ , "Invalid controller name '%s', ignoring", word) : -abs(_e); }); | |||
3245 | continue; | |||
3246 | } | |||
3247 | ||||
3248 | mask |= CGROUP_CONTROLLER_TO_MASK(cc)(1 << (cc)); | |||
3249 | } | |||
3250 | ||||
3251 | c->delegate = true1; | |||
3252 | c->delegate_controllers |= mask; | |||
3253 | ||||
3254 | } else if (r > 0) { | |||
3255 | c->delegate = true1; | |||
3256 | c->delegate_controllers = _CGROUP_MASK_ALL; | |||
3257 | } else { | |||
3258 | c->delegate = false0; | |||
3259 | c->delegate_controllers = 0; | |||
3260 | } | |||
3261 | ||||
3262 | return 0; | |||
3263 | } | |||
3264 | ||||
3265 | int config_parse_device_allow( | |||
3266 | const char *unit, | |||
3267 | const char *filename, | |||
3268 | unsigned line, | |||
3269 | const char *section, | |||
3270 | unsigned section_line, | |||
3271 | const char *lvalue, | |||
3272 | int ltype, | |||
3273 | const char *rvalue, | |||
3274 | void *data, | |||
3275 | void *userdata) { | |||
3276 | ||||
3277 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
3278 | CGroupContext *c = data; | |||
3279 | const char *p = rvalue; | |||
3280 | int r; | |||
3281 | ||||
3282 | if (isempty(rvalue)) { | |||
3283 | while (c->device_allow) | |||
3284 | cgroup_context_free_device_allow(c, c->device_allow); | |||
3285 | ||||
3286 | return 0; | |||
3287 | } | |||
3288 | ||||
3289 | r = extract_first_word(&p, &path, NULL((void*)0), EXTRACT_QUOTES); | |||
3290 | if (r == -ENOMEM12) | |||
3291 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3291, __func__); | |||
3292 | if (r < 0) { | |||
3293 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3294, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3294 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3294, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3295 | return 0; | |||
3296 | } | |||
3297 | if (r == 0) { | |||
3298 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3299, __func__ , "Failed to extract device path and rights from '%s', ignoring." , rvalue) : -abs(_e); }) | |||
3299 | "Failed to extract device path and rights from '%s', ignoring.", rvalue)({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3299, __func__ , "Failed to extract device path and rights from '%s', ignoring." , rvalue) : -abs(_e); }); | |||
3300 | return 0; | |||
3301 | } | |||
3302 | ||||
3303 | r = unit_full_printf(userdata, path, &resolved); | |||
3304 | if (r < 0) { | |||
3305 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3306, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }) | |||
3306 | "Failed to resolve unit specifiers in '%s', ignoring: %m", path)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3306, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }); | |||
3307 | return 0; | |||
3308 | } | |||
3309 | ||||
3310 | if (!startswith(resolved, "block-") && !startswith(resolved, "char-")) { | |||
3311 | ||||
3312 | r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue); | |||
3313 | if (r < 0) | |||
3314 | return 0; | |||
3315 | ||||
3316 | if (!valid_device_node_path(resolved)) { | |||
3317 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid device node path '%s', ignoring.", resolved)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3317, __func__ , "Invalid device node path '%s', ignoring.", resolved) : -abs (_e); }); | |||
3318 | return 0; | |||
3319 | } | |||
3320 | } | |||
3321 | ||||
3322 | if (!isempty(p) && !in_charset(p, "rwm")) { | |||
3323 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid device rights '%s', ignoring.", p)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3323, __func__ , "Invalid device rights '%s', ignoring.", p) : -abs(_e); }); | |||
3324 | return 0; | |||
3325 | } | |||
3326 | ||||
3327 | return cgroup_add_device_allow(c, resolved, p); | |||
3328 | } | |||
3329 | ||||
3330 | int config_parse_io_device_weight( | |||
3331 | const char *unit, | |||
3332 | const char *filename, | |||
3333 | unsigned line, | |||
3334 | const char *section, | |||
3335 | unsigned section_line, | |||
3336 | const char *lvalue, | |||
3337 | int ltype, | |||
3338 | const char *rvalue, | |||
3339 | void *data, | |||
3340 | void *userdata) { | |||
3341 | ||||
3342 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
3343 | CGroupIODeviceWeight *w; | |||
3344 | CGroupContext *c = data; | |||
3345 | const char *p = rvalue; | |||
3346 | uint64_t u; | |||
3347 | int r; | |||
3348 | ||||
3349 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3349, __PRETTY_FUNCTION__); } while (0); | |||
3350 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3350, __PRETTY_FUNCTION__); } while (0); | |||
3351 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3351, __PRETTY_FUNCTION__); } while (0); | |||
3352 | ||||
3353 | if (isempty(rvalue)) { | |||
3354 | while (c->io_device_weights) | |||
3355 | cgroup_context_free_io_device_weight(c, c->io_device_weights); | |||
3356 | ||||
3357 | return 0; | |||
3358 | } | |||
3359 | ||||
3360 | r = extract_first_word(&p, &path, NULL((void*)0), EXTRACT_QUOTES); | |||
3361 | if (r == -ENOMEM12) | |||
3362 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3362, __func__); | |||
3363 | if (r < 0) { | |||
3364 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3365, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3365 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3365, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3366 | return 0; | |||
3367 | } | |||
3368 | if (r == 0 || isempty(p)) { | |||
3369 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3370, __func__ , "Failed to extract device path and weight from '%s', ignoring." , rvalue) : -abs(_e); }) | |||
3370 | "Failed to extract device path and weight from '%s', ignoring.", rvalue)({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3370, __func__ , "Failed to extract device path and weight from '%s', ignoring." , rvalue) : -abs(_e); }); | |||
3371 | return 0; | |||
3372 | } | |||
3373 | ||||
3374 | r = unit_full_printf(userdata, path, &resolved); | |||
3375 | if (r < 0) { | |||
3376 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3377, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }) | |||
3377 | "Failed to resolve unit specifiers in '%s', ignoring: %m", path)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3377, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }); | |||
3378 | return 0; | |||
3379 | } | |||
3380 | ||||
3381 | r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue); | |||
3382 | if (r < 0) | |||
3383 | return 0; | |||
3384 | ||||
3385 | r = cg_weight_parse(p, &u); | |||
3386 | if (r < 0) { | |||
3387 | log_syntax(unit, LOG_ERR, filename, line, r, "IO weight '%s' invalid, ignoring: %m", p)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3387, __func__ , "IO weight '%s' invalid, ignoring: %m", p) : -abs(_e); }); | |||
3388 | return 0; | |||
3389 | } | |||
3390 | ||||
3391 | assert(u != CGROUP_WEIGHT_INVALID)do { if ((__builtin_expect(!!(!(u != ((uint64_t) -1))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u != CGROUP_WEIGHT_INVALID"), "../src/core/load-fragment.c" , 3391, __PRETTY_FUNCTION__); } while (0); | |||
3392 | ||||
3393 | w = new0(CGroupIODeviceWeight, 1)((CGroupIODeviceWeight*) calloc((1), sizeof(CGroupIODeviceWeight ))); | |||
3394 | if (!w) | |||
3395 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3395, __func__); | |||
3396 | ||||
3397 | w->path = TAKE_PTR(resolved)({ typeof(resolved) _ptr_ = (resolved); (resolved) = ((void*) 0); _ptr_; }); | |||
3398 | w->weight = u; | |||
3399 | ||||
3400 | LIST_PREPEND(device_weights, c->io_device_weights, w)do { typeof(*(c->io_device_weights)) **_head = &(c-> io_device_weights), *_item = (w); do { if ((__builtin_expect( !!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "_item"), "../src/core/load-fragment.c", 3400, __PRETTY_FUNCTION__ ); } while (0); if ((_item->device_weights_next = *_head)) _item->device_weights_next->device_weights_prev = _item ; _item->device_weights_prev = ((void*)0); *_head = _item; } while (0); | |||
3401 | return 0; | |||
3402 | } | |||
3403 | ||||
3404 | int config_parse_io_device_latency( | |||
3405 | const char *unit, | |||
3406 | const char *filename, | |||
3407 | unsigned line, | |||
3408 | const char *section, | |||
3409 | unsigned section_line, | |||
3410 | const char *lvalue, | |||
3411 | int ltype, | |||
3412 | const char *rvalue, | |||
3413 | void *data, | |||
3414 | void *userdata) { | |||
3415 | ||||
3416 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
3417 | CGroupIODeviceLatency *l; | |||
3418 | CGroupContext *c = data; | |||
3419 | const char *p = rvalue; | |||
3420 | usec_t usec; | |||
3421 | int r; | |||
3422 | ||||
3423 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3423, __PRETTY_FUNCTION__); } while (0); | |||
3424 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3424, __PRETTY_FUNCTION__); } while (0); | |||
3425 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3425, __PRETTY_FUNCTION__); } while (0); | |||
3426 | ||||
3427 | if (isempty(rvalue)) { | |||
3428 | while (c->io_device_latencies) | |||
3429 | cgroup_context_free_io_device_latency(c, c->io_device_latencies); | |||
3430 | ||||
3431 | return 0; | |||
3432 | } | |||
3433 | ||||
3434 | r = extract_first_word(&p, &path, NULL((void*)0), EXTRACT_QUOTES); | |||
3435 | if (r == -ENOMEM12) | |||
3436 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3436, __func__); | |||
3437 | if (r < 0) { | |||
3438 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3439, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3439 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3439, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3440 | return 0; | |||
3441 | } | |||
3442 | if (r == 0 || isempty(p)) { | |||
3443 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3444, __func__ , "Failed to extract device path and latency from '%s', ignoring." , rvalue) : -abs(_e); }) | |||
3444 | "Failed to extract device path and latency from '%s', ignoring.", rvalue)({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3444, __func__ , "Failed to extract device path and latency from '%s', ignoring." , rvalue) : -abs(_e); }); | |||
3445 | return 0; | |||
3446 | } | |||
3447 | ||||
3448 | r = unit_full_printf(userdata, path, &resolved); | |||
3449 | if (r < 0) { | |||
3450 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3451, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }) | |||
3451 | "Failed to resolve unit specifiers in '%s', ignoring: %m", path)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3451, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }); | |||
3452 | return 0; | |||
3453 | } | |||
3454 | ||||
3455 | r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue); | |||
3456 | if (r < 0) | |||
3457 | return 0; | |||
3458 | ||||
3459 | if (parse_sec(p, &usec) < 0) { | |||
3460 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse timer value, ignoring: %s", p)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3460, __func__ , "Failed to parse timer value, ignoring: %s", p) : -abs(_e); }); | |||
3461 | return 0; | |||
3462 | } | |||
3463 | ||||
3464 | l = new0(CGroupIODeviceLatency, 1)((CGroupIODeviceLatency*) calloc((1), sizeof(CGroupIODeviceLatency ))); | |||
3465 | if (!l) | |||
3466 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3466, __func__); | |||
3467 | ||||
3468 | l->path = TAKE_PTR(resolved)({ typeof(resolved) _ptr_ = (resolved); (resolved) = ((void*) 0); _ptr_; }); | |||
3469 | l->target_usec = usec; | |||
3470 | ||||
3471 | LIST_PREPEND(device_latencies, c->io_device_latencies, l)do { typeof(*(c->io_device_latencies)) **_head = &(c-> io_device_latencies), *_item = (l); do { if ((__builtin_expect (!!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 3471, __PRETTY_FUNCTION__ ); } while (0); if ((_item->device_latencies_next = *_head )) _item->device_latencies_next->device_latencies_prev = _item; _item->device_latencies_prev = ((void*)0); *_head = _item; } while (0); | |||
3472 | return 0; | |||
3473 | } | |||
3474 | ||||
3475 | int config_parse_io_limit( | |||
3476 | const char *unit, | |||
3477 | const char *filename, | |||
3478 | unsigned line, | |||
3479 | const char *section, | |||
3480 | unsigned section_line, | |||
3481 | const char *lvalue, | |||
3482 | int ltype, | |||
3483 | const char *rvalue, | |||
3484 | void *data, | |||
3485 | void *userdata) { | |||
3486 | ||||
3487 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
3488 | CGroupIODeviceLimit *l = NULL((void*)0), *t; | |||
3489 | CGroupContext *c = data; | |||
3490 | CGroupIOLimitType type; | |||
3491 | const char *p = rvalue; | |||
3492 | uint64_t num; | |||
3493 | int r; | |||
3494 | ||||
3495 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3495, __PRETTY_FUNCTION__); } while (0); | |||
3496 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3496, __PRETTY_FUNCTION__); } while (0); | |||
3497 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3497, __PRETTY_FUNCTION__); } while (0); | |||
3498 | ||||
3499 | type = cgroup_io_limit_type_from_string(lvalue); | |||
3500 | assert(type >= 0)do { if ((__builtin_expect(!!(!(type >= 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("type >= 0"), "../src/core/load-fragment.c" , 3500, __PRETTY_FUNCTION__); } while (0); | |||
3501 | ||||
3502 | if (isempty(rvalue)) { | |||
3503 | LIST_FOREACH(device_limits, l, c->io_device_limits)for ((l) = (c->io_device_limits); (l); (l) = (l)->device_limits_next ) | |||
3504 | l->limits[type] = cgroup_io_limit_defaults[type]; | |||
3505 | return 0; | |||
3506 | } | |||
3507 | ||||
3508 | r = extract_first_word(&p, &path, NULL((void*)0), EXTRACT_QUOTES); | |||
3509 | if (r == -ENOMEM12) | |||
3510 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3510, __func__); | |||
3511 | if (r < 0) { | |||
3512 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3513, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3513 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3513, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3514 | return 0; | |||
3515 | } | |||
3516 | if (r == 0 || isempty(p)) { | |||
3517 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3518, __func__ , "Failed to extract device node and bandwidth from '%s', ignoring." , rvalue) : -abs(_e); }) | |||
3518 | "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue)({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3518, __func__ , "Failed to extract device node and bandwidth from '%s', ignoring." , rvalue) : -abs(_e); }); | |||
3519 | return 0; | |||
3520 | } | |||
3521 | ||||
3522 | r = unit_full_printf(userdata, path, &resolved); | |||
3523 | if (r < 0) { | |||
3524 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3525, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }) | |||
3525 | "Failed to resolve unit specifiers in '%s', ignoring: %m", path)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3525, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }); | |||
3526 | return 0; | |||
3527 | } | |||
3528 | ||||
3529 | r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue); | |||
3530 | if (r < 0) | |||
3531 | return 0; | |||
3532 | ||||
3533 | if (streq("infinity", p)(strcmp(("infinity"),(p)) == 0)) | |||
3534 | num = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3535 | else { | |||
3536 | r = parse_size(p, 1000, &num); | |||
3537 | if (r < 0 || num <= 0) { | |||
3538 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid IO limit '%s', ignoring.", p)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3538, __func__ , "Invalid IO limit '%s', ignoring.", p) : -abs(_e); }); | |||
3539 | return 0; | |||
3540 | } | |||
3541 | } | |||
3542 | ||||
3543 | LIST_FOREACH(device_limits, t, c->io_device_limits)for ((t) = (c->io_device_limits); (t); (t) = (t)->device_limits_next ) { | |||
3544 | if (path_equal(resolved, t->path)) { | |||
3545 | l = t; | |||
3546 | break; | |||
3547 | } | |||
3548 | } | |||
3549 | ||||
3550 | if (!l) { | |||
3551 | CGroupIOLimitType ttype; | |||
3552 | ||||
3553 | l = new0(CGroupIODeviceLimit, 1)((CGroupIODeviceLimit*) calloc((1), sizeof(CGroupIODeviceLimit ))); | |||
3554 | if (!l) | |||
3555 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3555, __func__); | |||
3556 | ||||
3557 | l->path = TAKE_PTR(resolved)({ typeof(resolved) _ptr_ = (resolved); (resolved) = ((void*) 0); _ptr_; }); | |||
3558 | for (ttype = 0; ttype < _CGROUP_IO_LIMIT_TYPE_MAX; ttype++) | |||
3559 | l->limits[ttype] = cgroup_io_limit_defaults[ttype]; | |||
3560 | ||||
3561 | LIST_PREPEND(device_limits, c->io_device_limits, l)do { typeof(*(c->io_device_limits)) **_head = &(c-> io_device_limits), *_item = (l); do { if ((__builtin_expect(! !(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "_item"), "../src/core/load-fragment.c", 3561, __PRETTY_FUNCTION__ ); } while (0); if ((_item->device_limits_next = *_head)) _item ->device_limits_next->device_limits_prev = _item; _item ->device_limits_prev = ((void*)0); *_head = _item; } while (0); | |||
3562 | } | |||
3563 | ||||
3564 | l->limits[type] = num; | |||
3565 | ||||
3566 | return 0; | |||
3567 | } | |||
3568 | ||||
3569 | int config_parse_blockio_device_weight( | |||
3570 | const char *unit, | |||
3571 | const char *filename, | |||
3572 | unsigned line, | |||
3573 | const char *section, | |||
3574 | unsigned section_line, | |||
3575 | const char *lvalue, | |||
3576 | int ltype, | |||
3577 | const char *rvalue, | |||
3578 | void *data, | |||
3579 | void *userdata) { | |||
3580 | ||||
3581 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
3582 | CGroupBlockIODeviceWeight *w; | |||
3583 | CGroupContext *c = data; | |||
3584 | const char *p = rvalue; | |||
3585 | uint64_t u; | |||
3586 | int r; | |||
3587 | ||||
3588 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3588, __PRETTY_FUNCTION__); } while (0); | |||
3589 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3589, __PRETTY_FUNCTION__); } while (0); | |||
3590 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3590, __PRETTY_FUNCTION__); } while (0); | |||
3591 | ||||
3592 | if (isempty(rvalue)) { | |||
3593 | while (c->blockio_device_weights) | |||
3594 | cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights); | |||
3595 | ||||
3596 | return 0; | |||
3597 | } | |||
3598 | ||||
3599 | r = extract_first_word(&p, &path, NULL((void*)0), EXTRACT_QUOTES); | |||
3600 | if (r == -ENOMEM12) | |||
3601 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3601, __func__); | |||
3602 | if (r < 0) { | |||
3603 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3604, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3604 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3604, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3605 | return 0; | |||
3606 | } | |||
3607 | if (r == 0 || isempty(p)) { | |||
3608 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3609, __func__ , "Failed to extract device node and weight from '%s', ignoring." , rvalue) : -abs(_e); }) | |||
3609 | "Failed to extract device node and weight from '%s', ignoring.", rvalue)({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3609, __func__ , "Failed to extract device node and weight from '%s', ignoring." , rvalue) : -abs(_e); }); | |||
3610 | return 0; | |||
3611 | } | |||
3612 | ||||
3613 | r = unit_full_printf(userdata, path, &resolved); | |||
3614 | if (r < 0) { | |||
3615 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3616, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }) | |||
3616 | "Failed to resolve unit specifiers in '%s', ignoring: %m", path)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3616, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }); | |||
3617 | return 0; | |||
3618 | } | |||
3619 | ||||
3620 | r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue); | |||
3621 | if (r < 0) | |||
3622 | return 0; | |||
3623 | ||||
3624 | r = cg_blkio_weight_parse(p, &u); | |||
3625 | if (r < 0) { | |||
3626 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid block IO weight '%s', ignoring: %m", p)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3626, __func__ , "Invalid block IO weight '%s', ignoring: %m", p) : -abs(_e) ; }); | |||
3627 | return 0; | |||
3628 | } | |||
3629 | ||||
3630 | assert(u != CGROUP_BLKIO_WEIGHT_INVALID)do { if ((__builtin_expect(!!(!(u != ((uint64_t) -1))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u != CGROUP_BLKIO_WEIGHT_INVALID"), "../src/core/load-fragment.c" , 3630, __PRETTY_FUNCTION__); } while (0); | |||
3631 | ||||
3632 | w = new0(CGroupBlockIODeviceWeight, 1)((CGroupBlockIODeviceWeight*) calloc((1), sizeof(CGroupBlockIODeviceWeight ))); | |||
3633 | if (!w) | |||
3634 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3634, __func__); | |||
3635 | ||||
3636 | w->path = TAKE_PTR(resolved)({ typeof(resolved) _ptr_ = (resolved); (resolved) = ((void*) 0); _ptr_; }); | |||
3637 | w->weight = u; | |||
3638 | ||||
3639 | LIST_PREPEND(device_weights, c->blockio_device_weights, w)do { typeof(*(c->blockio_device_weights)) **_head = &( c->blockio_device_weights), *_item = (w); do { if ((__builtin_expect (!!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 3639, __PRETTY_FUNCTION__ ); } while (0); if ((_item->device_weights_next = *_head)) _item->device_weights_next->device_weights_prev = _item ; _item->device_weights_prev = ((void*)0); *_head = _item; } while (0); | |||
3640 | return 0; | |||
3641 | } | |||
3642 | ||||
3643 | int config_parse_blockio_bandwidth( | |||
3644 | const char *unit, | |||
3645 | const char *filename, | |||
3646 | unsigned line, | |||
3647 | const char *section, | |||
3648 | unsigned section_line, | |||
3649 | const char *lvalue, | |||
3650 | int ltype, | |||
3651 | const char *rvalue, | |||
3652 | void *data, | |||
3653 | void *userdata) { | |||
3654 | ||||
3655 | _cleanup_free___attribute__((cleanup(freep))) char *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
3656 | CGroupBlockIODeviceBandwidth *b = NULL((void*)0), *t; | |||
3657 | CGroupContext *c = data; | |||
3658 | const char *p = rvalue; | |||
3659 | uint64_t bytes; | |||
3660 | bool_Bool read; | |||
3661 | int r; | |||
3662 | ||||
3663 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3663, __PRETTY_FUNCTION__); } while (0); | |||
3664 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3664, __PRETTY_FUNCTION__); } while (0); | |||
3665 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3665, __PRETTY_FUNCTION__); } while (0); | |||
3666 | ||||
3667 | read = streq("BlockIOReadBandwidth", lvalue)(strcmp(("BlockIOReadBandwidth"),(lvalue)) == 0); | |||
3668 | ||||
3669 | if (isempty(rvalue)) { | |||
3670 | LIST_FOREACH(device_bandwidths, b, c->blockio_device_bandwidths)for ((b) = (c->blockio_device_bandwidths); (b); (b) = (b)-> device_bandwidths_next) { | |||
3671 | b->rbps = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3672 | b->wbps = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3673 | } | |||
3674 | return 0; | |||
3675 | } | |||
3676 | ||||
3677 | r = extract_first_word(&p, &path, NULL((void*)0), EXTRACT_QUOTES); | |||
3678 | if (r == -ENOMEM12) | |||
3679 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3679, __func__); | |||
3680 | if (r < 0) { | |||
3681 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3682, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3682 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3682, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3683 | return 0; | |||
3684 | } | |||
3685 | if (r == 0 || isempty(p)) { | |||
3686 | log_syntax(unit, LOG_WARNING, filename, line, 0,({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3687, __func__ , "Failed to extract device node and bandwidth from '%s', ignoring." , rvalue) : -abs(_e); }) | |||
3687 | "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue)({ int _level = (4), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3687, __func__ , "Failed to extract device node and bandwidth from '%s', ignoring." , rvalue) : -abs(_e); }); | |||
3688 | return 0; | |||
3689 | } | |||
3690 | ||||
3691 | r = unit_full_printf(userdata, path, &resolved); | |||
3692 | if (r < 0) { | |||
3693 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3694, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }) | |||
3694 | "Failed to resolve unit specifiers in '%s', ignoring: %m", path)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3694, __func__ , "Failed to resolve unit specifiers in '%s', ignoring: %m", path ) : -abs(_e); }); | |||
3695 | return 0; | |||
3696 | } | |||
3697 | ||||
3698 | r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue); | |||
3699 | if (r < 0) | |||
3700 | return 0; | |||
3701 | ||||
3702 | r = parse_size(p, 1000, &bytes); | |||
3703 | if (r < 0 || bytes <= 0) { | |||
3704 | log_syntax(unit, LOG_ERR, filename, line, r, "Invalid Block IO Bandwidth '%s', ignoring.", p)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3704, __func__ , "Invalid Block IO Bandwidth '%s', ignoring.", p) : -abs(_e) ; }); | |||
3705 | return 0; | |||
3706 | } | |||
3707 | ||||
3708 | LIST_FOREACH(device_bandwidths, t, c->blockio_device_bandwidths)for ((t) = (c->blockio_device_bandwidths); (t); (t) = (t)-> device_bandwidths_next) { | |||
3709 | if (path_equal(resolved, t->path)) { | |||
3710 | b = t; | |||
3711 | break; | |||
3712 | } | |||
3713 | } | |||
3714 | ||||
3715 | if (!t) { | |||
3716 | b = new0(CGroupBlockIODeviceBandwidth, 1)((CGroupBlockIODeviceBandwidth*) calloc((1), sizeof(CGroupBlockIODeviceBandwidth ))); | |||
3717 | if (!b) | |||
3718 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3718, __func__); | |||
3719 | ||||
3720 | b->path = TAKE_PTR(resolved)({ typeof(resolved) _ptr_ = (resolved); (resolved) = ((void*) 0); _ptr_; }); | |||
3721 | b->rbps = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3722 | b->wbps = CGROUP_LIMIT_MAX((uint64_t) -1); | |||
3723 | ||||
3724 | LIST_PREPEND(device_bandwidths, c->blockio_device_bandwidths, b)do { typeof(*(c->blockio_device_bandwidths)) **_head = & (c->blockio_device_bandwidths), *_item = (b); do { if ((__builtin_expect (!!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("_item"), "../src/core/load-fragment.c", 3724, __PRETTY_FUNCTION__ ); } while (0); if ((_item->device_bandwidths_next = *_head )) _item->device_bandwidths_next->device_bandwidths_prev = _item; _item->device_bandwidths_prev = ((void*)0); *_head = _item; } while (0); | |||
3725 | } | |||
3726 | ||||
3727 | if (read) | |||
3728 | b->rbps = bytes; | |||
3729 | else | |||
3730 | b->wbps = bytes; | |||
3731 | ||||
3732 | return 0; | |||
3733 | } | |||
3734 | ||||
3735 | int config_parse_job_mode_isolate( | |||
3736 | const char *unit, | |||
3737 | const char *filename, | |||
3738 | unsigned line, | |||
3739 | const char *section, | |||
3740 | unsigned section_line, | |||
3741 | const char *lvalue, | |||
3742 | int ltype, | |||
3743 | const char *rvalue, | |||
3744 | void *data, | |||
3745 | void *userdata) { | |||
3746 | ||||
3747 | JobMode *m = data; | |||
3748 | int r; | |||
3749 | ||||
3750 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3750, __PRETTY_FUNCTION__); } while (0); | |||
3751 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3751, __PRETTY_FUNCTION__); } while (0); | |||
3752 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3752, __PRETTY_FUNCTION__); } while (0); | |||
3753 | ||||
3754 | r = parse_boolean(rvalue); | |||
3755 | if (r < 0) { | |||
3756 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse boolean, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3756, __func__ , "Failed to parse boolean, ignoring: %s", rvalue) : -abs(_e) ; }); | |||
3757 | return 0; | |||
3758 | } | |||
3759 | ||||
3760 | log_notice("%s is deprecated. Please use OnFailureJobMode= instead", lvalue)({ int _level = (((5))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/core/load-fragment.c", 3760, __func__, "%s is deprecated. Please use OnFailureJobMode= instead" , lvalue) : -abs(_e); }); | |||
3761 | ||||
3762 | *m = r ? JOB_ISOLATE : JOB_REPLACE; | |||
3763 | return 0; | |||
3764 | } | |||
3765 | ||||
3766 | int config_parse_exec_directories( | |||
3767 | const char *unit, | |||
3768 | const char *filename, | |||
3769 | unsigned line, | |||
3770 | const char *section, | |||
3771 | unsigned section_line, | |||
3772 | const char *lvalue, | |||
3773 | int ltype, | |||
3774 | const char *rvalue, | |||
3775 | void *data, | |||
3776 | void *userdata) { | |||
3777 | ||||
3778 | char***rt = data; | |||
3779 | Unit *u = userdata; | |||
3780 | const char *p; | |||
3781 | int r; | |||
3782 | ||||
3783 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3783, __PRETTY_FUNCTION__); } while (0); | |||
3784 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3784, __PRETTY_FUNCTION__); } while (0); | |||
3785 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3785, __PRETTY_FUNCTION__); } while (0); | |||
3786 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 3786 , __PRETTY_FUNCTION__); } while (0); | |||
3787 | ||||
3788 | if (isempty(rvalue)) { | |||
3789 | /* Empty assignment resets the list */ | |||
3790 | *rt = strv_free(*rt); | |||
3791 | return 0; | |||
3792 | } | |||
3793 | ||||
3794 | for (p = rvalue;;) { | |||
3795 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *k = NULL((void*)0); | |||
3796 | ||||
3797 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
3798 | if (r == -ENOMEM12) | |||
3799 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3799, __func__); | |||
3800 | if (r < 0) { | |||
3801 | log_syntax(unit, LOG_WARNING, filename, line, r,({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3802, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }) | |||
3802 | "Invalid syntax, ignoring: %s", rvalue)({ int _level = (4), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3802, __func__ , "Invalid syntax, ignoring: %s", rvalue) : -abs(_e); }); | |||
3803 | return 0; | |||
3804 | } | |||
3805 | if (r == 0) | |||
3806 | return 0; | |||
3807 | ||||
3808 | r = unit_full_printf(u, word, &k); | |||
3809 | if (r < 0) { | |||
3810 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3811, __func__ , "Failed to resolve unit specifiers in \"%s\", ignoring: %m" , word) : -abs(_e); }) | |||
3811 | "Failed to resolve unit specifiers in \"%s\", ignoring: %m", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3811, __func__ , "Failed to resolve unit specifiers in \"%s\", ignoring: %m" , word) : -abs(_e); }); | |||
3812 | continue; | |||
3813 | } | |||
3814 | ||||
3815 | r = path_simplify_and_warn(k, PATH_CHECK_RELATIVE, unit, filename, line, lvalue); | |||
3816 | if (r < 0) | |||
3817 | continue; | |||
3818 | ||||
3819 | if (path_startswith(k, "private")) { | |||
3820 | log_syntax(unit, LOG_ERR, filename, line, 0,({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3821, __func__ , "%s= path can't be 'private', ingoring assignment: %s", lvalue , word) : -abs(_e); }) | |||
3821 | "%s= path can't be 'private', ingoring assignment: %s", lvalue, word)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3821, __func__ , "%s= path can't be 'private', ingoring assignment: %s", lvalue , word) : -abs(_e); }); | |||
3822 | continue; | |||
3823 | } | |||
3824 | ||||
3825 | r = strv_push(rt, k); | |||
3826 | if (r < 0) | |||
3827 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3827, __func__); | |||
3828 | k = NULL((void*)0); | |||
3829 | } | |||
3830 | } | |||
3831 | ||||
3832 | int config_parse_set_status( | |||
3833 | const char *unit, | |||
3834 | const char *filename, | |||
3835 | unsigned line, | |||
3836 | const char *section, | |||
3837 | unsigned section_line, | |||
3838 | const char *lvalue, | |||
3839 | int ltype, | |||
3840 | const char *rvalue, | |||
3841 | void *data, | |||
3842 | void *userdata) { | |||
3843 | ||||
3844 | size_t l; | |||
3845 | const char *word, *state; | |||
3846 | int r; | |||
3847 | ExitStatusSet *status_set = data; | |||
3848 | ||||
3849 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3849, __PRETTY_FUNCTION__); } while (0); | |||
| ||||
3850 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3850, __PRETTY_FUNCTION__); } while (0); | |||
3851 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3851, __PRETTY_FUNCTION__); } while (0); | |||
3852 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 3852 , __PRETTY_FUNCTION__); } while (0); | |||
3853 | ||||
3854 | /* Empty assignment resets the list */ | |||
3855 | if (isempty(rvalue)) { | |||
3856 | exit_status_set_free(status_set); | |||
3857 | return 0; | |||
3858 | } | |||
3859 | ||||
3860 | FOREACH_WORD(word, l, rvalue, state)for ((state) = (rvalue), (word) = split(&(state), &(l ), (" \t\n\r"), (0)); (word); (word) = split(&(state), & (l), (" \t\n\r"), (0))) { | |||
3861 | _cleanup_free___attribute__((cleanup(freep))) char *temp; | |||
3862 | int val; | |||
3863 | Set **set; | |||
3864 | ||||
3865 | temp = strndup(word, l); | |||
3866 | if (!temp) | |||
3867 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3867, __func__); | |||
3868 | ||||
3869 | r = safe_atoi(temp, &val); | |||
3870 | if (r < 0) { | |||
3871 | val = signal_from_string(temp); | |||
3872 | ||||
3873 | if (val <= 0) { | |||
3874 | log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse value, ignoring: %s", word)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3874, __func__ , "Failed to parse value, ignoring: %s", word) : -abs(_e); }); | |||
3875 | continue; | |||
3876 | } | |||
3877 | set = &status_set->signal; | |||
3878 | } else { | |||
3879 | if (val < 0 || val > 255) { | |||
| ||||
3880 | log_syntax(unit, LOG_ERR, filename, line, 0, "Value %d is outside range 0-255, ignoring", val)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3880, __func__ , "Value %d is outside range 0-255, ignoring", val) : -abs(_e ); }); | |||
3881 | continue; | |||
3882 | } | |||
3883 | set = &status_set->status; | |||
3884 | } | |||
3885 | ||||
3886 | r = set_ensure_allocated(set, NULL)internal_set_ensure_allocated(set, ((void*)0) ); | |||
3887 | if (r < 0) | |||
3888 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3888, __func__); | |||
3889 | ||||
3890 | r = set_put(*set, INT_TO_PTR(val)((void *) ((intptr_t) (val)))); | |||
3891 | if (r < 0) | |||
3892 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3892, __func__); | |||
3893 | } | |||
3894 | if (!isempty(state)) | |||
3895 | log_syntax(unit, LOG_ERR, filename, line, 0, "Trailing garbage, ignoring.")({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3895, __func__ , "Trailing garbage, ignoring.") : -abs(_e); }); | |||
3896 | ||||
3897 | return 0; | |||
3898 | } | |||
3899 | ||||
3900 | int config_parse_namespace_path_strv( | |||
3901 | const char *unit, | |||
3902 | const char *filename, | |||
3903 | unsigned line, | |||
3904 | const char *section, | |||
3905 | unsigned section_line, | |||
3906 | const char *lvalue, | |||
3907 | int ltype, | |||
3908 | const char *rvalue, | |||
3909 | void *data, | |||
3910 | void *userdata) { | |||
3911 | ||||
3912 | Unit *u = userdata; | |||
3913 | char*** sv = data; | |||
3914 | const char *p = rvalue; | |||
3915 | int r; | |||
3916 | ||||
3917 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3917, __PRETTY_FUNCTION__); } while (0); | |||
3918 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3918, __PRETTY_FUNCTION__); } while (0); | |||
3919 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3919, __PRETTY_FUNCTION__); } while (0); | |||
3920 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 3920 , __PRETTY_FUNCTION__); } while (0); | |||
3921 | ||||
3922 | if (isempty(rvalue)) { | |||
3923 | /* Empty assignment resets the list */ | |||
3924 | *sv = strv_free(*sv); | |||
3925 | return 0; | |||
3926 | } | |||
3927 | ||||
3928 | for (;;) { | |||
3929 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *resolved = NULL((void*)0), *joined = NULL((void*)0); | |||
3930 | const char *w; | |||
3931 | bool_Bool ignore_enoent = false0, shall_prefix = false0; | |||
3932 | ||||
3933 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
3934 | if (r == 0) | |||
3935 | break; | |||
3936 | if (r == -ENOMEM12) | |||
3937 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3937, __func__); | |||
3938 | if (r < 0) { | |||
3939 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3939, __func__ , "Failed to extract first word, ignoring: %s", rvalue) : -abs (_e); }); | |||
3940 | return 0; | |||
3941 | } | |||
3942 | ||||
3943 | w = word; | |||
3944 | if (startswith(w, "-")) { | |||
3945 | ignore_enoent = true1; | |||
3946 | w++; | |||
3947 | } | |||
3948 | if (startswith(w, "+")) { | |||
3949 | shall_prefix = true1; | |||
3950 | w++; | |||
3951 | } | |||
3952 | ||||
3953 | r = unit_full_printf(u, w, &resolved); | |||
3954 | if (r < 0) { | |||
3955 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s: %m", w)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 3955, __func__ , "Failed to resolve unit specifiers in %s: %m", w) : -abs(_e ); }); | |||
3956 | continue; | |||
3957 | } | |||
3958 | ||||
3959 | r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
3960 | if (r < 0) | |||
3961 | continue; | |||
3962 | ||||
3963 | joined = strjoin(ignore_enoent ? "-" : "",strjoin_real((ignore_enoent ? "-" : ""), shall_prefix ? "+" : "", resolved, ((void*)0)) | |||
3964 | shall_prefix ? "+" : "",strjoin_real((ignore_enoent ? "-" : ""), shall_prefix ? "+" : "", resolved, ((void*)0)) | |||
3965 | resolved)strjoin_real((ignore_enoent ? "-" : ""), shall_prefix ? "+" : "", resolved, ((void*)0)); | |||
3966 | ||||
3967 | r = strv_push(sv, joined); | |||
3968 | if (r < 0) | |||
3969 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 3969, __func__); | |||
3970 | ||||
3971 | joined = NULL((void*)0); | |||
3972 | } | |||
3973 | ||||
3974 | return 0; | |||
3975 | } | |||
3976 | ||||
3977 | int config_parse_temporary_filesystems( | |||
3978 | const char *unit, | |||
3979 | const char *filename, | |||
3980 | unsigned line, | |||
3981 | const char *section, | |||
3982 | unsigned section_line, | |||
3983 | const char *lvalue, | |||
3984 | int ltype, | |||
3985 | const char *rvalue, | |||
3986 | void *data, | |||
3987 | void *userdata) { | |||
3988 | ||||
3989 | Unit *u = userdata; | |||
3990 | ExecContext *c = data; | |||
3991 | const char *p = rvalue; | |||
3992 | int r; | |||
3993 | ||||
3994 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 3994, __PRETTY_FUNCTION__); } while (0); | |||
3995 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 3995, __PRETTY_FUNCTION__); } while (0); | |||
3996 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 3996, __PRETTY_FUNCTION__); } while (0); | |||
3997 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 3997 , __PRETTY_FUNCTION__); } while (0); | |||
3998 | ||||
3999 | if (isempty(rvalue)) { | |||
4000 | /* Empty assignment resets the list */ | |||
4001 | temporary_filesystem_free_many(c->temporary_filesystems, c->n_temporary_filesystems); | |||
4002 | c->temporary_filesystems = NULL((void*)0); | |||
4003 | c->n_temporary_filesystems = 0; | |||
4004 | return 0; | |||
4005 | } | |||
4006 | ||||
4007 | for (;;) { | |||
4008 | _cleanup_free___attribute__((cleanup(freep))) char *word = NULL((void*)0), *path = NULL((void*)0), *resolved = NULL((void*)0); | |||
4009 | const char *w; | |||
4010 | ||||
4011 | r = extract_first_word(&p, &word, NULL((void*)0), EXTRACT_QUOTES); | |||
4012 | if (r == 0) | |||
4013 | return 0; | |||
4014 | if (r == -ENOMEM12) | |||
4015 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4015, __func__); | |||
4016 | if (r < 0) { | |||
4017 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4017, __func__ , "Failed to extract first word, ignoring: %s", rvalue) : -abs (_e); }); | |||
4018 | return 0; | |||
4019 | } | |||
4020 | ||||
4021 | w = word; | |||
4022 | r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS); | |||
4023 | if (r == -ENOMEM12) | |||
4024 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4024, __func__); | |||
4025 | if (r < 0) { | |||
4026 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract first word, ignoring: %s", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4026, __func__ , "Failed to extract first word, ignoring: %s", word) : -abs( _e); }); | |||
4027 | continue; | |||
4028 | } | |||
4029 | if (r == 0) { | |||
4030 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring: %s", word)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4030, __func__ , "Invalid syntax, ignoring: %s", word) : -abs(_e); }); | |||
4031 | continue; | |||
4032 | } | |||
4033 | ||||
4034 | r = unit_full_printf(u, path, &resolved); | |||
4035 | if (r < 0) { | |||
4036 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers in %s, ignoring: %m", path)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4036, __func__ , "Failed to resolve unit specifiers in %s, ignoring: %m", path ) : -abs(_e); }); | |||
4037 | continue; | |||
4038 | } | |||
4039 | ||||
4040 | r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
4041 | if (r < 0) | |||
4042 | continue; | |||
4043 | ||||
4044 | r = temporary_filesystem_add(&c->temporary_filesystems, &c->n_temporary_filesystems, path, w); | |||
4045 | if (r == -ENOMEM12) | |||
4046 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4046, __func__); | |||
4047 | if (r < 0) { | |||
4048 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse mount options, ignoring: %s", word)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4048, __func__ , "Failed to parse mount options, ignoring: %s", word) : -abs (_e); }); | |||
4049 | continue; | |||
4050 | } | |||
4051 | } | |||
4052 | } | |||
4053 | ||||
4054 | int config_parse_bind_paths( | |||
4055 | const char *unit, | |||
4056 | const char *filename, | |||
4057 | unsigned line, | |||
4058 | const char *section, | |||
4059 | unsigned section_line, | |||
4060 | const char *lvalue, | |||
4061 | int ltype, | |||
4062 | const char *rvalue, | |||
4063 | void *data, | |||
4064 | void *userdata) { | |||
4065 | ||||
4066 | ExecContext *c = data; | |||
4067 | Unit *u = userdata; | |||
4068 | const char *p; | |||
4069 | int r; | |||
4070 | ||||
4071 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 4071, __PRETTY_FUNCTION__); } while (0); | |||
4072 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 4072, __PRETTY_FUNCTION__); } while (0); | |||
4073 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 4073, __PRETTY_FUNCTION__); } while (0); | |||
4074 | assert(data)do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/load-fragment.c", 4074 , __PRETTY_FUNCTION__); } while (0); | |||
4075 | ||||
4076 | if (isempty(rvalue)) { | |||
4077 | /* Empty assignment resets the list */ | |||
4078 | bind_mount_free_many(c->bind_mounts, c->n_bind_mounts); | |||
4079 | c->bind_mounts = NULL((void*)0); | |||
4080 | c->n_bind_mounts = 0; | |||
4081 | return 0; | |||
4082 | } | |||
4083 | ||||
4084 | p = rvalue; | |||
4085 | for (;;) { | |||
4086 | _cleanup_free___attribute__((cleanup(freep))) char *source = NULL((void*)0), *destination = NULL((void*)0); | |||
4087 | _cleanup_free___attribute__((cleanup(freep))) char *sresolved = NULL((void*)0), *dresolved = NULL((void*)0); | |||
4088 | char *s = NULL((void*)0), *d = NULL((void*)0); | |||
4089 | bool_Bool rbind = true1, ignore_enoent = false0; | |||
4090 | ||||
4091 | r = extract_first_word(&p, &source, ":" WHITESPACE" \t\n\r", EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS); | |||
4092 | if (r == 0) | |||
4093 | break; | |||
4094 | if (r == -ENOMEM12) | |||
4095 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4095, __func__); | |||
4096 | if (r < 0) { | |||
4097 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4097, __func__ , "Failed to parse %s, ignoring: %s", lvalue, rvalue) : -abs( _e); }); | |||
4098 | return 0; | |||
4099 | } | |||
4100 | ||||
4101 | r = unit_full_printf(u, source, &sresolved); | |||
4102 | if (r < 0) { | |||
4103 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4104, __func__ , "Failed to resolved unit specifiers in \"%s\", ignoring: %m" , source) : -abs(_e); }) | |||
4104 | "Failed to resolved unit specifiers in \"%s\", ignoring: %m", source)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4104, __func__ , "Failed to resolved unit specifiers in \"%s\", ignoring: %m" , source) : -abs(_e); }); | |||
4105 | continue; | |||
4106 | } | |||
4107 | ||||
4108 | s = sresolved; | |||
4109 | if (s[0] == '-') { | |||
4110 | ignore_enoent = true1; | |||
4111 | s++; | |||
4112 | } | |||
4113 | ||||
4114 | r = path_simplify_and_warn(s, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
4115 | if (r < 0) | |||
4116 | continue; | |||
4117 | ||||
4118 | /* Optionally, the destination is specified. */ | |||
4119 | if (p && p[-1] == ':') { | |||
4120 | r = extract_first_word(&p, &destination, ":" WHITESPACE" \t\n\r", EXTRACT_QUOTES|EXTRACT_DONT_COALESCE_SEPARATORS); | |||
4121 | if (r == -ENOMEM12) | |||
4122 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4122, __func__); | |||
4123 | if (r < 0) { | |||
4124 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4124, __func__ , "Failed to parse %s, ignoring: %s", lvalue, rvalue) : -abs( _e); }); | |||
4125 | return 0; | |||
4126 | } | |||
4127 | if (r == 0) { | |||
4128 | log_syntax(unit, LOG_ERR, filename, line, 0, "Missing argument after ':', ignoring: %s", s)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4128, __func__ , "Missing argument after ':', ignoring: %s", s) : -abs(_e); } ); | |||
4129 | continue; | |||
4130 | } | |||
4131 | ||||
4132 | r = unit_full_printf(u, destination, &dresolved); | |||
4133 | if (r < 0) { | |||
4134 | log_syntax(unit, LOG_ERR, filename, line, r,({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4135, __func__ , "Failed to resolved specifiers in \"%s\", ignoring: %m", destination ) : -abs(_e); }) | |||
4135 | "Failed to resolved specifiers in \"%s\", ignoring: %m", destination)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4135, __func__ , "Failed to resolved specifiers in \"%s\", ignoring: %m", destination ) : -abs(_e); }); | |||
4136 | continue; | |||
4137 | } | |||
4138 | ||||
4139 | r = path_simplify_and_warn(dresolved, PATH_CHECK_ABSOLUTE, unit, filename, line, lvalue); | |||
4140 | if (r < 0) | |||
4141 | continue; | |||
4142 | ||||
4143 | d = dresolved; | |||
4144 | ||||
4145 | /* Optionally, there's also a short option string specified */ | |||
4146 | if (p && p[-1] == ':') { | |||
4147 | _cleanup_free___attribute__((cleanup(freep))) char *options = NULL((void*)0); | |||
4148 | ||||
4149 | r = extract_first_word(&p, &options, NULL((void*)0), EXTRACT_QUOTES); | |||
4150 | if (r == -ENOMEM12) | |||
4151 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4151, __func__); | |||
4152 | if (r < 0) { | |||
4153 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse %s: %s", lvalue, rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4153, __func__ , "Failed to parse %s: %s", lvalue, rvalue) : -abs(_e); }); | |||
4154 | return 0; | |||
4155 | } | |||
4156 | ||||
4157 | if (isempty(options) || streq(options, "rbind")(strcmp((options),("rbind")) == 0)) | |||
4158 | rbind = true1; | |||
4159 | else if (streq(options, "norbind")(strcmp((options),("norbind")) == 0)) | |||
4160 | rbind = false0; | |||
4161 | else { | |||
4162 | log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid option string, ignoring setting: %s", options)({ int _level = (3), _e = (0); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4162, __func__ , "Invalid option string, ignoring setting: %s", options) : - abs(_e); }); | |||
4163 | continue; | |||
4164 | } | |||
4165 | } | |||
4166 | } else | |||
4167 | d = s; | |||
4168 | ||||
4169 | r = bind_mount_add(&c->bind_mounts, &c->n_bind_mounts, | |||
4170 | &(BindMount) { | |||
4171 | .source = s, | |||
4172 | .destination = d, | |||
4173 | .read_only = !!strstr(lvalue, "ReadOnly"), | |||
4174 | .recursive = rbind, | |||
4175 | .ignore_enoent = ignore_enoent, | |||
4176 | }); | |||
4177 | if (r < 0) | |||
4178 | return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/core/load-fragment.c" , 4178, __func__); | |||
4179 | } | |||
4180 | ||||
4181 | return 0; | |||
4182 | } | |||
4183 | ||||
4184 | int config_parse_job_timeout_sec( | |||
4185 | const char* unit, | |||
4186 | const char *filename, | |||
4187 | unsigned line, | |||
4188 | const char *section, | |||
4189 | unsigned section_line, | |||
4190 | const char *lvalue, | |||
4191 | int ltype, | |||
4192 | const char *rvalue, | |||
4193 | void *data, | |||
4194 | void *userdata) { | |||
4195 | ||||
4196 | Unit *u = data; | |||
4197 | usec_t usec; | |||
4198 | int r; | |||
4199 | ||||
4200 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 4200, __PRETTY_FUNCTION__); } while (0); | |||
4201 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 4201, __PRETTY_FUNCTION__); } while (0); | |||
4202 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 4202, __PRETTY_FUNCTION__); } while (0); | |||
4203 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 4203 , __PRETTY_FUNCTION__); } while (0); | |||
4204 | ||||
4205 | r = parse_sec_fix_0(rvalue, &usec); | |||
4206 | if (r < 0) { | |||
4207 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse JobTimeoutSec= parameter, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4207, __func__ , "Failed to parse JobTimeoutSec= parameter, ignoring: %s", rvalue ) : -abs(_e); }); | |||
4208 | return 0; | |||
4209 | } | |||
4210 | ||||
4211 | /* If the user explicitly changed JobTimeoutSec= also change JobRunningTimeoutSec=, for compatibility with old | |||
4212 | * versions. If JobRunningTimeoutSec= was explicitly set, avoid this however as whatever the user picked should | |||
4213 | * count. */ | |||
4214 | ||||
4215 | if (!u->job_running_timeout_set) | |||
4216 | u->job_running_timeout = usec; | |||
4217 | ||||
4218 | u->job_timeout = usec; | |||
4219 | ||||
4220 | return 0; | |||
4221 | } | |||
4222 | ||||
4223 | int config_parse_job_running_timeout_sec( | |||
4224 | const char* unit, | |||
4225 | const char *filename, | |||
4226 | unsigned line, | |||
4227 | const char *section, | |||
4228 | unsigned section_line, | |||
4229 | const char *lvalue, | |||
4230 | int ltype, | |||
4231 | const char *rvalue, | |||
4232 | void *data, | |||
4233 | void *userdata) { | |||
4234 | ||||
4235 | Unit *u = data; | |||
4236 | usec_t usec; | |||
4237 | int r; | |||
4238 | ||||
4239 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 4239, __PRETTY_FUNCTION__); } while (0); | |||
4240 | assert(lvalue)do { if ((__builtin_expect(!!(!(lvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("lvalue"), "../src/core/load-fragment.c" , 4240, __PRETTY_FUNCTION__); } while (0); | |||
4241 | assert(rvalue)do { if ((__builtin_expect(!!(!(rvalue)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("rvalue"), "../src/core/load-fragment.c" , 4241, __PRETTY_FUNCTION__); } while (0); | |||
4242 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 4242 , __PRETTY_FUNCTION__); } while (0); | |||
4243 | ||||
4244 | r = parse_sec_fix_0(rvalue, &usec); | |||
4245 | if (r < 0) { | |||
4246 | log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse JobRunningTimeoutSec= parameter, ignoring: %s", rvalue)({ int _level = (3), _e = (r); (log_get_max_level_realm(LOG_REALM_SYSTEMD ) >= ((_level) & 0x07)) ? log_syntax_internal(unit, _level , filename, line, _e, "../src/core/load-fragment.c", 4246, __func__ , "Failed to parse JobRunningTimeoutSec= parameter, ignoring: %s" , rvalue) : -abs(_e); }); | |||
4247 | return 0; | |||
4248 | } | |||
4249 | ||||
4250 | u->job_running_timeout = usec; | |||
4251 | u->job_running_timeout_set = true1; | |||
4252 | ||||
4253 | return 0; | |||
4254 | } | |||
4255 | ||||
4256 | #define FOLLOW_MAX8 8 | |||
4257 | ||||
4258 | static int open_follow(char **filename, FILE **_f, Set *names, char **_final) { | |||
4259 | char *id = NULL((void*)0); | |||
4260 | unsigned c = 0; | |||
4261 | int fd, r; | |||
4262 | FILE *f; | |||
4263 | ||||
4264 | assert(filename)do { if ((__builtin_expect(!!(!(filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("filename"), "../src/core/load-fragment.c" , 4264, __PRETTY_FUNCTION__); } while (0); | |||
4265 | assert(*filename)do { if ((__builtin_expect(!!(!(*filename)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("*filename"), "../src/core/load-fragment.c" , 4265, __PRETTY_FUNCTION__); } while (0); | |||
4266 | assert(_f)do { if ((__builtin_expect(!!(!(_f)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_f"), "../src/core/load-fragment.c", 4266 , __PRETTY_FUNCTION__); } while (0); | |||
4267 | assert(names)do { if ((__builtin_expect(!!(!(names)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("names"), "../src/core/load-fragment.c", 4267, __PRETTY_FUNCTION__); } while (0); | |||
4268 | ||||
4269 | /* This will update the filename pointer if the loaded file is | |||
4270 | * reached by a symlink. The old string will be freed. */ | |||
4271 | ||||
4272 | for (;;) { | |||
4273 | char *target, *name; | |||
4274 | ||||
4275 | if (c++ >= FOLLOW_MAX8) | |||
4276 | return -ELOOP40; | |||
4277 | ||||
4278 | path_simplify(*filename, false0); | |||
4279 | ||||
4280 | /* Add the file name we are currently looking at to | |||
4281 | * the names of this unit, but only if it is a valid | |||
4282 | * unit name. */ | |||
4283 | name = basename(*filename); | |||
4284 | if (unit_name_is_valid(name, UNIT_NAME_ANY)) { | |||
4285 | ||||
4286 | id = set_get(names, name); | |||
4287 | if (!id) { | |||
4288 | id = strdup(name); | |||
4289 | if (!id) | |||
4290 | return -ENOMEM12; | |||
4291 | ||||
4292 | r = set_consume(names, id); | |||
4293 | if (r < 0) | |||
4294 | return r; | |||
4295 | } | |||
4296 | } | |||
4297 | ||||
4298 | /* Try to open the file name, but don't if its a symlink */ | |||
4299 | fd = open(*filename, O_RDONLY00|O_CLOEXEC02000000|O_NOCTTY0400|O_NOFOLLOW0400000); | |||
4300 | if (fd >= 0) | |||
4301 | break; | |||
4302 | ||||
4303 | if (errno(*__errno_location ()) != ELOOP40) | |||
4304 | return -errno(*__errno_location ()); | |||
4305 | ||||
4306 | /* Hmm, so this is a symlink. Let's read the name, and follow it manually */ | |||
4307 | r = readlink_and_make_absolute(*filename, &target); | |||
4308 | if (r < 0) | |||
4309 | return r; | |||
4310 | ||||
4311 | free_and_replace(*filename, target)({ free(*filename); (*filename) = (target); (target) = ((void *)0); 0; }); | |||
4312 | } | |||
4313 | ||||
4314 | f = fdopen(fd, "re"); | |||
4315 | if (!f) { | |||
4316 | safe_close(fd); | |||
4317 | return -errno(*__errno_location ()); | |||
4318 | } | |||
4319 | ||||
4320 | *_f = f; | |||
4321 | *_final = id; | |||
4322 | ||||
4323 | return 0; | |||
4324 | } | |||
4325 | ||||
4326 | static int merge_by_names(Unit **u, Set *names, const char *id) { | |||
4327 | char *k; | |||
4328 | int r; | |||
4329 | ||||
4330 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 4330 , __PRETTY_FUNCTION__); } while (0); | |||
4331 | assert(*u)do { if ((__builtin_expect(!!(!(*u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("*u"), "../src/core/load-fragment.c", 4331 , __PRETTY_FUNCTION__); } while (0); | |||
4332 | assert(names)do { if ((__builtin_expect(!!(!(names)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("names"), "../src/core/load-fragment.c", 4332, __PRETTY_FUNCTION__); } while (0); | |||
4333 | ||||
4334 | /* Let's try to add in all symlink names we found */ | |||
4335 | while ((k = set_steal_first(names))) { | |||
4336 | ||||
4337 | /* First try to merge in the other name into our | |||
4338 | * unit */ | |||
4339 | r = unit_merge_by_name(*u, k); | |||
4340 | if (r < 0) { | |||
4341 | Unit *other; | |||
4342 | ||||
4343 | /* Hmm, we couldn't merge the other unit into | |||
4344 | * ours? Then let's try it the other way | |||
4345 | * round */ | |||
4346 | ||||
4347 | /* If the symlink name we are looking at is unit template, then | |||
4348 | we must search for instance of this template */ | |||
4349 | if (unit_name_is_valid(k, UNIT_NAME_TEMPLATE) && (*u)->instance) { | |||
4350 | _cleanup_free___attribute__((cleanup(freep))) char *instance = NULL((void*)0); | |||
4351 | ||||
4352 | r = unit_name_replace_instance(k, (*u)->instance, &instance); | |||
4353 | if (r < 0) | |||
4354 | return r; | |||
4355 | ||||
4356 | other = manager_get_unit((*u)->manager, instance); | |||
4357 | } else | |||
4358 | other = manager_get_unit((*u)->manager, k); | |||
4359 | ||||
4360 | free(k); | |||
4361 | ||||
4362 | if (other) { | |||
4363 | r = unit_merge(other, *u); | |||
4364 | if (r >= 0) { | |||
4365 | *u = other; | |||
4366 | return merge_by_names(u, names, NULL((void*)0)); | |||
4367 | } | |||
4368 | } | |||
4369 | ||||
4370 | return r; | |||
4371 | } | |||
4372 | ||||
4373 | if (id == k) | |||
4374 | unit_choose_id(*u, id); | |||
4375 | ||||
4376 | free(k); | |||
4377 | } | |||
4378 | ||||
4379 | return 0; | |||
4380 | } | |||
4381 | ||||
4382 | static int load_from_path(Unit *u, const char *path) { | |||
4383 | _cleanup_set_free_free___attribute__((cleanup(set_free_freep))) Set *symlink_names = NULL((void*)0); | |||
4384 | _cleanup_fclose___attribute__((cleanup(fclosep))) FILE *f = NULL((void*)0); | |||
4385 | _cleanup_free___attribute__((cleanup(freep))) char *filename = NULL((void*)0); | |||
4386 | char *id = NULL((void*)0); | |||
4387 | Unit *merged; | |||
4388 | struct stat st; | |||
4389 | int r; | |||
4390 | ||||
4391 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 4391 , __PRETTY_FUNCTION__); } while (0); | |||
4392 | assert(path)do { if ((__builtin_expect(!!(!(path)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path"), "../src/core/load-fragment.c", 4392 , __PRETTY_FUNCTION__); } while (0); | |||
4393 | ||||
4394 | symlink_names = set_new(&string_hash_ops)internal_set_new(&string_hash_ops ); | |||
4395 | if (!symlink_names) | |||
4396 | return -ENOMEM12; | |||
4397 | ||||
4398 | if (path_is_absolute(path)) { | |||
4399 | ||||
4400 | filename = strdup(path); | |||
4401 | if (!filename) | |||
4402 | return -ENOMEM12; | |||
4403 | ||||
4404 | r = open_follow(&filename, &f, symlink_names, &id); | |||
4405 | if (r < 0) { | |||
4406 | filename = mfree(filename); | |||
4407 | if (r != -ENOENT2) | |||
4408 | return r; | |||
4409 | } | |||
4410 | ||||
4411 | } else { | |||
4412 | char **p; | |||
4413 | ||||
4414 | STRV_FOREACH(p, u->manager->lookup_paths.search_path)for ((p) = (u->manager->lookup_paths.search_path); (p) && *(p); (p)++) { | |||
4415 | ||||
4416 | /* Instead of opening the path right away, we manually | |||
4417 | * follow all symlinks and add their name to our unit | |||
4418 | * name set while doing so */ | |||
4419 | filename = path_make_absolute(path, *p); | |||
4420 | if (!filename) | |||
4421 | return -ENOMEM12; | |||
4422 | ||||
4423 | if (u->manager->unit_path_cache && | |||
4424 | !set_get(u->manager->unit_path_cache, filename)) | |||
4425 | r = -ENOENT2; | |||
4426 | else | |||
4427 | r = open_follow(&filename, &f, symlink_names, &id); | |||
4428 | if (r >= 0) | |||
4429 | break; | |||
4430 | filename = mfree(filename); | |||
4431 | ||||
4432 | /* ENOENT means that the file is missing or is a dangling symlink. | |||
4433 | * ENOTDIR means that one of paths we expect to be is a directory | |||
4434 | * is not a directory, we should just ignore that. | |||
4435 | * EACCES means that the directory or file permissions are wrong. | |||
4436 | */ | |||
4437 | if (r == -EACCES13) | |||
4438 | log_debug_errno(r, "Cannot access \"%s\": %m", filename)({ int _level = ((7)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/core/load-fragment.c", 4438, __func__, "Cannot access \"%s\": %m" , filename) : -abs(_e); }); | |||
4439 | else if (!IN_SET(r, -ENOENT, -ENOTDIR)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){-2, -20})/sizeof(int)]; switch(r) { case -2: case -20: _found = 1; break; default: break; } _found; } )) | |||
4440 | return r; | |||
4441 | ||||
4442 | /* Empty the symlink names for the next run */ | |||
4443 | set_clear_free(symlink_names); | |||
4444 | } | |||
4445 | } | |||
4446 | ||||
4447 | if (!filename) | |||
4448 | /* Hmm, no suitable file found? */ | |||
4449 | return 0; | |||
4450 | ||||
4451 | if (!unit_type_may_alias(u->type) && set_size(symlink_names) > 1) { | |||
4452 | log_unit_warning(u, "Unit type of %s does not support alias names, refusing loading via symlink.", u->id)({ const Unit *_u = (u); _u ? log_object_internal(4, 0, "../src/core/load-fragment.c" , 4452, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Unit type of %s does not support alias names, refusing loading via symlink." , u->id) : log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((4))), 0, "../src/core/load-fragment.c", 4452, __func__ , "Unit type of %s does not support alias names, refusing loading via symlink." , u->id); }); | |||
4453 | return -ELOOP40; | |||
4454 | } | |||
4455 | ||||
4456 | merged = u; | |||
4457 | r = merge_by_names(&merged, symlink_names, id); | |||
4458 | if (r < 0) | |||
4459 | return r; | |||
4460 | ||||
4461 | if (merged != u) { | |||
4462 | u->load_state = UNIT_MERGED; | |||
4463 | return 0; | |||
4464 | } | |||
4465 | ||||
4466 | if (fstat(fileno(f), &st) < 0) | |||
4467 | return -errno(*__errno_location ()); | |||
4468 | ||||
4469 | if (null_or_empty(&st)) { | |||
4470 | u->load_state = UNIT_MASKED; | |||
4471 | u->fragment_mtime = 0; | |||
4472 | } else { | |||
4473 | u->load_state = UNIT_LOADED; | |||
4474 | u->fragment_mtime = timespec_load(&st.st_mtim); | |||
4475 | ||||
4476 | /* Now, parse the file contents */ | |||
4477 | r = config_parse(u->id, filename, f, | |||
4478 | UNIT_VTABLE(u)unit_vtable[(u)->type]->sections, | |||
4479 | config_item_perf_lookup, load_fragment_gperf_lookup, | |||
4480 | CONFIG_PARSE_ALLOW_INCLUDE, u); | |||
4481 | if (r < 0) | |||
4482 | return r; | |||
4483 | } | |||
4484 | ||||
4485 | free_and_replace(u->fragment_path, filename)({ free(u->fragment_path); (u->fragment_path) = (filename ); (filename) = ((void*)0); 0; }); | |||
4486 | ||||
4487 | if (u->source_path) { | |||
4488 | if (stat(u->source_path, &st) >= 0) | |||
4489 | u->source_mtime = timespec_load(&st.st_mtim); | |||
4490 | else | |||
4491 | u->source_mtime = 0; | |||
4492 | } | |||
4493 | ||||
4494 | return 0; | |||
4495 | } | |||
4496 | ||||
4497 | int unit_load_fragment(Unit *u) { | |||
4498 | int r; | |||
4499 | Iterator i; | |||
4500 | const char *t; | |||
4501 | ||||
4502 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/load-fragment.c", 4502 , __PRETTY_FUNCTION__); } while (0); | |||
4503 | assert(u->load_state == UNIT_STUB)do { if ((__builtin_expect(!!(!(u->load_state == UNIT_STUB )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("u->load_state == UNIT_STUB" ), "../src/core/load-fragment.c", 4503, __PRETTY_FUNCTION__); } while (0); | |||
4504 | assert(u->id)do { if ((__builtin_expect(!!(!(u->id)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u->id"), "../src/core/load-fragment.c" , 4504, __PRETTY_FUNCTION__); } while (0); | |||
4505 | ||||
4506 | if (u->transient) { | |||
4507 | u->load_state = UNIT_LOADED; | |||
4508 | return 0; | |||
4509 | } | |||
4510 | ||||
4511 | /* First, try to find the unit under its id. We always look | |||
4512 | * for unit files in the default directories, to make it easy | |||
4513 | * to override things by placing things in /etc/systemd/system */ | |||
4514 | r = load_from_path(u, u->id); | |||
4515 | if (r < 0) | |||
4516 | return r; | |||
4517 | ||||
4518 | /* Try to find an alias we can load this with */ | |||
4519 | if (u->load_state == UNIT_STUB) { | |||
4520 | SET_FOREACH(t, u->names, i)for ((i) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), . next_key = ((void*)0) }); set_iterate((u->names), &(i) , (void**)&(t)); ) { | |||
4521 | ||||
4522 | if (t == u->id) | |||
4523 | continue; | |||
4524 | ||||
4525 | r = load_from_path(u, t); | |||
4526 | if (r < 0) | |||
4527 | return r; | |||
4528 | ||||
4529 | if (u->load_state != UNIT_STUB) | |||
4530 | break; | |||
4531 | } | |||
4532 | } | |||
4533 | ||||
4534 | /* And now, try looking for it under the suggested (originally linked) path */ | |||
4535 | if (u->load_state == UNIT_STUB && u->fragment_path) { | |||
4536 | ||||
4537 | r = load_from_path(u, u->fragment_path); | |||
4538 | if (r < 0) | |||
4539 | return r; | |||
4540 | ||||
4541 | if (u->load_state == UNIT_STUB) | |||
4542 | /* Hmm, this didn't work? Then let's get rid | |||
4543 | * of the fragment path stored for us, so that | |||
4544 | * we don't point to an invalid location. */ | |||
4545 | u->fragment_path = mfree(u->fragment_path); | |||
4546 | } | |||
4547 | ||||
4548 | /* Look for a template */ | |||
4549 | if (u->load_state == UNIT_STUB && u->instance) { | |||
4550 | _cleanup_free___attribute__((cleanup(freep))) char *k = NULL((void*)0); | |||
4551 | ||||
4552 | r = unit_name_template(u->id, &k); | |||
4553 | if (r < 0) | |||
4554 | return r; | |||
4555 | ||||
4556 | r = load_from_path(u, k); | |||
4557 | if (r < 0) { | |||
4558 | if (r == -ENOEXEC8) | |||
4559 | log_unit_notice(u, "Unit configuration has fatal error, unit will not be started.")({ const Unit *_u = (u); _u ? log_object_internal(5, 0, "../src/core/load-fragment.c" , 4559, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Unit configuration has fatal error, unit will not be started." ) : log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((5 ))), 0, "../src/core/load-fragment.c", 4559, __func__, "Unit configuration has fatal error, unit will not be started." ); }); | |||
4560 | return r; | |||
4561 | } | |||
4562 | ||||
4563 | if (u->load_state == UNIT_STUB) { | |||
4564 | SET_FOREACH(t, u->names, i)for ((i) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), . next_key = ((void*)0) }); set_iterate((u->names), &(i) , (void**)&(t)); ) { | |||
4565 | _cleanup_free___attribute__((cleanup(freep))) char *z = NULL((void*)0); | |||
4566 | ||||
4567 | if (t == u->id) | |||
4568 | continue; | |||
4569 | ||||
4570 | r = unit_name_template(t, &z); | |||
4571 | if (r < 0) | |||
4572 | return r; | |||
4573 | ||||
4574 | r = load_from_path(u, z); | |||
4575 | if (r < 0) | |||
4576 | return r; | |||
4577 | ||||
4578 | if (u->load_state != UNIT_STUB) | |||
4579 | break; | |||
4580 | } | |||
4581 | } | |||
4582 | } | |||
4583 | ||||
4584 | return 0; | |||
4585 | } | |||
4586 | ||||
4587 | void unit_dump_config_items(FILE *f) { | |||
4588 | static const struct { | |||
4589 | const ConfigParserCallback callback; | |||
4590 | const char *rvalue; | |||
4591 | } table[] = { | |||
4592 | { config_parse_warn_compat, "NOTSUPPORTED" }, | |||
4593 | { config_parse_int, "INTEGER" }, | |||
4594 | { config_parse_unsigned, "UNSIGNED" }, | |||
4595 | { config_parse_iec_size, "SIZE" }, | |||
4596 | { config_parse_iec_uint64, "SIZE" }, | |||
4597 | { config_parse_si_size, "SIZE" }, | |||
4598 | { config_parse_bool, "BOOLEAN" }, | |||
4599 | { config_parse_string, "STRING" }, | |||
4600 | { config_parse_path, "PATH" }, | |||
4601 | { config_parse_unit_path_printf, "PATH" }, | |||
4602 | { config_parse_strv, "STRING [...]" }, | |||
4603 | { config_parse_exec_nice, "NICE" }, | |||
4604 | { config_parse_exec_oom_score_adjust, "OOMSCOREADJUST" }, | |||
4605 | { config_parse_exec_io_class, "IOCLASS" }, | |||
4606 | { config_parse_exec_io_priority, "IOPRIORITY" }, | |||
4607 | { config_parse_exec_cpu_sched_policy, "CPUSCHEDPOLICY" }, | |||
4608 | { config_parse_exec_cpu_sched_prio, "CPUSCHEDPRIO" }, | |||
4609 | { config_parse_exec_cpu_affinity, "CPUAFFINITY" }, | |||
4610 | { config_parse_mode, "MODE" }, | |||
4611 | { config_parse_unit_env_file, "FILE" }, | |||
4612 | { config_parse_exec_output, "OUTPUT" }, | |||
4613 | { config_parse_exec_input, "INPUT" }, | |||
4614 | { config_parse_log_facility, "FACILITY" }, | |||
4615 | { config_parse_log_level, "LEVEL" }, | |||
4616 | { config_parse_exec_secure_bits, "SECUREBITS" }, | |||
4617 | { config_parse_capability_set, "BOUNDINGSET" }, | |||
4618 | { config_parse_rlimit, "LIMIT" }, | |||
4619 | { config_parse_unit_deps, "UNIT [...]" }, | |||
4620 | { config_parse_exec, "PATH [ARGUMENT [...]]" }, | |||
4621 | { config_parse_service_type, "SERVICETYPE" }, | |||
4622 | { config_parse_service_restart, "SERVICERESTART" }, | |||
4623 | { config_parse_kill_mode, "KILLMODE" }, | |||
4624 | { config_parse_signal, "SIGNAL" }, | |||
4625 | { config_parse_socket_listen, "SOCKET [...]" }, | |||
4626 | { config_parse_socket_bind, "SOCKETBIND" }, | |||
4627 | { config_parse_socket_bindtodevice, "NETWORKINTERFACE" }, | |||
4628 | { config_parse_sec, "SECONDS" }, | |||
4629 | { config_parse_nsec, "NANOSECONDS" }, | |||
4630 | { config_parse_namespace_path_strv, "PATH [...]" }, | |||
4631 | { config_parse_bind_paths, "PATH[:PATH[:OPTIONS]] [...]" }, | |||
4632 | { config_parse_unit_requires_mounts_for, "PATH [...]" }, | |||
4633 | { config_parse_exec_mount_flags, "MOUNTFLAG [...]" }, | |||
4634 | { config_parse_unit_string_printf, "STRING" }, | |||
4635 | { config_parse_trigger_unit, "UNIT" }, | |||
4636 | { config_parse_timer, "TIMER" }, | |||
4637 | { config_parse_path_spec, "PATH" }, | |||
4638 | { config_parse_notify_access, "ACCESS" }, | |||
4639 | { config_parse_ip_tos, "TOS" }, | |||
4640 | { config_parse_unit_condition_path, "CONDITION" }, | |||
4641 | { config_parse_unit_condition_string, "CONDITION" }, | |||
4642 | { config_parse_unit_condition_null, "CONDITION" }, | |||
4643 | { config_parse_unit_slice, "SLICE" }, | |||
4644 | { config_parse_documentation, "URL" }, | |||
4645 | { config_parse_service_timeout, "SECONDS" }, | |||
4646 | { config_parse_emergency_action, "ACTION" }, | |||
4647 | { config_parse_set_status, "STATUS" }, | |||
4648 | { config_parse_service_sockets, "SOCKETS" }, | |||
4649 | { config_parse_environ, "ENVIRON" }, | |||
4650 | #if HAVE_SECCOMP1 | |||
4651 | { config_parse_syscall_filter, "SYSCALLS" }, | |||
4652 | { config_parse_syscall_archs, "ARCHS" }, | |||
4653 | { config_parse_syscall_errno, "ERRNO" }, | |||
4654 | { config_parse_address_families, "FAMILIES" }, | |||
4655 | { config_parse_restrict_namespaces, "NAMESPACES" }, | |||
4656 | #endif | |||
4657 | { config_parse_cpu_shares, "SHARES" }, | |||
4658 | { config_parse_cg_weight, "WEIGHT" }, | |||
4659 | { config_parse_memory_limit, "LIMIT" }, | |||
4660 | { config_parse_device_allow, "DEVICE" }, | |||
4661 | { config_parse_device_policy, "POLICY" }, | |||
4662 | { config_parse_io_limit, "LIMIT" }, | |||
4663 | { config_parse_io_device_weight, "DEVICEWEIGHT" }, | |||
4664 | { config_parse_io_device_latency, "DEVICELATENCY" }, | |||
4665 | { config_parse_blockio_bandwidth, "BANDWIDTH" }, | |||
4666 | { config_parse_blockio_weight, "WEIGHT" }, | |||
4667 | { config_parse_blockio_device_weight, "DEVICEWEIGHT" }, | |||
4668 | { config_parse_long, "LONG" }, | |||
4669 | { config_parse_socket_service, "SERVICE" }, | |||
4670 | #if HAVE_SELINUX1 | |||
4671 | { config_parse_exec_selinux_context, "LABEL" }, | |||
4672 | #endif | |||
4673 | { config_parse_job_mode, "MODE" }, | |||
4674 | { config_parse_job_mode_isolate, "BOOLEAN" }, | |||
4675 | { config_parse_personality, "PERSONALITY" }, | |||
4676 | }; | |||
4677 | ||||
4678 | const char *prev = NULL((void*)0); | |||
4679 | const char *i; | |||
4680 | ||||
4681 | assert(f)do { if ((__builtin_expect(!!(!(f)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("f"), "../src/core/load-fragment.c", 4681 , __PRETTY_FUNCTION__); } while (0); | |||
4682 | ||||
4683 | NULSTR_FOREACH(i, load_fragment_gperf_nulstr)for ((i) = (load_fragment_gperf_nulstr); (i) && *(i); (i) = strchr((i), 0)+1) { | |||
4684 | const char *rvalue = "OTHER", *lvalue; | |||
4685 | const ConfigPerfItem *p; | |||
4686 | size_t prefix_len; | |||
4687 | const char *dot; | |||
4688 | unsigned j; | |||
4689 | ||||
4690 | assert_se(p = load_fragment_gperf_lookup(i, strlen(i)))do { if ((__builtin_expect(!!(!(p = load_fragment_gperf_lookup (i, strlen(i)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("p = load_fragment_gperf_lookup(i, strlen(i))"), "../src/core/load-fragment.c" , 4690, __PRETTY_FUNCTION__); } while (0); | |||
4691 | ||||
4692 | /* Hide legacy settings */ | |||
4693 | if (p->parse == config_parse_warn_compat && | |||
4694 | p->ltype == DISABLED_LEGACY) | |||
4695 | continue; | |||
4696 | ||||
4697 | for (j = 0; j < ELEMENTSOF(table)__extension__ (__builtin_choose_expr( !__builtin_types_compatible_p (typeof(table), typeof(&*(table))), sizeof(table)/sizeof( (table)[0]), ((void)0))); j++) | |||
4698 | if (p->parse == table[j].callback) { | |||
4699 | rvalue = table[j].rvalue; | |||
4700 | break; | |||
4701 | } | |||
4702 | ||||
4703 | dot = strchr(i, '.'); | |||
4704 | lvalue = dot ? dot + 1 : i; | |||
4705 | prefix_len = dot-i; | |||
4706 | ||||
4707 | if (dot) | |||
4708 | if (!prev || !strneq(prev, i, prefix_len+1)(strncmp((prev), (i), (prefix_len+1)) == 0)) { | |||
4709 | if (prev) | |||
4710 | fputc('\n', f); | |||
4711 | ||||
4712 | fprintf(f, "[%.*s]\n", (int) prefix_len, i); | |||
4713 | } | |||
4714 | ||||
4715 | fprintf(f, "%s=%s\n", lvalue, rvalue); | |||
4716 | prev = i; | |||
4717 | } | |||
4718 | } |