chiark / gitweb /
core: rework syscall filter
[elogind.git] / src / core / load-fragment.c
index 72c46371e47eefb0d33165ec8375f983ec97fcd7..1b5856e27352adefc174a3b277fc9d55c5cf1017 100644 (file)
 #include <sys/time.h>
 #include <sys/resource.h>
 
+#ifdef HAVE_SECCOMP
+#include <seccomp.h>
+#endif
+
 #include "sd-messages.h"
 #include "unit.h"
 #include "strv.h"
 #include "missing.h"
 #include "unit-name.h"
 #include "unit-printf.h"
-#include "dbus-common.h"
 #include "utf8.h"
 #include "path-util.h"
-#include "syscall-list.h"
 #include "env-util.h"
 #include "cgroup.h"
+#include "bus-util.h"
+#include "bus-error.h"
+#include "errno-list.h"
 
-#ifndef HAVE_SYSV_COMPAT
-int config_parse_warn_compat(const char *unit,
-                             const char *filename,
-                             unsigned line,
-                             const char *section,
-                             const char *lvalue,
-                             int ltype,
-                             const char *rvalue,
-                             void *data,
-                             void *userdata) {
+#if !defined(HAVE_SYSV_COMPAT) || !defined(HAVE_SECCOMP)
+int config_parse_warn_compat(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
         log_syntax(unit, LOG_DEBUG, filename, line, EINVAL,
                    "Support for option %s= has been disabled at compile time and is ignored",
@@ -74,6 +81,7 @@ int config_parse_unit_deps(const char* unit,
                            const char *filename,
                            unsigned line,
                            const char *section,
+                           unsigned section_line,
                            const char *lvalue,
                            int ltype,
                            const char *rvalue,
@@ -118,6 +126,7 @@ int config_parse_unit_string_printf(const char *unit,
                                     const char *filename,
                                     unsigned line,
                                     const char *section,
+                                    unsigned section_line,
                                     const char *lvalue,
                                     int ltype,
                                     const char *rvalue,
@@ -138,7 +147,7 @@ int config_parse_unit_string_printf(const char *unit,
                 log_syntax(unit, LOG_ERR, filename, line, -r,
                            "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
 
-        return config_parse_string(unit, filename, line, section, lvalue, ltype,
+        return config_parse_string(unit, filename, line, section, section_line, lvalue, ltype,
                                    k ? k : rvalue, data, userdata);
 }
 
@@ -146,6 +155,7 @@ int config_parse_unit_strv_printf(const char *unit,
                                   const char *filename,
                                   unsigned line,
                                   const char *section,
+                                  unsigned section_line,
                                   const char *lvalue,
                                   int ltype,
                                   const char *rvalue,
@@ -166,7 +176,7 @@ int config_parse_unit_strv_printf(const char *unit,
                 log_syntax(unit, LOG_ERR, filename, line, -r,
                            "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
 
-        return config_parse_strv(unit, filename, line, section, lvalue, ltype,
+        return config_parse_strv(unit, filename, line, section, section_line, lvalue, ltype,
                                  k ? k : rvalue, data, userdata);
 }
 
@@ -174,6 +184,7 @@ int config_parse_unit_path_printf(const char *unit,
                                   const char *filename,
                                   unsigned line,
                                   const char *section,
+                                  unsigned section_line,
                                   const char *lvalue,
                                   int ltype,
                                   const char *rvalue,
@@ -194,7 +205,7 @@ int config_parse_unit_path_printf(const char *unit,
                 log_syntax(unit, LOG_ERR, filename, line, -r,
                            "Failed to resolve unit specifiers on %s, ignoring: %s", rvalue, strerror(-r));
 
-        return config_parse_path(unit, filename, line, section, lvalue, ltype,
+        return config_parse_path(unit, filename, line, section, section_line, lvalue, ltype,
                                  k ? k : rvalue, data, userdata);
 }
 
@@ -202,6 +213,7 @@ int config_parse_socket_listen(const char *unit,
                                const char *filename,
                                unsigned line,
                                const char *section,
+                               unsigned section_line,
                                const char *lvalue,
                                int ltype,
                                const char *rvalue,
@@ -297,6 +309,7 @@ int config_parse_socket_listen(const char *unit,
         }
 
         p->fd = -1;
+        p->socket = s;
 
         if (s->ports) {
                 LIST_FIND_TAIL(port, s->ports, tail);
@@ -311,6 +324,7 @@ int config_parse_socket_bind(const char *unit,
                              const char *filename,
                              unsigned line,
                              const char *section,
+                             unsigned section_line,
                              const char *lvalue,
                              int ltype,
                              const char *rvalue,
@@ -349,6 +363,7 @@ int config_parse_exec_nice(const char *unit,
                            const char *filename,
                            unsigned line,
                            const char *section,
+                           unsigned section_line,
                            const char *lvalue,
                            int ltype,
                            const char *rvalue,
@@ -386,6 +401,7 @@ int config_parse_exec_oom_score_adjust(const char* unit,
                                        const char *filename,
                                        unsigned line,
                                        const char *section,
+                                       unsigned section_line,
                                        const char *lvalue,
                                        int ltype,
                                        const char *rvalue,
@@ -423,6 +439,7 @@ int config_parse_exec(const char *unit,
                       const char *filename,
                       unsigned line,
                       const char *section,
+                      unsigned section_line,
                       const char *lvalue,
                       int ltype,
                       const char *rvalue,
@@ -594,6 +611,7 @@ int config_parse_socket_bindtodevice(const char* unit,
                                      const char *filename,
                                      unsigned line,
                                      const char *section,
+                                     unsigned section_line,
                                      const char *lvalue,
                                      int ltype,
                                      const char *rvalue,
@@ -628,6 +646,7 @@ int config_parse_exec_io_class(const char *unit,
                                const char *filename,
                                unsigned line,
                                const char *section,
+                               unsigned section_line,
                                const char *lvalue,
                                int ltype,
                                const char *rvalue,
@@ -659,6 +678,7 @@ int config_parse_exec_io_priority(const char *unit,
                                   const char *filename,
                                   unsigned line,
                                   const char *section,
+                                  unsigned section_line,
                                   const char *lvalue,
                                   int ltype,
                                   const char *rvalue,
@@ -690,6 +710,7 @@ int config_parse_exec_cpu_sched_policy(const char *unit,
                                        const char *filename,
                                        unsigned line,
                                        const char *section,
+                                       unsigned section_line,
                                        const char *lvalue,
                                        int ltype,
                                        const char *rvalue,
@@ -724,6 +745,7 @@ int config_parse_exec_cpu_sched_prio(const char *unit,
                                      const char *filename,
                                      unsigned line,
                                      const char *section,
+                                     unsigned section_line,
                                      const char *lvalue,
                                      int ltype,
                                      const char *rvalue,
@@ -765,6 +787,7 @@ int config_parse_exec_cpu_affinity(const char *unit,
                                    const char *filename,
                                    unsigned line,
                                    const char *section,
+                                   unsigned section_line,
                                    const char *lvalue,
                                    int ltype,
                                    const char *rvalue,
@@ -822,6 +845,7 @@ int config_parse_exec_capabilities(const char *unit,
                                    const char *filename,
                                    unsigned line,
                                    const char *section,
+                                   unsigned section_line,
                                    const char *lvalue,
                                    int ltype,
                                    const char *rvalue,
@@ -854,6 +878,7 @@ int config_parse_exec_secure_bits(const char *unit,
                                   const char *filename,
                                   unsigned line,
                                   const char *section,
+                                  unsigned section_line,
                                   const char *lvalue,
                                   int ltype,
                                   const char *rvalue,
@@ -903,6 +928,7 @@ int config_parse_bounding_set(const char *unit,
                               const char *filename,
                               unsigned line,
                               const char *section,
+                              unsigned section_line,
                               const char *lvalue,
                               int ltype,
                               const char *rvalue,
@@ -962,6 +988,7 @@ int config_parse_limit(const char *unit,
                        const char *filename,
                        unsigned line,
                        const char *section,
+                       unsigned section_line,
                        const char *lvalue,
                        int ltype,
                        const char *rvalue,
@@ -1006,6 +1033,7 @@ int config_parse_sysv_priority(const char *unit,
                                const char *filename,
                                unsigned line,
                                const char *section,
+                               unsigned section_line,
                                const char *lvalue,
                                int ltype,
                                const char *rvalue,
@@ -1038,6 +1066,7 @@ int config_parse_kill_signal(const char *unit,
                              const char *filename,
                              unsigned line,
                              const char *section,
+                             unsigned section_line,
                              const char *lvalue,
                              int ltype,
                              const char *rvalue,
@@ -1067,6 +1096,7 @@ int config_parse_exec_mount_flags(const char *unit,
                                   const char *filename,
                                   unsigned line,
                                   const char *section,
+                                  unsigned section_line,
                                   const char *lvalue,
                                   int ltype,
                                   const char *rvalue,
@@ -1113,6 +1143,7 @@ int config_parse_timer(const char *unit,
                        const char *filename,
                        unsigned line,
                        const char *section,
+                       unsigned section_line,
                        const char *lvalue,
                        int ltype,
                        const char *rvalue,
@@ -1183,6 +1214,7 @@ int config_parse_trigger_unit(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -1237,6 +1269,7 @@ int config_parse_path_spec(const char *unit,
                            const char *filename,
                            unsigned line,
                            const char *section,
+                           unsigned section_line,
                            const char *lvalue,
                            int ltype,
                            const char *rvalue,
@@ -1288,6 +1321,7 @@ int config_parse_path_spec(const char *unit,
         if (!s)
                 return log_oom();
 
+        s->unit = UNIT(p);
         s->path = path_kill_slashes(k);
         k = NULL;
         s->type = b;
@@ -1302,15 +1336,16 @@ int config_parse_socket_service(const char *unit,
                                 const char *filename,
                                 unsigned line,
                                 const char *section,
+                                unsigned section_line,
                                 const char *lvalue,
                                 int ltype,
                                 const char *rvalue,
                                 void *data,
                                 void *userdata) {
 
+        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         Socket *s = data;
         int r;
-        DBusError error;
         Unit *x;
         _cleanup_free_ char *p = NULL;
 
@@ -1319,25 +1354,20 @@ int config_parse_socket_service(const char *unit,
         assert(rvalue);
         assert(data);
 
-        dbus_error_init(&error);
-
         r = unit_name_printf(UNIT(s), rvalue, &p);
-        if (r < 0)
-                log_syntax(unit, LOG_ERR, filename, line, -r,
-                           "Failed to resolve specifiers, ignoring: %s", rvalue);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve specifiers, ignoring: %s", rvalue);
+                return 0;
+        }
 
-        if (!endswith(p ?: rvalue, ".service")) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Unit must be of type service, ignoring: %s", rvalue);
+        if (!endswith(p, ".service")) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Unit must be of type service, ignoring: %s", rvalue);
                 return 0;
         }
 
-        r = manager_load_unit(UNIT(s)->manager, p ?: rvalue, NULL, &error, &x);
+        r = manager_load_unit(UNIT(s)->manager, p, NULL, &error, &x);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r,
-                           "Failed to load unit %s, ignoring: %s",
-                           rvalue, bus_error(&error, r));
-                dbus_error_free(&error);
+                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r));
                 return 0;
         }
 
@@ -1350,6 +1380,7 @@ int config_parse_service_sockets(const char *unit,
                                  const char *filename,
                                  unsigned line,
                                  const char *section,
+                                 unsigned section_line,
                                  const char *lvalue,
                                  int ltype,
                                  const char *rvalue,
@@ -1402,6 +1433,7 @@ int config_parse_service_timeout(const char *unit,
                                  const char *filename,
                                  unsigned line,
                                  const char *section,
+                                 unsigned section_line,
                                  const char *lvalue,
                                  int ltype,
                                  const char *rvalue,
@@ -1416,7 +1448,7 @@ int config_parse_service_timeout(const char *unit,
         assert(rvalue);
         assert(s);
 
-        r = config_parse_sec(unit, filename, line, section, lvalue, ltype,
+        r = config_parse_sec(unit, filename, line, section, section_line, lvalue, ltype,
                              rvalue, data, userdata);
         if (r < 0)
                 return r;
@@ -1430,10 +1462,56 @@ int config_parse_service_timeout(const char *unit,
         return 0;
 }
 
+int config_parse_busname_service(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+        BusName *n = data;
+        int r;
+        Unit *x;
+        _cleanup_free_ char *p = NULL;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = unit_name_printf(UNIT(n), rvalue, &p);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve specifiers, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        if (!endswith(p, ".service")) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Unit must be of type service, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        r = manager_load_unit(UNIT(n)->manager, p, NULL, &error, &x);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r));
+                return 0;
+        }
+
+        unit_ref_set(&n->service, x);
+
+        return 0;
+}
+
 int config_parse_unit_env_file(const char *unit,
                                const char *filename,
                                unsigned line,
                                const char *section,
+                               unsigned section_line,
                                const char *lvalue,
                                int ltype,
                                const char *rvalue,
@@ -1481,6 +1559,7 @@ int config_parse_environ(const char *unit,
                          const char *filename,
                          unsigned line,
                          const char *section,
+                         unsigned section_line,
                          const char *lvalue,
                          int ltype,
                          const char *rvalue,
@@ -1546,6 +1625,7 @@ int config_parse_ip_tos(const char *unit,
                         const char *filename,
                         unsigned line,
                         const char *section,
+                        unsigned section_line,
                         const char *lvalue,
                         int ltype,
                         const char *rvalue,
@@ -1574,6 +1654,7 @@ int config_parse_unit_condition_path(const char *unit,
                                      const char *filename,
                                      unsigned line,
                                      const char *section,
+                                     unsigned section_line,
                                      const char *lvalue,
                                      int ltype,
                                      const char *rvalue,
@@ -1635,6 +1716,7 @@ int config_parse_unit_condition_string(const char *unit,
                                        const char *filename,
                                        unsigned line,
                                        const char *section,
+                                       unsigned section_line,
                                        const char *lvalue,
                                        int ltype,
                                        const char *rvalue,
@@ -1690,6 +1772,7 @@ int config_parse_unit_condition_null(const char *unit,
                                      const char *filename,
                                      unsigned line,
                                      const char *section,
+                                     unsigned section_line,
                                      const char *lvalue,
                                      int ltype,
                                      const char *rvalue,
@@ -1748,6 +1831,7 @@ int config_parse_unit_requires_mounts_for(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -1793,6 +1877,7 @@ int config_parse_documentation(const char *unit,
                                const char *filename,
                                unsigned line,
                                const char *section,
+                               unsigned section_line,
                                const char *lvalue,
                                int ltype,
                                const char *rvalue,
@@ -1815,7 +1900,7 @@ int config_parse_documentation(const char *unit,
                 return 0;
         }
 
-        r = config_parse_unit_strv_printf(unit, filename, line, section, lvalue, ltype,
+        r = config_parse_unit_strv_printf(unit, filename, line, section, section_line, lvalue, ltype,
                                           rvalue, data, userdata);
         if (r < 0)
                 return r;
@@ -1836,32 +1921,32 @@ int config_parse_documentation(const char *unit,
         return r;
 }
 
-static void syscall_set(uint32_t *p, int nr) {
-        nr = SYSCALL_TO_INDEX(nr);
-        p[nr >> 4] |= 1 << (nr & 31);
-}
-
-static void syscall_unset(uint32_t *p, int nr) {
-        nr = SYSCALL_TO_INDEX(nr);
-        p[nr >> 4] &= ~(1 << (nr & 31));
-}
+#ifdef HAVE_SECCOMP
+int config_parse_syscall_filter(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
-int config_parse_syscall_filter(const char *unit,
-                                const char *filename,
-                                unsigned line,
-                                const char *section,
-                                const char *lvalue,
-                                int ltype,
-                                const char *rvalue,
-                                void *data,
-                                void *userdata) {
+        static const char default_syscalls[] =
+                "execve\0"
+                "exit\0"
+                "exit_group\0"
+                "rt_sigreturn\0"
+                "sigreturn\0";
 
         ExecContext *c = data;
         Unit *u = userdata;
         bool invert = false;
-        char *w;
+        char *w, *state;
         size_t l;
-        char *state;
+        int r;
 
         assert(filename);
         assert(lvalue);
@@ -1870,8 +1955,9 @@ int config_parse_syscall_filter(const char *unit,
 
         if (isempty(rvalue)) {
                 /* Empty assignment resets the list */
-                free(c->syscall_filter);
+                set_free(c->syscall_filter);
                 c->syscall_filter = NULL;
+                c->syscall_whitelist = false;
                 return 0;
         }
 
@@ -1881,44 +1967,61 @@ int config_parse_syscall_filter(const char *unit,
         }
 
         if (!c->syscall_filter) {
-                size_t n;
-
-                n = (syscall_max() + 31) >> 4;
-                c->syscall_filter = new(uint32_t, n);
+                c->syscall_filter = set_new(trivial_hash_func, trivial_compare_func);
                 if (!c->syscall_filter)
                         return log_oom();
 
-                memset(c->syscall_filter, invert ? 0xFF : 0, n * sizeof(uint32_t));
+                if (invert)
+                        /* Allow everything but the ones listed */
+                        c->syscall_whitelist = false;
+                else {
+                        const char *i;
 
-                /* Add these by default */
-                syscall_set(c->syscall_filter, __NR_execve);
-                syscall_set(c->syscall_filter, __NR_rt_sigreturn);
-#ifdef __NR_sigreturn
-                syscall_set(c->syscall_filter, __NR_sigreturn);
-#endif
-                syscall_set(c->syscall_filter, __NR_exit_group);
-                syscall_set(c->syscall_filter, __NR_exit);
+                        /* Allow nothing but the ones listed */
+                        c->syscall_whitelist = true;
+
+                        /* Accept default syscalls if we are on a whitelist */
+                        NULSTR_FOREACH(i, default_syscalls)  {
+                                int id;
+
+                                id = seccomp_syscall_resolve_name(i);
+                                if (id < 0)
+                                        continue;
+
+                                r = set_put(c->syscall_filter, INT_TO_PTR(id + 1));
+                                if (r == -EEXIST)
+                                        continue;
+                                if (r < 0)
+                                        return log_oom();
+                        }
+                }
         }
 
         FOREACH_WORD_QUOTED(w, l, rvalue, state) {
-                int id;
                 _cleanup_free_ char *t = NULL;
+                int id;
 
                 t = strndup(w, l);
                 if (!t)
                         return log_oom();
 
-                id = syscall_from_name(t);
+                id = seccomp_syscall_resolve_name(t);
                 if (id < 0)  {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                                   "Failed to parse syscall, ignoring: %s", t);
+                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse system call, ignoring: %s", t);
                         continue;
                 }
 
-                if (invert)
-                        syscall_unset(c->syscall_filter, id);
-                else
-                        syscall_set(c->syscall_filter, id);
+                /* If we previously wanted to forbid a syscall and now
+                 * we want to allow it, then remove it from the list
+                 */
+                if (!invert == c->syscall_whitelist)  {
+                        r = set_put(c->syscall_filter, INT_TO_PTR(id + 1));
+                        if (r == -EEXIST)
+                                continue;
+                        if (r < 0)
+                                return log_oom();
+                } else
+                        set_remove(c->syscall_filter, INT_TO_PTR(id + 1));
         }
 
         c->no_new_privileges = true;
@@ -1926,11 +2029,48 @@ int config_parse_syscall_filter(const char *unit,
         return 0;
 }
 
+int config_parse_syscall_errno(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        ExecContext *c = data;
+        int e;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+
+        if (isempty(rvalue)) {
+                /* Empty assignment resets to KILL */
+                c->syscall_errno = 0;
+                return 0;
+        }
+
+        e = errno_from_name(rvalue);
+        if (e < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse error number, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        c->syscall_errno = e;
+        return 0;
+}
+#endif
+
 int config_parse_unit_slice(
                 const char *unit,
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -1980,6 +2120,7 @@ int config_parse_cpu_shares(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -2015,6 +2156,7 @@ int config_parse_memory_limit(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -2048,6 +2190,7 @@ int config_parse_device_allow(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -2107,6 +2250,7 @@ int config_parse_blockio_weight(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -2143,6 +2287,7 @@ int config_parse_blockio_device_weight(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -2213,6 +2358,7 @@ int config_parse_blockio_bandwidth(
                 const char *filename,
                 unsigned line,
                 const char *section,
+                unsigned section_line,
                 const char *lvalue,
                 int ltype,
                 const char *rvalue,
@@ -2285,6 +2431,37 @@ int config_parse_blockio_bandwidth(
         return 0;
 }
 
+DEFINE_CONFIG_PARSE_ENUM(config_parse_job_mode, job_mode, JobMode, "Failed to parse job mode");
+
+int config_parse_job_mode_isolate(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        JobMode *m = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+
+        r = parse_boolean(rvalue);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse boolean, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        *m = r ? JOB_ISOLATE : JOB_REPLACE;
+        return 0;
+}
+
 #define FOLLOW_MAX 8
 
 static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
@@ -2312,9 +2489,9 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
                 /* Add the file name we are currently looking at to
                  * the names of this unit, but only if it is a valid
                  * unit name. */
-                name = path_get_file_name(*filename);
+                name = basename(*filename);
 
-                if (unit_name_is_valid(name, true)) {
+                if (unit_name_is_valid(name, TEMPLATE_VALID)) {
 
                         id = set_get(names, name);
                         if (!id) {
@@ -2561,31 +2738,28 @@ int unit_load_fragment(Unit *u) {
 
         /* Look for a template */
         if (u->load_state == UNIT_STUB && u->instance) {
-                char *k;
+                _cleanup_free_ char *k;
 
                 k = unit_name_template(u->id);
                 if (!k)
                         return -ENOMEM;
 
                 r = load_from_path(u, k);
-                free(k);
-
                 if (r < 0)
                         return r;
 
                 if (u->load_state == UNIT_STUB)
                         SET_FOREACH(t, u->names, i) {
+                                _cleanup_free_ char *z = NULL;
 
                                 if (t == u->id)
                                         continue;
 
-                                k = unit_name_template(t);
-                                if (!k)
+                                z = unit_name_template(t);
+                                if (!z)
                                         return -ENOMEM;
 
-                                r = load_from_path(u, k);
-                                free(k);
-
+                                r = load_from_path(u, z);
                                 if (r < 0)
                                         return r;
 
@@ -2602,6 +2776,9 @@ void unit_dump_config_items(FILE *f) {
                 const ConfigParserCallback callback;
                 const char *rvalue;
         } table[] = {
+#if !defined(HAVE_SYSV_COMPAT) || !defined(HAVE_SECCOMP)
+                { config_parse_warn_compat,           "NOTSUPPORTED" },
+#endif
                 { config_parse_int,                   "INTEGER" },
                 { config_parse_unsigned,              "UNSIGNED" },
                 { config_parse_bytes_size,            "SIZE" },
@@ -2633,8 +2810,6 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_service_restart,       "SERVICERESTART" },
 #ifdef HAVE_SYSV_COMPAT
                 { config_parse_sysv_priority,         "SYSVPRIORITY" },
-#else
-                { config_parse_warn_compat,           "NOTSUPPORTED" },
 #endif
                 { config_parse_kill_mode,             "KILLMODE" },
                 { config_parse_kill_signal,           "SIGNAL" },
@@ -2662,7 +2837,10 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_set_status,            "STATUS" },
                 { config_parse_service_sockets,       "SOCKETS" },
                 { config_parse_environ,               "ENVIRON" },
-                { config_parse_syscall_filter,        "SYSCALL" },
+#ifdef HAVE_SECCOMP
+                { config_parse_syscall_filter,        "SYSCALLS" },
+                { config_parse_syscall_errno,         "ERRNO" },
+#endif
                 { config_parse_cpu_shares,            "SHARES" },
                 { config_parse_memory_limit,          "LIMIT" },
                 { config_parse_device_allow,          "DEVICE" },