Check XDG_RUNTIME_DIR owner before creating session directory

This avoids an issue when using `su` and running Kakoune which creates
a session directory owned by root and prevents the user from creating
more sessions.
This commit is contained in:
Maxime Coste 2021-01-25 17:12:18 +11:00
parent b8f1df6458
commit 7751c7e188

View File

@ -604,6 +604,10 @@ void make_session_directory()
// set sticky bit on the shared kakoune directory
make_directory(format("{}/kakoune", tmpdir()), 01777);
}
else if (struct stat st;
stat(xdg_runtime_dir.zstr(), &st) == 0 && st.st_uid != geteuid())
throw runtime_error("XDG_RUNTIME_DIR is not owned by current user");
make_directory(session_directory(), 0711);
}