|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
It is considered beerware. Prost. Skol. Cheers or whatever.
|
|
|
|
|
Some of the stuff below is stolen from Fefes example libowfat httpd.
|
|
|
|
|
|
|
|
|
|
$Id: opentracker.c,v 1.227 2009/11/18 04:00:26 erdgeist Exp $ */
|
|
|
|
|
$Id: opentracker.c,v 1.228 2010/04/09 09:33:39 erdgeist Exp $ */
|
|
|
|
|
|
|
|
|
|
/* System */
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@ -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 );
|
|
|
|
@ -605,4 +605,4 @@ int main( int argc, char **argv ) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.227 $\n";
|
|
|
|
|
const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.228 $\n";
|
|
|
|
|