summaryrefslogtreecommitdiff
path: root/anzeige.c
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-26 16:48:41 +0200
committerErich Eckner <git@eckner.net>2018-10-26 16:48:41 +0200
commit3dc6603ce56951f3868cdffeb9bb99cb8db2e4bf (patch)
tree4fba7163f85fca53d38f84fd649ccf4e5c25735f /anzeige.c
parent8b40ddb3f47c1faa3c671e701426c4a2c167022c (diff)
downloadanzeige-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.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/anzeige.c b/anzeige.c
index 60ac8f9..90282a2 100644
--- a/anzeige.c
+++ b/anzeige.c
@@ -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)