diff options
author | Erich Eckner <git@eckner.net> | 2018-10-26 16:48:41 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-26 16:48:41 +0200 |
commit | 3dc6603ce56951f3868cdffeb9bb99cb8db2e4bf (patch) | |
tree | 4fba7163f85fca53d38f84fd649ccf4e5c25735f /anzeige.c | |
parent | 8b40ddb3f47c1faa3c671e701426c4a2c167022c (diff) | |
download | anzeige-3dc6603ce56951f3868cdffeb9bb99cb8db2e4bf.tar.xz |
anzeige.c: do not fail if dropping of privileges fails due to being non-root
Diffstat (limited to 'anzeige.c')
-rw-r--r-- | anzeige.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -117,16 +117,20 @@ int main(int argc, char **argv) // void drop_privileges() { - /* Drop superuser privileges in correct order */ + /* Drop superuser privileges in correct order */ - if (setgid(99) == -1) { - perror("can't drop group privileges"); + int is_already_unprivileged = 0; + + if (setgid(99) == -1) { + perror("can't drop group privileges"); + if (! (is_already_unprivileged = (errno == 1))) exit(-1); - } - if (setuid(99) == -1) { - perror("can't drop user privileges"); + } + if (setuid(99) == -1) { + perror("can't drop user privileges"); + if (is_already_unprivileged != (errno == 1)) exit(-1); - } + } } // drop_root void handle_signals(int signo) |