|
|
3f3db9f |
diff -Nur opentracker-20160728.orig/opentracker.c opentracker-20160728/opentracker.c
|
|
|
3f3db9f |
--- opentracker-20160728.orig/opentracker.c 2014-10-06 16:32:28.000000000 -0600
|
|
|
3f3db9f |
+++ opentracker-20160728/opentracker.c 2016-07-28 14:35:00.232095930 -0600
|
|
|
3f3db9f |
@@ -103,7 +103,7 @@
|
|
Simon Wesp |
4294686 |
}
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
static void usage( char *name ) {
|
|
Simon Wesp |
4294686 |
- fprintf( stderr, "Usage: %s [-i ip] [-p port] [-P port] [-r redirect] [-d dir] [-u user] [-A ip] [-f config] [-s livesyncport]"
|
|
Simon Wesp |
4294686 |
+ fprintf( stderr, "Usage: %s [-i ip] [-p port] [-P port] [-r redirect] [-d dir] [-u user] [-A ip] [-f config] [-s livesyncport] [-m run as daemon]"
|
|
Simon Wesp |
4294686 |
#ifdef WANT_ACCESSLIST_BLACK
|
|
Simon Wesp |
4294686 |
" [-b blacklistfile]"
|
|
Simon Wesp |
4294686 |
#elif defined ( WANT_ACCESSLIST_WHITE )
|
|
|
3f3db9f |
@@ -122,8 +122,9 @@
|
|
Simon Wesp |
4294686 |
HELPLINE("-P port","specify udp port to bind to (default: 6969, you may specify more than one)");
|
|
Simon Wesp |
4294686 |
HELPLINE("-r redirecturl","specify url where / should be redirected to (default none)");
|
|
Simon Wesp |
4294686 |
HELPLINE("-d dir","specify directory to try to chroot to (default: \".\")");
|
|
Simon Wesp |
4294686 |
- HELPLINE("-u user","specify user under whose priviliges opentracker should run (default: \"nobody\")");
|
|
Simon Wesp |
4294686 |
+ HELPLINE("-u user","specify user under whose priviliges opentracker should run (default: \"opentracker\")");
|
|
Simon Wesp |
4294686 |
HELPLINE("-A ip","bless an ip address as admin address (e.g. to allow syncs from this address)");
|
|
Simon Wesp |
4294686 |
+ HELPLINE("-m ","run as deamon");
|
|
Simon Wesp |
4294686 |
#ifdef WANT_ACCESSLIST_BLACK
|
|
Simon Wesp |
4294686 |
HELPLINE("-b file","specify blacklist file.");
|
|
Simon Wesp |
4294686 |
#elif defined( WANT_ACCESSLIST_WHITE )
|
|
|
3f3db9f |
@@ -552,7 +553,7 @@
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
int main( int argc, char **argv ) {
|
|
Simon Wesp |
4294686 |
ot_ip6 serverip, tmpip;
|
|
Simon Wesp |
4294686 |
- int bound = 0, scanon = 1;
|
|
Simon Wesp |
4294686 |
+ int bound = 0, scanon = 1, pid = 0;
|
|
Simon Wesp |
4294686 |
uint16_t tmpport;
|
|
Simon Wesp |
4294686 |
char * statefile = 0;
|
|
Simon Wesp |
4294686 |
|
|
|
3f3db9f |
@@ -569,7 +570,7 @@
|
|
Simon Wesp |
4294686 |
#endif
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
while( scanon ) {
|
|
Simon Wesp |
4294686 |
- switch( getopt( argc, argv, ":i:p:A:P:d:u:r:s:f:l:v"
|
|
Simon Wesp |
4294686 |
+ switch( getopt( argc, argv, ":i:p:A:P:d:u:r:s:f:l:v:m"
|
|
Simon Wesp |
4294686 |
#ifdef WANT_ACCESSLIST_BLACK
|
|
Simon Wesp |
4294686 |
"b:"
|
|
Simon Wesp |
4294686 |
#elif defined( WANT_ACCESSLIST_WHITE )
|
|
|
3f3db9f |
@@ -605,6 +606,7 @@
|
|
Simon Wesp |
4294686 |
accesslist_blessip( tmpip, 0xffff ); /* Allow everything for now */
|
|
Simon Wesp |
4294686 |
break;
|
|
Simon Wesp |
4294686 |
case 'f': bound += parse_configfile( optarg ); break;
|
|
Simon Wesp |
4294686 |
+ case 'm': pid = 1; break;
|
|
Simon Wesp |
4294686 |
case 'h': help( argv[0] ); exit( 0 );
|
|
Simon Wesp |
4294686 |
case 'v': {
|
|
Simon Wesp |
4294686 |
char buffer[8192];
|
|
|
3f3db9f |
@@ -617,6 +619,7 @@
|
|
Simon Wesp |
4294686 |
}
|
|
Simon Wesp |
4294686 |
}
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
+ bound += parse_configfile( "INPUTCONFFILEHERE" );
|
|
Simon Wesp |
4294686 |
/* Bind to our default tcp/udp ports */
|
|
Simon Wesp |
4294686 |
if( !bound) {
|
|
Simon Wesp |
4294686 |
ot_try_bind( serverip, 6969, FLAG_TCP );
|
|
|
3f3db9f |
@@ -628,9 +631,21 @@
|
|
|
3f3db9f |
setlogmask(LOG_UPTO(LOG_INFO));
|
|
|
3f3db9f |
#endif
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
- if( drop_privileges( g_serveruser ? g_serveruser : "nobody", g_serverdir ) == -1 )
|
|
Simon Wesp |
4294686 |
+ if( drop_privileges( g_serveruser ? g_serveruser : "opentracker", g_serverdir ) == -1 )
|
|
Simon Wesp |
4294686 |
panic( "drop_privileges failed, exiting. Last error");
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
+ if (pid) {
|
|
Simon Wesp |
4294686 |
+ pid = fork();
|
|
|
3f3db9f |
+ if (pid == -1) {
|
|
Simon Wesp |
4294686 |
+ perror("fork");
|
|
Simon Wesp |
4294686 |
+ exit(EXIT_FAILURE);
|
|
|
3f3db9f |
+ } else if (pid != 0) {
|
|
Simon Wesp |
4294686 |
+ exit(EXIT_SUCCESS);
|
|
|
3f3db9f |
+ }
|
|
|
3f3db9f |
+ freopen("/dev/null", "a+", stdout);
|
|
|
3f3db9f |
+ freopen("/dev/null", "a+", stderr);
|
|
Simon Wesp |
4294686 |
+ }
|
|
Simon Wesp |
4294686 |
+
|
|
Simon Wesp |
4294686 |
g_now_seconds = time( NULL );
|
|
Simon Wesp |
4294686 |
|
|
Simon Wesp |
4294686 |
/* Create our self pipe which allows us to interrupt mainloops
|