diff options
| author | erdgeist <> | 2010-12-11 15:50:56 +0000 |
|---|---|---|
| committer | erdgeist <> | 2010-12-11 15:50:56 +0000 |
| commit | 85df3dbc016578481bf6c7e532e40c657a0b9b50 (patch) | |
| tree | 39dfaca9ddc85db7d6ef8dc354c3a2e153b05079 | |
| parent | 09adf4a9e15a04217df64adcba64e5e683ff24f8 (diff) | |
Open syslog connection before dropping privileges
| -rw-r--r-- | opentracker.c | 13 | ||||
| -rw-r--r-- | ot_stats.c | 7 |
2 files changed, 13 insertions, 7 deletions
diff --git a/opentracker.c b/opentracker.c index bb024b0..0c535ec 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -16,6 +16,9 @@ | |||
| 16 | #include <pwd.h> | 16 | #include <pwd.h> |
| 17 | #include <ctype.h> | 17 | #include <ctype.h> |
| 18 | #include <pthread.h> | 18 | #include <pthread.h> |
| 19 | #ifdef WANT_SYSLOGS | ||
| 20 | #include <syslog.h> | ||
| 21 | #endif | ||
| 19 | 22 | ||
| 20 | /* Libowfat */ | 23 | /* Libowfat */ |
| 21 | #include "socket.h" | 24 | #include "socket.h" |
| @@ -59,6 +62,11 @@ static void signal_handler( int s ) { | |||
| 59 | g_opentracker_running = 0; | 62 | g_opentracker_running = 0; |
| 60 | 63 | ||
| 61 | trackerlogic_deinit(); | 64 | trackerlogic_deinit(); |
| 65 | |||
| 66 | #ifdef WANT_SYSLOGS | ||
| 67 | closelog(); | ||
| 68 | #endif | ||
| 69 | |||
| 62 | exit( 0 ); | 70 | exit( 0 ); |
| 63 | } else if( s == SIGALRM ) { | 71 | } else if( s == SIGALRM ) { |
| 64 | /* Maintain our copy of the clock. time() on BSDs is very expensive. */ | 72 | /* Maintain our copy of the clock. time() on BSDs is very expensive. */ |
| @@ -600,6 +608,11 @@ int main( int argc, char **argv ) { | |||
| 600 | ot_try_bind( serverip, 6969, FLAG_UDP ); | 608 | ot_try_bind( serverip, 6969, FLAG_UDP ); |
| 601 | } | 609 | } |
| 602 | 610 | ||
| 611 | #ifdef WANT_SYSLOGS | ||
| 612 | openlog( "opentracker", 0, LOG_USER ); | ||
| 613 | setlogmask(LOG_UPTO(LOG_INFO)); | ||
| 614 | #endif | ||
| 615 | |||
| 603 | if( drop_privileges( g_serveruser ? g_serveruser : "nobody", g_serverdir ) == -1 ) | 616 | if( drop_privileges( g_serveruser ? g_serveruser : "nobody", g_serverdir ) == -1 ) |
| 604 | panic( "drop_privileges failed, exiting. Last error"); | 617 | panic( "drop_privileges failed, exiting. Last error"); |
| 605 | 618 | ||
| @@ -745,17 +745,10 @@ static pthread_t thread_id; | |||
| 745 | void stats_init( ) { | 745 | void stats_init( ) { |
| 746 | ot_start_time = g_now_seconds; | 746 | ot_start_time = g_now_seconds; |
| 747 | pthread_create( &thread_id, NULL, stats_worker, NULL ); | 747 | pthread_create( &thread_id, NULL, stats_worker, NULL ); |
| 748 | #ifdef WANT_SYSLOGS | ||
| 749 | openlog( "opentracker", 0, LOG_USER ); | ||
| 750 | setlogmask(LOG_UPTO(LOG_INFO)); | ||
| 751 | #endif | ||
| 752 | } | 748 | } |
| 753 | 749 | ||
| 754 | void stats_deinit( ) { | 750 | void stats_deinit( ) { |
| 755 | pthread_cancel( thread_id ); | 751 | pthread_cancel( thread_id ); |
| 756 | #ifdef WANT_SYSLOGS | ||
| 757 | closelog(); | ||
| 758 | #endif | ||
| 759 | } | 752 | } |
| 760 | 753 | ||
| 761 | const char *g_version_stats_c = "$Source$: $Revision$\n"; | 754 | const char *g_version_stats_c = "$Source$: $Revision$\n"; |
