summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Porte <microjoe@microjoe.org>2021-08-03 13:53:13 +0200
committerDirk Engling <erdgeist@erdgeist.org>2021-08-22 14:40:31 +0200
commitc4fc41a8315614dd91119b34330152775682e280 (patch)
treec7068ea7b171c9ee692c47f746a0ebb9b55f1fad
parent9a20ebe3f2ee5c4aebb8b5abb679ede92dddb90c (diff)
opentracker.c: check set*id return values
This commit fix the following similar warnings: opentracker.c:562:7: warning: ignoring return value of ‘setegid’ declared with attribute ‘warn_unused_result’ [-Wunused-result] […] The man page of these functions ask users to explicitly check the return value in case of any error happening.
-rw-r--r--opentracker.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c
index 8323552..2bb66fa 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -559,12 +559,20 @@ int drop_privileges ( const char * const serveruser, const char * const serverdi
559 /* If we can't find server user, revert to nobody's default uid */ 559 /* If we can't find server user, revert to nobody's default uid */
560 if( !pws ) { 560 if( !pws ) {
561 fprintf( stderr, "Warning: Could not get password entry for %s. Reverting to uid -2.\n", serveruser ); 561 fprintf( stderr, "Warning: Could not get password entry for %s. Reverting to uid -2.\n", serveruser );
562 setegid( (gid_t)-2 ); setgid( (gid_t)-2 ); 562 if (!setegid( (gid_t)-2 ) ||
563 setuid( (uid_t)-2 ); seteuid( (uid_t)-2 ); 563 !setgid( (gid_t)-2 ) ||
564 !setuid( (uid_t)-2 ) ||
565 !seteuid( (uid_t)-2 )) {
566 panic("Could not set uid to value -2");
567 }
564 } 568 }
565 else { 569 else {
566 setegid( pws->pw_gid ); setgid( pws->pw_gid ); 570 if (!setegid( pws->pw_gid ) ||
567 setuid( pws->pw_uid ); seteuid( pws->pw_uid ); 571 !setgid( pws->pw_gid ) ||
572 !setuid( pws->pw_uid ) ||
573 !seteuid( pws->pw_uid )) {
574 panic("Could not set uid to specified value");
575 }
568 } 576 }
569 577
570 if( geteuid() == 0 || getegid() == 0 ) 578 if( geteuid() == 0 || getegid() == 0 )