Fix remaining uses of hardcoded /tmp to get the socket paths
Fixes #1097
This commit is contained in:
parent
968e573d80
commit
e42881fa38
|
@ -133,6 +133,15 @@ String compact_path(StringView filename)
|
||||||
return filename.str();
|
return filename.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringView tmpdir()
|
||||||
|
{
|
||||||
|
StringView tmpdir = getenv("TMPDIR");
|
||||||
|
if (not tmpdir.empty())
|
||||||
|
return tmpdir.back() == '/' ? tmpdir.substr(0_byte, tmpdir.length()-1)
|
||||||
|
: tmpdir;
|
||||||
|
return "/tmp";
|
||||||
|
}
|
||||||
|
|
||||||
bool fd_readable(int fd)
|
bool fd_readable(int fd)
|
||||||
{
|
{
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
|
|
|
@ -24,6 +24,8 @@ String parse_filename(StringView filename);
|
||||||
String real_path(StringView filename);
|
String real_path(StringView filename);
|
||||||
String compact_path(StringView filename);
|
String compact_path(StringView filename);
|
||||||
|
|
||||||
|
StringView tmpdir();
|
||||||
|
|
||||||
// returns pair { directory, filename }
|
// returns pair { directory, filename }
|
||||||
std::pair<StringView, StringView> split_path(StringView path);
|
std::pair<StringView, StringView> split_path(StringView path);
|
||||||
|
|
||||||
|
|
|
@ -761,8 +761,10 @@ int main(int argc, char* argv[])
|
||||||
const bool clear_sessions = (bool)parser.get_switch("clear");
|
const bool clear_sessions = (bool)parser.get_switch("clear");
|
||||||
if (list_sessions or clear_sessions)
|
if (list_sessions or clear_sessions)
|
||||||
{
|
{
|
||||||
StringView username = getpwuid(geteuid())->pw_name;
|
const StringView username = getpwuid(geteuid())->pw_name;
|
||||||
for (auto& session : list_files(format("/tmp/kakoune/{}/", username)))
|
const StringView tmp_dir = tmpdir();
|
||||||
|
for (auto& session : list_files(format("{}/kakoune/{}/", tmp_dir,
|
||||||
|
username)))
|
||||||
{
|
{
|
||||||
const bool valid = check_session(session);
|
const bool valid = check_session(session);
|
||||||
if (list_sessions)
|
if (list_sessions)
|
||||||
|
@ -770,7 +772,8 @@ int main(int argc, char* argv[])
|
||||||
if (not valid and clear_sessions)
|
if (not valid and clear_sessions)
|
||||||
{
|
{
|
||||||
char socket_file[128];
|
char socket_file[128];
|
||||||
format_to(socket_file, "/tmp/kakoune/{}/{}", username, session);
|
format_to(socket_file, "{}/kakoune/{}/{}", tmp_dir,
|
||||||
|
username, session);
|
||||||
unlink(socket_file);
|
unlink(socket_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,15 +480,6 @@ void RemoteUI::set_ui_options(const Options& options)
|
||||||
m_socket_watcher.events() |= FdEvents::Write;
|
m_socket_watcher.events() |= FdEvents::Write;
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringView tmpdir()
|
|
||||||
{
|
|
||||||
StringView tmpdir = getenv("TMPDIR");
|
|
||||||
if (not tmpdir.empty())
|
|
||||||
return tmpdir.back() == '/' ? tmpdir.substr(0_byte, tmpdir.length()-1)
|
|
||||||
: tmpdir;
|
|
||||||
return "/tmp";
|
|
||||||
}
|
|
||||||
|
|
||||||
static sockaddr_un session_addr(StringView session)
|
static sockaddr_un session_addr(StringView session)
|
||||||
{
|
{
|
||||||
sockaddr_un addr;
|
sockaddr_un addr;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user