Move journal pipe file to fix permissions issues

This commit is contained in:
Vinyl Darkscratch 2019-02-14 02:19:46 -08:00
parent dc63f3ea82
commit 8e93cf51ef
3 changed files with 10 additions and 7 deletions

View file

@ -16,11 +16,15 @@
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <pwd.h>
#include <string>
std::string PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-pipe";
void cleanup_pipe() void cleanup_pipe()
{ {
unlink(PIPE_PATH); unlink(PIPE_PATH.c_str());
remove(PIPE_PATH); remove(PIPE_PATH.c_str());
} }
#endif #endif
@ -48,10 +52,10 @@ int server_thread(void *data)
} }
CloseHandle(pipe); CloseHandle(pipe);
#else #else
if (FILE *file = fopen(PIPE_PATH, "r")) if (FILE *file = fopen(PIPE_PATH.c_str(), "r"))
{ {
fclose(file); 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); SDL_LockMutex(mutex);
active = true; active = true;
if (message_len > 0) if (message_len > 0)
@ -148,7 +152,7 @@ void journalBindingInit()
memset((char*)lang_buffer, 0, BUFFER_SIZE); memset((char*)lang_buffer, 0, BUFFER_SIZE);
lang_buffer[0] = '_'; lang_buffer[0] = '_';
#if defined __linux #if defined __linux
mkfifo(PIPE_PATH, 0666); mkfifo(PIPE_PATH.c_str(), 0666);
atexit(cleanup_pipe); atexit(cleanup_pipe);
#endif #endif

View file

@ -41,7 +41,6 @@ static volatile bool active = false;
static volatile int message_len = 0; static volatile int message_len = 0;
#ifdef LINUX #ifdef LINUX
#define PIPE_PATH "/tmp/oneshot-pipe"
static volatile int out_pipe = -1; static volatile int out_pipe = -1;
void cleanup_pipe(); void cleanup_pipe();
#endif #endif

View file

@ -13,7 +13,7 @@ if sys.platform == "win32":
ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf) ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)
documents_path = os.path.join(buf.value, 'My Games') documents_path = os.path.join(buf.value, 'My Games')
else: else:
pipe_path = '/tmp/oneshot-pipe' pipe_path = os.path.expanduser('~/.oneshot-pipe')
documents_path = os.path.expanduser('~/Documents') documents_path = os.path.expanduser('~/Documents')
left_close = False left_close = False