Skip to content

Commit

Permalink
Util: workaround in start_daemon() for AppImage
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTumultuousUnicornOfDarkness committed Jan 9, 2021
1 parent f573111 commit 4567e88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ add_definitions(-DPRGVER="${PROJECT_VERSION}"
-DGETTEXT_PACKAGE="${CMAKE_PROJECT_NAME}"
-DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
-DTERMINFODIR="/lib/terminfo"
-DDAEMON_EXEC="${DAEMON_EXEC}"
-DDAEMON_PATH="${DAEMON_PATH}"
)

Expand Down
3 changes: 3 additions & 0 deletions src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,5 +408,8 @@ int main(void)
free(ti->thread);
pthread_mutex_destroy(&ti->mutex);

if(getenv("APPDIR") != NULL)
remove("/tmp/"DAEMON_EXEC);

return err;
}
9 changes: 8 additions & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,19 @@ const char *start_daemon(bool graphical)
pid_t pid;
char *msg = NULL;
char *const appdir = getenv("APPDIR");
char *const daemon = (appdir == NULL) ? DAEMON_PATH : format("%s/%s", appdir, DAEMON_PATH);
char *const daemon = (appdir == NULL) ? DAEMON_PATH : format("/tmp/%s", DAEMON_EXEC);
char *const cmd1[] = { daemon, NULL };
char *const cmd2[] = { "pkexec", daemon, NULL };
char *const cmd3[] = { "pkexec", "--disable-internal-agent", daemon, NULL };
char *const *cmd = cmd2;

if(appdir != NULL)
{
/* Hack to allow pkexec to run daemon (when running from AppImage) */
char *const cmdcopy = format("cp %s/%s %s", appdir, DAEMON_PATH, daemon);
system(cmdcopy);
}

if(graphical)
cmd = cmd3;
else if(IS_ROOT)
Expand Down

0 comments on commit 4567e88

Please sign in to comment.