mirror of
git://erdgeist.org/opentracker
synced 2025-04-19 11:14:32 +08:00
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.
This commit is contained in:
parent
9a20ebe3f2
commit
c4fc41a831
@ -559,12 +559,20 @@ int drop_privileges ( const char * const serveruser, const char * const serverdi
|
|||||||
/* If we can't find server user, revert to nobody's default uid */
|
/* If we can't find server user, revert to nobody's default uid */
|
||||||
if( !pws ) {
|
if( !pws ) {
|
||||||
fprintf( stderr, "Warning: Could not get password entry for %s. Reverting to uid -2.\n", serveruser );
|
fprintf( stderr, "Warning: Could not get password entry for %s. Reverting to uid -2.\n", serveruser );
|
||||||
setegid( (gid_t)-2 ); setgid( (gid_t)-2 );
|
if (!setegid( (gid_t)-2 ) ||
|
||||||
setuid( (uid_t)-2 ); seteuid( (uid_t)-2 );
|
!setgid( (gid_t)-2 ) ||
|
||||||
|
!setuid( (uid_t)-2 ) ||
|
||||||
|
!seteuid( (uid_t)-2 )) {
|
||||||
|
panic("Could not set uid to value -2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setegid( pws->pw_gid ); setgid( pws->pw_gid );
|
if (!setegid( pws->pw_gid ) ||
|
||||||
setuid( pws->pw_uid ); seteuid( pws->pw_uid );
|
!setgid( pws->pw_gid ) ||
|
||||||
|
!setuid( pws->pw_uid ) ||
|
||||||
|
!seteuid( pws->pw_uid )) {
|
||||||
|
panic("Could not set uid to specified value");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( geteuid() == 0 || getegid() == 0 )
|
if( geteuid() == 0 || getegid() == 0 )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user