diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-02-25 18:09:20 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-02-25 18:09:20 -0500 |
commit | 40b3215444ed48d2ed9bbaa00f20f266f5318f5a (patch) | |
tree | 4965c10cc32bf0159bca874c50d9a53767159a2f | |
parent | Merge pull request #493 from mikkeloscar/view-behind-swaylock (diff) | |
parent | Fix for when sway_abort doesn't exit (diff) | |
download | sway-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
-rw-r--r-- | sway/main.c | 6 | ||||
-rw-r--r-- | sway/sway.5.txt | 2 |
2 files changed, 6 insertions, 2 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; | |||
25 | void sway_terminate(void) { | 25 | void 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 | ||
30 | void sig_handler(int signal) { | 31 | void 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"); |
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index b54ae8da..004e0f54 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -16,7 +16,7 @@ startup. These commands usually consist of setting your preferences and setting | |||
16 | key bindings. An example config is likely present in /etc/sway/config for you to | 16 | key bindings. An example config is likely present in /etc/sway/config for you to |
17 | check out. | 17 | check out. |
18 | 18 | ||
19 | All of these commands may be issued at runtime through **sway-msg**(1). | 19 | All of these commands may be issued at runtime through **swaymsg**(1). |
20 | 20 | ||
21 | Commands | 21 | Commands |
22 | -------- | 22 | -------- |