diff options
Diffstat (limited to 'src/machine/machine.c')
-rw-r--r-- | src/machine/machine.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index 7ab84607fb..196bc4b8f4 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -25,18 +25,24 @@ #include "sd-messages.h" +#include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" +#include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hashmap.h" +#include "machine-dbus.h" +#include "machine.h" #include "mkdir.h" +#include "parse-util.h" #include "special.h" +#include "string-table.h" #include "terminal-util.h" #include "unit-name.h" #include "util.h" -#include "machine-dbus.h" -#include "machine.h" +#include "extract-word.h" Machine* machine_new(Manager *manager, MachineClass class, const char *name) { Machine *m; @@ -307,19 +313,26 @@ int machine_load(Machine *m) { } if (netif) { - size_t l, allocated = 0, nr = 0; - const char *word, *state; + size_t allocated = 0, nr = 0; + const char *p; int *ni = NULL; - FOREACH_WORD(word, l, netif, state) { - char buf[l+1]; + p = netif; + for(;;) { + _cleanup_free_ char *word = NULL; int ifi; - *(char*) (mempcpy(buf, word, l)) = 0; + r = extract_first_word(&p, &word, NULL, 0); + if (r == 0) + break; + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_warning_errno(r, "Failed to parse NETIF: %s", netif); + break; + } - if (safe_atoi(buf, &ifi) < 0) - continue; - if (ifi <= 0) + if (parse_ifindex(word, &ifi) < 0) continue; if (!GREEDY_REALLOC(ni, allocated, nr+1)) { @@ -539,7 +552,7 @@ int machine_kill(Machine *m, KillWho who, int signo) { return 0; } - /* Otherwise make PID 1 do it for us, for the entire cgroup */ + /* Otherwise, make PID 1 do it for us, for the entire cgroup */ return manager_kill_unit(m->manager, m->unit, signo, NULL); } |