Unverified Commit 02b05b04 by Tycho Andersen Committed by Christian Brauner

better check for lock dir

Consider the case where we're running in a user namespace but in the host's mount ns with the host's filesystem (something like lxc-usernsexec ... lxc-execute ...), in this case, we'll be euid 0, but we can't actually write to /run. Let's improve this locking check to make sure we can actually write to /run before we decide to actually use it as our locking dir. Signed-off-by: 's avatarTycho Andersen <tycho@tycho.ws>
parent a48622d8
...@@ -214,8 +214,13 @@ char *get_rundir() ...@@ -214,8 +214,13 @@ char *get_rundir()
{ {
char *rundir; char *rundir;
const char *homedir; const char *homedir;
struct stat sb;
if (stat(RUNTIME_PATH, &sb) < 0) {
return NULL;
}
if (geteuid() == 0) { if (geteuid() == sb.st_uid || getegid() == sb.st_gid) {
rundir = strdup(RUNTIME_PATH); rundir = strdup(RUNTIME_PATH);
return rundir; return rundir;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment