Update to 0.24.2

master
Alexey Khromov 6 months ago
commit 721fa8fdf1

12
.gitignore vendored

@ -0,0 +1,12 @@
*.o
debian/Makefile
source/Makefile
source/bin/
source/bforce/expression.c
source/config.log
source/config.status
source/include/config.h
bforce.geany

@ -1 +1 @@
0.24.1
0.24.2

@ -23,6 +23,8 @@
/* PID of our child process (if use fork) */
pid_t child_pid = 0;
char * mainenv[EXEC_MAX_NUM_ENVS+1];
const char *BFERR[] = {
/* 00 */ "Successfull",
/* 01 */ "Fatal error occured",
@ -253,6 +255,16 @@ int main(int argc, char *argv[], char *envp[])
int rc = 0;
int ch = 0;
opts.runmode = MODE_UNDEFINED;
int i = 0;
mainenv[0] = NULL;
i=0;
while (envp[i]) {
mainenv[i] = malloc(strlen(envp[i])+2);
strcpy(mainenv[i], envp[i]);
mainenv[++i] = NULL;
DEB((D_FREE, "Program ENV: %s\n", mainenv[(i-1)]));
}
memset(&opts, '\0', sizeof(s_bforce_opts));
@ -491,6 +503,13 @@ exit:
deinit_conf();
deinit_opts(&opts);
/* de-init sessenv */
i=0;
while(mainenv[i]) {
DEB((D_FREE, "De-init session ENV: %s\n", mainenv[(i)]));
free(mainenv[i++]);
}
/* Shutdown logging services */
if( log_isopened() ) log_close();
DEB((D_FREE, "good exit"));

@ -170,7 +170,7 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
{
if (earlydbg)
fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"\n", confname);
return(PROC_RC_IGNORE);
return(PROC_RC_ABORT);
}
if (earlydbg)
fprintf(stderr,"BF-DEBUG: start reading config \"%s\"\n", confname);

@ -283,6 +283,8 @@ int logerr(const char *s, ...)
#ifdef USE_SYSLOG
bool slog_active = FALSE;
const char *log_getfilename(int whatfor)
{
const char *p = "/dev/null";
@ -291,21 +293,26 @@ const char *log_getfilename(int whatfor)
bool log_isopened(void)
{
return TRUE;
return slog_active;
}
int log_open(const char *logname, const char *ext, const char *tty)
{
char *p = "bforce ";
p = xstrcat(p, BF_VERSION);
int fac = conf_number(cf_syslog_facility);
if( tty && *tty )
strncpy(p, tty, sizeof(p));
openlog(p, LOG_PID, fac);
slog_active = TRUE;
return 0;
}
int log_reopen(const char *logname, const char *ext, const char *tty)
{
if ( !slog_active ) {
return (log_reopen(logname, ext, tty));
} else
return 0;
}

@ -73,9 +73,18 @@ int exec_options_parse(char *str)
void exec_options_init(s_exec_options *eopt)
{
int i = 0;
memset(eopt, '\0', sizeof(s_exec_options));
eopt->umask = EXEC_DEFAULT_UMASK;
eopt->envp[0] = NULL;
while(mainenv[i]) {
DEB((D_FREE,"EXEC: Added ENV variable: %s\n", mainenv[i]));
eopt->envp[i] = xmalloc(strlen(mainenv[i]) + 2);
strcpy(eopt->envp[i],mainenv[i]);
eopt->envp[++i] = NULL;
}
}
void exec_options_deinit(s_exec_options *eopt)

@ -117,12 +117,13 @@ int binkp_loop(s_binkp_state *bstate) {
// session criterium handshake criterium
while (!bstate->complete || bstate->waiting_got) {
DEB((D_24554, "loop s: %d r: %d p: %d sp: %d", bstate->batchsendcomplete, bstate->batchreceivecomplete,
DEB((D_24554, ">>> BinkP loop sendcpl: %d recvcpl: %d phase: %d subphase: %d", bstate->batchsendcomplete, bstate->batchreceivecomplete,
bstate->phase, bstate->subphase));
if (bstate->continuesend) {
no_more_to_send = false;
bstate->continuesend = false;
}
if (have_to_write==0 && (!no_more_to_send || bstate->extracmd[0]!=-1)) {
m = binkp_getforsend(bstate, writebuf+BINKP_HEADER, &block_type, &block_length);
if(m==1 || m==3) {
@ -267,6 +268,7 @@ int binkp_loop(s_binkp_state *bstate) {
have_to_write -= n;
}
}
DEB((D_24554,"+++ BinkP Loop ended with rc=%d", bstate->rc));
return bstate->rc;
}
@ -339,7 +341,7 @@ int binkp_getforsend(s_binkp_state *bstate, char *buf, int *block_type, unsigned
int my_sf, wr_pos;
int n; // read file
if (bstate->extracmd[0]!=-1) {
DEB((D_24554, "send command from receiver %d %s", bstate->extracmd[0], bstate->extracmd+1));
DEB((D_24554, "Send cmd to remote %d %s", bstate->extracmd[0], bstate->extracmd+1));
buf[0] = bstate->extracmd[0];
strcpy(buf+1, bstate->extracmd+1);
*block_type = BINKP_BLK_CMD;
@ -625,7 +627,7 @@ case 4:
return 1;
case 5:
DEB((D_24554, "nothing to send"));
DEB((D_24554, "BinkP_GetForSend: nothing to send"));
return 2;
@ -804,7 +806,7 @@ case 0:
bstate->frs = frs_data;
return 1;
}
DEB((D_24554, "making M_GET to skip downloaded part"));
DEB((D_24554, "making M_GET to skip downloaded part, file: %s, size %ld, time %ld, mode 0",recvfi.fn,recvfi.sz, recvfi.tm ));
bstate->extracmd[0] = BPMSG_GET;
sprintf(bstate->extracmd+1, "%s %ld %ld %ld",
bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total,

@ -45,7 +45,7 @@ int binkp_parsfinfo(const char *str, s_bpfinfo *fi, bool with_offset)
return -1;
}
DEB((D_24554, "info to parse: %s", str));
r = sscanf(str, with_offset? "%s %d %d %d": "%s %d %d", &fi->fn, &fi->sz, &fi->tm, &fi->offs);
r = sscanf(str, with_offset? "%s %ld %ld %ld": "%s %ld %ld", &fi->fn, &fi->sz, &fi->tm, &fi->offs);
chkslash = fi->fn;
while (1) {
chkslash = strchr(chkslash, '/');

@ -860,6 +860,8 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
size_t minfree = 0;
size_t needed_bytes_total = 0;
DEB((D_FREE, "P_RX_FOPEN: File: %s, Size: %ld", fn, sz));
/*
* Check. May be we are receiving this file allready
*/

@ -117,7 +117,7 @@ int answ_system(e_session type, char *connstr, int inetd)
rc = session();
if( (inetd != 0) && (state.inet = FALSE) )
if( (inetd == 0) && (state.inet == FALSE) )
{
port_deinit(0, &oldtio);
port_close();

@ -145,6 +145,7 @@ char *file_name_makesafe(char *filename)
char *file_getname(char *filename)
{
char *p = strrchr(filename, '/');
DEB((D_FREE, "File_getname: %s", (p ? p + 1 : filename) ));
return p ? p + 1 : filename;
}

@ -181,6 +181,8 @@ typedef struct {
*/
extern const char *BFERR[];
extern char * mainenv[];
int daemon_run(const char *confname, const char *incname, bool quit);
#endif

@ -19,7 +19,7 @@
#define EXEC_OPT_LOGOUT 0x04
#define EXEC_OPT_USESHELL 0x08
#define EXEC_MAX_NUM_ENVS 40
#define EXEC_MAX_NUM_ENVS 4095
#define EXEC_MAX_NUM_ARGS 20
#define EXEC_DEFAULT_UMASK ~(S_IRUSR|S_IWUSR);

Loading…
Cancel
Save