From 8e93cf51ef8255b1d64c668188146e9ea661b24c Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 14 Feb 2019 02:19:46 -0800 Subject: [PATCH] Move journal pipe file to fix permissions issues --- binding-mri/journal-binding.cpp | 14 +++++++++----- binding-mri/journal-binding.h | 1 - journal/unix/journal.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/binding-mri/journal-binding.cpp b/binding-mri/journal-binding.cpp index a577a14..2407c5c 100644 --- a/binding-mri/journal-binding.cpp +++ b/binding-mri/journal-binding.cpp @@ -16,11 +16,15 @@ #endif #include #include + #include + #include + + std::string PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-pipe"; void cleanup_pipe() { - unlink(PIPE_PATH); - remove(PIPE_PATH); + unlink(PIPE_PATH.c_str()); + remove(PIPE_PATH.c_str()); } #endif @@ -48,10 +52,10 @@ int server_thread(void *data) } CloseHandle(pipe); #else - if (FILE *file = fopen(PIPE_PATH, "r")) + if (FILE *file = fopen(PIPE_PATH.c_str(), "r")) { fclose(file); - out_pipe = open(PIPE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + out_pipe = open(PIPE_PATH.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); SDL_LockMutex(mutex); active = true; if (message_len > 0) @@ -148,7 +152,7 @@ void journalBindingInit() memset((char*)lang_buffer, 0, BUFFER_SIZE); lang_buffer[0] = '_'; #if defined __linux - mkfifo(PIPE_PATH, 0666); + mkfifo(PIPE_PATH.c_str(), 0666); atexit(cleanup_pipe); #endif diff --git a/binding-mri/journal-binding.h b/binding-mri/journal-binding.h index 45c8b1b..74b7d68 100644 --- a/binding-mri/journal-binding.h +++ b/binding-mri/journal-binding.h @@ -41,7 +41,6 @@ static volatile bool active = false; static volatile int message_len = 0; #ifdef LINUX - #define PIPE_PATH "/tmp/oneshot-pipe" static volatile int out_pipe = -1; void cleanup_pipe(); #endif diff --git a/journal/unix/journal.py b/journal/unix/journal.py index 23b994c..b7973f6 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -13,7 +13,7 @@ if sys.platform == "win32": ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf) documents_path = os.path.join(buf.value, 'My Games') else: - pipe_path = '/tmp/oneshot-pipe' + pipe_path = os.path.expanduser('~/.oneshot-pipe') documents_path = os.path.expanduser('~/Documents') left_close = False