diff options
-rw-r--r-- | opentracker.c | 16 |
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 ) |