mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-06 13:41:31 +00:00
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.
(cherry picked from commit 4d858e7d9f)
Conflicts:
src/login/logind-user.c
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
f0e9c36257
commit
8ce77d0b80
@@ -330,7 +330,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;
|
||||
@@ -338,7 +337,8 @@ static int user_mkdir_runtime_path(User *u) {
|
||||
|
||||
r = mount("tmpfs", p, "tmpfs", MS_NODEV|MS_NOSUID, t);
|
||||
if (r < 0) {
|
||||
log_error("Failed to mount per-user tmpfs directory %s: %s", p, strerror(-r));
|
||||
log_error("Failed to mount per-user tmpfs directory %s: %m", p);
|
||||
r = -errno;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user