summaryrefslogtreecommitdiffstats
path: root/plugin/eurephia.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/eurephia.c')
-rw-r--r--plugin/eurephia.c46
1 files changed, 11 insertions, 35 deletions
diff --git a/plugin/eurephia.c b/plugin/eurephia.c
index 761ab71..f93ee81 100644
--- a/plugin/eurephia.c
+++ b/plugin/eurephia.c
@@ -183,26 +183,15 @@ eurephiaCTX *eurephiaInit(const char **argv)
ctx->context_type = ECTX_PLUGIN_AUTH;
// Open a log file
- if( logfile != NULL ) {
- if( strcmp(logfile, "openvpn:") == 0 ) { // Let openvpn do the logging
- ctx->log = stderr;
- } else if( strcmp(logfile, "none:") == 0 ) { // Do not perform any logging
- ctx->log = NULL;
- } else { // if no hit on these ones,open a file with given name
- ctx->log = fopen(logfile, "aw");
- if( ctx->log == NULL ) {
- fprintf(stderr, "Could not open eurephia log file: %s\n", argv[1]);
- return NULL;
- }
- }
- } else {
- // If no logging is given ... log to openvpn:
- ctx->log = stderr;
+ if( (logfile == NULL) || (strcmp(logfile, "openvpn:") == 0) ) {
+ // If no logfile is given, or openvpn: is given, log to stderr which OpenVPN will
+ // take care of
+ eurephia_log_init(ctx, "stderr:", loglvl);
+ } else {
+ // If another log file is given, process that
+ eurephia_log_init(ctx, logfile, loglvl);
}
- // Set log verbosity
- ctx->loglevel = loglvl;
-
// Load the database driver
if( (error == 0) && eDBlink_init(ctx, dbi, 1) ) {
// Connect to the database
@@ -217,10 +206,8 @@ eurephiaCTX *eurephiaInit(const char **argv)
}
if( error > 0 ) {
- if( ctx->log != NULL ) {
- eurephia_log(ctx, LOG_PANIC, 0, "eurephia-auth is not available");
- fclose(ctx->log);
- }
+ eurephia_log(ctx, LOG_PANIC, 0, "eurephia-auth is not available");
+ eurephia_log_close(ctx);
free_nullsafe(ctx, ctx);
return NULL;
}
@@ -234,7 +221,7 @@ eurephiaCTX *eurephiaInit(const char **argv)
free_nullsafe(ctx, ctx->server_salt);
eDBdisconnect(ctx);
- fclose(ctx->log);
+ eurephia_log_close(ctx);
free_nullsafe(ctx, ctx);
return NULL;
}
@@ -287,18 +274,7 @@ int eurephiaShutdown(eurephiaCTX *ctx)
eDBlink_close(ctx);
}
- if( ctx->log != NULL ) {
- fflush(ctx->log);
-
- // Do not close log file if we're on stdout or stderr
- if( (ctx->log != stderr) && (ctx->log != stdout) ) {
- eurephia_log(ctx, LOG_INFO, 2, "Closing log file");
- fclose(ctx->log);
- }
-
- ctx->log = NULL;
- ctx->loglevel = 0;
- }
+ eurephia_log_close(ctx);
memset(ctx->server_salt, 0xff, SIZE_PWDCACHE_SALT+2);
free_nullsafe(ctx, ctx->server_salt);