From 09f4e65ada787ddeb7220a77b9489815c35cfa9a Mon Sep 17 00:00:00 2001 From: Andrew Dunai Date: Mon, 12 Dec 2016 14:34:57 +0200 Subject: [PATCH 1/3] Fix for missing cmd.py in default config that leads to a segfault --- src/lighthouse.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index 7095250..4716735 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -412,6 +412,7 @@ static void set_color_setting(char* val, color_t* color) { * @return Void. */ static void set_setting(char *param, char *val) { + fprintf(stderr, "%s = %s\n", param, val); if (!strcmp("font_name", param)) { settings.font_name = val; } else if (!strcmp("font_size", param)) { @@ -705,7 +706,14 @@ int main(int argc, char **argv) { /* Set up the remote process. */ int32_t to_child_fd, from_child_fd; - char *exec_file = settings.cmd; + char *exec_file; + if( access( settings.cmd, F_OK ) == -1 ) { + exec_file = "/usr/share/lighthouse/cmd.py"; + } else { + exec_file = settings.cmd; + } + + fprintf(stderr, exec_file); if (spawn_piped_process(exec_file, &to_child_fd, &from_child_fd, (char **)cmdargs)) { fprintf(stderr, "Failed to spawn piped process.\n"); From acd1d91e58371171db729a42e963a9e4152dc3a7 Mon Sep 17 00:00:00 2001 From: Andrew Dunai Date: Mon, 12 Dec 2016 14:38:06 +0200 Subject: [PATCH 2/3] Cleanup. --- src/lighthouse.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index 4716735..1589c32 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -412,7 +412,6 @@ static void set_color_setting(char* val, color_t* color) { * @return Void. */ static void set_setting(char *param, char *val) { - fprintf(stderr, "%s = %s\n", param, val); if (!strcmp("font_name", param)) { settings.font_name = val; } else if (!strcmp("font_size", param)) { @@ -707,14 +706,12 @@ int main(int argc, char **argv) { int32_t to_child_fd, from_child_fd; char *exec_file; - if( access( settings.cmd, F_OK ) == -1 ) { + if(access( settings.cmd, F_OK ) == -1) { exec_file = "/usr/share/lighthouse/cmd.py"; } else { exec_file = settings.cmd; } - fprintf(stderr, exec_file); - if (spawn_piped_process(exec_file, &to_child_fd, &from_child_fd, (char **)cmdargs)) { fprintf(stderr, "Failed to spawn piped process.\n"); exit_code = 1; From 4bc0c6dd52fdcc0e4d4f9a6668b435114c398ca9 Mon Sep 17 00:00:00 2001 From: Andrew Dunai Date: Mon, 12 Dec 2016 14:40:31 +0200 Subject: [PATCH 3/3] More cleanup. --- src/lighthouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lighthouse.c b/src/lighthouse.c index 1589c32..dc477dd 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -706,7 +706,7 @@ int main(int argc, char **argv) { int32_t to_child_fd, from_child_fd; char *exec_file; - if(access( settings.cmd, F_OK ) == -1) { + if(access(settings.cmd, F_OK) == -1) { exec_file = "/usr/share/lighthouse/cmd.py"; } else { exec_file = settings.cmd;