]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: rescan /home/ in more occasions automatically
authorLennart Poettering <lennart@poettering.net>
Fri, 28 Feb 2025 07:47:46 +0000 (08:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Mar 2025 17:14:55 +0000 (18:14 +0100)
When unregistering a home there's a chance this "reveals" another home
by the same name in /home/, hence immediately schedule a rescan, the
same way we already schedule it in on remove.

Also, drop the conditionalization when scheduling a rescan during
remove, for the same reasons: a remove might reveal another home, and we
cannot check for that ahead of time. Trying to check is kinda a
pointless optimization anyway, since this is not a frequent operation
and rescanning is not the end of the world.

src/home/homed-home.c

index 871ccdffe9167f6d22308cf858990dd1e2c6db04..ee9f54b3223ae368549b787e4907270874b16ae3 100644 (file)
@@ -915,8 +915,7 @@ static void home_remove_finish(Home *h, int ret, UserRecord *hr) {
          * partitions like USB sticks, or so). Sometimes these storage locations are among those we normally
          * automatically discover in /home or in udev. When such a home is deleted let's hence issue a rescan
          * after completion, so that "unfixated" entries are rediscovered.  */
-        if (!IN_SET(user_record_test_image_path(h->record), USER_TEST_UNDEFINED, USER_TEST_ABSENT))
-                manager_enqueue_rescan(m);
+        (void) manager_enqueue_rescan(m);
 
         /* The image is now removed from disk. Now also remove our stored record */
         r = home_unlink_record(h);
@@ -2063,12 +2062,17 @@ int home_unregister(Home *h, sd_bus_error *error) {
                 return sd_bus_error_setf(error, BUS_ERROR_HOME_BUSY, "Home %s is currently being used, or an operation on home %s is currently being executed.", h->user_name, h->user_name);
         }
 
+        Manager *m = ASSERT_PTR(h->manager);
+
         r = home_unlink_record(h);
         if (r < 0)
                 return r;
 
         /* And destroy the whole entry. The caller needs to be prepared for that. */
         h = home_free(h);
+
+        /* Let's rescan, who knows, maybe this revealed a directory in /home/ that we should pick up now */
+        manager_enqueue_rescan(m);
         return 1;
 }