]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Mar 2021 16:51:34 +0000 (17:51 +0100)
committerGitHub <noreply@github.com>
Fri, 5 Mar 2021 16:51:34 +0000 (17:51 +0100)
tree-wide: use UINT64_MAX or friends

62 files changed:
hwdb.d/60-evdev.hwdb
man/journald.conf.xml
man/systemd.link.xml
src/basic/copy.c
src/basic/copy.h
src/basic/fileio.c
src/basic/fileio.h
src/basic/strv.c
src/basic/strv.h
src/firstboot/firstboot.c
src/journal/journald-server.c
src/libsystemd-network/sd-dhcp-server.c
src/network/netdev/netdev.c
src/network/networkd-network.c
src/shared/install.c
src/sysusers/sysusers.c
src/test/test-device-nodes.c
src/test/test-strv.c
src/udev/net/link-config.c
src/udev/udev-event.c
src/udev/udev-rules.c
test/TEST-17-UDEV-WANTS/test.sh [deleted file]
test/TEST-17-UDEV/Makefile [moved from test/TEST-17-UDEV-WANTS/Makefile with 100% similarity]
test/TEST-17-UDEV/test.sh [moved from test/TEST-29-UDEV-ID_RENAMING/test.sh with 61% similarity]
test/TEST-29-PORTABLE/Makefile [moved from test/TEST-29-UDEV-ID_RENAMING/Makefile with 100% similarity]
test/TEST-29-PORTABLE/test.sh [moved from test/TEST-58-PORTABLE/test.sh with 97% similarity]
test/TEST-49-RUNTIME-BIND-PATHS/Makefile [moved from test/TEST-49-UDEV-EVENT-TIMEOUT/Makefile with 100% similarity]
test/TEST-49-RUNTIME-BIND-PATHS/test.sh [moved from test/TEST-57-RUNTIME-BIND-PATHS/test.sh with 89% similarity]
test/TEST-49-UDEV-EVENT-TIMEOUT/test.sh [deleted file]
test/TEST-55-OOMD/Makefile [moved from test/TEST-55-UDEV-TAGS/Makefile with 100% similarity]
test/TEST-55-OOMD/test.sh [moved from test/TEST-56-OOMD/test.sh with 98% similarity]
test/TEST-55-UDEV-TAGS/test.sh [deleted file]
test/TEST-56-OOMD/Makefile [deleted symlink]
test/TEST-57-RUNTIME-BIND-PATHS/Makefile [deleted symlink]
test/TEST-58-PORTABLE/Makefile [deleted symlink]
test/units/testsuite-17.01.sh [new file with mode: 0755]
test/units/testsuite-17.02.sh [new file with mode: 0755]
test/units/testsuite-17.03.sh [new file with mode: 0755]
test/units/testsuite-17.04.sh [new file with mode: 0755]
test/units/testsuite-17.05.sh [new file with mode: 0755]
test/units/testsuite-17.service
test/units/testsuite-17.sh
test/units/testsuite-29.service
test/units/testsuite-29.sh
test/units/testsuite-49-namespaced.service [moved from test/units/testsuite-57-namespaced.service with 89% similarity]
test/units/testsuite-49-non-namespaced.service [moved from test/units/testsuite-57-non-namespaced.service with 100% similarity]
test/units/testsuite-49.service
test/units/testsuite-49.sh
test/units/testsuite-55-slowgrowth.sh [moved from test/units/testsuite-56-slowgrowth.sh with 100% similarity]
test/units/testsuite-55-testbloat.service [moved from test/units/testsuite-56-testbloat.service with 68% similarity]
test/units/testsuite-55-testchill.service [moved from test/units/testsuite-56-testchill.service with 68% similarity]
test/units/testsuite-55-testmunch.service [new file with mode: 0644]
test/units/testsuite-55-workload.slice [moved from test/units/testsuite-56-workload.slice with 100% similarity]
test/units/testsuite-55.service
test/units/testsuite-55.sh
test/units/testsuite-56-testmunch.service [deleted file]
test/units/testsuite-56.service [deleted file]
test/units/testsuite-56.sh [deleted file]
test/units/testsuite-57.service [deleted file]
test/units/testsuite-57.sh [deleted file]
test/units/testsuite-58.service [deleted file]
test/units/testsuite-58.sh [deleted file]

index 081d0b297f0ede1ad766b59d9ffc30bb3239b283..82a92cf5478364d6e3a7fe6be7238a8bfa27d2d4 100644 (file)
@@ -265,10 +265,10 @@ evdev:name:AlpsPS/2 ALPS GlidePoint:dmi:bvn*:bvr*:bd*:svnDellInc.:pnLatitudeE725
 
 # Dell Latitude E7470
 evdev:name:AlpsPS/2 ALPS DualPoint TouchPad:dmi:bvn*:bvr*:bd*:svnDellInc.:pnLatitudeE7470:*
- EVDEV_ABS_00=29:2930:30
- EVDEV_ABS_01=26:1533:29
- EVDEV_ABS_35=29:2930:30
- EVDEV_ABS_36=26:1533:29
+ EVDEV_ABS_00=29:2930:30:16
+ EVDEV_ABS_01=26:1533:29:16
+ EVDEV_ABS_35=29:2930:30:16
+ EVDEV_ABS_36=26:1533:29:16
 
 # Dell Precision 5510
 evdev:name:SynPS/2 Synaptics TouchPad:dmi:bvn*:bvr*:bd*:svnDellInc.:pnPrecision5510:*
index 959815a8f183c38d6db4fbba06a19dded3fbccb7..86137a951de82bfe6f668629e0a4663b519ab51a 100644 (file)
@@ -28,6 +28,9 @@
     <para><filename>/run/systemd/journald.conf.d/*.conf</filename></para>
     <para><filename>/usr/lib/systemd/journald.conf.d/*.conf</filename></para>
     <para><filename>/etc/systemd/journald@<replaceable>NAMESPACE</replaceable>.conf</filename></para>
+    <para><filename>/etc/systemd/journald@<replaceable>NAMESPACE</replaceable>.conf.d/*.conf</filename></para>
+    <para><filename>/run/systemd/journald@<replaceable>NAMESPACE</replaceable>.conf.d/*.conf</filename></para>
+    <para><filename>/usr/lib/systemd/journald@<replaceable>NAMESPACE</replaceable>.conf.d/*.conf</filename></para>
   </refsynopsisdiv>
 
   <refsect1>
@@ -41,8 +44,9 @@
 
     <para>The <command>systemd-journald</command> instance managing the default namespace is configured by
     <filename>/etc/systemd/journald.conf</filename> and associated drop-ins. Instances managing other
-    namespaces read <filename>/etc/systemd/journald@<replaceable>NAMESPACE</replaceable>.conf</filename> with
-    the namespace identifier filled in. This allows each namespace to carry a distinct configuration. See
+    namespaces read <filename>/etc/systemd/journald@<replaceable>NAMESPACE</replaceable>.conf</filename>
+    and associated drop-ins with the namespace identifier filled in. This allows each namespace to carry
+    a distinct configuration. See
     <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
     for details about journal namespaces.</para>
   </refsect1>
index 93f7191b3321109aad8f875d0280e3fb9d8abce9..5918a32189810c54190d92e19aa6343ce3ad519a 100644 (file)
     <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry> for a
     general description of the syntax.</para>
 
-    <para>The link files are read from the files located in the system
-    network directory <filename>/usr/lib/systemd/network</filename>,
-    the volatile runtime network directory
-    <filename>/run/systemd/network</filename>, and the local
-    administration network directory
-    <filename>/etc/systemd/network</filename>. Link files must have
-    the extension <filename>.link</filename>; other extensions are
-    ignored. All link files are collectively sorted and processed in
-    lexical order, regardless of the directories in which they live.
-    However, files with identical filenames replace each other. Files
-    in <filename>/etc/</filename> have the highest priority, files in
-    <filename>/run/</filename> take precedence over files with the same
-    name in <filename>/usr/lib/</filename>. This can be used to
-    override a system-supplied link file with a local file if needed.
-    As a special case, an empty file (file size 0) or symlink with the
-    same name pointing to <filename>/dev/null</filename> disables the
-    configuration file entirely (it is "masked").</para>
+    <para>The link files are read from the files located in the system network directory
+    <filename>/usr/lib/systemd/network</filename>, the volatile runtime network directory
+    <filename>/run/systemd/network</filename>, and the local administration network directory
+    <filename>/etc/systemd/network</filename>. Link files must have the extension
+    <filename>.link</filename>; other extensions are ignored. All link files are collectively sorted
+    and processed in lexical order, regardless of the directories in which they live. However, files
+    with identical filenames replace each other. Files in <filename>/etc/</filename> have the highest
+    priority, files in <filename>/run/</filename> take precedence over files with the same name in
+    <filename>/usr/lib/</filename>. This can be used to override a system-supplied link file with a
+    local file if needed. As a special case, an empty file (file size 0) or symlink with the same name
+    pointing to <filename>/dev/null</filename> disables the configuration file entirely (it is
+    "masked").</para>
+
+    <para>Along with the link file <filename>foo.link</filename>, a "drop-in" directory
+    <filename>foo.link.d/</filename> may exist. All files with the suffix <literal>.conf</literal>
+    from this directory will be parsed after the file itself is parsed. This is useful to alter or add
+    configuration settings, without having to modify the main configuration file. Each drop-in file
+    must have appropriate section headers.</para>
+
+    <para>In addition to <filename>/etc/systemd/network</filename>, drop-in <literal>.d</literal>
+    directories can be placed in <filename>/usr/lib/systemd/network</filename> or
+    <filename>/run/systemd/network</filename> directories. Drop-in files in <filename>/etc/</filename>
+    take precedence over those in <filename>/run/</filename> which in turn take precedence over those
+    in <filename>/usr/lib/</filename>. Drop-in files under any of these directories take precedence
+    over the main link file wherever located.</para>
 
     <para>The link file contains a [Match] section, which determines if a given link file may be applied to a
     given device, as well as a [Link] section specifying how the device should be configured. The first (in
index 6391e34ed63c82e7067d722e1c0ebabca06e2a17..d25777cc4b47a030b03014ab1b55aea20d323a43 100644 (file)
@@ -1147,24 +1147,24 @@ int copy_file_atomic_full(
          * writing it. */
 
         if (copy_flags & COPY_REPLACE) {
-                r = tempfn_random(to, NULL, &t);
+                _cleanup_free_ char *f = NULL;
+
+                r = tempfn_random(to, NULL, &f);
                 if (r < 0)
                         return r;
 
                 if (copy_flags & COPY_MAC_CREATE) {
                         r = mac_selinux_create_file_prepare(to, S_IFREG);
-                        if (r < 0) {
-                                t = mfree(t);
+                        if (r < 0)
                                 return r;
-                        }
                 }
-                fdt = open(t, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|O_WRONLY|O_CLOEXEC, 0600);
+                fdt = open(f, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|O_WRONLY|O_CLOEXEC, 0600);
                 if (copy_flags & COPY_MAC_CREATE)
                         mac_selinux_create_file_clear();
-                if (fdt < 0) {
-                        t = mfree(t);
+                if (fdt < 0)
                         return -errno;
-                }
+
+                t = TAKE_PTR(f);
         } else {
                 if (copy_flags & COPY_MAC_CREATE) {
                         r = mac_selinux_create_file_prepare(to, S_IFREG);
@@ -1232,6 +1232,8 @@ int copy_access(int fdf, int fdt) {
         assert(fdf >= 0);
         assert(fdt >= 0);
 
+        /* Copies just the access mode (and not the ownership) from fdf to fdt */
+
         if (fstat(fdf, &st) < 0)
                 return -errno;
 
@@ -1241,6 +1243,20 @@ int copy_access(int fdf, int fdt) {
         return 0;
 }
 
+int copy_rights(int fdf, int fdt) {
+        struct stat st;
+
+        assert(fdf >= 0);
+        assert(fdt >= 0);
+
+        /* Copies both access mode and ownership from fdf to fdt */
+
+        if (fstat(fdf, &st) < 0)
+                return -errno;
+
+        return fchmod_and_chown(fdt, st.st_mode & 07777, st.st_uid, st.st_gid);
+}
+
 int copy_xattr(int fdf, int fdt) {
         _cleanup_free_ char *names = NULL;
         int ret = 0, r;
index b583dff2c09e966a1ce78956668f927247cc8707..da3ba07ad27868c27221756321cdad44a17d846d 100644 (file)
@@ -64,4 +64,5 @@ static inline int copy_bytes(int fdf, int fdt, uint64_t max_bytes, CopyFlags cop
 
 int copy_times(int fdf, int fdt, CopyFlags flags);
 int copy_access(int fdf, int fdt);
+int copy_rights(int fdf, int fdt);
 int copy_xattr(int fdf, int fdt);
index 596946ccf4982d6a6fc87e23413bdea34b48e2e5..8560982aab209b0f2624e7a4c2bc90018be1e303 100644 (file)
@@ -1327,15 +1327,6 @@ int warn_file_is_world_accessible(const char *filename, struct stat *st, const c
         return 0;
 }
 
-int sync_rights(int from, int to) {
-        struct stat st;
-
-        if (fstat(from, &st) < 0)
-                return -errno;
-
-        return fchmod_and_chown(to, st.st_mode & 07777, st.st_uid, st.st_gid);
-}
-
 int rename_and_apply_smack_floor_label(const char *from, const char *to) {
         int r = 0;
         if (rename(from, to) < 0)
index 498e88035483cfa5716dcb8f521613bafb4a2f88..64a30ab7bb12df0236c776366a733c5670c7da71 100644 (file)
@@ -118,6 +118,4 @@ int safe_fgetc(FILE *f, char *ret);
 
 int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line);
 
-int sync_rights(int from, int to);
-
 int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path);
index 492dfe40023a6056cc686debb3ed36d53c014a0f..765da04a7bd972cc040779c27c07c25c16e71181 100644 (file)
@@ -240,27 +240,28 @@ int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix) {
         return 0;
 }
 
-char **strv_split_newlines(const char *s) {
-        char **l;
+int strv_split_newlines_full(char ***ret, const char *s, ExtractFlags flags) {
+        _cleanup_strv_free_ char **l = NULL;
         size_t n;
+        int r;
 
         assert(s);
 
-        /* Special version of strv_split() that splits on newlines and
-         * suppresses an empty string at the end */
+        /* Special version of strv_split_full() that splits on newlines and
+         * suppresses an empty string at the end. */
 
-        l = strv_split(s, NEWLINE);
-        if (!l)
-                return NULL;
+        r = strv_split_full(&l, s, NEWLINE, flags);
+        if (r < 0)
+                return r;
 
         n = strv_length(l);
-        if (n <= 0)
-                return l;
-
-        if (isempty(l[n - 1]))
+        if (n > 0 && isempty(l[n - 1])) {
                 l[n - 1] = mfree(l[n - 1]);
+                n--;
+        }
 
-        return l;
+        *ret = TAKE_PTR(l);
+        return n;
 }
 
 int strv_split_full(char ***t, const char *s, const char *separators, ExtractFlags flags) {
index 6b3e8e7f8600f57c8e4e99188c8a5b02a03e8136..911528fab495a9d761211ccfd8f7116f168a526b 100644 (file)
@@ -73,15 +73,21 @@ static inline bool strv_isempty(char * const *l) {
         return !l || !*l;
 }
 
-char **strv_split_newlines(const char *s);
-
 int strv_split_full(char ***t, const char *s, const char *separators, ExtractFlags flags);
 static inline char **strv_split(const char *s, const char *separators) {
         char **ret;
-        int r;
 
-        r = strv_split_full(&ret, s, separators, 0);
-        if (r < 0)
+        if (strv_split_full(&ret, s, separators, 0) < 0)
+                return NULL;
+
+        return ret;
+}
+
+int strv_split_newlines_full(char ***ret, const char *s, ExtractFlags flags);
+static inline char **strv_split_newlines(const char *s) {
+        char **ret;
+
+        if (strv_split_newlines_full(&ret, s, 0) < 0)
                 return NULL;
 
         return ret;
index feb682792d7b36dde1876df42222f823cb4f00fd..8e3028717e79dbccc4d07acb3e93d9e331befabb 100644 (file)
@@ -675,7 +675,7 @@ static int write_root_passwd(const char *passwd_path, const char *password, cons
         if (original) {
                 struct passwd *i;
 
-                r = sync_rights(fileno(original), fileno(passwd));
+                r = copy_rights(fileno(original), fileno(passwd));
                 if (r < 0)
                         return r;
 
@@ -743,7 +743,7 @@ static int write_root_shadow(const char *shadow_path, const char *hashed_passwor
         if (original) {
                 struct spwd *i;
 
-                r = sync_rights(fileno(original), fileno(shadow));
+                r = copy_rights(fileno(original), fileno(shadow));
                 if (r < 0)
                         return r;
 
index e76c13a3b65195ac818823fb5112df4e7ca1a341..6d87fa0f844bf16b8fe4b9cc3b40a35854259465 100644 (file)
@@ -1625,17 +1625,19 @@ static int server_parse_config_file(Server *s) {
         assert(s);
 
         if (s->namespace) {
-                const char *namespaced;
+                const char *namespaced, *dropin_dirname;
 
                 /* If we are running in namespace mode, load the namespace specific configuration file, and nothing else */
                 namespaced = strjoina(PKGSYSCONFDIR "/journald@", s->namespace, ".conf");
-
-                r = config_parse(NULL,
-                                 namespaced, NULL,
-                                 "Journal\0",
-                                 config_item_perf_lookup, journald_gperf_lookup,
-                                 CONFIG_PARSE_WARN, s,
-                                 NULL);
+                dropin_dirname = strjoina("journald@", s->namespace, ".conf.d");
+
+                r = config_parse_many(
+                                STRV_MAKE_CONST(namespaced),
+                                (const char* const*) CONF_PATHS_STRV("systemd"),
+                                dropin_dirname,
+                                "Journal\0",
+                                config_item_perf_lookup, journald_gperf_lookup,
+                                CONFIG_PARSE_WARN, s, NULL);
                 if (r < 0)
                         return r;
 
index d0e249b104b9cdedb0c495b456b10c9486090392..2b1384cff085ae78785ebd63a92289debf1b1029 100644 (file)
@@ -425,66 +425,23 @@ static int server_message_init(sd_dhcp_server *server, DHCPPacket **ret,
         return 0;
 }
 
-static int server_send_offer(sd_dhcp_server *server, DHCPRequest *req,
-                             be32_t address) {
-        _cleanup_free_ DHCPPacket *packet = NULL;
-        size_t offset;
-        be32_t lease_time;
-        int r;
-
-        r = server_message_init(server, &packet, DHCP_OFFER, &offset, req);
-        if (r < 0)
-                return r;
-
-        packet->dhcp.yiaddr = address;
-
-        lease_time = htobe32(req->lifetime);
-        r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0,
-                               SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME, 4,
-                               &lease_time);
-        if (r < 0)
-                return r;
-
-        r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0,
-                               SD_DHCP_OPTION_SUBNET_MASK, 4, &server->netmask);
-        if (r < 0)
-                return r;
-
-        if (server->emit_router) {
-                r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0,
-                                       SD_DHCP_OPTION_ROUTER, 4, &server->address);
-                if (r < 0)
-                        return r;
-        }
-
-        r = dhcp_server_send_packet(server, req, packet, DHCP_OFFER, offset);
-        if (r < 0)
-                return r;
-
-        return 0;
-}
-
-static int server_send_ack(
+static int server_send_offer_or_ack(
                 sd_dhcp_server *server,
                 DHCPRequest *req,
-                be32_t address) {
-
-        static const uint8_t option_map[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
-                [SD_DHCP_LEASE_DNS] = SD_DHCP_OPTION_DOMAIN_NAME_SERVER,
-                [SD_DHCP_LEASE_NTP] = SD_DHCP_OPTION_NTP_SERVER,
-                [SD_DHCP_LEASE_SIP] = SD_DHCP_OPTION_SIP_SERVER,
-                [SD_DHCP_LEASE_POP3] = SD_DHCP_OPTION_POP3_SERVER,
-                [SD_DHCP_LEASE_SMTP] = SD_DHCP_OPTION_SMTP_SERVER,
-                [SD_DHCP_LEASE_LPR] = SD_DHCP_OPTION_LPR_SERVER,
-        };
+                be32_t address,
+                uint8_t type) {
 
         _cleanup_free_ DHCPPacket *packet = NULL;
-        be32_t lease_time;
         sd_dhcp_option *j;
+        be32_t lease_time;
         size_t offset;
         int r;
 
-        r = server_message_init(server, &packet, DHCP_ACK, &offset, req);
+        assert(server);
+        assert(req);
+        assert(IN_SET(type, DHCP_OFFER, DHCP_ACK));
+
+        r = server_message_init(server, &packet, type, &offset, req);
         if (r < 0)
                 return r;
 
@@ -509,27 +466,38 @@ static int server_send_ack(
                         return r;
         }
 
-        for (sd_dhcp_lease_server_type_t k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
-
-                if (server->servers[k].size <= 0)
-                        continue;
-
-                r = dhcp_option_append(
-                                &packet->dhcp, req->max_optlen, &offset, 0,
-                                option_map[k],
-                                sizeof(struct in_addr) * server->servers[k].size, server->servers[k].addr);
-                if (r < 0)
-                        return r;
-        }
+        if (type == DHCP_ACK) {
+                static const uint8_t option_map[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
+                        [SD_DHCP_LEASE_DNS] = SD_DHCP_OPTION_DOMAIN_NAME_SERVER,
+                        [SD_DHCP_LEASE_NTP] = SD_DHCP_OPTION_NTP_SERVER,
+                        [SD_DHCP_LEASE_SIP] = SD_DHCP_OPTION_SIP_SERVER,
+                        [SD_DHCP_LEASE_POP3] = SD_DHCP_OPTION_POP3_SERVER,
+                        [SD_DHCP_LEASE_SMTP] = SD_DHCP_OPTION_SMTP_SERVER,
+                        [SD_DHCP_LEASE_LPR] = SD_DHCP_OPTION_LPR_SERVER,
+                };
+
+                for (sd_dhcp_lease_server_type_t k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
+                        if (server->servers[k].size <= 0)
+                                continue;
+
+                        r = dhcp_option_append(
+                                        &packet->dhcp, req->max_optlen, &offset, 0,
+                                        option_map[k],
+                                        sizeof(struct in_addr) * server->servers[k].size,
+                                        server->servers[k].addr);
+                        if (r < 0)
+                                return r;
+                }
 
 
-        if (server->timezone) {
-                r = dhcp_option_append(
-                                &packet->dhcp, req->max_optlen, &offset, 0,
-                                SD_DHCP_OPTION_NEW_TZDB_TIMEZONE,
-                                strlen(server->timezone), server->timezone);
-                if (r < 0)
-                        return r;
+                if (server->timezone) {
+                        r = dhcp_option_append(
+                                        &packet->dhcp, req->max_optlen, &offset, 0,
+                                        SD_DHCP_OPTION_NEW_TZDB_TIMEZONE,
+                                        strlen(server->timezone), server->timezone);
+                        if (r < 0)
+                                return r;
+                }
         }
 
         ORDERED_SET_FOREACH(j, server->extra_options) {
@@ -548,7 +516,7 @@ static int server_send_ack(
                         return r;
         }
 
-        r = dhcp_server_send_packet(server, req, packet, DHCP_ACK, offset);
+        r = dhcp_server_send_packet(server, req, packet, type, offset);
         if (r < 0)
                 return r;
 
@@ -783,7 +751,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
                         /* no free addresses left */
                         return 0;
 
-                r = server_send_offer(server, req, address);
+                r = server_send_offer_or_ack(server, req, address, DHCP_OFFER);
                 if (r < 0)
                         /* this only fails on critical errors */
                         return log_dhcp_server_errno(server, r, "Could not send offer: %m");
@@ -886,7 +854,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
 
                         lease->expiration = req->lifetime * USEC_PER_SEC + time_now;
 
-                        r = server_send_ack(server, req, address);
+                        r = server_send_offer_or_ack(server, req, address, DHCP_ACK);
                         if (r < 0) {
                                 /* this only fails on critical errors */
                                 log_dhcp_server_errno(server, r, "Could not send ack: %m");
index fb0353486932596363ae00d4ed3ae6f72ba02275..b31f0fa81ab23f7c77fc604a28e37edd28c29635 100644 (file)
@@ -656,7 +656,6 @@ int netdev_join(NetDev *netdev, Link *link, link_netlink_message_handler_t callb
 
 int netdev_load_one(Manager *manager, const char *filename) {
         _cleanup_(netdev_unrefp) NetDev *netdev_raw = NULL, *netdev = NULL;
-        _cleanup_fclose_ FILE *file = NULL;
         const char *dropin_dirname;
         bool independent = false;
         int r;
@@ -664,15 +663,12 @@ int netdev_load_one(Manager *manager, const char *filename) {
         assert(manager);
         assert(filename);
 
-        file = fopen(filename, "re");
-        if (!file) {
-                if (errno == ENOENT)
-                        return 0;
-
-                return -errno;
-        }
-
-        if (null_or_empty_fd(fileno(file))) {
+        r = null_or_empty_path(filename);
+        if (r == -ENOENT)
+                return 0;
+        if (r < 0)
+                return r;
+        if (r > 0) {
                 log_debug("Skipping empty file: %s", filename);
                 return 0;
         }
@@ -714,10 +710,6 @@ int netdev_load_one(Manager *manager, const char *filename) {
                 return 0;
         }
 
-        r = fseek(file, 0, SEEK_SET);
-        if (r < 0)
-                return -errno;
-
         netdev = malloc0(NETDEV_VTABLE(netdev_raw)->object_size);
         if (!netdev)
                 return log_oom();
index 9865ebd2552a2ac5e738cfd1314eb2d9a211c31f..e5ffd35b6f9ab4b6a785678acec3622d60357ddd 100644 (file)
@@ -288,7 +288,6 @@ int network_verify(Network *network) {
 int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) {
         _cleanup_free_ char *fname = NULL, *name = NULL;
         _cleanup_(network_unrefp) Network *network = NULL;
-        _cleanup_fclose_ FILE *file = NULL;
         const char *dropin_dirname;
         char *d;
         int r;
@@ -296,15 +295,12 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
         assert(manager);
         assert(filename);
 
-        file = fopen(filename, "re");
-        if (!file) {
-                if (errno == ENOENT)
-                        return 0;
-
-                return -errno;
-        }
-
-        if (null_or_empty_fd(fileno(file))) {
+        r = null_or_empty_path(filename);
+        if (r == -ENOENT)
+                return 0;
+        if (r < 0)
+                return r;
+        if (r > 0) {
                 log_debug("Skipping empty file: %s", filename);
                 return 0;
         }
index 183da5865e0247914fae5a2be8e6e1d08605bb6c..0f18b1bb05352e6b4b132994a230020c86261bb2 100644 (file)
@@ -1335,8 +1335,8 @@ static int unit_file_load_or_readlink(
                 const char *path,
                 const char *root_dir,
                 SearchFlags flags) {
+
         _cleanup_free_ char *resolved = NULL;
-        struct stat st;
         int r;
 
         r = unit_file_load(c, info, path, root_dir, flags);
@@ -1351,9 +1351,7 @@ static int unit_file_load_or_readlink(
                  * so let's see if the path is a (possibly dangling) symlink to /dev/null. */
                 info->type = UNIT_FILE_TYPE_MASKED;
 
-        else if (r > 0 &&
-                 stat(resolved, &st) >= 0 &&
-                 null_or_empty(&st))
+        else if (r > 0 && null_or_empty_path(resolved) > 0)
 
                 info->type = UNIT_FILE_TYPE_MASKED;
 
index aad044d418ec04bbc38e557daf2fe4157adb37bf..b098eb27cd46468fbeb711f2433a82d247da7ed5 100644 (file)
@@ -393,7 +393,7 @@ static int write_temporary_passwd(const char *passwd_path, FILE **tmpfile, char
         original = fopen(passwd_path, "re");
         if (original) {
 
-                r = sync_rights(fileno(original), fileno(passwd));
+                r = copy_rights(fileno(original), fileno(passwd));
                 if (r < 0)
                         return r;
 
@@ -494,7 +494,7 @@ static int write_temporary_shadow(const char *shadow_path, FILE **tmpfile, char
         original = fopen(shadow_path, "re");
         if (original) {
 
-                r = sync_rights(fileno(original), fileno(shadow));
+                r = copy_rights(fileno(original), fileno(shadow));
                 if (r < 0)
                         return r;
 
@@ -590,7 +590,7 @@ static int write_temporary_group(const char *group_path, FILE **tmpfile, char **
         original = fopen(group_path, "re");
         if (original) {
 
-                r = sync_rights(fileno(original), fileno(group));
+                r = copy_rights(fileno(original), fileno(group));
                 if (r < 0)
                         return r;
 
@@ -688,7 +688,7 @@ static int write_temporary_gshadow(const char * gshadow_path, FILE **tmpfile, ch
         if (original) {
                 struct sgrp *sg;
 
-                r = sync_rights(fileno(original), fileno(gshadow));
+                r = copy_rights(fileno(original), fileno(gshadow));
                 if (r < 0)
                         return r;
 
index 9efb3fe3b3f9754ab426fb9793f840aa8d86a57a..c914d78324f9b8b6b5288c8298082db0ccb14e89 100644 (file)
@@ -31,6 +31,7 @@ static void test_encode_devnode_name(void) {
         assert_se(expect_encoded_as("s/ash/ng", "s\\x2fash\\x2fng"));
         assert_se(expect_encoded_as("/", "\\x2f"));
         assert_se(expect_encoded_as("!", "\\x21"));
+        assert_se(expect_encoded_as("QEMU    ", "QEMU\\x20\\x20\\x20\\x20"));
 }
 
 int main(int argc, char *argv[]) {
index 6b5005f9fc9cedf6a90d556e48d4585e36a76117..162d8bed951d10a8b3a13dbb6fac120133027609 100644 (file)
@@ -118,6 +118,20 @@ static const char* const input_table_one_empty[] = {
         NULL,
 };
 
+static const char* const input_table_unescape[] = {
+        "ID_VENDOR=QEMU",
+        "ID_VENDOR_ENC=QEMUx20x20x20x20",
+        "ID_MODEL_ENC=QEMUx20HARDDISKx20x20x20",
+        NULL,
+};
+
+static const char* const input_table_retain_escape[] = {
+        "ID_VENDOR=QEMU",
+        "ID_VENDOR_ENC=QEMU\\x20\\x20\\x20\\x20",
+        "ID_MODEL_ENC=QEMU\\x20HARDDISK\\x20\\x20\\x20",
+        NULL,
+};
+
 static void test_strv_find(void) {
         log_info("/* %s */", __func__);
 
@@ -453,6 +467,25 @@ static void test_strv_split_newlines(void) {
                 assert_se(streq(*s, input_table_multiple[i++]));
 }
 
+static void test_strv_split_newlines_full(void) {
+        const char str[] =
+                "ID_VENDOR=QEMU\n"
+                "ID_VENDOR_ENC=QEMU\\x20\\x20\\x20\\x20\n"
+                "ID_MODEL_ENC=QEMU\\x20HARDDISK\\x20\\x20\\x20\n"
+                "\n\n\n";
+        _cleanup_strv_free_ char **l = NULL;
+
+        log_info("/* %s */", __func__);
+
+        assert_se(strv_split_newlines_full(&l, str, 0) == 3);
+        assert_se(strv_equal(l, (char**) input_table_unescape));
+
+        l = strv_free(l);
+
+        assert_se(strv_split_newlines_full(&l, str, EXTRACT_RETAIN_ESCAPE) == 3);
+        assert_se(strv_equal(l, (char**) input_table_retain_escape));
+}
+
 static void test_strv_split_nulstr(void) {
         _cleanup_strv_free_ char **l = NULL;
         const char nulstr[] = "str0\0str1\0str2\0str3\0";
@@ -1031,6 +1064,7 @@ int main(int argc, char *argv[]) {
         test_strv_split_full();
         test_strv_split_colon_pairs();
         test_strv_split_newlines();
+        test_strv_split_newlines_full();
         test_strv_split_nulstr();
         test_strv_parse_nulstr();
         test_strv_overlap();
index 10d64d526085302aa3489c1107bc07d083e08a3b..f06ecd455df534019e86e10ea69f87ecdcd08d82 100644 (file)
@@ -110,19 +110,20 @@ int link_config_ctx_new(link_config_ctx **ret) {
 
 int link_load_one(link_config_ctx *ctx, const char *filename) {
         _cleanup_(link_config_freep) link_config *link = NULL;
-        _cleanup_fclose_ FILE *file = NULL;
         _cleanup_free_ char *name = NULL;
+        const char *dropin_dirname;
         size_t i;
         int r;
 
         assert(ctx);
         assert(filename);
 
-        file = fopen(filename, "re");
-        if (!file)
-                return errno == ENOENT ? 0 : -errno;
-
-        if (null_or_empty_fd(fileno(file))) {
+        r = null_or_empty_path(filename);
+        if (r == -ENOENT)
+                return 0;
+        if (r < 0)
+                return r;
+        if (r > 0) {
                 log_debug("Skipping empty file: %s", filename);
                 return 0;
         }
@@ -151,11 +152,14 @@ int link_load_one(link_config_ctx *ctx, const char *filename) {
         for (i = 0; i < ELEMENTSOF(link->features); i++)
                 link->features[i] = -1;
 
-        r = config_parse(NULL, filename, file,
-                         "Match\0Link\0",
-                         config_item_perf_lookup, link_config_gperf_lookup,
-                         CONFIG_PARSE_WARN, link,
-                         NULL);
+        dropin_dirname = strjoina(basename(filename), ".d");
+        r = config_parse_many(
+                        STRV_MAKE_CONST(filename),
+                        (const char* const*) CONF_PATHS_STRV("systemd/network"),
+                        dropin_dirname,
+                        "Match\0Link\0",
+                        config_item_perf_lookup, link_config_gperf_lookup,
+                        CONFIG_PARSE_WARN, link, NULL);
         if (r < 0)
                 return r;
 
index 78a999d00a1ed316b1f809aa5e16cb9525270f4a..d5d89d6802f75b10911aa897e63b3b1c034cd07f 100644 (file)
@@ -573,9 +573,11 @@ static int on_spawn_io(sd_event_source *s, int fd, uint32_t revents, void *userd
                 _cleanup_strv_free_ char **v = NULL;
                 char **q;
 
-                v = strv_split_newlines(p);
-                if (!v)
-                        log_oom_debug();
+                r = strv_split_newlines_full(&v, p, EXTRACT_RETAIN_ESCAPE);
+                if (r < 0)
+                        log_device_debug(spawn->device,
+                                         "Failed to split output from '%s'(%s), ignoring: %m",
+                                         spawn->cmd, fd == spawn->fd_stdout ? "out" : "err");
 
                 STRV_FOREACH(q, v)
                         log_device_debug(spawn->device, "'%s'(%s) '%s'", spawn->cmd,
index 0f10116a997075600d9d3311e3b9f638b266c05e..57ede6a197f6dffef867b835fb11f4de8c1dd35f 100644 (file)
@@ -1746,9 +1746,10 @@ static int udev_rule_apply_token_to_event(
                         return token->op == OP_NOMATCH;
                 }
 
-                lines = strv_split_newlines(result);
-                if (!lines)
-                        return log_oom();
+                r = strv_split_newlines_full(&lines, result, EXTRACT_RETAIN_ESCAPE);
+                if (r < 0)
+                        log_rule_warning_errno(dev, rules, r,
+                                               "Failed to extract lines from result of command \"%s\", ignoring: %m", buf);
 
                 STRV_FOREACH(line, lines) {
                         char *key, *value;
diff --git a/test/TEST-17-UDEV-WANTS/test.sh b/test/TEST-17-UDEV-WANTS/test.sh
deleted file mode 100755 (executable)
index 5b8f22c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-set -e
-TEST_DESCRIPTION="UDEV SYSTEMD_WANTS property"
-TEST_NO_NSPAWN=1
-
-. $TEST_BASE_DIR/test-functions
-QEMU_TIMEOUT=300
-
-do_test "$@" 17
similarity index 61%
rename from test/TEST-29-UDEV-ID_RENAMING/test.sh
rename to test/TEST-17-UDEV/test.sh
index c918e5af6aaed39021904a5bb972a132ccf43a45..b13ae0aa78267ff69c644207aba541fbd8a6babd 100755 (executable)
@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 set -e
-TEST_DESCRIPTION="UDEV ID_RENAMING property"
-IMAGE_NAME="udev-id-renaming"
+TEST_DESCRIPTION="UDEV"
+IMAGE_NAME="udev"
 TEST_NO_NSPAWN=1
 
 . $TEST_BASE_DIR/test-functions
-QEMU_TIMEOUT=300
+QEMU_TIMEOUT=500
 
 test_append_files() {
     (
@@ -14,4 +14,4 @@ test_append_files() {
     )
 }
 
-do_test "$@" 29
+do_test "$@" 17
similarity index 97%
rename from test/TEST-58-PORTABLE/test.sh
rename to test/TEST-29-PORTABLE/test.sh
index 98e697962e324c777b1ee06c1e914dc5d5cdb021..801e74c13d828a4e109fc065ea1e8c69811dad9d 100755 (executable)
@@ -24,4 +24,4 @@ test_append_files() {
     )
 }
 
-do_test "$@" 58
+do_test "$@" 29
similarity index 89%
rename from test/TEST-57-RUNTIME-BIND-PATHS/test.sh
rename to test/TEST-49-RUNTIME-BIND-PATHS/test.sh
index 76d1b496adbf88652bdaa2443272b63f75e54ab1..ff24a4f254efc7afc2a043225ccfcbb9b632f814 100755 (executable)
@@ -4,4 +4,4 @@ set -e
 TEST_DESCRIPTION="test adding new BindPaths while unit is already running"
 . $TEST_BASE_DIR/test-functions
 
-do_test "$@" 57
+do_test "$@" 49
diff --git a/test/TEST-49-UDEV-EVENT-TIMEOUT/test.sh b/test/TEST-49-UDEV-EVENT-TIMEOUT/test.sh
deleted file mode 100755 (executable)
index 249d8a2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-TEST_DESCRIPTION="test udev's event-timeout and timeout-signal options"
-TEST_NO_NSPAWN=1
-. $TEST_BASE_DIR/test-functions
-
-do_test "$@" 49
similarity index 98%
rename from test/TEST-56-OOMD/test.sh
rename to test/TEST-55-OOMD/test.sh
index 55b0d1dafdb238ef7e375ebf00578f23221a08ac..121aa8d56e9393d1cb615354f6239f76375c353f 100755 (executable)
@@ -45,4 +45,4 @@ check_result_qemu() {
     return $ret
 }
 
-do_test "$@" 56
+do_test "$@" 55
diff --git a/test/TEST-55-UDEV-TAGS/test.sh b/test/TEST-55-UDEV-TAGS/test.sh
deleted file mode 100755 (executable)
index 325d70f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-set -e
-TEST_DESCRIPTION="UDEV tags management"
-TEST_NO_NSPAWN=1
-
-. $TEST_BASE_DIR/test-functions
-
-do_test "$@" 55
diff --git a/test/TEST-56-OOMD/Makefile b/test/TEST-56-OOMD/Makefile
deleted file mode 120000 (symlink)
index e9f93b1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-57-RUNTIME-BIND-PATHS/Makefile b/test/TEST-57-RUNTIME-BIND-PATHS/Makefile
deleted file mode 120000 (symlink)
index e9f93b1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-58-PORTABLE/Makefile b/test/TEST-58-PORTABLE/Makefile
deleted file mode 120000 (symlink)
index e9f93b1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/units/testsuite-17.01.sh b/test/units/testsuite-17.01.sh
new file mode 100755 (executable)
index 0000000..573ad41
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+set -ex
+set -o pipefail
+
+mkdir -p /run/udev/rules.d/
+
+rm -f /run/udev/rules.d/50-testsuite.rules
+udevadm control --reload
+udevadm trigger /dev/sda
+
+while : ; do
+    (
+        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
+        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
+        systemctl show -p WantedBy foobar.service | grep -q -v sda
+        systemctl show -p WantedBy waldo.service | grep -q -v sda
+    ) && break
+
+    sleep .5
+done
+
+cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="foobar.service"
+EOF
+udevadm control --reload
+udevadm trigger /dev/sda
+
+while : ; do
+    (
+        udevadm info /dev/sda | grep -q SYSTEMD_WANTS=foobar.service
+        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
+        systemctl show -p WantedBy foobar.service | grep -q sda
+        systemctl show -p WantedBy waldo.service | grep -q -v sda
+    ) && break
+
+    sleep .5
+done
+
+cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="waldo.service"
+EOF
+udevadm control --reload
+udevadm trigger /dev/sda
+
+while : ; do
+    (
+        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
+        udevadm info /dev/sda | grep -q SYSTEMD_WANTS=waldo.service
+        systemctl show -p WantedBy foobar.service | grep -q -v sda
+        systemctl show -p WantedBy waldo.service | grep -q sda
+    ) && break
+
+    sleep .5
+done
+
+rm /run/udev/rules.d/50-testsuite.rules
+
+udevadm control --reload
+udevadm trigger /dev/sda
+
+while : ; do
+    (
+        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
+        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
+        systemctl show -p WantedBy foobar.service | grep -q -v sda
+        systemctl show -p WantedBy waldo.service | grep -q -v sda
+    ) && break
+
+    sleep .5
+done
+
+exit 0
diff --git a/test/units/testsuite-17.02.sh b/test/units/testsuite-17.02.sh
new file mode 100755 (executable)
index 0000000..c21fcc7
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+set -ex
+set -o pipefail
+
+mkdir -p /run/udev/rules.d/
+
+cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+ACTION=="remove", GOTO="lo_end"
+
+SUBSYSTEM=="net", KERNEL=="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/net/devices/lo"
+
+ACTION!="change", GOTO="lo_end"
+
+SUBSYSTEM=="net", KERNEL=="lo", ENV{ID_RENAMING}="1"
+
+LABEL="lo_end"
+EOF
+
+udevadm control --log-priority=debug --reload --timeout=600
+udevadm trigger --action=add --settle /sys/devices/virtual/net/lo
+udevadm info /sys/devices/virtual/net/lo
+sleep 1
+STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
+[[ $STATE == "active" ]] || exit 1
+
+udevadm trigger --action=change --settle /sys/devices/virtual/net/lo
+udevadm info /sys/devices/virtual/net/lo
+sleep 1
+STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
+[[ $STATE == "inactive" ]] || exit 1
+
+udevadm trigger --action=move --settle /sys/devices/virtual/net/lo
+udevadm info /sys/devices/virtual/net/lo
+sleep 1
+STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
+[[ $STATE == "active" ]] || exit 1
+
+rm -f /run/udev/rules.d/50-testsuite.rules
+udevadm control --reload --timeout=600
+
+# test for issue #16967
+
+ip link add hoge type dummy
+udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/hoge
+sleep 1
+if ! systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
+if ! systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
+
+ip link set hoge name foobar
+udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/foobar
+sleep 1
+if systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
+if systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
+if ! systemctl status sys-devices-virtual-net-foobar.device; then exit 1; fi
+if ! systemctl status sys-subsystem-net-devices-foobar.device; then exit 1; fi
+
+exit 0
diff --git a/test/units/testsuite-17.03.sh b/test/units/testsuite-17.03.sh
new file mode 100755 (executable)
index 0000000..02ac217
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+set -ex
+
+test_rule="/run/udev/rules.d/49-test.rules"
+
+setup() {
+    mkdir -p "${test_rule%/*}"
+    cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
+    echo 'KERNEL=="lo", SUBSYSTEM=="net", PROGRAM=="/bin/sleep 60"' > "${test_rule}"
+    echo "event_timeout=30" >> /etc/udev/udev.conf
+    echo "timeout_signal=SIGABRT" >> /etc/udev/udev.conf
+
+    systemctl restart systemd-udevd.service
+}
+
+teardown() {
+    set +e
+
+    mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
+    rm -f "$test_rule"
+    systemctl restart systemd-udevd.service
+}
+
+run_test() {
+    since="$(date +%T)"
+
+    echo add > /sys/class/net/lo/uevent
+
+    for n in {1..20}; do
+        sleep 5
+        if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
+            return 0
+        fi
+    done
+
+    return 1
+}
+
+trap teardown EXIT
+
+setup
+run_test
+
+exit 0
diff --git a/test/units/testsuite-17.04.sh b/test/units/testsuite-17.04.sh
new file mode 100755 (executable)
index 0000000..c799936
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/bash
+set -ex
+set -o pipefail
+
+mkdir -p /run/udev/rules.d/
+
+! test -f /run/udev/tags/added/c1:3 &&
+    ! test -f /run/udev/tags/changed/c1:3 &&
+    udevadm info /dev/null | grep -q -v 'E: TAGS=.*:added:.*' &&
+    udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
+    udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
+    udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*'
+
+cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", TAG+="added"
+ACTION=="change", SUBSYSTEM=="mem", KERNEL=="null", TAG+="changed"
+EOF
+
+udevadm control --reload
+udevadm trigger -c add /dev/null
+
+while : ; do
+    test -f /run/udev/tags/added/c1:3 &&
+        ! test -f /run/udev/tags/changed/c1:3 &&
+        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
+        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
+        udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
+        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
+        break
+
+    sleep .5
+done
+
+udevadm control --reload
+udevadm trigger -c change /dev/null
+
+while : ; do
+    test -f /run/udev/tags/added/c1:3 &&
+        test -f /run/udev/tags/changed/c1:3 &&
+        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
+        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
+        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
+        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*' &&
+        break
+
+    sleep .5
+done
+
+udevadm control --reload
+udevadm trigger -c add /dev/null
+
+while : ; do
+    test -f /run/udev/tags/added/c1:3 &&
+        test -f /run/udev/tags/changed/c1:3 &&
+        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
+        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
+        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
+        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
+        break
+
+    sleep .5
+done
+
+exit 0
diff --git a/test/units/testsuite-17.05.sh b/test/units/testsuite-17.05.sh
new file mode 100755 (executable)
index 0000000..0991ec9
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+set -ex
+set -o pipefail
+
+mkdir -p /run/udev/rules.d/
+
+cat > /run/udev/rules.d/50-testsuite.rules <<EOF
+SUBSYSTEM=="mem", KERNEL=="null", OPTIONS="log_level=debug"
+ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", IMPORT{program}="/bin/echo -e HOGE=aa\\\\x20\\\\x20\\\\x20bb\nFOO=\\\\x20aaa\\\\x20\n\n\n"
+EOF
+
+udevadm control --reload
+udevadm trigger -c add /dev/null
+
+while : ; do
+    test -f /run/udev/data/c1:3 &&
+        udevadm info /dev/null | grep -q 'E: HOGE=aa\\x20\\x20\\x20bb' &&
+        udevadm info /dev/null | grep -q 'E: FOO=\\x20aaa\\x20' &&
+        break
+
+    sleep .5
+done
+
+exit 0
index ed2017a848620a349b3b2dd5ca045af6a2abddbd..bd6221551c34b5cb7e262abcf342407bceca2e2d 100644 (file)
@@ -1,5 +1,5 @@
 [Unit]
-Description=TEST-17-UDEV-WANTS
+Description=TEST-17-UDEV
 
 [Service]
 ExecStartPre=rm -f /failed /testok
index 7f8740ba3506390a769064677c5fd0c4623a6f24..afce85aceb9bcf11cc3f671538ef4fdf93daf3f1 100755 (executable)
@@ -1,74 +1,13 @@
 #!/usr/bin/env bash
-set -ex
-set -o pipefail
 
-mkdir -p /run/udev/rules.d/
+set -x
+set -e
 
-rm -f /run/udev/rules.d/50-testsuite.rules
-udevadm control --reload
-udevadm trigger /dev/sda
+>/failed
 
-while : ; do
-    (
-        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
-        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
-        systemctl show -p WantedBy foobar.service | grep -q -v sda
-        systemctl show -p WantedBy waldo.service | grep -q -v sda
-    ) && break
-
-    sleep .5
-done
-
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
-ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="foobar.service"
-EOF
-udevadm control --reload
-udevadm trigger /dev/sda
-
-while : ; do
-    (
-        udevadm info /dev/sda | grep -q SYSTEMD_WANTS=foobar.service
-        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
-        systemctl show -p WantedBy foobar.service | grep -q sda
-        systemctl show -p WantedBy waldo.service | grep -q -v sda
-    ) && break
-
-    sleep .5
+for t in ${0%.sh}.*.sh; do
+    echo "Running $t"; ./$t
 done
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
-ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="waldo.service"
-EOF
-udevadm control --reload
-udevadm trigger /dev/sda
-
-while : ; do
-    (
-        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
-        udevadm info /dev/sda | grep -q SYSTEMD_WANTS=waldo.service
-        systemctl show -p WantedBy foobar.service | grep -q -v sda
-        systemctl show -p WantedBy waldo.service | grep -q sda
-    ) && break
-
-    sleep .5
-done
-
-rm /run/udev/rules.d/50-testsuite.rules
-
-udevadm control --reload
-udevadm trigger /dev/sda
-
-while : ; do
-    (
-        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
-        udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
-        systemctl show -p WantedBy foobar.service | grep -q -v sda
-        systemctl show -p WantedBy waldo.service | grep -q -v sda
-    ) && break
-
-    sleep .5
-done
-
-echo OK >/testok
-
-exit 0
+touch /testok
+rm /failed
index 90c2187bd79d63c45e23eaf60c68761f59823d42..900b99f77b96db76f55775a1a8cadbbfe83f790a 100644 (file)
@@ -1,5 +1,5 @@
 [Unit]
-Description=TEST-29-UDEV-ID_RENAMING
+Description=TEST-29-PORTABLE
 
 [Service]
 ExecStartPre=rm -f /failed /testok
index 5c625568953bb88b18280d854afa79349772197d..b5b05b42d9bf40c13a64bb6abf438e19c2fa996b 100755 (executable)
@@ -1,58 +1,67 @@
 #!/usr/bin/env bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
 set -ex
 set -o pipefail
 
-mkdir -p /run/udev/rules.d/
+export SYSTEMD_LOG_LEVEL=debug
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
-ACTION=="remove", GOTO="lo_end"
+portablectl attach --now --runtime /usr/share/minimal_0.raw app0
 
-SUBSYSTEM=="net", KERNEL=="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/net/devices/lo"
+systemctl is-active app0.service
+systemctl is-active app0-foo.service
+set +o pipefail
+set +e
+systemctl is-active app0-bar.service && exit 1
+set -e
+set -o pipefail
+
+portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
+
+systemctl is-active app0.service
+systemctl is-active app0-bar.service
+set +o pipefail
+set +e
+systemctl is-active app0-foo.service && exit 1
+set -e
+set -o pipefail
 
-ACTION!="change", GOTO="lo_end"
+portablectl list | grep -q -F "minimal_1"
 
-SUBSYSTEM=="net", KERNEL=="lo", ENV{ID_RENAMING}="1"
+portablectl detach --now --runtime /usr/share/minimal_1.raw app0
 
-LABEL="lo_end"
-EOF
+portablectl list | grep -q -F "No images."
 
-udevadm control --log-priority=debug --reload --timeout=600
-udevadm trigger --action=add --settle /sys/devices/virtual/net/lo
-udevadm info /sys/devices/virtual/net/lo
-sleep 1
-STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
-[[ $STATE == "active" ]] || exit 1
+# portablectl also works with directory paths rather than images
 
-udevadm trigger --action=change --settle /sys/devices/virtual/net/lo
-udevadm info /sys/devices/virtual/net/lo
-sleep 1
-STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
-[[ $STATE == "inactive" ]] || exit 1
+unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
+unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
 
-udevadm trigger --action=move --settle /sys/devices/virtual/net/lo
-udevadm info /sys/devices/virtual/net/lo
-sleep 1
-STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
-[[ $STATE == "active" ]] || exit 1
+portablectl attach --copy=symlink --now --runtime /tmp/minimal_0 app0
 
-rm -f /run/udev/rules.d/50-testsuite.rules
-udevadm control --reload --timeout=600
+systemctl is-active app0.service
+systemctl is-active app0-foo.service
+set +o pipefail
+set +e
+systemctl is-active app0-bar.service && exit 1
+set -e
+set -o pipefail
+
+portablectl reattach --now --enable --runtime /tmp/minimal_1 app0
+
+systemctl is-active app0.service
+systemctl is-active app0-bar.service
+set +o pipefail
+set +e
+systemctl is-active app0-foo.service && exit 1
+set -e
+set -o pipefail
 
-# test for issue #16967
+portablectl list | grep -q -F "minimal_1"
 
-ip link add hoge type dummy
-udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/hoge
-sleep 1
-if ! systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
-if ! systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
+portablectl detach --now --enable --runtime /tmp/minimal_1 app0
 
-ip link set hoge name foobar
-udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/foobar
-sleep 1
-if systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
-if systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
-if ! systemctl status sys-devices-virtual-net-foobar.device; then exit 1; fi
-if ! systemctl status sys-subsystem-net-devices-foobar.device; then exit 1; fi
+portablectl list | grep -q -F "No images."
 
 echo OK > /testok
 
similarity index 89%
rename from test/units/testsuite-57-namespaced.service
rename to test/units/testsuite-49-namespaced.service
index 0abcc4faf44e6018a493af97be7ef4cf929ce5b2..722dbe246d688283f93179a96b08455ca5411452 100644 (file)
@@ -6,7 +6,7 @@ Type=notify
 RemainAfterExit=yes
 MountAPIVFS=yes
 PrivateTmp=yes
-BindPaths=/run/testservice-57-fixed:/tmp/testfile_fixed
+BindPaths=/run/testservice-49-fixed:/tmp/testfile_fixed
 InaccessiblePaths=/run/inaccessible
 ExecStartPre=grep -q -F MARKER_FIXED /tmp/testfile_fixed
 ExecStart=/bin/sh -c 'systemd-notify --ready; while ! grep -q -F MARKER_RUNTIME /tmp/testfile_runtime; do sleep 0.1; done; test ! -f /run/inaccessible/testfile_fixed'
index f47177106fe5c42dfa2ec12f1a59fb654b412b65..9475109ca2cc5b6c8bc92fb10a1057913a66f888 100644 (file)
@@ -1,6 +1,7 @@
 [Unit]
-Description=TEST-49-UDEV-EVENT-TIMEOUT
+Description=TEST-49-RUNTIME-BIND-PATHS
 
 [Service]
+ExecStartPre=rm -f /failed /testok
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
 Type=oneshot
index ffa98016446c1f96ffe3d509f0bd5a281b829f8a..07bb20d99c67f5f39e77f62099bc9216e6ad85df 100755 (executable)
@@ -1,46 +1,42 @@
 #!/usr/bin/env bash
-
 set -ex
 
-test_rule="/run/udev/rules.d/49-test.rules"
+echo "MARKER_FIXED" > /run/testservice-49-fixed
+mkdir -p /run/inaccessible
 
-setup() {
-    mkdir -p "${test_rule%/*}"
-    cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
-    echo 'KERNEL=="lo", SUBSYSTEM=="net", PROGRAM=="/bin/sleep 60"' > "${test_rule}"
-    echo "event_timeout=30" >> /etc/udev/udev.conf
-    echo "timeout_signal=SIGABRT" >> /etc/udev/udev.conf
+systemctl start testsuite-49-namespaced.service
 
-    systemctl restart systemd-udevd.service
-}
+# Ensure that inaccessible paths aren't bypassed by the runtime setup
+set +e
+systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-fixed /run/inaccessible/testfile_fixed && exit 1
+set -e
 
-teardown() {
-    set +e
+echo "MARKER_RUNTIME" > /run/testservice-49-runtime
 
-    mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
-    rm -f "$test_rule"
-    systemctl restart systemd-udevd.service
-}
+systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime
 
-run_test() {
-    since="$(date +%T)"
+while systemctl show -P SubState testsuite-49-namespaced.service | grep -q running
+do
+    sleep 0.1
+done
 
-    echo add > /sys/class/net/lo/uevent
+systemctl is-active testsuite-49-namespaced.service
 
-    for n in {1..20}; do
-        sleep 5
-        if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
-            return 0
-        fi
-    done
+# Now test that systemctl bind fails when attempted on a non-namespaced unit
+systemctl start testsuite-49-non-namespaced.service
 
-    return 1
-}
+set +e
+systemctl bind --mkdir testsuite-49-non-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime && exit 1
+set -e
 
-trap teardown EXIT
+while systemctl show -P SubState testsuite-49-non-namespaced.service | grep -q running
+do
+    sleep 0.1
+done
 
-setup
-run_test
+set +e
+systemctl is-active testsuite-49-non-namespaced.service && exit 1
+set -e
 
 echo OK > /testok
 
similarity index 68%
rename from test/units/testsuite-56-testbloat.service
rename to test/units/testsuite-55-testbloat.service
index 6163aae1dbadfaeb6c67f9816be331eccb602736..7aa794b9f9a241bce19c2c5b5b299e13becba8a8 100644 (file)
@@ -5,5 +5,5 @@ Description=Create a lot of memory pressure
 # A VERY small memory.high will cause the script (trying to use a lot of memory)
 # to throttle and be put under heavy pressure.
 MemoryHigh=1M
-Slice=testsuite-56-workload.slice
-ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh
+Slice=testsuite-55-workload.slice
+ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh
similarity index 68%
rename from test/units/testsuite-56-testchill.service
rename to test/units/testsuite-55-testchill.service
index 6cae3d852a3eed0d8cf1258c9c3e00815f801c6b..aca6bc4ab97690d4376ee6ef0c5b8e2b03d39213 100644 (file)
@@ -2,5 +2,5 @@
 Description=No memory pressure
 
 [Service]
-Slice=testsuite-56-workload.slice
+Slice=testsuite-55-workload.slice
 ExecStart=sleep infinity
diff --git a/test/units/testsuite-55-testmunch.service b/test/units/testsuite-55-testmunch.service
new file mode 100644 (file)
index 0000000..457e4a5
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Create some memory pressure
+
+[Service]
+MemoryHigh=2M
+Slice=testsuite-55-workload.slice
+ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh
index 2127a4db7f7db023cfec46cc69508d7b40336d45..592e9d5becadf3b4b6100c1c8a03e1daf0469417 100644 (file)
@@ -1,7 +1,7 @@
 [Unit]
-Description=TESTSUITE-55-UDEV-TAGS
+Description=TESTSUITE-55-OOMD
 
 [Service]
-ExecStartPre=rm -f /failed /testok
+ExecStartPre=rm -f /failed /skipped /testok
 ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
 Type=oneshot
index ffceefb6a57ae2fe1beb5d0923aef7fc88fad0ca..f7896ada4274c3d53a5138b345acd121db6d66dd 100755 (executable)
@@ -1,66 +1,76 @@
-#!/bin/bash
+#!/usr/bin/env bash
 set -ex
 set -o pipefail
 
-mkdir -p /run/udev/rules.d/
-
-! test -f /run/udev/tags/added/c1:3 &&
-    ! test -f /run/udev/tags/changed/c1:3 &&
-    udevadm info /dev/null | grep -q -v 'E: TAGS=.*:added:.*' &&
-    udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
-    udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
-    udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*'
-
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
-ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", TAG+="added"
-ACTION=="change", SUBSYSTEM=="mem", KERNEL=="null", TAG+="changed"
-EOF
-
-udevadm control --reload
-udevadm trigger -c add /dev/null
-
-while : ; do
-    test -f /run/udev/tags/added/c1:3 &&
-        ! test -f /run/udev/tags/changed/c1:3 &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
-        break
+systemd-analyze log-level debug
+systemd-analyze log-target console
 
-    sleep .5
-done
+# Loose checks to ensure the environment has the necessary features for systemd-oomd
+[[ -e /proc/pressure ]] || echo "no PSI" >> /skipped
+cgroup_type=$(stat -fc %T /sys/fs/cgroup/)
+if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then
+    echo "no cgroup2" >> /skipped
+fi
+if [ ! -f /usr/lib/systemd/systemd-oomd ] && [ ! -f /lib/systemd/systemd-oomd ]; then
+    echo "no oomd" >> /skipped
+fi
+[[ -e /skipped ]] && exit 0 || true
 
-udevadm control --reload
-udevadm trigger -c change /dev/null
+rm -rf /etc/systemd/system/testsuite-55-testbloat.service.d
 
-while : ; do
-    test -f /run/udev/tags/added/c1:3 &&
-        test -f /run/udev/tags/changed/c1:3 &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
-        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*' &&
-        break
+echo "DefaultMemoryPressureDurationSec=5s" >> /etc/systemd/oomd.conf
 
-    sleep .5
-done
+systemctl start testsuite-55-testchill.service
+systemctl start testsuite-55-testbloat.service
 
-udevadm control --reload
-udevadm trigger -c add /dev/null
+# Verify systemd-oomd is monitoring the expected units
+oomctl | grep "/testsuite-55-workload.slice"
+oomctl | grep "1.00%"
+oomctl | grep "Default Memory Pressure Duration: 5s"
 
-while : ; do
-    test -f /run/udev/tags/added/c1:3 &&
-        test -f /run/udev/tags/changed/c1:3 &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
-        udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
-        udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
+# systemd-oomd watches for elevated pressure for 5 seconds before acting.
+# It can take time to build up pressure so either wait 2 minutes or for the service to fail.
+timeout=$(date -ud "2 minutes" +%s)
+while [[ $(date -u +%s) -le $timeout ]]; do
+    if ! systemctl status testsuite-55-testbloat.service; then
         break
-
-    sleep .5
+    fi
+    sleep 5
 done
 
+# testbloat should be killed and testchill should be fine
+if systemctl status testsuite-55-testbloat.service; then exit 42; fi
+if ! systemctl status testsuite-55-testchill.service; then exit 24; fi
+
+# only run this portion of the test if we can set xattrs
+if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then
+    sleep 120 # wait for systemd-oomd kill cool down and elevated memory pressure to come down
+
+    mkdir -p /etc/systemd/system/testsuite-55-testbloat.service.d/
+    echo "[Service]" > /etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
+    echo "ManagedOOMPreference=avoid" >> /etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
+
+    systemctl daemon-reload
+    systemctl start testsuite-55-testchill.service
+    systemctl start testsuite-55-testmunch.service
+    systemctl start testsuite-55-testbloat.service
+
+    timeout=$(date -ud "2 minutes" +%s)
+    while [[ $(date -u +%s) -le $timeout ]]; do
+        if ! systemctl status testsuite-55-testmunch.service; then
+            break
+        fi
+        sleep 5
+    done
+
+    # testmunch should be killed since testbloat had the avoid xattr on it
+    if ! systemctl status testsuite-55-testbloat.service; then exit 25; fi
+    if systemctl status testsuite-55-testmunch.service; then exit 43; fi
+    if ! systemctl status testsuite-55-testchill.service; then exit 24; fi
+fi
+
+systemd-analyze log-level info
+
 echo OK > /testok
 
 exit 0
diff --git a/test/units/testsuite-56-testmunch.service b/test/units/testsuite-56-testmunch.service
deleted file mode 100644 (file)
index b4b925a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Create some memory pressure
-
-[Service]
-MemoryHigh=2M
-Slice=testsuite-56-workload.slice
-ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh
diff --git a/test/units/testsuite-56.service b/test/units/testsuite-56.service
deleted file mode 100644 (file)
index b53b090..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=TESTSUITE-56-OOMD
-
-[Service]
-ExecStartPre=rm -f /failed /skipped /testok
-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
-Type=oneshot
diff --git a/test/units/testsuite-56.sh b/test/units/testsuite-56.sh
deleted file mode 100755 (executable)
index 6835802..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env bash
-set -ex
-set -o pipefail
-
-systemd-analyze log-level debug
-systemd-analyze log-target console
-
-# Loose checks to ensure the environment has the necessary features for systemd-oomd
-[[ -e /proc/pressure ]] || echo "no PSI" >> /skipped
-cgroup_type=$(stat -fc %T /sys/fs/cgroup/)
-if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then
-    echo "no cgroup2" >> /skipped
-fi
-if [ ! -f /usr/lib/systemd/systemd-oomd ] && [ ! -f /lib/systemd/systemd-oomd ]; then
-    echo "no oomd" >> /skipped
-fi
-[[ -e /skipped ]] && exit 0 || true
-
-rm -rf /etc/systemd/system/testsuite-56-testbloat.service.d
-
-echo "DefaultMemoryPressureDurationSec=5s" >> /etc/systemd/oomd.conf
-
-systemctl start testsuite-56-testchill.service
-systemctl start testsuite-56-testbloat.service
-
-# Verify systemd-oomd is monitoring the expected units
-oomctl | grep "/testsuite-56-workload.slice"
-oomctl | grep "1.00%"
-oomctl | grep "Default Memory Pressure Duration: 5s"
-
-# systemd-oomd watches for elevated pressure for 5 seconds before acting.
-# It can take time to build up pressure so either wait 2 minutes or for the service to fail.
-timeout=$(date -ud "2 minutes" +%s)
-while [[ $(date -u +%s) -le $timeout ]]; do
-    if ! systemctl status testsuite-56-testbloat.service; then
-        break
-    fi
-    sleep 5
-done
-
-# testbloat should be killed and testchill should be fine
-if systemctl status testsuite-56-testbloat.service; then exit 42; fi
-if ! systemctl status testsuite-56-testchill.service; then exit 24; fi
-
-# only run this portion of the test if we can set xattrs
-if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then
-    sleep 120 # wait for systemd-oomd kill cool down and elevated memory pressure to come down
-
-    mkdir -p /etc/systemd/system/testsuite-56-testbloat.service.d/
-    echo "[Service]" > /etc/systemd/system/testsuite-56-testbloat.service.d/override.conf
-    echo "ManagedOOMPreference=avoid" >> /etc/systemd/system/testsuite-56-testbloat.service.d/override.conf
-
-    systemctl daemon-reload
-    systemctl start testsuite-56-testchill.service
-    systemctl start testsuite-56-testmunch.service
-    systemctl start testsuite-56-testbloat.service
-
-    timeout=$(date -ud "2 minutes" +%s)
-    while [[ $(date -u +%s) -le $timeout ]]; do
-        if ! systemctl status testsuite-56-testmunch.service; then
-            break
-        fi
-        sleep 5
-    done
-
-    # testmunch should be killed since testbloat had the avoid xattr on it
-    if ! systemctl status testsuite-56-testbloat.service; then exit 25; fi
-    if systemctl status testsuite-56-testmunch.service; then exit 43; fi
-    if ! systemctl status testsuite-56-testchill.service; then exit 24; fi
-fi
-
-systemd-analyze log-level info
-
-echo OK > /testok
-
-exit 0
diff --git a/test/units/testsuite-57.service b/test/units/testsuite-57.service
deleted file mode 100644 (file)
index b6edd86..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=TEST-57-RUNTIME-BIND-PATHS
-
-[Service]
-ExecStartPre=rm -f /failed /testok
-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
-Type=oneshot
diff --git a/test/units/testsuite-57.sh b/test/units/testsuite-57.sh
deleted file mode 100755 (executable)
index c24cf32..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-set -ex
-
-echo "MARKER_FIXED" > /run/testservice-57-fixed
-mkdir -p /run/inaccessible
-
-systemctl start testsuite-57-namespaced.service
-
-# Ensure that inaccessible paths aren't bypassed by the runtime setup
-set +e
-systemctl bind --mkdir testsuite-57-namespaced.service /run/testservice-57-fixed /run/inaccessible/testfile_fixed && exit 1
-set -e
-
-echo "MARKER_RUNTIME" > /run/testservice-57-runtime
-
-systemctl bind --mkdir testsuite-57-namespaced.service /run/testservice-57-runtime /tmp/testfile_runtime
-
-while systemctl show -P SubState testsuite-57-namespaced.service | grep -q running
-do
-    sleep 0.1
-done
-
-systemctl is-active testsuite-57-namespaced.service
-
-# Now test that systemctl bind fails when attempted on a non-namespaced unit
-systemctl start testsuite-57-non-namespaced.service
-
-set +e
-systemctl bind --mkdir testsuite-57-non-namespaced.service /run/testservice-57-runtime /tmp/testfile_runtime && exit 1
-set -e
-
-while systemctl show -P SubState testsuite-57-non-namespaced.service | grep -q running
-do
-    sleep 0.1
-done
-
-set +e
-systemctl is-active testsuite-57-non-namespaced.service && exit 1
-set -e
-
-echo OK > /testok
-
-exit 0
diff --git a/test/units/testsuite-58.service b/test/units/testsuite-58.service
deleted file mode 100644 (file)
index 47deba7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=TEST-58-PORTABLE
-
-[Service]
-ExecStartPre=rm -f /failed /testok
-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
-Type=oneshot
diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh
deleted file mode 100755 (executable)
index b5b05b4..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-set -ex
-set -o pipefail
-
-export SYSTEMD_LOG_LEVEL=debug
-
-portablectl attach --now --runtime /usr/share/minimal_0.raw app0
-
-systemctl is-active app0.service
-systemctl is-active app0-foo.service
-set +o pipefail
-set +e
-systemctl is-active app0-bar.service && exit 1
-set -e
-set -o pipefail
-
-portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
-
-systemctl is-active app0.service
-systemctl is-active app0-bar.service
-set +o pipefail
-set +e
-systemctl is-active app0-foo.service && exit 1
-set -e
-set -o pipefail
-
-portablectl list | grep -q -F "minimal_1"
-
-portablectl detach --now --runtime /usr/share/minimal_1.raw app0
-
-portablectl list | grep -q -F "No images."
-
-# portablectl also works with directory paths rather than images
-
-unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
-unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
-
-portablectl attach --copy=symlink --now --runtime /tmp/minimal_0 app0
-
-systemctl is-active app0.service
-systemctl is-active app0-foo.service
-set +o pipefail
-set +e
-systemctl is-active app0-bar.service && exit 1
-set -e
-set -o pipefail
-
-portablectl reattach --now --enable --runtime /tmp/minimal_1 app0
-
-systemctl is-active app0.service
-systemctl is-active app0-bar.service
-set +o pipefail
-set +e
-systemctl is-active app0-foo.service && exit 1
-set -e
-set -o pipefail
-
-portablectl list | grep -q -F "minimal_1"
-
-portablectl detach --now --enable --runtime /tmp/minimal_1 app0
-
-portablectl list | grep -q -F "No images."
-
-echo OK > /testok
-
-exit 0