From 7751c7e188bfc7b2f7e4a70e33032677d84597e5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 25 Jan 2021 17:12:18 +1100 Subject: [PATCH] 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. --- src/remote.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/remote.cc b/src/remote.cc index 6ba9164e..0cafd763 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -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); }