mirror of
git://erdgeist.org/opentracker
synced 2025-02-22 17:11:29 +08:00
Only chroot if -d option or tracker.rootdir are set
This commit is contained in:
parent
a7cd2084df
commit
a1eec929a1
@ -482,7 +482,7 @@ int drop_privileges (const char * const serverdir) {
|
||||
|
||||
if( geteuid() == 0 ) {
|
||||
/* Running as root: chroot and drop privileges */
|
||||
if(chroot( serverdir )) {
|
||||
if( serverdir && chroot( serverdir ) ) {
|
||||
fprintf( stderr, "Could not chroot to %s, because: %s\n", serverdir, strerror(errno) );
|
||||
return -1;
|
||||
}
|
||||
@ -504,7 +504,7 @@ int drop_privileges (const char * const serverdir) {
|
||||
}
|
||||
else {
|
||||
/* Normal user, just chdir() */
|
||||
if(chdir( serverdir )) {
|
||||
if( serverdir && chdir( serverdir ) ) {
|
||||
fprintf( stderr, "Could not chroot to %s, because: %s\n", serverdir, strerror(errno) );
|
||||
return -1;
|
||||
}
|
||||
@ -578,7 +578,7 @@ int main( int argc, char **argv ) {
|
||||
ot_try_bind( serverip, 6969, FLAG_UDP );
|
||||
}
|
||||
|
||||
if( drop_privileges( g_serverdir ? g_serverdir : "." ) == -1 )
|
||||
if( drop_privileges( g_serverdir ) == -1 )
|
||||
panic( "drop_privileges failed, exiting. Last error");
|
||||
|
||||
g_now_seconds = time( NULL );
|
||||
|
Loading…
x
Reference in New Issue
Block a user