From: Lennart Poettering Date: Fri, 28 Feb 2025 07:47:46 +0000 (+0100) Subject: homed: rescan /home/ in more occasions automatically X-Git-Tag: v258-rc1~1143^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efe2ce7277c6da2a9d25906cf53f59278b2f35f6;p=thirdparty%2Fsystemd.git homed: rescan /home/ in more occasions automatically 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. --- diff --git a/src/home/homed-home.c b/src/home/homed-home.c index 871ccdffe91..ee9f54b3223 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -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; }