diff options
author | erdgeist <> | 2010-04-09 09:33:39 +0000 |
---|---|---|
committer | erdgeist <> | 2010-04-09 09:33:39 +0000 |
commit | a1eec929a1c6e0661c8ce4a56cb044f7176170bf (patch) | |
tree | 15f174e42d7151ac0b70846423f19bf521c0d388 /opentracker.c | |
parent | a7cd2084df214c3488df8b754c68f0cd7a14c34e (diff) |
Only chroot if -d option or tracker.rootdir are set
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/opentracker.c b/opentracker.c index 57eca12..d0ab047 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -482,7 +482,7 @@ int drop_privileges (const char * const serverdir) { | |||
482 | 482 | ||
483 | if( geteuid() == 0 ) { | 483 | if( geteuid() == 0 ) { |
484 | /* Running as root: chroot and drop privileges */ | 484 | /* Running as root: chroot and drop privileges */ |
485 | if(chroot( serverdir )) { | 485 | if( serverdir && chroot( serverdir ) ) { |
486 | fprintf( stderr, "Could not chroot to %s, because: %s\n", serverdir, strerror(errno) ); | 486 | fprintf( stderr, "Could not chroot to %s, because: %s\n", serverdir, strerror(errno) ); |
487 | return -1; | 487 | return -1; |
488 | } | 488 | } |
@@ -504,7 +504,7 @@ int drop_privileges (const char * const serverdir) { | |||
504 | } | 504 | } |
505 | else { | 505 | else { |
506 | /* Normal user, just chdir() */ | 506 | /* Normal user, just chdir() */ |
507 | if(chdir( serverdir )) { | 507 | if( serverdir && chdir( serverdir ) ) { |
508 | fprintf( stderr, "Could not chroot to %s, because: %s\n", serverdir, strerror(errno) ); | 508 | fprintf( stderr, "Could not chroot to %s, because: %s\n", serverdir, strerror(errno) ); |
509 | return -1; | 509 | return -1; |
510 | } | 510 | } |
@@ -578,7 +578,7 @@ int main( int argc, char **argv ) { | |||
578 | ot_try_bind( serverip, 6969, FLAG_UDP ); | 578 | ot_try_bind( serverip, 6969, FLAG_UDP ); |
579 | } | 579 | } |
580 | 580 | ||
581 | if( drop_privileges( g_serverdir ? g_serverdir : "." ) == -1 ) | 581 | if( drop_privileges( g_serverdir ) == -1 ) |
582 | panic( "drop_privileges failed, exiting. Last error"); | 582 | panic( "drop_privileges failed, exiting. Last error"); |
583 | 583 | ||
584 | g_now_seconds = time( NULL ); | 584 | g_now_seconds = time( NULL ); |