]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: don't choke on overly long device paths 19801/head
authorLennart Poettering <lennart@poettering.net>
Wed, 2 Jun 2021 13:49:10 +0000 (15:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Jun 2021 13:01:05 +0000 (15:01 +0200)
This mimics what we do for device units: if there's a device we cannot
synthesize a good swap unit name for, then proceed without failure.

src/core/swap.c

index fc781a3815b7c1dd6441ed95e95970746169f157..8aecc391e7bac65ef91fbaa498482646312b61f0 100644 (file)
@@ -1426,13 +1426,14 @@ int swap_process_device_new(Manager *m, sd_device *dev) {
         assert(m);
         assert(dev);
 
-        r = sd_device_get_devname(dev, &dn);
-        if (r < 0)
+        if (sd_device_get_devname(dev, &dn) < 0)
                 return 0;
 
         r = unit_name_from_path(dn, ".swap", &e);
-        if (r < 0)
-                return r;
+        if (r < 0) {
+                log_debug_errno(r, "Cannot convert device name '%s' to unit name, ignoring: %m", dn);
+                return 0;
+        }
 
         u = manager_get_unit(m, e);
         if (u)