Minor fixes of Wunused_var, environment copy on subprocess creation

master
Alexey Khromov 6 months ago
parent 30e860885f
commit 097b39faa7

@ -146,6 +146,7 @@ clean:
rm -f ./bin/core
clean-am:
rm -f ./Makefile
rm -f ../debian/Makefile
rm -f ./include/config.h
rm -f ./config.log
rm -f ./config.status

@ -755,6 +755,7 @@ int daemon_pidfile(int cmd)
pid_t hispid, mypid = getpid();
FILE *pf;
struct stat sb;
int res;
if( !pidfile )
return 0;
@ -768,7 +769,12 @@ int daemon_pidfile(int cmd)
return -1;
}
fscanf(pf, "%d", &hispid);
res = fscanf(pf, "%d", &hispid);
if (res != 1) {
log("daemon pidfile: not readable");
return -1;
}
fclose(pf);
if( hispid ) {
@ -807,7 +813,12 @@ int daemon_pidfile(int cmd)
return -1;
}
fscanf(pf, "%d", &hispid);
res = fscanf(pf, "%d", &hispid);
if (res != 1) {
log("daemon pidfile: not readable");
return -1;
}
fclose(pf);
if( !hispid || (hispid == mypid) ) {
@ -831,7 +842,12 @@ int daemon_pidfile(int cmd)
return -1;
}
fscanf(pf, "%d", &hispid);
res = fscanf(pf, "%d", &hispid);
if (res != 1) {
log("daemon pidfile: not readable");
return -1;
}
fclose(pf);
unlink(pidfile);

@ -26,6 +26,8 @@ struct {
{ NULL, 0 }
};
extern char **environ;
int exec_file_exist(const char *command)
{
const char *p;
@ -73,9 +75,19 @@ int exec_options_parse(char *str)
void exec_options_init(s_exec_options *eopt)
{
char ** env;
int i;
memset(eopt, '\0', sizeof(s_exec_options));
eopt->umask = EXEC_DEFAULT_UMASK;
env = environ;
eopt->envp[0] = NULL;
for (i=0; env[i]; i++) {
log("EXEC: Added ENV variable: %s\n", env[i]);
eopt->envp[i] = xmalloc(strlen(env[i]) + 2);
sprintf(eopt->envp[i], env[i]);
eopt->envp[i+1] = NULL;
}
}
void exec_options_deinit(s_exec_options *eopt)

@ -311,6 +311,7 @@ int session_set_inbound(void)
{
struct stat st;
char *p_inb;
int res;
p_inb = conf_string(cf_inbound_directory);
if( !p_inb ) {
@ -342,7 +343,11 @@ int session_set_inbound(void)
log("inbound: %s", buf);
state.inbound = (char*)xstrcpy(buf);
snprintf( buf, PATH_MAX+30, "/bin/mkdir -p -m 700 %s", state.inbound ); /* 30 additional chars allowed */
system( buf );
res = system( buf );
if (res != 0) {
log("Inbound create error: %d", res);
return -1;
}
}
else
{

@ -70,12 +70,14 @@ static char *session_stat_get_stsfile(s_faddr *addr, int linenum)
static int session_stat_read_stsfile(FILE *fp, s_sess_stat *stat)
{
int res;
if( fseek(fp, 0, SEEK_SET) == -1 )
return -1;
memset(stat, '\0', sizeof(s_sess_stat));
fscanf(fp, "%u %u %u %u %u %u %lu %lu %lu %lu",
res = fscanf(fp, "%u %u %u %u %u %u %lu %lu %lu %lu",
(unsigned int *) &stat->tries,
(unsigned int *) &stat->tries_noconn,
(unsigned int *) &stat->tries_noansw,
@ -86,7 +88,10 @@ static int session_stat_read_stsfile(FILE *fp, s_sess_stat *stat)
(unsigned long *) &stat->hold_freqs,
(unsigned long *) &stat->last_success_out,
(unsigned long *) &stat->last_success_in);
if (res == 0) {
log("Read STS unsuccessfull...");
return -1;
}
/* Set last successfull session time */
stat->last_success = MAX(stat->last_success_out, stat->last_success_in);

Loading…
Cancel
Save