summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Seiler <christian@iwakd.de>2015-01-23 15:26:18 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-27 18:55:50 +0100
commit4d858e7d9f39038713f760d7acc64acf7bba2aa7 (patch)
tree7fca23504352992759cfe0af8a714bc55b5747fc
parente611755d98ac6b213f39426359c3a94defc6a029 (diff)
logind: remove per-user runtime dir again if setup fails
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.
-rw-r--r--src/login/logind-user.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 49c373b50..d1f91d6a2 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -328,7 +328,6 @@ static int user_mkdir_runtime_path(User *u) {
r = asprintf(&t, "mode=0700,smackfsroot=*,uid=" UID_FMT ",gid=" GID_FMT ",size=%zu", u->uid, u->gid, u->manager->runtime_dir_size);
else
r = asprintf(&t, "mode=0700,uid=" UID_FMT ",gid=" GID_FMT ",size=%zu", u->uid, u->gid, u->manager->runtime_dir_size);
-
if (r < 0) {
r = log_oom();
goto fail;
@@ -336,7 +335,7 @@ static int user_mkdir_runtime_path(User *u) {
r = mount("tmpfs", p, "tmpfs", MS_NODEV|MS_NOSUID, t);
if (r < 0) {
- log_error_errno(r, "Failed to mount per-user tmpfs directory %s: %m", p);
+ r = log_error_errno(errno, "Failed to mount per-user tmpfs directory %s: %m", p);
goto fail;
}
}
@@ -345,7 +344,12 @@ static int user_mkdir_runtime_path(User *u) {
return 0;
fail:
- free(p);
+ if (p) {
+ /* Try to clean up, but ignore errors */
+ (void) rmdir(p);
+ free(p);
+ }
+
u->runtime_path = NULL;
return r;
}