Logger fixes for syslog, version up, merge

This commit is contained in:
Alexey Khromov 2024-05-15 21:53:57 +03:00
parent a315b13075
commit 8f2670091c
3 changed files with 11 additions and 6 deletions

View File

@ -1 +1 @@
0.24.1
0.24.2

View File

@ -26,6 +26,7 @@ static char log_name[BF_MAXPATH+1] = BFORCE_LOGFILE;
static char log_extension[32] = "";
static char log_ident[32] = "";
static char log_ttyname[32] = "";
static int log_sl_opened = FALSE;
#ifdef DEBUG
/*
@ -291,7 +292,7 @@ const char *log_getfilename(int whatfor)
bool log_isopened(void)
{
return TRUE;
return log_sl_opened;
}
int log_open(const char *logname, const char *ext, const char *tty)
@ -299,14 +300,17 @@ int log_open(const char *logname, const char *ext, const char *tty)
char *p = "bforce";
int fac = conf_number(cf_syslog_facility);
if( tty && *tty )
strncpy(p, tty, sizeof(p));
strncpy(tty, p, sizeof(p));
openlog(p, LOG_PID, fac);
log_sl_opened = TRUE;
return 0;
}
int log_reopen(const char *logname, const char *ext, const char *tty)
{
return 0;
if (!log_sl_opened) {
return log_open(logname, ext, tty);
} else return 0;
}
int log_close(void)

View File

@ -79,8 +79,8 @@ void exec_options_init(s_exec_options *eopt)
eopt->envp[0] = NULL;
i = 0;
while(mainenv[i]) {
log("EXEC: Added ENV variable: %s\n", mainenv[i]);
eopt->envp[i] = malloc(strlen(mainenv[i]) + 2);
DEB((D_FREE, "EXEC: Added ENV variable: %s\n", mainenv[i]));
eopt->envp[i] = xmalloc(strlen(mainenv[i]) + 2);
sprintf(eopt->envp[i], mainenv[i]);
eopt->envp[++i] = NULL;
}
@ -109,6 +109,7 @@ void exec_env_add(s_exec_options *eopt, const char *name, const char *value)
{
eopt->envp[i] = xmalloc(strlen(name) + strlen(value) + 2);
sprintf(eopt->envp[i], "%s=%s", name, value);
DEB((D_FREE, "EXEC: Added ENV variable: %s=%s\n", name, value));
eopt->envp[i+1] = NULL;
}
}