aboutsummaryrefslogtreecommitdiffstats
path: root/sway/main.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-02-25 18:09:20 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-02-25 18:09:20 -0500
commit40b3215444ed48d2ed9bbaa00f20f266f5318f5a (patch)
tree4965c10cc32bf0159bca874c50d9a53767159a2f /sway/main.c
parentMerge pull request #493 from mikkeloscar/view-behind-swaylock (diff)
parentFix for when sway_abort doesn't exit (diff)
downloadsway-40b3215444ed48d2ed9bbaa00f20f266f5318f5a.tar.gz
sway-40b3215444ed48d2ed9bbaa00f20f266f5318f5a.tar.zst
sway-40b3215444ed48d2ed9bbaa00f20f266f5318f5a.zip
Merge pull request #494 from gpyh/argsegfault
Fix segfault when trying to use sway as IPC without a sway instance
Diffstat (limited to 'sway/main.c')
-rw-r--r--sway/main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sway/main.c b/sway/main.c
index db2ed856..6adbf89d 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -25,6 +25,7 @@ static bool terminate_request = false;
25void sway_terminate(void) { 25void sway_terminate(void) {
26 terminate_request = true; 26 terminate_request = true;
27 wlc_terminate(); 27 wlc_terminate();
28 exit(EXIT_FAILURE);
28} 29}
29 30
30void sig_handler(int signal) { 31void sig_handler(int signal) {
@@ -103,7 +104,7 @@ int main(int argc, char **argv) {
103 int c; 104 int c;
104 while (1) { 105 while (1) {
105 int option_index = 0; 106 int option_index = 0;
106 c = getopt_long(argc, argv, "hCdvVpc:", long_options, &option_index); 107 c = getopt_long(argc, argv, "hCdvVc:", long_options, &option_index);
107 if (c == -1) { 108 if (c == -1) {
108 break; 109 break;
109 } 110 }
@@ -148,6 +149,9 @@ int main(int argc, char **argv) {
148 } 149 }
149 150
150 if (optind < argc) { // Behave as IPC client 151 if (optind < argc) { // Behave as IPC client
152 if(optind != 1) {
153 sway_abort("Don't use options with the IPC client");
154 }
151 if (getuid() != geteuid() || getgid() != getegid()) { 155 if (getuid() != geteuid() || getgid() != getegid()) {
152 if (setgid(getgid()) != 0 || setuid(getuid()) != 0) { 156 if (setgid(getgid()) != 0 || setuid(getuid()) != 0) {
153 sway_abort("Unable to drop root"); 157 sway_abort("Unable to drop root");