Lennart Poettering | d6c9574 | 2010-08-14 19:59:25 +0200 | [diff] [blame] | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 2 | |
Lennart Poettering | a7334b0 | 2010-02-03 13:03:47 +0100 | [diff] [blame] | 3 | /*** |
| 4 | This file is part of systemd. |
| 5 | |
| 6 | Copyright 2010 Lennart Poettering |
| 7 | |
| 8 | systemd is free software; you can redistribute it and/or modify it |
| 9 | under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | systemd is distributed in the hope that it will be useful, but |
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
| 20 | ***/ |
| 21 | |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 22 | #include <linux/oom.h> |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 23 | #include <assert.h> |
| 24 | #include <errno.h> |
| 25 | #include <string.h> |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 26 | #include <unistd.h> |
| 27 | #include <fcntl.h> |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 28 | #include <sched.h> |
| 29 | #include <sys/prctl.h> |
Lennart Poettering | 15ae422 | 2010-04-21 22:15:06 +0200 | [diff] [blame] | 30 | #include <sys/mount.h> |
Kay Sievers | 25e870b | 2010-04-24 05:05:01 +0200 | [diff] [blame] | 31 | #include <linux/fs.h> |
Lennart Poettering | 45fb069 | 2010-07-17 00:57:51 +0200 | [diff] [blame] | 32 | #include <sys/stat.h> |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 33 | |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 34 | #include "unit.h" |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 35 | #include "strv.h" |
| 36 | #include "conf-parser.h" |
| 37 | #include "load-fragment.h" |
Lennart Poettering | 16354ef | 2010-01-20 19:19:53 +0100 | [diff] [blame] | 38 | #include "log.h" |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 39 | #include "ioprio.h" |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 40 | #include "securebits.h" |
| 41 | #include "missing.h" |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 42 | #include "unit-name.h" |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 43 | #include "bus-errors.h" |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 44 | |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 45 | #ifndef HAVE_SYSV_COMPAT |
| 46 | static int config_parse_warn_compat( |
| 47 | const char *filename, |
| 48 | unsigned line, |
| 49 | const char *section, |
| 50 | const char *lvalue, |
| 51 | const char *rvalue, |
| 52 | void *data, |
| 53 | void *userdata) { |
| 54 | |
| 55 | log_debug("[%s:%u] Support for option %s= has been disabled at compile time and is ignored", filename, line, lvalue); |
| 56 | return 0; |
| 57 | } |
| 58 | #endif |
| 59 | |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 60 | static int config_parse_deps( |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 61 | const char *filename, |
| 62 | unsigned line, |
| 63 | const char *section, |
| 64 | const char *lvalue, |
| 65 | const char *rvalue, |
| 66 | void *data, |
| 67 | void *userdata) { |
| 68 | |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 69 | UnitDependency d = PTR_TO_UINT(data); |
| 70 | Unit *u = userdata; |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 71 | char *w; |
| 72 | size_t l; |
| 73 | char *state; |
| 74 | |
| 75 | assert(filename); |
| 76 | assert(lvalue); |
| 77 | assert(rvalue); |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 78 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 79 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 80 | char *t, *k; |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 81 | int r; |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 82 | |
| 83 | if (!(t = strndup(w, l))) |
| 84 | return -ENOMEM; |
| 85 | |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 86 | k = unit_name_printf(u, t); |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 87 | free(t); |
| 88 | |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 89 | if (!k) |
| 90 | return -ENOMEM; |
| 91 | |
Lennart Poettering | 701cc38 | 2010-04-21 06:01:13 +0200 | [diff] [blame] | 92 | r = unit_add_dependency_by_name(u, d, k, NULL, true); |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 93 | |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 94 | if (r < 0) { |
| 95 | log_error("Failed to add dependency on %s, ignoring: %s", k, strerror(-r)); |
| 96 | free(k); |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | free(k); |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | return 0; |
| 104 | } |
| 105 | |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 106 | static int config_parse_names( |
Lennart Poettering | 87d1515 | 2010-01-18 23:50:13 +0100 | [diff] [blame] | 107 | const char *filename, |
| 108 | unsigned line, |
| 109 | const char *section, |
| 110 | const char *lvalue, |
| 111 | const char *rvalue, |
| 112 | void *data, |
| 113 | void *userdata) { |
| 114 | |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 115 | Unit *u = userdata; |
Lennart Poettering | 87d1515 | 2010-01-18 23:50:13 +0100 | [diff] [blame] | 116 | char *w; |
| 117 | size_t l; |
| 118 | char *state; |
| 119 | |
| 120 | assert(filename); |
| 121 | assert(lvalue); |
| 122 | assert(rvalue); |
| 123 | assert(data); |
| 124 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 125 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 126 | char *t, *k; |
Lennart Poettering | 87d1515 | 2010-01-18 23:50:13 +0100 | [diff] [blame] | 127 | int r; |
Lennart Poettering | 87d1515 | 2010-01-18 23:50:13 +0100 | [diff] [blame] | 128 | |
| 129 | if (!(t = strndup(w, l))) |
| 130 | return -ENOMEM; |
| 131 | |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 132 | k = unit_name_printf(u, t); |
Lennart Poettering | 87d1515 | 2010-01-18 23:50:13 +0100 | [diff] [blame] | 133 | free(t); |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 134 | |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 135 | if (!k) |
| 136 | return -ENOMEM; |
| 137 | |
| 138 | r = unit_merge_by_name(u, k); |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 139 | |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 140 | if (r < 0) { |
| 141 | log_error("Failed to add name %s, ignoring: %s", k, strerror(-r)); |
| 142 | free(k); |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | free(k); |
Lennart Poettering | 87d1515 | 2010-01-18 23:50:13 +0100 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | return 0; |
| 150 | } |
| 151 | |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 152 | static int config_parse_string_printf( |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 153 | const char *filename, |
| 154 | unsigned line, |
| 155 | const char *section, |
| 156 | const char *lvalue, |
| 157 | const char *rvalue, |
| 158 | void *data, |
| 159 | void *userdata) { |
| 160 | |
| 161 | Unit *u = userdata; |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 162 | char **s = data; |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 163 | char *k; |
| 164 | |
| 165 | assert(filename); |
| 166 | assert(lvalue); |
| 167 | assert(rvalue); |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 168 | assert(s); |
| 169 | assert(u); |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 170 | |
| 171 | if (!(k = unit_full_printf(u, rvalue))) |
| 172 | return -ENOMEM; |
| 173 | |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 174 | free(*s); |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 175 | if (*k) |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 176 | *s = k; |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 177 | else { |
| 178 | free(k); |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 179 | *s = NULL; |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | return 0; |
| 183 | } |
| 184 | |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 185 | static int config_parse_listen( |
| 186 | const char *filename, |
| 187 | unsigned line, |
| 188 | const char *section, |
| 189 | const char *lvalue, |
| 190 | const char *rvalue, |
| 191 | void *data, |
| 192 | void *userdata) { |
| 193 | |
Lennart Poettering | 16354ef | 2010-01-20 19:19:53 +0100 | [diff] [blame] | 194 | int r; |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 195 | SocketPort *p; |
| 196 | Socket *s; |
Lennart Poettering | 16354ef | 2010-01-20 19:19:53 +0100 | [diff] [blame] | 197 | |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 198 | assert(filename); |
| 199 | assert(lvalue); |
| 200 | assert(rvalue); |
| 201 | assert(data); |
| 202 | |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 203 | s = (Socket*) data; |
| 204 | |
| 205 | if (!(p = new0(SocketPort, 1))) |
| 206 | return -ENOMEM; |
| 207 | |
| 208 | if (streq(lvalue, "ListenFIFO")) { |
| 209 | p->type = SOCKET_FIFO; |
| 210 | |
| 211 | if (!(p->path = strdup(rvalue))) { |
| 212 | free(p); |
| 213 | return -ENOMEM; |
| 214 | } |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 215 | |
| 216 | path_kill_slashes(p->path); |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 217 | } else { |
| 218 | p->type = SOCKET_SOCKET; |
| 219 | |
| 220 | if ((r = socket_address_parse(&p->address, rvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 221 | log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue); |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 222 | free(p); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 223 | return 0; |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | if (streq(lvalue, "ListenStream")) |
| 227 | p->address.type = SOCK_STREAM; |
| 228 | else if (streq(lvalue, "ListenDatagram")) |
| 229 | p->address.type = SOCK_DGRAM; |
| 230 | else { |
| 231 | assert(streq(lvalue, "ListenSequentialPacket")); |
| 232 | p->address.type = SOCK_SEQPACKET; |
| 233 | } |
| 234 | |
| 235 | if (socket_address_family(&p->address) != AF_LOCAL && p->address.type == SOCK_SEQPACKET) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 236 | log_error("[%s:%u] Address family not supported, ignoring: %s", filename, line, rvalue); |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 237 | free(p); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 238 | return 0; |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 239 | } |
Lennart Poettering | 16354ef | 2010-01-20 19:19:53 +0100 | [diff] [blame] | 240 | } |
| 241 | |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 242 | p->fd = -1; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 243 | LIST_PREPEND(SocketPort, port, s->ports, p); |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 244 | |
Lennart Poettering | 16354ef | 2010-01-20 19:19:53 +0100 | [diff] [blame] | 245 | return 0; |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 246 | } |
| 247 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 248 | static int config_parse_socket_bind( |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 249 | const char *filename, |
| 250 | unsigned line, |
| 251 | const char *section, |
| 252 | const char *lvalue, |
| 253 | const char *rvalue, |
| 254 | void *data, |
| 255 | void *userdata) { |
| 256 | |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 257 | Socket *s; |
Lennart Poettering | c0120d9 | 2010-05-21 23:41:25 +0200 | [diff] [blame] | 258 | SocketAddressBindIPv6Only b; |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 259 | |
| 260 | assert(filename); |
| 261 | assert(lvalue); |
| 262 | assert(rvalue); |
| 263 | assert(data); |
| 264 | |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 265 | s = (Socket*) data; |
| 266 | |
Lennart Poettering | c0120d9 | 2010-05-21 23:41:25 +0200 | [diff] [blame] | 267 | if ((b = socket_address_bind_ipv6_only_from_string(rvalue)) < 0) { |
| 268 | int r; |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 269 | |
Lennart Poettering | c0120d9 | 2010-05-21 23:41:25 +0200 | [diff] [blame] | 270 | if ((r = parse_boolean(rvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 271 | log_error("[%s:%u] Failed to parse bind IPv6 only value, ignoring: %s", filename, line, rvalue); |
| 272 | return 0; |
Lennart Poettering | c0120d9 | 2010-05-21 23:41:25 +0200 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | s->bind_ipv6_only = r ? SOCKET_ADDRESS_IPV6_ONLY : SOCKET_ADDRESS_BOTH; |
| 276 | } else |
| 277 | s->bind_ipv6_only = b; |
Lennart Poettering | 542563b | 2010-01-23 03:35:54 +0100 | [diff] [blame] | 278 | |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 279 | return 0; |
| 280 | } |
| 281 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 282 | static int config_parse_nice( |
| 283 | const char *filename, |
| 284 | unsigned line, |
| 285 | const char *section, |
| 286 | const char *lvalue, |
| 287 | const char *rvalue, |
| 288 | void *data, |
| 289 | void *userdata) { |
| 290 | |
Lennart Poettering | fb33a39 | 2010-01-28 02:53:56 +0100 | [diff] [blame] | 291 | ExecContext *c = data; |
| 292 | int priority, r; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 293 | |
| 294 | assert(filename); |
| 295 | assert(lvalue); |
| 296 | assert(rvalue); |
| 297 | assert(data); |
| 298 | |
| 299 | if ((r = safe_atoi(rvalue, &priority)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 300 | log_error("[%s:%u] Failed to parse nice priority, ignoring: %s. ", filename, line, rvalue); |
| 301 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | if (priority < PRIO_MIN || priority >= PRIO_MAX) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 305 | log_error("[%s:%u] Nice priority out of range, ignoring: %s", filename, line, rvalue); |
| 306 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 307 | } |
| 308 | |
Lennart Poettering | fb33a39 | 2010-01-28 02:53:56 +0100 | [diff] [blame] | 309 | c->nice = priority; |
| 310 | c->nice_set = false; |
| 311 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 312 | return 0; |
| 313 | } |
| 314 | |
Lennart Poettering | dd6c17b | 2010-08-31 01:33:39 +0200 | [diff] [blame] | 315 | static int config_parse_oom_score_adjust( |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 316 | const char *filename, |
| 317 | unsigned line, |
| 318 | const char *section, |
| 319 | const char *lvalue, |
| 320 | const char *rvalue, |
| 321 | void *data, |
| 322 | void *userdata) { |
| 323 | |
Lennart Poettering | fb33a39 | 2010-01-28 02:53:56 +0100 | [diff] [blame] | 324 | ExecContext *c = data; |
| 325 | int oa, r; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 326 | |
| 327 | assert(filename); |
| 328 | assert(lvalue); |
| 329 | assert(rvalue); |
| 330 | assert(data); |
| 331 | |
| 332 | if ((r = safe_atoi(rvalue, &oa)) < 0) { |
Lennart Poettering | dd6c17b | 2010-08-31 01:33:39 +0200 | [diff] [blame] | 333 | log_error("[%s:%u] Failed to parse the OOM score adjust value, ignoring: %s", filename, line, rvalue); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 334 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 335 | } |
| 336 | |
Lennart Poettering | dd6c17b | 2010-08-31 01:33:39 +0200 | [diff] [blame] | 337 | if (oa < OOM_SCORE_ADJ_MIN || oa > OOM_SCORE_ADJ_MAX) { |
| 338 | log_error("[%s:%u] OOM score adjust value out of range, ignoring: %s", filename, line, rvalue); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 339 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 340 | } |
| 341 | |
Lennart Poettering | dd6c17b | 2010-08-31 01:33:39 +0200 | [diff] [blame] | 342 | c->oom_score_adjust = oa; |
| 343 | c->oom_score_adjust_set = true; |
Lennart Poettering | fb33a39 | 2010-01-28 02:53:56 +0100 | [diff] [blame] | 344 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 345 | return 0; |
| 346 | } |
| 347 | |
Lennart Poettering | b5a0699 | 2010-02-12 02:02:14 +0100 | [diff] [blame] | 348 | static int config_parse_mode( |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 349 | const char *filename, |
| 350 | unsigned line, |
| 351 | const char *section, |
| 352 | const char *lvalue, |
| 353 | const char *rvalue, |
| 354 | void *data, |
| 355 | void *userdata) { |
| 356 | |
| 357 | mode_t *m = data; |
| 358 | long l; |
| 359 | char *x = NULL; |
| 360 | |
| 361 | assert(filename); |
| 362 | assert(lvalue); |
| 363 | assert(rvalue); |
| 364 | assert(data); |
| 365 | |
| 366 | errno = 0; |
| 367 | l = strtol(rvalue, &x, 8); |
| 368 | if (!x || *x || errno) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 369 | log_error("[%s:%u] Failed to parse mode value, ignoring: %s", filename, line, rvalue); |
| 370 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 371 | } |
| 372 | |
Lennart Poettering | b5a0699 | 2010-02-12 02:02:14 +0100 | [diff] [blame] | 373 | if (l < 0000 || l > 07777) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 374 | log_error("[%s:%u] mode value out of range, ignoring: %s", filename, line, rvalue); |
| 375 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | *m = (mode_t) l; |
| 379 | return 0; |
| 380 | } |
| 381 | |
| 382 | static int config_parse_exec( |
| 383 | const char *filename, |
| 384 | unsigned line, |
| 385 | const char *section, |
| 386 | const char *lvalue, |
| 387 | const char *rvalue, |
| 388 | void *data, |
| 389 | void *userdata) { |
| 390 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 391 | ExecCommand **e = data, *nce; |
| 392 | char *path, **n; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 393 | unsigned k; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 394 | |
| 395 | assert(filename); |
| 396 | assert(lvalue); |
| 397 | assert(rvalue); |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 398 | assert(e); |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 399 | |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 400 | /* We accept an absolute path as first argument, or |
| 401 | * alternatively an absolute prefixed with @ to allow |
| 402 | * overriding of argv[0]. */ |
| 403 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 404 | for (;;) { |
| 405 | char *w; |
| 406 | size_t l; |
| 407 | char *state; |
Lennart Poettering | b708e7c | 2010-07-12 02:25:42 +0200 | [diff] [blame] | 408 | bool honour_argv0 = false, ignore = false; |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 409 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 410 | path = NULL; |
| 411 | nce = NULL; |
| 412 | n = NULL; |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 413 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 414 | rvalue += strspn(rvalue, WHITESPACE); |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 415 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 416 | if (rvalue[0] == 0) |
| 417 | break; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 418 | |
Lennart Poettering | b708e7c | 2010-07-12 02:25:42 +0200 | [diff] [blame] | 419 | if (rvalue[0] == '-') { |
| 420 | ignore = true; |
| 421 | rvalue ++; |
| 422 | } |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 423 | |
Lennart Poettering | b708e7c | 2010-07-12 02:25:42 +0200 | [diff] [blame] | 424 | if (rvalue[0] == '@') { |
| 425 | honour_argv0 = true; |
| 426 | rvalue ++; |
| 427 | } |
| 428 | |
| 429 | if (*rvalue != '/') { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 430 | log_error("[%s:%u] Invalid executable path in command line, ignoring: %s", filename, line, rvalue); |
| 431 | return 0; |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 432 | } |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 433 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 434 | k = 0; |
| 435 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
| 436 | if (strncmp(w, ";", l) == 0) |
| 437 | break; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 438 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 439 | k++; |
| 440 | } |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 441 | |
Lennart Poettering | b708e7c | 2010-07-12 02:25:42 +0200 | [diff] [blame] | 442 | if (!(n = new(char*, k + !honour_argv0))) |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 443 | return -ENOMEM; |
| 444 | |
| 445 | k = 0; |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 446 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
| 447 | if (strncmp(w, ";", l) == 0) |
| 448 | break; |
| 449 | |
Lennart Poettering | b708e7c | 2010-07-12 02:25:42 +0200 | [diff] [blame] | 450 | if (honour_argv0 && w == rvalue) { |
| 451 | assert(!path); |
| 452 | if (!(path = cunescape_length(w, l))) |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 453 | goto fail; |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 454 | } else { |
| 455 | if (!(n[k++] = cunescape_length(w, l))) |
| 456 | goto fail; |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | n[k] = NULL; |
| 461 | |
| 462 | if (!n[0]) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 463 | log_error("[%s:%u] Invalid command line, ignoring: %s", filename, line, rvalue); |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 464 | strv_free(n); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 465 | return 0; |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | if (!path) |
| 469 | if (!(path = strdup(n[0]))) |
| 470 | goto fail; |
| 471 | |
| 472 | assert(path_is_absolute(path)); |
| 473 | |
| 474 | if (!(nce = new0(ExecCommand, 1))) |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 475 | goto fail; |
| 476 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 477 | nce->argv = n; |
| 478 | nce->path = path; |
Lennart Poettering | b708e7c | 2010-07-12 02:25:42 +0200 | [diff] [blame] | 479 | nce->ignore = ignore; |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 480 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 481 | path_kill_slashes(nce->path); |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 482 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 483 | exec_command_append_list(e, nce); |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 484 | |
Lennart Poettering | 61e5d8e | 2010-07-07 20:59:20 +0200 | [diff] [blame] | 485 | rvalue = state; |
| 486 | } |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 487 | |
| 488 | return 0; |
| 489 | |
| 490 | fail: |
Lennart Poettering | 6c666e2 | 2010-05-19 21:51:53 +0200 | [diff] [blame] | 491 | n[k] = NULL; |
| 492 | strv_free(n); |
| 493 | free(path); |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 494 | free(nce); |
| 495 | |
| 496 | return -ENOMEM; |
| 497 | } |
| 498 | |
| 499 | static int config_parse_usec( |
| 500 | const char *filename, |
| 501 | unsigned line, |
| 502 | const char *section, |
| 503 | const char *lvalue, |
| 504 | const char *rvalue, |
| 505 | void *data, |
| 506 | void *userdata) { |
| 507 | |
| 508 | usec_t *usec = data; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 509 | int r; |
| 510 | |
| 511 | assert(filename); |
| 512 | assert(lvalue); |
| 513 | assert(rvalue); |
| 514 | assert(data); |
| 515 | |
Lennart Poettering | 24a6e4a | 2010-04-23 20:26:59 +0200 | [diff] [blame] | 516 | if ((r = parse_usec(rvalue, usec)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 517 | log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue); |
| 518 | return 0; |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 519 | } |
| 520 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 521 | return 0; |
| 522 | } |
| 523 | |
Lennart Poettering | 487393e | 2010-07-07 01:10:27 +0200 | [diff] [blame] | 524 | static DEFINE_CONFIG_PARSE_ENUM(config_parse_service_type, service_type, ServiceType, "Failed to parse service type"); |
| 525 | static DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart, service_restart, ServiceRestart, "Failed to parse service restart specifier"); |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 526 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 527 | static int config_parse_bindtodevice( |
Lennart Poettering | acbb022 | 2010-01-27 04:31:52 +0100 | [diff] [blame] | 528 | const char *filename, |
| 529 | unsigned line, |
| 530 | const char *section, |
| 531 | const char *lvalue, |
| 532 | const char *rvalue, |
| 533 | void *data, |
| 534 | void *userdata) { |
| 535 | |
| 536 | Socket *s = data; |
| 537 | char *n; |
| 538 | |
| 539 | assert(filename); |
| 540 | assert(lvalue); |
| 541 | assert(rvalue); |
| 542 | assert(data); |
| 543 | |
| 544 | if (rvalue[0] && !streq(rvalue, "*")) { |
| 545 | if (!(n = strdup(rvalue))) |
| 546 | return -ENOMEM; |
| 547 | } else |
| 548 | n = NULL; |
| 549 | |
| 550 | free(s->bind_to_device); |
| 551 | s->bind_to_device = n; |
| 552 | |
| 553 | return 0; |
| 554 | } |
| 555 | |
Lennart Poettering | 487393e | 2010-07-07 01:10:27 +0200 | [diff] [blame] | 556 | static DEFINE_CONFIG_PARSE_ENUM(config_parse_output, exec_output, ExecOutput, "Failed to parse output specifier"); |
| 557 | static DEFINE_CONFIG_PARSE_ENUM(config_parse_input, exec_input, ExecInput, "Failed to parse input specifier"); |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 558 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 559 | static int config_parse_facility( |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 560 | const char *filename, |
| 561 | unsigned line, |
| 562 | const char *section, |
| 563 | const char *lvalue, |
| 564 | const char *rvalue, |
| 565 | void *data, |
| 566 | void *userdata) { |
| 567 | |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 568 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 569 | int *o = data, x; |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 570 | |
| 571 | assert(filename); |
| 572 | assert(lvalue); |
| 573 | assert(rvalue); |
| 574 | assert(data); |
| 575 | |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 576 | if ((x = log_facility_from_string(rvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 577 | log_error("[%s:%u] Failed to parse log facility, ignoring: %s", filename, line, rvalue); |
| 578 | return 0; |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 579 | } |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 580 | |
| 581 | *o = LOG_MAKEPRI(x, LOG_PRI(*o)); |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 582 | |
| 583 | return 0; |
| 584 | } |
| 585 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 586 | static int config_parse_level( |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 587 | const char *filename, |
| 588 | unsigned line, |
| 589 | const char *section, |
| 590 | const char *lvalue, |
| 591 | const char *rvalue, |
| 592 | void *data, |
| 593 | void *userdata) { |
| 594 | |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 595 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 596 | int *o = data, x; |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 597 | |
| 598 | assert(filename); |
| 599 | assert(lvalue); |
| 600 | assert(rvalue); |
| 601 | assert(data); |
| 602 | |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 603 | if ((x = log_level_from_string(rvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 604 | log_error("[%s:%u] Failed to parse log level, ignoring: %s", filename, line, rvalue); |
| 605 | return 0; |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 606 | } |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 607 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 608 | *o = LOG_MAKEPRI(LOG_FAC(*o), x); |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 609 | return 0; |
| 610 | } |
| 611 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 612 | static int config_parse_io_class( |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 613 | const char *filename, |
| 614 | unsigned line, |
| 615 | const char *section, |
| 616 | const char *lvalue, |
| 617 | const char *rvalue, |
| 618 | void *data, |
| 619 | void *userdata) { |
| 620 | |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 621 | ExecContext *c = data; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 622 | int x; |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 623 | |
| 624 | assert(filename); |
| 625 | assert(lvalue); |
| 626 | assert(rvalue); |
| 627 | assert(data); |
| 628 | |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 629 | if ((x = ioprio_class_from_string(rvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 630 | log_error("[%s:%u] Failed to parse IO scheduling class, ignoring: %s", filename, line, rvalue); |
| 631 | return 0; |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 632 | } |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 633 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 634 | c->ioprio = IOPRIO_PRIO_VALUE(x, IOPRIO_PRIO_DATA(c->ioprio)); |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 635 | c->ioprio_set = true; |
| 636 | |
| 637 | return 0; |
| 638 | } |
| 639 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 640 | static int config_parse_io_priority( |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 641 | const char *filename, |
| 642 | unsigned line, |
| 643 | const char *section, |
| 644 | const char *lvalue, |
| 645 | const char *rvalue, |
| 646 | void *data, |
| 647 | void *userdata) { |
| 648 | |
| 649 | ExecContext *c = data; |
| 650 | int i; |
| 651 | |
| 652 | assert(filename); |
| 653 | assert(lvalue); |
| 654 | assert(rvalue); |
| 655 | assert(data); |
| 656 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 657 | if (safe_atoi(rvalue, &i) < 0 || i < 0 || i >= IOPRIO_BE_NR) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 658 | log_error("[%s:%u] Failed to parse io priority, ignoring: %s", filename, line, rvalue); |
| 659 | return 0; |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 660 | } |
| 661 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 662 | c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c->ioprio), i); |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 663 | c->ioprio_set = true; |
| 664 | |
| 665 | return 0; |
| 666 | } |
| 667 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 668 | static int config_parse_cpu_sched_policy( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 669 | const char *filename, |
| 670 | unsigned line, |
| 671 | const char *section, |
| 672 | const char *lvalue, |
| 673 | const char *rvalue, |
| 674 | void *data, |
| 675 | void *userdata) { |
| 676 | |
| 677 | |
| 678 | ExecContext *c = data; |
| 679 | int x; |
| 680 | |
| 681 | assert(filename); |
| 682 | assert(lvalue); |
| 683 | assert(rvalue); |
| 684 | assert(data); |
| 685 | |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 686 | if ((x = sched_policy_from_string(rvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 687 | log_error("[%s:%u] Failed to parse CPU scheduling policy, ignoring: %s", filename, line, rvalue); |
| 688 | return 0; |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 689 | } |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 690 | |
| 691 | c->cpu_sched_policy = x; |
| 692 | c->cpu_sched_set = true; |
| 693 | |
| 694 | return 0; |
| 695 | } |
| 696 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 697 | static int config_parse_cpu_sched_prio( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 698 | const char *filename, |
| 699 | unsigned line, |
| 700 | const char *section, |
| 701 | const char *lvalue, |
| 702 | const char *rvalue, |
| 703 | void *data, |
| 704 | void *userdata) { |
| 705 | |
| 706 | ExecContext *c = data; |
| 707 | int i; |
| 708 | |
| 709 | assert(filename); |
| 710 | assert(lvalue); |
| 711 | assert(rvalue); |
| 712 | assert(data); |
| 713 | |
| 714 | /* On Linux RR/FIFO have the same range */ |
| 715 | if (safe_atoi(rvalue, &i) < 0 || i < sched_get_priority_min(SCHED_RR) || i > sched_get_priority_max(SCHED_RR)) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 716 | log_error("[%s:%u] Failed to parse CPU scheduling priority, ignoring: %s", filename, line, rvalue); |
| 717 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | c->cpu_sched_priority = i; |
| 721 | c->cpu_sched_set = true; |
| 722 | |
| 723 | return 0; |
| 724 | } |
| 725 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 726 | static int config_parse_cpu_affinity( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 727 | const char *filename, |
| 728 | unsigned line, |
| 729 | const char *section, |
| 730 | const char *lvalue, |
| 731 | const char *rvalue, |
| 732 | void *data, |
| 733 | void *userdata) { |
| 734 | |
| 735 | ExecContext *c = data; |
| 736 | char *w; |
| 737 | size_t l; |
| 738 | char *state; |
| 739 | |
| 740 | assert(filename); |
| 741 | assert(lvalue); |
| 742 | assert(rvalue); |
| 743 | assert(data); |
| 744 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 745 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 746 | char *t; |
| 747 | int r; |
| 748 | unsigned cpu; |
| 749 | |
| 750 | if (!(t = strndup(w, l))) |
| 751 | return -ENOMEM; |
| 752 | |
Lennart Poettering | 487393e | 2010-07-07 01:10:27 +0200 | [diff] [blame] | 753 | r = safe_atou(t, &cpu); |
| 754 | free(t); |
| 755 | |
Lennart Poettering | 82c121a | 2010-07-04 16:44:58 +0200 | [diff] [blame] | 756 | if (!(c->cpuset)) |
| 757 | if (!(c->cpuset = cpu_set_malloc(&c->cpuset_ncpus))) |
| 758 | return -ENOMEM; |
| 759 | |
Lennart Poettering | 82c121a | 2010-07-04 16:44:58 +0200 | [diff] [blame] | 760 | if (r < 0 || cpu >= c->cpuset_ncpus) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 761 | log_error("[%s:%u] Failed to parse CPU affinity, ignoring: %s", filename, line, rvalue); |
| 762 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 763 | } |
| 764 | |
Lennart Poettering | 82c121a | 2010-07-04 16:44:58 +0200 | [diff] [blame] | 765 | CPU_SET_S(cpu, CPU_ALLOC_SIZE(c->cpuset_ncpus), c->cpuset); |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 766 | } |
| 767 | |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 768 | return 0; |
| 769 | } |
| 770 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 771 | static int config_parse_capabilities( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 772 | const char *filename, |
| 773 | unsigned line, |
| 774 | const char *section, |
| 775 | const char *lvalue, |
| 776 | const char *rvalue, |
| 777 | void *data, |
| 778 | void *userdata) { |
| 779 | |
| 780 | ExecContext *c = data; |
| 781 | cap_t cap; |
| 782 | |
| 783 | assert(filename); |
| 784 | assert(lvalue); |
| 785 | assert(rvalue); |
| 786 | assert(data); |
| 787 | |
| 788 | if (!(cap = cap_from_text(rvalue))) { |
| 789 | if (errno == ENOMEM) |
| 790 | return -ENOMEM; |
| 791 | |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 792 | log_error("[%s:%u] Failed to parse capabilities, ignoring: %s", filename, line, rvalue); |
| 793 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | if (c->capabilities) |
| 797 | cap_free(c->capabilities); |
| 798 | c->capabilities = cap; |
| 799 | |
| 800 | return 0; |
| 801 | } |
| 802 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 803 | static int config_parse_secure_bits( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 804 | const char *filename, |
| 805 | unsigned line, |
| 806 | const char *section, |
| 807 | const char *lvalue, |
| 808 | const char *rvalue, |
| 809 | void *data, |
| 810 | void *userdata) { |
| 811 | |
| 812 | ExecContext *c = data; |
| 813 | char *w; |
| 814 | size_t l; |
| 815 | char *state; |
| 816 | |
| 817 | assert(filename); |
| 818 | assert(lvalue); |
| 819 | assert(rvalue); |
| 820 | assert(data); |
| 821 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 822 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 823 | if (first_word(w, "keep-caps")) |
| 824 | c->secure_bits |= SECURE_KEEP_CAPS; |
| 825 | else if (first_word(w, "keep-caps-locked")) |
| 826 | c->secure_bits |= SECURE_KEEP_CAPS_LOCKED; |
| 827 | else if (first_word(w, "no-setuid-fixup")) |
| 828 | c->secure_bits |= SECURE_NO_SETUID_FIXUP; |
| 829 | else if (first_word(w, "no-setuid-fixup-locked")) |
| 830 | c->secure_bits |= SECURE_NO_SETUID_FIXUP_LOCKED; |
| 831 | else if (first_word(w, "noroot")) |
| 832 | c->secure_bits |= SECURE_NOROOT; |
| 833 | else if (first_word(w, "noroot-locked")) |
| 834 | c->secure_bits |= SECURE_NOROOT_LOCKED; |
| 835 | else { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 836 | log_error("[%s:%u] Failed to parse secure bits, ignoring: %s", filename, line, rvalue); |
| 837 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 838 | } |
| 839 | } |
| 840 | |
| 841 | return 0; |
| 842 | } |
| 843 | |
Lennart Poettering | 47be870 | 2010-02-03 14:21:48 +0100 | [diff] [blame] | 844 | static int config_parse_bounding_set( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 845 | const char *filename, |
| 846 | unsigned line, |
| 847 | const char *section, |
| 848 | const char *lvalue, |
| 849 | const char *rvalue, |
| 850 | void *data, |
| 851 | void *userdata) { |
| 852 | |
| 853 | ExecContext *c = data; |
| 854 | char *w; |
| 855 | size_t l; |
| 856 | char *state; |
| 857 | |
| 858 | assert(filename); |
| 859 | assert(lvalue); |
| 860 | assert(rvalue); |
| 861 | assert(data); |
| 862 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 863 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 864 | char *t; |
| 865 | int r; |
| 866 | cap_value_t cap; |
| 867 | |
| 868 | if (!(t = strndup(w, l))) |
| 869 | return -ENOMEM; |
| 870 | |
| 871 | r = cap_from_name(t, &cap); |
| 872 | free(t); |
| 873 | |
| 874 | if (r < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 875 | log_error("[%s:%u] Failed to parse capability bounding set, ignoring: %s", filename, line, rvalue); |
| 876 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | c->capability_bounding_set_drop |= 1 << cap; |
| 880 | } |
| 881 | |
| 882 | return 0; |
| 883 | } |
| 884 | |
Lennart Poettering | 03fae01 | 2010-07-04 21:12:10 +0200 | [diff] [blame] | 885 | static int config_parse_timer_slack_nsec( |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 886 | const char *filename, |
| 887 | unsigned line, |
| 888 | const char *section, |
| 889 | const char *lvalue, |
| 890 | const char *rvalue, |
| 891 | void *data, |
| 892 | void *userdata) { |
| 893 | |
| 894 | ExecContext *c = data; |
| 895 | unsigned long u; |
| 896 | int r; |
| 897 | |
| 898 | assert(filename); |
| 899 | assert(lvalue); |
| 900 | assert(rvalue); |
| 901 | assert(data); |
| 902 | |
| 903 | if ((r = safe_atolu(rvalue, &u)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 904 | log_error("[%s:%u] Failed to parse time slack value, ignoring: %s", filename, line, rvalue); |
| 905 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 906 | } |
| 907 | |
Lennart Poettering | 03fae01 | 2010-07-04 21:12:10 +0200 | [diff] [blame] | 908 | c->timer_slack_nsec = u; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 909 | |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | static int config_parse_limit( |
| 914 | const char *filename, |
| 915 | unsigned line, |
| 916 | const char *section, |
| 917 | const char *lvalue, |
| 918 | const char *rvalue, |
| 919 | void *data, |
| 920 | void *userdata) { |
| 921 | |
| 922 | struct rlimit **rl = data; |
| 923 | unsigned long long u; |
| 924 | int r; |
| 925 | |
| 926 | assert(filename); |
| 927 | assert(lvalue); |
| 928 | assert(rvalue); |
| 929 | assert(data); |
| 930 | |
| 931 | if ((r = safe_atollu(rvalue, &u)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 932 | log_error("[%s:%u] Failed to parse resource value, ignoring: %s", filename, line, rvalue); |
| 933 | return 0; |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | if (!*rl) |
| 937 | if (!(*rl = new(struct rlimit, 1))) |
| 938 | return -ENOMEM; |
| 939 | |
| 940 | (*rl)->rlim_cur = (*rl)->rlim_max = (rlim_t) u; |
| 941 | return 0; |
| 942 | } |
| 943 | |
Lennart Poettering | 8e27452 | 2010-03-31 16:29:55 +0200 | [diff] [blame] | 944 | static int config_parse_cgroup( |
| 945 | const char *filename, |
| 946 | unsigned line, |
| 947 | const char *section, |
| 948 | const char *lvalue, |
| 949 | const char *rvalue, |
| 950 | void *data, |
| 951 | void *userdata) { |
| 952 | |
| 953 | Unit *u = userdata; |
| 954 | char *w; |
| 955 | size_t l; |
| 956 | char *state; |
| 957 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 958 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 8e27452 | 2010-03-31 16:29:55 +0200 | [diff] [blame] | 959 | char *t; |
| 960 | int r; |
| 961 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 962 | if (!(t = cunescape_length(w, l))) |
Lennart Poettering | 8e27452 | 2010-03-31 16:29:55 +0200 | [diff] [blame] | 963 | return -ENOMEM; |
| 964 | |
| 965 | r = unit_add_cgroup_from_text(u, t); |
| 966 | free(t); |
| 967 | |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 968 | if (r < 0) { |
| 969 | log_error("[%s:%u] Failed to parse cgroup value, ignoring: %s", filename, line, rvalue); |
| 970 | return 0; |
| 971 | } |
Lennart Poettering | 8e27452 | 2010-03-31 16:29:55 +0200 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | return 0; |
| 975 | } |
| 976 | |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 977 | #ifdef HAVE_SYSV_COMPAT |
Lennart Poettering | a9a1e00 | 2010-04-06 02:40:10 +0200 | [diff] [blame] | 978 | static int config_parse_sysv_priority( |
| 979 | const char *filename, |
| 980 | unsigned line, |
| 981 | const char *section, |
| 982 | const char *lvalue, |
| 983 | const char *rvalue, |
| 984 | void *data, |
| 985 | void *userdata) { |
| 986 | |
| 987 | int *priority = data; |
| 988 | int r, i; |
| 989 | |
| 990 | assert(filename); |
| 991 | assert(lvalue); |
| 992 | assert(rvalue); |
| 993 | assert(data); |
| 994 | |
| 995 | if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 996 | log_error("[%s:%u] Failed to parse SysV start priority, ignoring: %s", filename, line, rvalue); |
| 997 | return 0; |
Lennart Poettering | a9a1e00 | 2010-04-06 02:40:10 +0200 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | *priority = (int) i; |
| 1001 | return 0; |
| 1002 | } |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 1003 | #endif |
Lennart Poettering | a9a1e00 | 2010-04-06 02:40:10 +0200 | [diff] [blame] | 1004 | |
Lennart Poettering | 2ba545f | 2010-10-20 14:22:23 +0200 | [diff] [blame^] | 1005 | static int config_parse_fsck_passno( |
| 1006 | const char *filename, |
| 1007 | unsigned line, |
| 1008 | const char *section, |
| 1009 | const char *lvalue, |
| 1010 | const char *rvalue, |
| 1011 | void *data, |
| 1012 | void *userdata) { |
| 1013 | |
| 1014 | int *passno = data; |
| 1015 | int r, i; |
| 1016 | |
| 1017 | assert(filename); |
| 1018 | assert(lvalue); |
| 1019 | assert(rvalue); |
| 1020 | assert(data); |
| 1021 | |
| 1022 | if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) { |
| 1023 | log_error("[%s:%u] Failed to parse fsck pass number, ignoring: %s", filename, line, rvalue); |
| 1024 | return 0; |
| 1025 | } |
| 1026 | |
| 1027 | *passno = (int) i; |
| 1028 | return 0; |
| 1029 | } |
| 1030 | |
Lennart Poettering | 487393e | 2010-07-07 01:10:27 +0200 | [diff] [blame] | 1031 | static DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode"); |
Lennart Poettering | 50159e6 | 2010-04-08 00:52:14 +0200 | [diff] [blame] | 1032 | |
Lennart Poettering | 2e22afe | 2010-07-10 04:49:37 +0200 | [diff] [blame] | 1033 | static int config_parse_kill_signal( |
| 1034 | const char *filename, |
| 1035 | unsigned line, |
| 1036 | const char *section, |
| 1037 | const char *lvalue, |
| 1038 | const char *rvalue, |
| 1039 | void *data, |
| 1040 | void *userdata) { |
| 1041 | |
| 1042 | int *sig = data; |
| 1043 | int r; |
| 1044 | |
| 1045 | assert(filename); |
| 1046 | assert(lvalue); |
| 1047 | assert(rvalue); |
| 1048 | assert(sig); |
| 1049 | |
| 1050 | if ((r = signal_from_string(rvalue)) <= 0) |
| 1051 | if (startswith(rvalue, "SIG")) |
| 1052 | r = signal_from_string(rvalue+3); |
| 1053 | |
| 1054 | if (r <= 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1055 | log_error("[%s:%u] Failed to parse kill signal, ignoring: %s", filename, line, rvalue); |
| 1056 | return 0; |
Lennart Poettering | 2e22afe | 2010-07-10 04:49:37 +0200 | [diff] [blame] | 1057 | } |
| 1058 | |
| 1059 | *sig = r; |
| 1060 | return 0; |
| 1061 | } |
| 1062 | |
Lennart Poettering | 15ae422 | 2010-04-21 22:15:06 +0200 | [diff] [blame] | 1063 | static int config_parse_mount_flags( |
| 1064 | const char *filename, |
| 1065 | unsigned line, |
| 1066 | const char *section, |
| 1067 | const char *lvalue, |
| 1068 | const char *rvalue, |
| 1069 | void *data, |
| 1070 | void *userdata) { |
| 1071 | |
| 1072 | ExecContext *c = data; |
| 1073 | char *w; |
| 1074 | size_t l; |
| 1075 | char *state; |
| 1076 | unsigned long flags = 0; |
| 1077 | |
| 1078 | assert(filename); |
| 1079 | assert(lvalue); |
| 1080 | assert(rvalue); |
| 1081 | assert(data); |
| 1082 | |
Lennart Poettering | f60f22d | 2010-07-07 20:58:41 +0200 | [diff] [blame] | 1083 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
Lennart Poettering | 15ae422 | 2010-04-21 22:15:06 +0200 | [diff] [blame] | 1084 | if (strncmp(w, "shared", l) == 0) |
| 1085 | flags |= MS_SHARED; |
| 1086 | else if (strncmp(w, "slave", l) == 0) |
| 1087 | flags |= MS_SLAVE; |
| 1088 | else if (strncmp(w, "private", l) == 0) |
| 1089 | flags |= MS_PRIVATE; |
| 1090 | else { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1091 | log_error("[%s:%u] Failed to parse mount flags, ignoring: %s", filename, line, rvalue); |
| 1092 | return 0; |
Lennart Poettering | 15ae422 | 2010-04-21 22:15:06 +0200 | [diff] [blame] | 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | c->mount_flags = flags; |
| 1097 | return 0; |
| 1098 | } |
| 1099 | |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1100 | static int config_parse_timer( |
| 1101 | const char *filename, |
| 1102 | unsigned line, |
| 1103 | const char *section, |
| 1104 | const char *lvalue, |
| 1105 | const char *rvalue, |
| 1106 | void *data, |
| 1107 | void *userdata) { |
| 1108 | |
| 1109 | Timer *t = data; |
| 1110 | usec_t u; |
| 1111 | int r; |
| 1112 | TimerValue *v; |
| 1113 | TimerBase b; |
| 1114 | |
| 1115 | assert(filename); |
| 1116 | assert(lvalue); |
| 1117 | assert(rvalue); |
| 1118 | assert(data); |
| 1119 | |
| 1120 | if ((b = timer_base_from_string(lvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1121 | log_error("[%s:%u] Failed to parse timer base, ignoring: %s", filename, line, lvalue); |
| 1122 | return 0; |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1123 | } |
| 1124 | |
| 1125 | if ((r = parse_usec(rvalue, &u)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1126 | log_error("[%s:%u] Failed to parse timer value, ignoring: %s", filename, line, rvalue); |
| 1127 | return 0; |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | if (!(v = new0(TimerValue, 1))) |
| 1131 | return -ENOMEM; |
| 1132 | |
| 1133 | v->base = b; |
| 1134 | v->value = u; |
| 1135 | |
| 1136 | LIST_PREPEND(TimerValue, value, t->values, v); |
| 1137 | |
| 1138 | return 0; |
| 1139 | } |
| 1140 | |
| 1141 | static int config_parse_timer_unit( |
| 1142 | const char *filename, |
| 1143 | unsigned line, |
| 1144 | const char *section, |
| 1145 | const char *lvalue, |
| 1146 | const char *rvalue, |
| 1147 | void *data, |
| 1148 | void *userdata) { |
| 1149 | |
| 1150 | Timer *t = data; |
| 1151 | int r; |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 1152 | DBusError error; |
| 1153 | |
| 1154 | assert(filename); |
| 1155 | assert(lvalue); |
| 1156 | assert(rvalue); |
| 1157 | assert(data); |
| 1158 | |
| 1159 | dbus_error_init(&error); |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1160 | |
| 1161 | if (endswith(rvalue, ".timer")) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1162 | log_error("[%s:%u] Unit cannot be of type timer, ignoring: %s", filename, line, rvalue); |
| 1163 | return 0; |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1164 | } |
| 1165 | |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 1166 | if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, NULL, &t->unit)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1167 | log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r)); |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 1168 | dbus_error_free(&error); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1169 | return 0; |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | return 0; |
| 1173 | } |
| 1174 | |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1175 | static int config_parse_path_spec( |
| 1176 | const char *filename, |
| 1177 | unsigned line, |
| 1178 | const char *section, |
| 1179 | const char *lvalue, |
| 1180 | const char *rvalue, |
| 1181 | void *data, |
| 1182 | void *userdata) { |
| 1183 | |
| 1184 | Path *p = data; |
| 1185 | PathSpec *s; |
| 1186 | PathType b; |
| 1187 | |
| 1188 | assert(filename); |
| 1189 | assert(lvalue); |
| 1190 | assert(rvalue); |
| 1191 | assert(data); |
| 1192 | |
| 1193 | if ((b = path_type_from_string(lvalue)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1194 | log_error("[%s:%u] Failed to parse path type, ignoring: %s", filename, line, lvalue); |
| 1195 | return 0; |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | if (!path_is_absolute(rvalue)) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1199 | log_error("[%s:%u] Path is not absolute, ignoring: %s", filename, line, rvalue); |
| 1200 | return 0; |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | if (!(s = new0(PathSpec, 1))) |
| 1204 | return -ENOMEM; |
| 1205 | |
| 1206 | if (!(s->path = strdup(rvalue))) { |
| 1207 | free(s); |
| 1208 | return -ENOMEM; |
| 1209 | } |
| 1210 | |
| 1211 | path_kill_slashes(s->path); |
| 1212 | |
| 1213 | s->type = b; |
| 1214 | s->inotify_fd = -1; |
| 1215 | |
| 1216 | LIST_PREPEND(PathSpec, spec, p->specs, s); |
| 1217 | |
| 1218 | return 0; |
| 1219 | } |
| 1220 | |
| 1221 | static int config_parse_path_unit( |
| 1222 | const char *filename, |
| 1223 | unsigned line, |
| 1224 | const char *section, |
| 1225 | const char *lvalue, |
| 1226 | const char *rvalue, |
| 1227 | void *data, |
| 1228 | void *userdata) { |
| 1229 | |
| 1230 | Path *t = data; |
| 1231 | int r; |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 1232 | DBusError error; |
| 1233 | |
| 1234 | assert(filename); |
| 1235 | assert(lvalue); |
| 1236 | assert(rvalue); |
| 1237 | assert(data); |
| 1238 | |
| 1239 | dbus_error_init(&error); |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1240 | |
| 1241 | if (endswith(rvalue, ".path")) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1242 | log_error("[%s:%u] Unit cannot be of type path, ignoring: %s", filename, line, rvalue); |
| 1243 | return 0; |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1244 | } |
| 1245 | |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 1246 | if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &error, &t->unit)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1247 | log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r)); |
Lennart Poettering | 398ef8b | 2010-07-08 02:43:18 +0200 | [diff] [blame] | 1248 | dbus_error_free(&error); |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1249 | return 0; |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | return 0; |
| 1253 | } |
| 1254 | |
Lennart Poettering | d9ff321 | 2010-09-30 02:19:12 +0200 | [diff] [blame] | 1255 | static int config_parse_socket_service( |
| 1256 | const char *filename, |
| 1257 | unsigned line, |
| 1258 | const char *section, |
| 1259 | const char *lvalue, |
| 1260 | const char *rvalue, |
| 1261 | void *data, |
| 1262 | void *userdata) { |
| 1263 | |
| 1264 | Socket *s = data; |
| 1265 | int r; |
| 1266 | DBusError error; |
| 1267 | |
| 1268 | assert(filename); |
| 1269 | assert(lvalue); |
| 1270 | assert(rvalue); |
| 1271 | assert(data); |
| 1272 | |
| 1273 | dbus_error_init(&error); |
| 1274 | |
Lennart Poettering | f976f3f | 2010-10-05 19:49:15 +0200 | [diff] [blame] | 1275 | if (!endswith(rvalue, ".service")) { |
| 1276 | log_error("[%s:%u] Unit must be of type service, ignoring: %s", filename, line, rvalue); |
Lennart Poettering | d9ff321 | 2010-09-30 02:19:12 +0200 | [diff] [blame] | 1277 | return 0; |
| 1278 | } |
| 1279 | |
| 1280 | if ((r = manager_load_unit(s->meta.manager, rvalue, NULL, &error, (Unit**) &s->service)) < 0) { |
| 1281 | log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r)); |
| 1282 | dbus_error_free(&error); |
| 1283 | return 0; |
| 1284 | } |
| 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
Lennart Poettering | f976f3f | 2010-10-05 19:49:15 +0200 | [diff] [blame] | 1289 | static int config_parse_service_sockets( |
| 1290 | const char *filename, |
| 1291 | unsigned line, |
| 1292 | const char *section, |
| 1293 | const char *lvalue, |
| 1294 | const char *rvalue, |
| 1295 | void *data, |
| 1296 | void *userdata) { |
| 1297 | |
| 1298 | Service *s = data; |
| 1299 | int r; |
| 1300 | DBusError error; |
| 1301 | char *state, *w; |
| 1302 | size_t l; |
| 1303 | |
| 1304 | assert(filename); |
| 1305 | assert(lvalue); |
| 1306 | assert(rvalue); |
| 1307 | assert(data); |
| 1308 | |
| 1309 | dbus_error_init(&error); |
| 1310 | |
| 1311 | FOREACH_WORD_QUOTED(w, l, rvalue, state) { |
| 1312 | char *t; |
| 1313 | Unit *sock; |
| 1314 | |
| 1315 | if (!(t = strndup(w, l))) |
| 1316 | return -ENOMEM; |
| 1317 | |
| 1318 | if (!endswith(t, ".socket")) { |
| 1319 | log_error("[%s:%u] Unit must be of type socket, ignoring: %s", filename, line, rvalue); |
| 1320 | free(t); |
| 1321 | continue; |
| 1322 | } |
| 1323 | |
| 1324 | r = manager_load_unit(s->meta.manager, t, NULL, &error, &sock); |
| 1325 | free(t); |
| 1326 | |
| 1327 | if (r < 0) { |
| 1328 | log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r)); |
| 1329 | dbus_error_free(&error); |
| 1330 | continue; |
| 1331 | } |
| 1332 | |
| 1333 | if ((r = set_ensure_allocated(&s->configured_sockets, trivial_hash_func, trivial_compare_func)) < 0) |
| 1334 | return r; |
| 1335 | |
| 1336 | if ((r = set_put(s->configured_sockets, sock)) < 0) |
| 1337 | return r; |
| 1338 | } |
| 1339 | |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
Lennart Poettering | ddb26e1 | 2010-06-18 06:06:24 +0200 | [diff] [blame] | 1343 | static int config_parse_env_file( |
| 1344 | const char *filename, |
| 1345 | unsigned line, |
| 1346 | const char *section, |
| 1347 | const char *lvalue, |
| 1348 | const char *rvalue, |
| 1349 | void *data, |
| 1350 | void *userdata) { |
| 1351 | |
| 1352 | FILE *f; |
| 1353 | int r; |
| 1354 | char ***env = data; |
| 1355 | |
| 1356 | assert(filename); |
| 1357 | assert(lvalue); |
| 1358 | assert(rvalue); |
| 1359 | assert(data); |
| 1360 | |
| 1361 | if (!(f = fopen(rvalue, "re"))) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1362 | log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue); |
| 1363 | return 0; |
Lennart Poettering | ddb26e1 | 2010-06-18 06:06:24 +0200 | [diff] [blame] | 1364 | } |
| 1365 | |
| 1366 | while (!feof(f)) { |
| 1367 | char l[LINE_MAX], *p; |
| 1368 | char **t; |
| 1369 | |
| 1370 | if (!fgets(l, sizeof(l), f)) { |
| 1371 | if (feof(f)) |
| 1372 | break; |
| 1373 | |
| 1374 | r = -errno; |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1375 | log_error("[%s:%u] Failed to read environment file '%s', ignoring: %m", filename, line, rvalue); |
| 1376 | r = 0; |
Lennart Poettering | ddb26e1 | 2010-06-18 06:06:24 +0200 | [diff] [blame] | 1377 | goto finish; |
| 1378 | } |
| 1379 | |
| 1380 | p = strstrip(l); |
| 1381 | |
| 1382 | if (!*p) |
| 1383 | continue; |
| 1384 | |
| 1385 | if (strchr(COMMENTS, *p)) |
| 1386 | continue; |
| 1387 | |
| 1388 | t = strv_env_set(*env, p); |
| 1389 | strv_free(*env); |
| 1390 | *env = t; |
| 1391 | } |
| 1392 | |
| 1393 | r = 0; |
| 1394 | |
| 1395 | finish: |
| 1396 | if (f) |
| 1397 | fclose(f); |
| 1398 | |
| 1399 | return r; |
| 1400 | } |
| 1401 | |
Lennart Poettering | 4fd5948 | 2010-07-01 00:29:17 +0200 | [diff] [blame] | 1402 | static int config_parse_ip_tos( |
| 1403 | const char *filename, |
| 1404 | unsigned line, |
| 1405 | const char *section, |
| 1406 | const char *lvalue, |
| 1407 | const char *rvalue, |
| 1408 | void *data, |
| 1409 | void *userdata) { |
| 1410 | |
| 1411 | int *ip_tos = data, x; |
| 1412 | int r; |
| 1413 | |
| 1414 | assert(filename); |
| 1415 | assert(lvalue); |
| 1416 | assert(rvalue); |
| 1417 | assert(data); |
| 1418 | |
| 1419 | if ((x = ip_tos_from_string(rvalue)) < 0) |
| 1420 | if ((r = safe_atoi(rvalue, &x)) < 0) { |
Lennart Poettering | c0b3469 | 2010-08-17 03:30:53 +0200 | [diff] [blame] | 1421 | log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue); |
| 1422 | return 0; |
Lennart Poettering | 4fd5948 | 2010-07-01 00:29:17 +0200 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | *ip_tos = x; |
| 1426 | return 0; |
| 1427 | } |
| 1428 | |
Lennart Poettering | 52661ef | 2010-10-13 02:15:41 +0200 | [diff] [blame] | 1429 | static int config_parse_condition_path( |
| 1430 | const char *filename, |
| 1431 | unsigned line, |
| 1432 | const char *section, |
| 1433 | const char *lvalue, |
| 1434 | const char *rvalue, |
| 1435 | void *data, |
| 1436 | void *userdata) { |
| 1437 | |
| 1438 | Unit *u = data; |
| 1439 | bool negate; |
| 1440 | Condition *c; |
| 1441 | |
| 1442 | assert(filename); |
| 1443 | assert(lvalue); |
| 1444 | assert(rvalue); |
| 1445 | assert(data); |
| 1446 | |
| 1447 | if ((negate = rvalue[0] == '!')) |
| 1448 | rvalue++; |
| 1449 | |
| 1450 | if (!path_is_absolute(rvalue)) { |
| 1451 | log_error("[%s:%u] Path in condition not absolute: %s", filename, line, rvalue); |
| 1452 | return 0; |
| 1453 | } |
| 1454 | |
| 1455 | if (!(c = condition_new(CONDITION_PATH_EXISTS, rvalue, negate))) |
| 1456 | return -ENOMEM; |
| 1457 | |
| 1458 | LIST_PREPEND(Condition, conditions, u->meta.conditions, c); |
| 1459 | return 0; |
| 1460 | } |
| 1461 | |
| 1462 | static int config_parse_condition_kernel( |
| 1463 | const char *filename, |
| 1464 | unsigned line, |
| 1465 | const char *section, |
| 1466 | const char *lvalue, |
| 1467 | const char *rvalue, |
| 1468 | void *data, |
| 1469 | void *userdata) { |
| 1470 | |
| 1471 | Unit *u = data; |
| 1472 | bool negate; |
| 1473 | Condition *c; |
| 1474 | |
| 1475 | assert(filename); |
| 1476 | assert(lvalue); |
| 1477 | assert(rvalue); |
| 1478 | assert(data); |
| 1479 | |
| 1480 | if ((negate = rvalue[0] == '!')) |
| 1481 | rvalue++; |
| 1482 | |
| 1483 | if (!(c = condition_new(CONDITION_KERNEL_COMMAND_LINE, rvalue, negate))) |
| 1484 | return -ENOMEM; |
| 1485 | |
| 1486 | LIST_PREPEND(Condition, conditions, u->meta.conditions, c); |
| 1487 | return 0; |
| 1488 | } |
| 1489 | |
Lennart Poettering | 487393e | 2010-07-07 01:10:27 +0200 | [diff] [blame] | 1490 | static DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier"); |
Lennart Poettering | c952c6e | 2010-06-18 23:12:48 +0200 | [diff] [blame] | 1491 | |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 1492 | #define FOLLOW_MAX 8 |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1493 | |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 1494 | static int open_follow(char **filename, FILE **_f, Set *names, char **_final) { |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1495 | unsigned c = 0; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1496 | int fd, r; |
| 1497 | FILE *f; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1498 | char *id = NULL; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1499 | |
| 1500 | assert(filename); |
| 1501 | assert(*filename); |
| 1502 | assert(_f); |
| 1503 | assert(names); |
| 1504 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1505 | /* This will update the filename pointer if the loaded file is |
| 1506 | * reached by a symlink. The old string will be freed. */ |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1507 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1508 | for (;;) { |
Lennart Poettering | 2c7108c | 2010-06-16 01:56:00 +0200 | [diff] [blame] | 1509 | char *target, *name; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1510 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1511 | if (c++ >= FOLLOW_MAX) |
| 1512 | return -ELOOP; |
| 1513 | |
Lennart Poettering | b08d03f | 2010-01-29 02:07:41 +0100 | [diff] [blame] | 1514 | path_kill_slashes(*filename); |
| 1515 | |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1516 | /* Add the file name we are currently looking at to |
Lennart Poettering | 8f05424 | 2010-07-21 03:13:15 +0200 | [diff] [blame] | 1517 | * the names of this unit, but only if it is a valid |
| 1518 | * unit name. */ |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1519 | name = file_name_from_path(*filename); |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1520 | |
Lennart Poettering | b9c0d44 | 2010-10-08 03:09:25 +0200 | [diff] [blame] | 1521 | if (unit_name_is_valid(name, false)) { |
Lennart Poettering | 8f05424 | 2010-07-21 03:13:15 +0200 | [diff] [blame] | 1522 | if (!(id = set_get(names, name))) { |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1523 | |
Lennart Poettering | 8f05424 | 2010-07-21 03:13:15 +0200 | [diff] [blame] | 1524 | if (!(id = strdup(name))) |
| 1525 | return -ENOMEM; |
| 1526 | |
| 1527 | if ((r = set_put(names, id)) < 0) { |
| 1528 | free(id); |
| 1529 | return r; |
| 1530 | } |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1531 | } |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1532 | } |
| 1533 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1534 | /* Try to open the file name, but don't if its a symlink */ |
| 1535 | if ((fd = open(*filename, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW)) >= 0) |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1536 | break; |
| 1537 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1538 | if (errno != ELOOP) |
| 1539 | return -errno; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1540 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1541 | /* Hmm, so this is a symlink. Let's read the name, and follow it manually */ |
Lennart Poettering | 2c7108c | 2010-06-16 01:56:00 +0200 | [diff] [blame] | 1542 | if ((r = readlink_and_make_absolute(*filename, &target)) < 0) |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1543 | return r; |
| 1544 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1545 | free(*filename); |
Lennart Poettering | 2c7108c | 2010-06-16 01:56:00 +0200 | [diff] [blame] | 1546 | *filename = target; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1547 | } |
| 1548 | |
Lennart Poettering | 8f05424 | 2010-07-21 03:13:15 +0200 | [diff] [blame] | 1549 | if (!(f = fdopen(fd, "re"))) { |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1550 | r = -errno; |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 1551 | close_nointr_nofail(fd); |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1552 | return r; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1553 | } |
| 1554 | |
| 1555 | *_f = f; |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 1556 | *_final = id; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1557 | return 0; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1558 | } |
| 1559 | |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1560 | static int merge_by_names(Unit **u, Set *names, const char *id) { |
| 1561 | char *k; |
| 1562 | int r; |
| 1563 | |
| 1564 | assert(u); |
| 1565 | assert(*u); |
| 1566 | assert(names); |
| 1567 | |
| 1568 | /* Let's try to add in all symlink names we found */ |
| 1569 | while ((k = set_steal_first(names))) { |
| 1570 | |
| 1571 | /* First try to merge in the other name into our |
| 1572 | * unit */ |
| 1573 | if ((r = unit_merge_by_name(*u, k)) < 0) { |
| 1574 | Unit *other; |
| 1575 | |
| 1576 | /* Hmm, we couldn't merge the other unit into |
| 1577 | * ours? Then let's try it the other way |
| 1578 | * round */ |
| 1579 | |
| 1580 | other = manager_get_unit((*u)->meta.manager, k); |
| 1581 | free(k); |
| 1582 | |
| 1583 | if (other) |
| 1584 | if ((r = unit_merge(other, *u)) >= 0) { |
| 1585 | *u = other; |
| 1586 | return merge_by_names(u, names, NULL); |
| 1587 | } |
| 1588 | |
| 1589 | return r; |
| 1590 | } |
| 1591 | |
| 1592 | if (id == k) |
| 1593 | unit_choose_id(*u, id); |
| 1594 | |
| 1595 | free(k); |
| 1596 | } |
| 1597 | |
| 1598 | return 0; |
| 1599 | } |
| 1600 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1601 | static void dump_items(FILE *f, const ConfigItem *items) { |
| 1602 | const ConfigItem *i; |
| 1603 | const char *prev_section = NULL; |
| 1604 | bool not_first = false; |
| 1605 | |
| 1606 | struct { |
| 1607 | ConfigParserCallback callback; |
| 1608 | const char *rvalue; |
| 1609 | } table[] = { |
| 1610 | { config_parse_int, "INTEGER" }, |
| 1611 | { config_parse_unsigned, "UNSIGNED" }, |
| 1612 | { config_parse_size, "SIZE" }, |
| 1613 | { config_parse_bool, "BOOLEAN" }, |
| 1614 | { config_parse_string, "STRING" }, |
| 1615 | { config_parse_path, "PATH" }, |
| 1616 | { config_parse_strv, "STRING [...]" }, |
| 1617 | { config_parse_nice, "NICE" }, |
Lennart Poettering | dd6c17b | 2010-08-31 01:33:39 +0200 | [diff] [blame] | 1618 | { config_parse_oom_score_adjust, "OOMSCOREADJUST" }, |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1619 | { config_parse_io_class, "IOCLASS" }, |
| 1620 | { config_parse_io_priority, "IOPRIORITY" }, |
| 1621 | { config_parse_cpu_sched_policy, "CPUSCHEDPOLICY" }, |
| 1622 | { config_parse_cpu_sched_prio, "CPUSCHEDPRIO" }, |
| 1623 | { config_parse_cpu_affinity, "CPUAFFINITY" }, |
| 1624 | { config_parse_mode, "MODE" }, |
Lennart Poettering | ddb26e1 | 2010-06-18 06:06:24 +0200 | [diff] [blame] | 1625 | { config_parse_env_file, "FILE" }, |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1626 | { config_parse_output, "OUTPUT" }, |
| 1627 | { config_parse_input, "INPUT" }, |
| 1628 | { config_parse_facility, "FACILITY" }, |
| 1629 | { config_parse_level, "LEVEL" }, |
| 1630 | { config_parse_capabilities, "CAPABILITIES" }, |
| 1631 | { config_parse_secure_bits, "SECUREBITS" }, |
| 1632 | { config_parse_bounding_set, "BOUNDINGSET" }, |
Lennart Poettering | 03fae01 | 2010-07-04 21:12:10 +0200 | [diff] [blame] | 1633 | { config_parse_timer_slack_nsec, "TIMERSLACK" }, |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1634 | { config_parse_limit, "LIMIT" }, |
| 1635 | { config_parse_cgroup, "CGROUP [...]" }, |
| 1636 | { config_parse_deps, "UNIT [...]" }, |
| 1637 | { config_parse_names, "UNIT [...]" }, |
| 1638 | { config_parse_exec, "PATH [ARGUMENT [...]]" }, |
| 1639 | { config_parse_service_type, "SERVICETYPE" }, |
| 1640 | { config_parse_service_restart, "SERVICERESTART" }, |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 1641 | #ifdef HAVE_SYSV_COMPAT |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1642 | { config_parse_sysv_priority, "SYSVPRIORITY" }, |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 1643 | #else |
| 1644 | { config_parse_warn_compat, "NOTSUPPORTED" }, |
| 1645 | #endif |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1646 | { config_parse_kill_mode, "KILLMODE" }, |
Lennart Poettering | 2e22afe | 2010-07-10 04:49:37 +0200 | [diff] [blame] | 1647 | { config_parse_kill_signal, "SIGNAL" }, |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1648 | { config_parse_listen, "SOCKET [...]" }, |
| 1649 | { config_parse_socket_bind, "SOCKETBIND" }, |
Lennart Poettering | 93ef5e8 | 2010-04-23 20:27:47 +0200 | [diff] [blame] | 1650 | { config_parse_bindtodevice, "NETWORKINTERFACE" }, |
| 1651 | { config_parse_usec, "SECONDS" }, |
| 1652 | { config_parse_path_strv, "PATH [...]" }, |
Lennart Poettering | 932921b | 2010-04-24 03:11:01 +0200 | [diff] [blame] | 1653 | { config_parse_mount_flags, "MOUNTFLAG [...]" }, |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 1654 | { config_parse_string_printf, "STRING" }, |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1655 | { config_parse_timer, "TIMER" }, |
| 1656 | { config_parse_timer_unit, "NAME" }, |
Lennart Poettering | c952c6e | 2010-06-18 23:12:48 +0200 | [diff] [blame] | 1657 | { config_parse_path_spec, "PATH" }, |
| 1658 | { config_parse_path_unit, "UNIT" }, |
Lennart Poettering | 8b03dae | 2010-07-01 16:34:26 +0200 | [diff] [blame] | 1659 | { config_parse_notify_access, "ACCESS" }, |
| 1660 | { config_parse_ip_tos, "TOS" }, |
Lennart Poettering | 52661ef | 2010-10-13 02:15:41 +0200 | [diff] [blame] | 1661 | { config_parse_condition_path, "CONDITION" }, |
| 1662 | { config_parse_condition_kernel, "CONDITION" }, |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1663 | }; |
| 1664 | |
| 1665 | assert(f); |
| 1666 | assert(items); |
| 1667 | |
| 1668 | for (i = items; i->lvalue; i++) { |
| 1669 | unsigned j; |
| 1670 | const char *rvalue = "OTHER"; |
| 1671 | |
| 1672 | if (!streq_ptr(i->section, prev_section)) { |
| 1673 | if (!not_first) |
| 1674 | not_first = true; |
| 1675 | else |
| 1676 | fputc('\n', f); |
| 1677 | |
| 1678 | fprintf(f, "[%s]\n", i->section); |
| 1679 | prev_section = i->section; |
| 1680 | } |
| 1681 | |
| 1682 | for (j = 0; j < ELEMENTSOF(table); j++) |
| 1683 | if (i->parse == table[j].callback) { |
| 1684 | rvalue = table[j].rvalue; |
| 1685 | break; |
| 1686 | } |
| 1687 | |
| 1688 | fprintf(f, "%s=%s\n", i->lvalue, rvalue); |
| 1689 | } |
| 1690 | } |
| 1691 | |
| 1692 | static int load_from_path(Unit *u, const char *path) { |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1693 | |
| 1694 | static const char* const section_table[_UNIT_TYPE_MAX] = { |
| 1695 | [UNIT_SERVICE] = "Service", |
| 1696 | [UNIT_TIMER] = "Timer", |
| 1697 | [UNIT_SOCKET] = "Socket", |
| 1698 | [UNIT_TARGET] = "Target", |
| 1699 | [UNIT_DEVICE] = "Device", |
| 1700 | [UNIT_MOUNT] = "Mount", |
| 1701 | [UNIT_AUTOMOUNT] = "Automount", |
Maarten Lankhorst | 07b0b13 | 2010-05-09 18:44:11 +0200 | [diff] [blame] | 1702 | [UNIT_SNAPSHOT] = "Snapshot", |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1703 | [UNIT_SWAP] = "Swap", |
| 1704 | [UNIT_PATH] = "Path" |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 1705 | }; |
| 1706 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1707 | #define EXEC_CONTEXT_CONFIG_ITEMS(context, section) \ |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 1708 | { "WorkingDirectory", config_parse_path, &(context).working_directory, section }, \ |
| 1709 | { "RootDirectory", config_parse_path, &(context).root_directory, section }, \ |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 1710 | { "User", config_parse_string_printf, &(context).user, section }, \ |
| 1711 | { "Group", config_parse_string_printf, &(context).group, section }, \ |
Lennart Poettering | 1c01f82 | 2010-01-27 02:16:11 +0100 | [diff] [blame] | 1712 | { "SupplementaryGroups", config_parse_strv, &(context).supplementary_groups, section }, \ |
Lennart Poettering | fb33a39 | 2010-01-28 02:53:56 +0100 | [diff] [blame] | 1713 | { "Nice", config_parse_nice, &(context), section }, \ |
Lennart Poettering | dd6c17b | 2010-08-31 01:33:39 +0200 | [diff] [blame] | 1714 | { "OOMScoreAdjust", config_parse_oom_score_adjust,&(context), section }, \ |
Lennart Poettering | 9eba9da | 2010-01-29 20:46:22 +0100 | [diff] [blame] | 1715 | { "IOSchedulingClass", config_parse_io_class, &(context), section }, \ |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 1716 | { "IOSchedulingPriority", config_parse_io_priority, &(context), section }, \ |
| 1717 | { "CPUSchedulingPolicy", config_parse_cpu_sched_policy,&(context), section }, \ |
| 1718 | { "CPUSchedulingPriority", config_parse_cpu_sched_prio, &(context), section }, \ |
Lennart Poettering | 38b4875 | 2010-02-02 12:50:04 +0100 | [diff] [blame] | 1719 | { "CPUSchedulingResetOnFork", config_parse_bool, &(context).cpu_sched_reset_on_fork, section }, \ |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 1720 | { "CPUAffinity", config_parse_cpu_affinity, &(context), section }, \ |
Lennart Poettering | b5a0699 | 2010-02-12 02:02:14 +0100 | [diff] [blame] | 1721 | { "UMask", config_parse_mode, &(context).umask, section }, \ |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 1722 | { "Environment", config_parse_strv, &(context).environment, section }, \ |
Lennart Poettering | ddb26e1 | 2010-06-18 06:06:24 +0200 | [diff] [blame] | 1723 | { "EnvironmentFile", config_parse_env_file, &(context).environment, section }, \ |
Lennart Poettering | 80876c2 | 2010-04-13 02:06:27 +0200 | [diff] [blame] | 1724 | { "StandardInput", config_parse_input, &(context).std_input, section }, \ |
| 1725 | { "StandardOutput", config_parse_output, &(context).std_output, section }, \ |
Lennart Poettering | a4ddf82 | 2010-06-03 03:37:12 +0200 | [diff] [blame] | 1726 | { "StandardError", config_parse_output, &(context).std_error, section }, \ |
Lennart Poettering | 80876c2 | 2010-04-13 02:06:27 +0200 | [diff] [blame] | 1727 | { "TTYPath", config_parse_path, &(context).tty_path, section }, \ |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 1728 | { "SyslogIdentifier", config_parse_string_printf, &(context).syslog_identifier, section }, \ |
Lennart Poettering | 071830f | 2010-01-28 02:06:20 +0100 | [diff] [blame] | 1729 | { "SyslogFacility", config_parse_facility, &(context).syslog_priority, section }, \ |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 1730 | { "SyslogLevel", config_parse_level, &(context).syslog_priority, section }, \ |
Lennart Poettering | 7492290 | 2010-07-05 01:08:13 +0200 | [diff] [blame] | 1731 | { "SyslogLevelPrefix", config_parse_bool, &(context).syslog_level_prefix, section }, \ |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 1732 | { "Capabilities", config_parse_capabilities, &(context), section }, \ |
| 1733 | { "SecureBits", config_parse_secure_bits, &(context), section }, \ |
| 1734 | { "CapabilityBoundingSetDrop", config_parse_bounding_set, &(context), section }, \ |
Lennart Poettering | 03fae01 | 2010-07-04 21:12:10 +0200 | [diff] [blame] | 1735 | { "TimerSlackNSec", config_parse_timer_slack_nsec,&(context), section }, \ |
Lennart Poettering | 94f0434 | 2010-01-30 01:55:42 +0100 | [diff] [blame] | 1736 | { "LimitCPU", config_parse_limit, &(context).rlimit[RLIMIT_CPU], section }, \ |
| 1737 | { "LimitFSIZE", config_parse_limit, &(context).rlimit[RLIMIT_FSIZE], section }, \ |
| 1738 | { "LimitDATA", config_parse_limit, &(context).rlimit[RLIMIT_DATA], section }, \ |
| 1739 | { "LimitSTACK", config_parse_limit, &(context).rlimit[RLIMIT_STACK], section }, \ |
| 1740 | { "LimitCORE", config_parse_limit, &(context).rlimit[RLIMIT_CORE], section }, \ |
| 1741 | { "LimitRSS", config_parse_limit, &(context).rlimit[RLIMIT_RSS], section }, \ |
| 1742 | { "LimitNOFILE", config_parse_limit, &(context).rlimit[RLIMIT_NOFILE], section }, \ |
| 1743 | { "LimitAS", config_parse_limit, &(context).rlimit[RLIMIT_AS], section }, \ |
| 1744 | { "LimitNPROC", config_parse_limit, &(context).rlimit[RLIMIT_NPROC], section }, \ |
| 1745 | { "LimitMEMLOCK", config_parse_limit, &(context).rlimit[RLIMIT_MEMLOCK], section }, \ |
| 1746 | { "LimitLOCKS", config_parse_limit, &(context).rlimit[RLIMIT_LOCKS], section }, \ |
| 1747 | { "LimitSIGPENDING", config_parse_limit, &(context).rlimit[RLIMIT_SIGPENDING], section }, \ |
| 1748 | { "LimitMSGQUEUE", config_parse_limit, &(context).rlimit[RLIMIT_MSGQUEUE], section }, \ |
| 1749 | { "LimitNICE", config_parse_limit, &(context).rlimit[RLIMIT_NICE], section }, \ |
| 1750 | { "LimitRTPRIO", config_parse_limit, &(context).rlimit[RLIMIT_RTPRIO], section }, \ |
Lennart Poettering | 451a074 | 2010-02-12 02:00:18 +0100 | [diff] [blame] | 1751 | { "LimitRTTIME", config_parse_limit, &(context).rlimit[RLIMIT_RTTIME], section }, \ |
Lennart Poettering | 15ae422 | 2010-04-21 22:15:06 +0200 | [diff] [blame] | 1752 | { "ControlGroup", config_parse_cgroup, u, section }, \ |
| 1753 | { "ReadWriteDirectories", config_parse_path_strv, &(context).read_write_dirs, section }, \ |
| 1754 | { "ReadOnlyDirectories", config_parse_path_strv, &(context).read_only_dirs, section }, \ |
| 1755 | { "InaccessibleDirectories",config_parse_path_strv, &(context).inaccessible_dirs, section }, \ |
| 1756 | { "PrivateTmp", config_parse_bool, &(context).private_tmp, section }, \ |
Lennart Poettering | df1f0af | 2010-06-16 16:25:42 +0200 | [diff] [blame] | 1757 | { "MountFlags", config_parse_mount_flags, &(context), section }, \ |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 1758 | { "TCPWrapName", config_parse_string_printf, &(context).tcpwrap_name, section }, \ |
Lennart Poettering | 2e22afe | 2010-07-10 04:49:37 +0200 | [diff] [blame] | 1759 | { "PAMName", config_parse_string_printf, &(context).pam_name, section }, \ |
| 1760 | { "KillMode", config_parse_kill_mode, &(context).kill_mode, section }, \ |
Lennart Poettering | 169c1bd | 2010-10-08 16:06:23 +0200 | [diff] [blame] | 1761 | { "KillSignal", config_parse_kill_signal, &(context).kill_signal, section }, \ |
| 1762 | { "UtmpIdentifier", config_parse_string_printf, &(context).utmp_id, section } |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1763 | |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 1764 | const ConfigItem items[] = { |
Lennart Poettering | 0947726 | 2010-04-15 23:20:17 +0200 | [diff] [blame] | 1765 | { "Names", config_parse_names, u, "Unit" }, |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 1766 | { "Description", config_parse_string_printf, &u->meta.description, "Unit" }, |
Lennart Poettering | 0947726 | 2010-04-15 23:20:17 +0200 | [diff] [blame] | 1767 | { "Requires", config_parse_deps, UINT_TO_PTR(UNIT_REQUIRES), "Unit" }, |
| 1768 | { "RequiresOverridable", config_parse_deps, UINT_TO_PTR(UNIT_REQUIRES_OVERRIDABLE), "Unit" }, |
| 1769 | { "Requisite", config_parse_deps, UINT_TO_PTR(UNIT_REQUISITE), "Unit" }, |
| 1770 | { "RequisiteOverridable", config_parse_deps, UINT_TO_PTR(UNIT_REQUISITE_OVERRIDABLE), "Unit" }, |
| 1771 | { "Wants", config_parse_deps, UINT_TO_PTR(UNIT_WANTS), "Unit" }, |
| 1772 | { "Conflicts", config_parse_deps, UINT_TO_PTR(UNIT_CONFLICTS), "Unit" }, |
| 1773 | { "Before", config_parse_deps, UINT_TO_PTR(UNIT_BEFORE), "Unit" }, |
| 1774 | { "After", config_parse_deps, UINT_TO_PTR(UNIT_AFTER), "Unit" }, |
Lennart Poettering | 45fb069 | 2010-07-17 00:57:51 +0200 | [diff] [blame] | 1775 | { "OnFailure", config_parse_deps, UINT_TO_PTR(UNIT_ON_FAILURE), "Unit" }, |
Lennart Poettering | 0947726 | 2010-04-15 23:20:17 +0200 | [diff] [blame] | 1776 | { "RecursiveStop", config_parse_bool, &u->meta.recursive_stop, "Unit" }, |
| 1777 | { "StopWhenUnneeded", config_parse_bool, &u->meta.stop_when_unneeded, "Unit" }, |
Lennart Poettering | b5e9dba | 2010-08-10 20:57:21 +0200 | [diff] [blame] | 1778 | { "RefuseManualStart", config_parse_bool, &u->meta.refuse_manual_start, "Unit" }, |
| 1779 | { "RefuseManualStop", config_parse_bool, &u->meta.refuse_manual_stop, "Unit" }, |
Lennart Poettering | 2528a7a | 2010-08-30 22:45:46 +0200 | [diff] [blame] | 1780 | { "AllowIsolate", config_parse_bool, &u->meta.allow_isolate, "Unit" }, |
Lennart Poettering | a40eb73 | 2010-07-03 19:48:33 +0200 | [diff] [blame] | 1781 | { "DefaultDependencies", config_parse_bool, &u->meta.default_dependencies, "Unit" }, |
Lennart Poettering | 3b6fdb5 | 2010-07-12 02:56:17 +0200 | [diff] [blame] | 1782 | { "IgnoreDependencyFailure",config_parse_bool, &u->meta.ignore_dependency_failure, "Unit" }, |
Lennart Poettering | faf919f | 2010-07-17 04:09:28 +0200 | [diff] [blame] | 1783 | { "JobTimeoutSec", config_parse_usec, &u->meta.job_timeout, "Unit" }, |
Lennart Poettering | 52661ef | 2010-10-13 02:15:41 +0200 | [diff] [blame] | 1784 | { "ConditionPathExists", config_parse_condition_path, u, "Unit" }, |
| 1785 | { "ConditionKernelCommandLine", config_parse_condition_kernel, u, "Unit" }, |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1786 | |
Lennart Poettering | 1c01f82 | 2010-01-27 02:16:11 +0100 | [diff] [blame] | 1787 | { "PIDFile", config_parse_path, &u->service.pid_file, "Service" }, |
| 1788 | { "ExecStartPre", config_parse_exec, u->service.exec_command+SERVICE_EXEC_START_PRE, "Service" }, |
| 1789 | { "ExecStart", config_parse_exec, u->service.exec_command+SERVICE_EXEC_START, "Service" }, |
| 1790 | { "ExecStartPost", config_parse_exec, u->service.exec_command+SERVICE_EXEC_START_POST, "Service" }, |
| 1791 | { "ExecReload", config_parse_exec, u->service.exec_command+SERVICE_EXEC_RELOAD, "Service" }, |
| 1792 | { "ExecStop", config_parse_exec, u->service.exec_command+SERVICE_EXEC_STOP, "Service" }, |
| 1793 | { "ExecStopPost", config_parse_exec, u->service.exec_command+SERVICE_EXEC_STOP_POST, "Service" }, |
| 1794 | { "RestartSec", config_parse_usec, &u->service.restart_usec, "Service" }, |
| 1795 | { "TimeoutSec", config_parse_usec, &u->service.timeout_usec, "Service" }, |
Lennart Poettering | 0d87eb4 | 2010-04-13 02:22:41 +0200 | [diff] [blame] | 1796 | { "Type", config_parse_service_type, &u->service.type, "Service" }, |
| 1797 | { "Restart", config_parse_service_restart, &u->service.restart, "Service" }, |
Lennart Poettering | 81a2b7c | 2010-02-14 22:43:08 +0100 | [diff] [blame] | 1798 | { "PermissionsStartOnly", config_parse_bool, &u->service.permissions_start_only, "Service" }, |
| 1799 | { "RootDirectoryStartOnly", config_parse_bool, &u->service.root_directory_start_only, "Service" }, |
Lennart Poettering | 02ee865 | 2010-08-17 19:37:36 +0200 | [diff] [blame] | 1800 | { "RemainAfterExit", config_parse_bool, &u->service.remain_after_exit, "Service" }, |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 1801 | #ifdef HAVE_SYSV_COMPAT |
Lennart Poettering | a9a1e00 | 2010-04-06 02:40:10 +0200 | [diff] [blame] | 1802 | { "SysVStartPriority", config_parse_sysv_priority, &u->service.sysv_start_priority, "Service" }, |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 1803 | #else |
Lennart Poettering | f976f3f | 2010-10-05 19:49:15 +0200 | [diff] [blame] | 1804 | { "SysVStartPriority", config_parse_warn_compat, NULL, "Service" }, |
Fabiano Fidencio | 07459bb | 2010-09-21 00:23:12 -0300 | [diff] [blame] | 1805 | #endif |
Lennart Poettering | b778d55 | 2010-04-10 17:48:41 +0200 | [diff] [blame] | 1806 | { "NonBlocking", config_parse_bool, &u->service.exec_context.non_blocking, "Service" }, |
Lennart Poettering | f2d3769 | 2010-06-18 23:25:19 +0200 | [diff] [blame] | 1807 | { "BusName", config_parse_string_printf, &u->service.bus_name, "Service" }, |
Lennart Poettering | c952c6e | 2010-06-18 23:12:48 +0200 | [diff] [blame] | 1808 | { "NotifyAccess", config_parse_notify_access, &u->service.notify_access, "Service" }, |
Lennart Poettering | f976f3f | 2010-10-05 19:49:15 +0200 | [diff] [blame] | 1809 | { "Sockets", config_parse_service_sockets, &u->service, "Service" }, |
Lennart Poettering | 2ba545f | 2010-10-20 14:22:23 +0200 | [diff] [blame^] | 1810 | { "FsckPassNo", config_parse_fsck_passno, &u->service.fsck_passno, "Service" }, |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1811 | EXEC_CONTEXT_CONFIG_ITEMS(u->service.exec_context, "Service"), |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1812 | |
Lennart Poettering | 1c01f82 | 2010-01-27 02:16:11 +0100 | [diff] [blame] | 1813 | { "ListenStream", config_parse_listen, &u->socket, "Socket" }, |
| 1814 | { "ListenDatagram", config_parse_listen, &u->socket, "Socket" }, |
| 1815 | { "ListenSequentialPacket", config_parse_listen, &u->socket, "Socket" }, |
| 1816 | { "ListenFIFO", config_parse_listen, &u->socket, "Socket" }, |
| 1817 | { "BindIPv6Only", config_parse_socket_bind, &u->socket, "Socket" }, |
| 1818 | { "Backlog", config_parse_unsigned, &u->socket.backlog, "Socket" }, |
Lennart Poettering | acbb022 | 2010-01-27 04:31:52 +0100 | [diff] [blame] | 1819 | { "BindToDevice", config_parse_bindtodevice, &u->socket, "Socket" }, |
Lennart Poettering | 1c01f82 | 2010-01-27 02:16:11 +0100 | [diff] [blame] | 1820 | { "ExecStartPre", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_START_PRE, "Socket" }, |
| 1821 | { "ExecStartPost", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_START_POST, "Socket" }, |
| 1822 | { "ExecStopPre", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_STOP_PRE, "Socket" }, |
| 1823 | { "ExecStopPost", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_STOP_POST, "Socket" }, |
Lennart Poettering | 108736d | 2010-04-10 17:50:54 +0200 | [diff] [blame] | 1824 | { "TimeoutSec", config_parse_usec, &u->socket.timeout_usec, "Socket" }, |
Lennart Poettering | b5a0699 | 2010-02-12 02:02:14 +0100 | [diff] [blame] | 1825 | { "DirectoryMode", config_parse_mode, &u->socket.directory_mode, "Socket" }, |
| 1826 | { "SocketMode", config_parse_mode, &u->socket.socket_mode, "Socket" }, |
Lennart Poettering | 4f2d528 | 2010-04-15 06:19:54 +0200 | [diff] [blame] | 1827 | { "Accept", config_parse_bool, &u->socket.accept, "Socket" }, |
Lennart Poettering | 6cf6bbc | 2010-06-19 04:25:28 +0200 | [diff] [blame] | 1828 | { "MaxConnections", config_parse_unsigned, &u->socket.max_connections, "Socket" }, |
Lennart Poettering | 4fd5948 | 2010-07-01 00:29:17 +0200 | [diff] [blame] | 1829 | { "KeepAlive", config_parse_bool, &u->socket.keep_alive, "Socket" }, |
| 1830 | { "Priority", config_parse_int, &u->socket.priority, "Socket" }, |
| 1831 | { "ReceiveBuffer", config_parse_size, &u->socket.receive_buffer, "Socket" }, |
| 1832 | { "SendBuffer", config_parse_size, &u->socket.send_buffer, "Socket" }, |
| 1833 | { "IPTOS", config_parse_ip_tos, &u->socket.ip_tos, "Socket" }, |
| 1834 | { "IPTTL", config_parse_int, &u->socket.ip_ttl, "Socket" }, |
| 1835 | { "Mark", config_parse_int, &u->socket.mark, "Socket" }, |
| 1836 | { "PipeSize", config_parse_size, &u->socket.pipe_size, "Socket" }, |
| 1837 | { "FreeBind", config_parse_bool, &u->socket.free_bind, "Socket" }, |
Tomasz Torcz | cebf8b2 | 2010-08-03 13:33:40 +0200 | [diff] [blame] | 1838 | { "TCPCongestion", config_parse_string, &u->socket.tcp_congestion, "Socket" }, |
Lennart Poettering | d9ff321 | 2010-09-30 02:19:12 +0200 | [diff] [blame] | 1839 | { "Service", config_parse_socket_service, &u->socket, "Socket" }, |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1840 | EXEC_CONTEXT_CONFIG_ITEMS(u->socket.exec_context, "Socket"), |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1841 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1842 | { "What", config_parse_string, &u->mount.parameters_fragment.what, "Mount" }, |
| 1843 | { "Where", config_parse_path, &u->mount.where, "Mount" }, |
| 1844 | { "Options", config_parse_string, &u->mount.parameters_fragment.options, "Mount" }, |
| 1845 | { "Type", config_parse_string, &u->mount.parameters_fragment.fstype, "Mount" }, |
| 1846 | { "TimeoutSec", config_parse_usec, &u->mount.timeout_usec, "Mount" }, |
Lennart Poettering | 3e5235b | 2010-07-02 00:28:44 +0200 | [diff] [blame] | 1847 | { "DirectoryMode", config_parse_mode, &u->mount.directory_mode, "Mount" }, |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1848 | EXEC_CONTEXT_CONFIG_ITEMS(u->mount.exec_context, "Mount"), |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1849 | |
Lennart Poettering | 8d56758 | 2010-04-16 23:24:39 +0200 | [diff] [blame] | 1850 | { "Where", config_parse_path, &u->automount.where, "Automount" }, |
Lennart Poettering | 1cf18f2 | 2010-07-02 01:17:21 +0200 | [diff] [blame] | 1851 | { "DirectoryMode", config_parse_mode, &u->automount.directory_mode, "Automount" }, |
Lennart Poettering | 8d56758 | 2010-04-16 23:24:39 +0200 | [diff] [blame] | 1852 | |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1853 | { "What", config_parse_path, &u->swap.parameters_fragment.what, "Swap" }, |
| 1854 | { "Priority", config_parse_int, &u->swap.parameters_fragment.priority, "Swap" }, |
Maarten Lankhorst | 07b0b13 | 2010-05-09 18:44:11 +0200 | [diff] [blame] | 1855 | |
Lennart Poettering | 03fae01 | 2010-07-04 21:12:10 +0200 | [diff] [blame] | 1856 | { "OnActiveSec", config_parse_timer, &u->timer, "Timer" }, |
| 1857 | { "OnBootSec", config_parse_timer, &u->timer, "Timer" }, |
| 1858 | { "OnStartupSec", config_parse_timer, &u->timer, "Timer" }, |
| 1859 | { "OnUnitActiveSec", config_parse_timer, &u->timer, "Timer" }, |
| 1860 | { "OnUnitInactiveSec", config_parse_timer, &u->timer, "Timer" }, |
Lennart Poettering | 01f7847 | 2010-05-24 05:25:33 +0200 | [diff] [blame] | 1861 | { "Unit", config_parse_timer_unit, &u->timer, "Timer" }, |
| 1862 | |
| 1863 | { "PathExists", config_parse_path_spec, &u->path, "Path" }, |
| 1864 | { "PathChanged", config_parse_path_spec, &u->path, "Path" }, |
| 1865 | { "DirectoryNotEmpty", config_parse_path_spec, &u->path, "Path" }, |
| 1866 | { "Unit", config_parse_path_unit, &u->path, "Path" }, |
Lennart Poettering | 871d7de | 2010-05-24 01:45:54 +0200 | [diff] [blame] | 1867 | |
Lennart Poettering | 10e87ee | 2010-06-16 01:58:50 +0200 | [diff] [blame] | 1868 | /* The [Install] section is ignored here. */ |
| 1869 | { "Alias", NULL, NULL, "Install" }, |
| 1870 | { "WantedBy", NULL, NULL, "Install" }, |
| 1871 | { "Also", NULL, NULL, "Install" }, |
| 1872 | |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 1873 | { NULL, NULL, NULL, NULL } |
| 1874 | }; |
| 1875 | |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1876 | #undef EXEC_CONTEXT_CONFIG_ITEMS |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 1877 | |
Lennart Poettering | 10e87ee | 2010-06-16 01:58:50 +0200 | [diff] [blame] | 1878 | const char *sections[4]; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1879 | int r; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1880 | Set *symlink_names; |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1881 | FILE *f = NULL; |
| 1882 | char *filename = NULL, *id = NULL; |
| 1883 | Unit *merged; |
Lennart Poettering | 45fb069 | 2010-07-17 00:57:51 +0200 | [diff] [blame] | 1884 | struct stat st; |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1885 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1886 | if (!u) { |
| 1887 | /* Dirty dirty hack. */ |
| 1888 | dump_items((FILE*) path, items); |
| 1889 | return 0; |
| 1890 | } |
| 1891 | |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1892 | assert(u); |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1893 | assert(path); |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 1894 | |
Lennart Poettering | 0947726 | 2010-04-15 23:20:17 +0200 | [diff] [blame] | 1895 | sections[0] = "Unit"; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1896 | sections[1] = section_table[u->meta.type]; |
Lennart Poettering | 10e87ee | 2010-06-16 01:58:50 +0200 | [diff] [blame] | 1897 | sections[2] = "Install"; |
| 1898 | sections[3] = NULL; |
Lennart Poettering | 42f4e3c | 2010-01-19 02:56:37 +0100 | [diff] [blame] | 1899 | |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1900 | if (!(symlink_names = set_new(string_hash_func, string_compare_func))) |
| 1901 | return -ENOMEM; |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 1902 | |
Lennart Poettering | 036643a | 2010-02-13 01:07:02 +0100 | [diff] [blame] | 1903 | if (path_is_absolute(path)) { |
| 1904 | |
| 1905 | if (!(filename = strdup(path))) { |
| 1906 | r = -ENOMEM; |
| 1907 | goto finish; |
| 1908 | } |
| 1909 | |
| 1910 | if ((r = open_follow(&filename, &f, symlink_names, &id)) < 0) { |
| 1911 | free(filename); |
| 1912 | filename = NULL; |
| 1913 | |
| 1914 | if (r != -ENOENT) |
| 1915 | goto finish; |
| 1916 | } |
| 1917 | |
| 1918 | } else { |
| 1919 | char **p; |
| 1920 | |
Lennart Poettering | 84e3543 | 2010-06-15 14:45:15 +0200 | [diff] [blame] | 1921 | STRV_FOREACH(p, u->meta.manager->lookup_paths.unit_path) { |
Lennart Poettering | 036643a | 2010-02-13 01:07:02 +0100 | [diff] [blame] | 1922 | |
| 1923 | /* Instead of opening the path right away, we manually |
| 1924 | * follow all symlinks and add their name to our unit |
| 1925 | * name set while doing so */ |
| 1926 | if (!(filename = path_make_absolute(path, *p))) { |
| 1927 | r = -ENOMEM; |
| 1928 | goto finish; |
| 1929 | } |
| 1930 | |
Lennart Poettering | fe51822 | 2010-07-11 00:52:00 +0200 | [diff] [blame] | 1931 | if (u->meta.manager->unit_path_cache && |
| 1932 | !set_get(u->meta.manager->unit_path_cache, filename)) |
| 1933 | r = -ENOENT; |
| 1934 | else |
| 1935 | r = open_follow(&filename, &f, symlink_names, &id); |
| 1936 | |
| 1937 | if (r < 0) { |
Lennart Poettering | 036643a | 2010-02-13 01:07:02 +0100 | [diff] [blame] | 1938 | char *sn; |
| 1939 | |
| 1940 | free(filename); |
| 1941 | filename = NULL; |
| 1942 | |
| 1943 | if (r != -ENOENT) |
| 1944 | goto finish; |
| 1945 | |
| 1946 | /* Empty the symlink names for the next run */ |
| 1947 | while ((sn = set_steal_first(symlink_names))) |
| 1948 | free(sn); |
| 1949 | |
| 1950 | continue; |
| 1951 | } |
| 1952 | |
| 1953 | break; |
| 1954 | } |
Lennart Poettering | 034c6ed | 2010-01-26 04:18:44 +0100 | [diff] [blame] | 1955 | } |
| 1956 | |
Lennart Poettering | 036643a | 2010-02-13 01:07:02 +0100 | [diff] [blame] | 1957 | if (!filename) { |
Lennart Poettering | 8f05424 | 2010-07-21 03:13:15 +0200 | [diff] [blame] | 1958 | /* Hmm, no suitable file found? */ |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1959 | r = 0; |
| 1960 | goto finish; |
| 1961 | } |
| 1962 | |
| 1963 | merged = u; |
| 1964 | if ((r = merge_by_names(&merged, symlink_names, id)) < 0) |
| 1965 | goto finish; |
| 1966 | |
| 1967 | if (merged != u) { |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 1968 | u->meta.load_state = UNIT_MERGED; |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1969 | r = 0; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1970 | goto finish; |
| 1971 | } |
| 1972 | |
Lennart Poettering | 45fb069 | 2010-07-17 00:57:51 +0200 | [diff] [blame] | 1973 | zero(st); |
| 1974 | if (fstat(fileno(f), &st) < 0) { |
| 1975 | r = -errno; |
| 1976 | goto finish; |
| 1977 | } |
| 1978 | |
Lennart Poettering | 00dc5d7 | 2010-10-08 02:31:36 +0200 | [diff] [blame] | 1979 | if (null_or_empty(&st)) |
Lennart Poettering | 6daf4f9 | 2010-10-08 18:21:52 +0200 | [diff] [blame] | 1980 | u->meta.load_state = UNIT_MASKED; |
Lennart Poettering | 00dc5d7 | 2010-10-08 02:31:36 +0200 | [diff] [blame] | 1981 | else { |
| 1982 | /* Now, parse the file contents */ |
| 1983 | if ((r = config_parse(filename, f, sections, items, false, u)) < 0) |
| 1984 | goto finish; |
| 1985 | |
| 1986 | u->meta.load_state = UNIT_LOADED; |
| 1987 | } |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1988 | |
Lennart Poettering | 6be1e7d | 2010-02-14 01:01:10 +0100 | [diff] [blame] | 1989 | free(u->meta.fragment_path); |
| 1990 | u->meta.fragment_path = filename; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1991 | filename = NULL; |
| 1992 | |
Lennart Poettering | 45fb069 | 2010-07-17 00:57:51 +0200 | [diff] [blame] | 1993 | u->meta.fragment_mtime = timespec_load(&st.st_mtim); |
| 1994 | |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 1995 | r = 0; |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 1996 | |
| 1997 | finish: |
Lennart Poettering | 53ec43c | 2010-06-15 02:45:26 +0200 | [diff] [blame] | 1998 | set_free_free(symlink_names); |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 1999 | free(filename); |
| 2000 | |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2001 | if (f) |
| 2002 | fclose(f); |
| 2003 | |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 2004 | return r; |
| 2005 | } |
| 2006 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 2007 | int unit_load_fragment(Unit *u) { |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2008 | int r; |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2009 | Iterator i; |
| 2010 | const char *t; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 2011 | |
| 2012 | assert(u); |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2013 | assert(u->meta.load_state == UNIT_STUB); |
| 2014 | assert(u->meta.id); |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 2015 | |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2016 | /* First, try to find the unit under its id. We always look |
| 2017 | * for unit files in the default directories, to make it easy |
| 2018 | * to override things by placing things in /etc/systemd/system */ |
| 2019 | if ((r = load_from_path(u, u->meta.id)) < 0) |
| 2020 | return r; |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2021 | |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2022 | /* Try to find an alias we can load this with */ |
| 2023 | if (u->meta.load_state == UNIT_STUB) |
| 2024 | SET_FOREACH(t, u->meta.names, i) { |
| 2025 | |
| 2026 | if (t == u->meta.id) |
| 2027 | continue; |
| 2028 | |
| 2029 | if ((r = load_from_path(u, t)) < 0) |
| 2030 | return r; |
| 2031 | |
| 2032 | if (u->meta.load_state != UNIT_STUB) |
| 2033 | break; |
| 2034 | } |
| 2035 | |
| 2036 | /* And now, try looking for it under the suggested (originally linked) path */ |
Lennart Poettering | 6ccb1b4 | 2010-09-27 20:31:23 +0200 | [diff] [blame] | 2037 | if (u->meta.load_state == UNIT_STUB && u->meta.fragment_path) { |
| 2038 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 2039 | if ((r = load_from_path(u, u->meta.fragment_path)) < 0) |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2040 | return r; |
| 2041 | |
Lennart Poettering | 6ccb1b4 | 2010-09-27 20:31:23 +0200 | [diff] [blame] | 2042 | if (u->meta.load_state == UNIT_STUB) { |
| 2043 | /* Hmm, this didn't work? Then let's get rid |
| 2044 | * of the fragment path stored for us, so that |
| 2045 | * we don't point to an invalid location. */ |
| 2046 | free(u->meta.fragment_path); |
| 2047 | u->meta.fragment_path = NULL; |
| 2048 | } |
| 2049 | } |
| 2050 | |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2051 | /* Look for a template */ |
| 2052 | if (u->meta.load_state == UNIT_STUB && u->meta.instance) { |
| 2053 | char *k; |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 2054 | |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2055 | if (!(k = unit_name_template(u->meta.id))) |
| 2056 | return -ENOMEM; |
| 2057 | |
| 2058 | r = load_from_path(u, k); |
| 2059 | free(k); |
| 2060 | |
| 2061 | if (r < 0) |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 2062 | return r; |
Lennart Poettering | 890f434 | 2010-02-14 01:08:20 +0100 | [diff] [blame] | 2063 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 2064 | if (u->meta.load_state == UNIT_STUB) |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2065 | SET_FOREACH(t, u->meta.names, i) { |
| 2066 | |
Lennart Poettering | 9e2f7c1 | 2010-04-15 03:11:11 +0200 | [diff] [blame] | 2067 | if (t == u->meta.id) |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2068 | continue; |
| 2069 | |
Lennart Poettering | 294d81f | 2010-07-21 03:28:10 +0200 | [diff] [blame] | 2070 | if (!(k = unit_name_template(t))) |
| 2071 | return -ENOMEM; |
| 2072 | |
| 2073 | r = load_from_path(u, k); |
| 2074 | free(k); |
| 2075 | |
| 2076 | if (r < 0) |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2077 | return r; |
| 2078 | |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 2079 | if (u->meta.load_state != UNIT_STUB) |
Lennart Poettering | 890f434 | 2010-02-14 01:08:20 +0100 | [diff] [blame] | 2080 | break; |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2081 | } |
Lennart Poettering | 0301abf | 2010-01-27 00:15:56 +0100 | [diff] [blame] | 2082 | } |
Lennart Poettering | 87f0e41 | 2010-01-26 21:39:06 +0100 | [diff] [blame] | 2083 | |
Lennart Poettering | 23a177e | 2010-04-06 02:43:58 +0200 | [diff] [blame] | 2084 | return 0; |
Lennart Poettering | 3efd419 | 2009-11-19 23:13:20 +0100 | [diff] [blame] | 2085 | } |
Lennart Poettering | e537352 | 2010-04-10 17:53:17 +0200 | [diff] [blame] | 2086 | |
| 2087 | void unit_dump_config_items(FILE *f) { |
| 2088 | /* OK, this wins a prize for extreme ugliness. */ |
| 2089 | |
| 2090 | load_from_path(NULL, (const void*) f); |
| 2091 | } |