summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)