From 1b16ad995937d0b3d87072e7192dd2f96b76b472 Mon Sep 17 00:00:00 2001 From: Sergey Dorofeev Date: Wed, 14 Dec 2011 21:56:39 +0400 Subject: [PATCH] body --- source/bforce/sess_common.c | 7 ++++++- source/bforce/sess_main.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/source/bforce/sess_common.c b/source/bforce/sess_common.c index 028f617..0fd32f1 100644 --- a/source/bforce/sess_common.c +++ b/source/bforce/sess_common.c @@ -36,7 +36,8 @@ * $INBOUND * $CONNECT, * $CALLERID, - * $RC + * $RC, + * $PEERNAME */ int session_run_command(const char *execstr) { @@ -111,6 +112,10 @@ int session_run_command(const char *execstr) if( state.cidstr && *state.cidstr ) exec_env_add(&eopts, "CALLERID", state.cidstr); + + if( state.peername && *state.peername ) + exec_env_add(&eopts, "PEERNAME", state.peername); + if( state.session_rc >= 0 ) { diff --git a/source/bforce/sess_main.c b/source/bforce/sess_main.c index 309c8cc..59b5d2c 100644 --- a/source/bforce/sess_main.c +++ b/source/bforce/sess_main.c @@ -311,14 +311,36 @@ int session_set_inbound(void) struct stat st; char *p_inb; - if( (p_inb = conf_string(cf_inbound_directory)) ) - { - state.inbound = (char*)xstrcpy(p_inb); + p_inb = conf_string(cf_inbound_directory); + if( !p_inb ) { + log("no inbound specified, assume current directory"); + p_inb = "./"; } - else - { - log("no inbound specified, assume \"./\""); - state.inbound = (char*)xstrcpy("./"); + + if( conf_boolean(cf_split_inbound) ) { + char buf[500]; + if( state.node.addr.point ) { + sprintf( buf, "%s%d:%d/%d.%d/%s-in/", + p_inb, + state.node.addr.zone, + state.node.addr.net, + state.node.addr.node, + state.node.addr.point, + state.protected? "pwd": "unchecked" ); + } else { + sprintf( buf, "%s%d:%d/%d/%s-in/", + p_inb, + state.node.addr.zone, + state.node.addr.net, + state.node.addr.node, + state.protected? "pwd": "unchecked" ); + } + log("inbound: %s", buf); + state.inbound = (char*)xstrcpy(buf); + sprintf( buf, "/bin/mkdir -p %s -m 700", state.inbound ); + system( buf ); + } else { + state.inbound = (char*)xstrcpy(p_inb); } state.tinbound = (char*)xstrcpy(state.inbound);