[systemd-devel] [PATCH 1/2] logind: remove per-user runtime dir again if setup fails

Christian Seiler christian at iwakd.de
Fri Jan 23 06:26:18 PST 2015


If setup of per-user runtime dir fails, clean up afterwards by removing
the directory before returning from the function, so we don't leave the
directory behind.

If this is not done, the second time the user logs in logind would
assume that the directory is already set up, even though it isn't.
---
 src/login/logind-user.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 49c373b..d7930ad 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -336,6 +336,9 @@ static int user_mkdir_runtime_path(User *u) {
 
                 r = mount("tmpfs", p, "tmpfs", MS_NODEV|MS_NOSUID, t);
                 if (r < 0) {
+                        /* try to clean up, but ignore errors */
+                        r = -errno;
+                        rmdir(p);
                         log_error_errno(r, "Failed to mount per-user tmpfs directory %s: %m", p);
                         goto fail;
                 }
-- 
2.1.4



More information about the systemd-devel mailing list