New nodelist features test
This commit is contained in:
parent
92e96084b5
commit
79d31bda0a
@ -30,6 +30,8 @@ v0.37.00 26-Dec-2002.
|
|||||||
mbcico:
|
mbcico:
|
||||||
With binkp and EMSI sessions double received remote aka's are
|
With binkp and EMSI sessions double received remote aka's are
|
||||||
filtered.
|
filtered.
|
||||||
|
When calling ITN nodes, the default port is now 23.
|
||||||
|
Call setup changed and uses now the nodelist lookup URL.
|
||||||
|
|
||||||
mbout:
|
mbout:
|
||||||
When a poll was removed, the outbound was not rescanned.
|
When a poll was removed, the outbound was not rescanned.
|
||||||
|
134
mbcico/call.c
134
mbcico/call.c
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Fidonet mailer
|
* Purpose ...............: Fidonet mailer
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2002
|
* Copyright (C) 1997-2003
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -52,11 +52,11 @@
|
|||||||
|
|
||||||
|
|
||||||
extern int tcp_mode;
|
extern int tcp_mode;
|
||||||
extern int forcedcalls;
|
|
||||||
extern int immediatecall;
|
extern int immediatecall;
|
||||||
extern char *forcedphone;
|
extern char *forcedphone;
|
||||||
extern char *forcedline;
|
extern char *forcedline;
|
||||||
extern char *inetaddr;
|
extern char *inetaddr;
|
||||||
|
extern char *protocol;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +70,6 @@ int portopen(faddr *addr)
|
|||||||
if ((rc = opentcp(inetaddr))) {
|
if ((rc = opentcp(inetaddr))) {
|
||||||
Syslog('+', "Cannot connect %s", inetaddr);
|
Syslog('+', "Cannot connect %s", inetaddr);
|
||||||
nodeulock(addr);
|
nodeulock(addr);
|
||||||
// putstatus(addr,1,MBERR_NO_CONNECTION);
|
|
||||||
return MBERR_NO_CONNECTION;
|
return MBERR_NO_CONNECTION;
|
||||||
}
|
}
|
||||||
return MBERR_OK;
|
return MBERR_OK;
|
||||||
@ -104,10 +103,9 @@ int portopen(faddr *addr)
|
|||||||
|
|
||||||
int call(faddr *addr)
|
int call(faddr *addr)
|
||||||
{
|
{
|
||||||
int i, rc = 1, proto = FALSE;
|
int rc = 1;
|
||||||
struct hostent *he;
|
char *p, temp[81];
|
||||||
unsigned long cmmask, ipmask;
|
unsigned long cmmask;
|
||||||
nodelist_modem **tmpm;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't call points, call their boss instead.
|
* Don't call points, call their boss instead.
|
||||||
@ -152,91 +150,56 @@ int call(faddr *addr)
|
|||||||
sprintf(history.aka.domain, "%s", addr->domain);
|
sprintf(history.aka.domain, "%s", addr->domain);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First see if this node can be reached over the internet and
|
* Extract the protocol from the URL.
|
||||||
* that internet calls are allowed.
|
|
||||||
*/
|
*/
|
||||||
if (nlent->iflags) {
|
strncpy(temp, nlent->url, 80);
|
||||||
|
p = strchr(temp, ':');
|
||||||
|
*p = '\0';
|
||||||
|
protocol = xstrcpy(temp);
|
||||||
|
|
||||||
|
if (strcasecmp(protocol, "pots") && strcasecmp(protocol, "isdn")) {
|
||||||
if (!inetaddr) {
|
if (!inetaddr) {
|
||||||
Syslog('d', "Trying to find IP address...");
|
|
||||||
/*
|
/*
|
||||||
* There is no fdn or IP address at the commandline.
|
* Get the internet address from the URL.
|
||||||
* First check nodesetup for an override in the phone field.
|
|
||||||
* Try to find the fdn in several places in the nodelist fields.
|
|
||||||
*/
|
*/
|
||||||
if ((nlent->phone != NULL) && (strncmp(nlent->phone, (char *)"000-", 4) == 0)) {
|
p = strchr(nlent->url, '/');
|
||||||
inetaddr = xstrcpy(nlent->phone+4);
|
p++;
|
||||||
for (i = 0; i < strlen(inetaddr); i++)
|
p++;
|
||||||
if (inetaddr[i] == '-')
|
inetaddr = xstrcpy(p);
|
||||||
inetaddr[i] = '.';
|
}
|
||||||
Syslog('d', "Got IP address from phone field");
|
RegTCP();
|
||||||
} else if ((he = gethostbyname(nlent->name))) {
|
|
||||||
inetaddr = xstrcpy(nlent->name);
|
if (tcp_mode == TCPMODE_NONE) {
|
||||||
Syslog('d', "Got hostname from nodelist system name");
|
if (strcmp(protocol, "binkp") == 0) {
|
||||||
} else if ((he = gethostbyname(nlent->location))) {
|
tcp_mode = TCPMODE_IBN;
|
||||||
/*
|
} else if (strcmp(protocol, "fido") == 0) {
|
||||||
* A fdn at the nodelist location field is not in the specs
|
tcp_mode = TCPMODE_IFC;
|
||||||
* but the real world differs from the specs.
|
} else if (strcmp(protocol, "telnet") == 0) {
|
||||||
*/
|
tcp_mode = TCPMODE_ITN;
|
||||||
inetaddr = xstrcpy(nlent->location);
|
} else {
|
||||||
Syslog('d', "Got hostname from nodelist location");
|
Syslog('+', "No common TCP/IP protocols for node %s", nlent->name);
|
||||||
|
free(inetaddr);
|
||||||
|
inetaddr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (inetaddr == NULL) {
|
||||||
* If we have an internet address, set protocol
|
|
||||||
*/
|
|
||||||
if (inetaddr) {
|
|
||||||
RegTCP();
|
|
||||||
Syslog('d', "TCP/IP node \"%s\"", MBSE_SS(inetaddr));
|
|
||||||
|
|
||||||
if (tcp_mode == TCPMODE_NONE) {
|
|
||||||
/*
|
|
||||||
* If protocol not forced at the commandline, get it
|
|
||||||
* from the nodelist. If it fails, fallback to dial.
|
|
||||||
* Priority IBN, IFC, ITN.
|
|
||||||
*/
|
|
||||||
ipmask = 0;
|
|
||||||
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next))
|
|
||||||
if (strcmp("IBN", (*tmpm)->name) == 0)
|
|
||||||
ipmask = (*tmpm)->mask;
|
|
||||||
if (nlent->iflags & ipmask) {
|
|
||||||
tcp_mode = TCPMODE_IBN;
|
|
||||||
Syslog('d', "TCP/IP mode set to IBN");
|
|
||||||
proto = TRUE;
|
|
||||||
}
|
|
||||||
if (!proto) {
|
|
||||||
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next))
|
|
||||||
if (strcmp("IFC", (*tmpm)->name) == 0)
|
|
||||||
ipmask = (*tmpm)->mask;
|
|
||||||
if (nlent->iflags & ipmask) {
|
|
||||||
tcp_mode = TCPMODE_IFC;
|
|
||||||
Syslog('d', "TCP/IP mode set to IFC");
|
|
||||||
proto = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!proto) {
|
|
||||||
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next))
|
|
||||||
if (strcmp("ITN", (*tmpm)->name) == 0)
|
|
||||||
ipmask = (*tmpm)->mask;
|
|
||||||
if (nlent->iflags & ipmask) {
|
|
||||||
tcp_mode = TCPMODE_ITN;
|
|
||||||
Syslog('d', "TCP/IP mode seto to ITN");
|
|
||||||
proto = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!proto) {
|
|
||||||
Syslog('+', "No common TCP/IP protocols for node %s", nlent->name);
|
|
||||||
free(inetaddr);
|
|
||||||
inetaddr = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
WriteError("No IP address, abort call");
|
WriteError("No IP address, abort call");
|
||||||
rc = MBERR_NO_IP_ADDRESS;
|
rc = MBERR_NO_IP_ADDRESS;
|
||||||
putstatus(addr, 10, rc);
|
putstatus(addr, 10, rc);
|
||||||
nodeulock(addr);
|
nodeulock(addr);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!forcedphone) {
|
||||||
|
/*
|
||||||
|
* Get the phone number from the URL.
|
||||||
|
*/
|
||||||
|
p = strchr(nlent->url, '/');
|
||||||
|
p++;
|
||||||
|
p++;
|
||||||
|
forcedphone = xstrcpy(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((nlent->oflags & cmmask) == 0) && (!IsZMH())) {
|
if (((nlent->oflags & cmmask) == 0) && (!IsZMH())) {
|
||||||
@ -249,20 +212,19 @@ int call(faddr *addr)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Call when:
|
* Call when:
|
||||||
* the nodelist has a phone, or phone on commandline, or TCP address given
|
* there is a phone number or fqdn/ip-address
|
||||||
* and
|
* and
|
||||||
* nodenumber on commandline, or node is CM and not down, hold, pvt
|
* nodenumber on commandline, or node is CM and not down, hold, pvt
|
||||||
* and
|
* and
|
||||||
* nocall is false
|
* nocall is false
|
||||||
*/
|
*/
|
||||||
if ((nlent->phone || forcedphone || inetaddr ) &&
|
if ((forcedphone||inetaddr) && (((nlent->pflag & (NL_DUMMY|NL_DOWN|NL_HOLD|NL_PVT))==0) && ((localoptions & NOCALL)==0))) {
|
||||||
(forcedcalls || (((nlent->pflag & (NL_DUMMY|NL_DOWN|NL_HOLD|NL_PVT)) == 0) && ((localoptions & NOCALL) == 0)))) {
|
Syslog('+', "Calling %s (%s, phone %s)", ascfnode(addr,0x1f), nlent->name, forcedphone);
|
||||||
Syslog('+', "Calling %s (%s, phone %s)",ascfnode(addr,0x1f), nlent->name,nlent->phone?nlent->phone:forcedphone);
|
|
||||||
IsDoing("Call %s", ascfnode(addr, 0x0f));
|
IsDoing("Call %s", ascfnode(addr, 0x0f));
|
||||||
rc = portopen(addr);
|
rc = portopen(addr);
|
||||||
|
|
||||||
if ((rc == MBERR_OK) && (!inetaddr)) {
|
if ((rc == MBERR_OK) && (forcedphone)) {
|
||||||
if ((rc = dialphone(forcedphone?forcedphone:nlent->phone))) {
|
if ((rc = dialphone(forcedphone))) {
|
||||||
Syslog('+', "Dial failed");
|
Syslog('+', "Dial failed");
|
||||||
nodeulock(addr);
|
nodeulock(addr);
|
||||||
}
|
}
|
||||||
@ -297,7 +259,7 @@ int call(faddr *addr)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IsDoing("NoCall");
|
IsDoing("NoCall");
|
||||||
Syslog('+', "Cannot call %s (%s, phone %s)", ascfnode(addr,0x1f),MBSE_SS(nlent->name), MBSE_SS(nlent->phone));
|
Syslog('+', "Cannot call %s (%s)", ascfnode(addr,0x1f), MBSE_SS(nlent->name));
|
||||||
rc = MBERR_NO_CONNECTION;
|
rc = MBERR_NO_CONNECTION;
|
||||||
putstatus(addr, 10, rc);
|
putstatus(addr, 10, rc);
|
||||||
nodeulock(addr);
|
nodeulock(addr);
|
||||||
|
534
mbcico/mbcico.c
534
mbcico/mbcico.c
@ -4,7 +4,7 @@
|
|||||||
* Purpose: Fidonet mailer
|
* Purpose: Fidonet mailer
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2002
|
* Copyright (C) 1997-2003
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -51,11 +51,11 @@
|
|||||||
|
|
||||||
|
|
||||||
int master = 0;
|
int master = 0;
|
||||||
int forcedcalls = 0;
|
|
||||||
int immediatecall = FALSE;
|
int immediatecall = FALSE;
|
||||||
char *forcedphone = NULL;
|
char *forcedphone = NULL;
|
||||||
char *forcedline = NULL;
|
char *forcedline = NULL;
|
||||||
char *inetaddr = NULL;
|
char *inetaddr = NULL;
|
||||||
|
char *protocol = NULL;
|
||||||
char *envptr = NULL;
|
char *envptr = NULL;
|
||||||
time_t t_start;
|
time_t t_start;
|
||||||
time_t t_end;
|
time_t t_end;
|
||||||
@ -80,333 +80,309 @@ extern int mypid;
|
|||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ifcico; (c) Eugene G. Crosser, 1993-1997\n");
|
fprintf(stderr,"ifcico; (c) Eugene G. Crosser, 1993-1997\n");
|
||||||
fprintf(stderr,"mbcico ver. %s; (c) %s\n\n", VERSION, SHORTRIGHT);
|
fprintf(stderr,"mbcico ver. %s; (c) %s\n\n", VERSION, SHORTRIGHT);
|
||||||
fprintf(stderr,"-r<role> -a<inetaddr> <node> ...\n");
|
fprintf(stderr,"-a<inetaddr> <node>\n");
|
||||||
fprintf(stderr,"-n<phone> forced phone number\n");
|
fprintf(stderr,"-n<phone> forced phone number\n");
|
||||||
fprintf(stderr,"-l<ttydevice> forced tty device\n");
|
fprintf(stderr,"-l<ttydevice> forced tty device\n");
|
||||||
fprintf(stderr,"-t<tcpmode> must be one of ifc|itn|ibn, forces TCP/IP\n");
|
fprintf(stderr,"-t<tcpmode> must be one of ifc|itn|ibn, forces TCP/IP\n");
|
||||||
fprintf(stderr,"-a<inetaddr> supply internet hostname if not in nodelist\n");
|
fprintf(stderr,"-a<inetaddr> supply internet hostname if not in nodelist\n");
|
||||||
fprintf(stderr," <node> should be in domain form, e.g. f11.n22.z3\n");
|
fprintf(stderr," <node> should be in domain form, e.g. f11.n22.z3\n");
|
||||||
fprintf(stderr," (this implies master mode)\n");
|
fprintf(stderr," (this implies master mode)\n");
|
||||||
fprintf(stderr,"\n or: %s tsync|yoohoo|**EMSI_INQC816|-t ibn|-t ifc|-t itn\n",myname);
|
fprintf(stderr,"\n or: %s tsync|yoohoo|**EMSI_INQC816|-t ibn|-t ifc|-t itn\n",myname);
|
||||||
fprintf(stderr," (this implies slave mode)\n");
|
fprintf(stderr," (this implies slave mode)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void free_mem(void)
|
void free_mem(void)
|
||||||
{
|
{
|
||||||
free(inbound);
|
free(inbound);
|
||||||
if (name)
|
if (name)
|
||||||
free(name);
|
free(name);
|
||||||
if (phone)
|
if (phone)
|
||||||
free(phone);
|
free(phone);
|
||||||
if (flags)
|
if (flags)
|
||||||
free(flags);
|
free(flags);
|
||||||
if (uxoutbound)
|
if (uxoutbound)
|
||||||
free(uxoutbound);
|
free(uxoutbound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void die(int onsig)
|
void die(int onsig)
|
||||||
{
|
{
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
signal(onsig, SIG_IGN);
|
signal(onsig, SIG_IGN);
|
||||||
|
|
||||||
if (onsig) {
|
if (onsig) {
|
||||||
if (onsig <= NSIG)
|
if (onsig <= NSIG)
|
||||||
WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]);
|
WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]);
|
||||||
else
|
else
|
||||||
Syslog('+', "Terminated with error %d", onsig);
|
Syslog('+', "Terminated with error %d", onsig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sentbytes || rcvdbytes) {
|
if (sentbytes || rcvdbytes) {
|
||||||
total = (int)(c_end - c_start);
|
total = (int)(c_end - c_start);
|
||||||
if (!total)
|
if (!total)
|
||||||
total = 1;
|
total = 1;
|
||||||
Syslog('+', "Sent %lu bytes, received %lu bytes, avg %d cps",
|
Syslog('+', "Sent %lu bytes, received %lu bytes, avg %d cps", sentbytes, rcvdbytes, (sentbytes + rcvdbytes) / total);
|
||||||
sentbytes, rcvdbytes, (sentbytes + rcvdbytes) / total);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (online)
|
if (online)
|
||||||
Syslog('+', "Connected %s", str_time(online));
|
Syslog('+', "Connected %s", str_time(online));
|
||||||
|
|
||||||
if (gotfiles)
|
if (gotfiles)
|
||||||
CreateSema((char *)"mailin");
|
CreateSema((char *)"mailin");
|
||||||
|
|
||||||
t_end = time(NULL);
|
t_end = time(NULL);
|
||||||
Syslog(' ', "MBCICO finished in %s", t_elapsed(t_start, t_end));
|
Syslog(' ', "MBCICO finished in %s", t_elapsed(t_start, t_end));
|
||||||
free_mem();
|
free_mem();
|
||||||
if (envptr)
|
if (envptr)
|
||||||
free(envptr);
|
free(envptr);
|
||||||
ExitClient(onsig);
|
ExitClient(onsig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, c, uid;
|
faddr *addr = NULL;
|
||||||
fa_list *callist = NULL, **tmpl;
|
int i, c, uid, rc, maxrc;
|
||||||
faddr *tmp;
|
char *answermode = NULL, *p = NULL, *cmd = NULL;
|
||||||
int rc, maxrc, callno = 0, succno = 0;
|
struct passwd *pw;
|
||||||
char *answermode = NULL, *p = NULL, *cmd = NULL;
|
FILE *fp;
|
||||||
struct passwd *pw;
|
|
||||||
FILE *fp;
|
|
||||||
#ifdef IEMSI
|
#ifdef IEMSI
|
||||||
char temp[81];
|
char temp[PATH_MAX];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MEMWATCH
|
#ifdef MEMWATCH
|
||||||
mwInit();
|
mwInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The next trick is to supply a fake environment variable
|
* The next trick is to supply a fake environment variable
|
||||||
* MBSE_ROOT in case we are started from inetd or mgetty,
|
* MBSE_ROOT in case we are started from inetd or mgetty,
|
||||||
* this will setup the variable so InitConfig() will work.
|
* this will setup the variable so InitConfig() will work.
|
||||||
* The /etc/passwd must point to the correct homedirectory.
|
* The /etc/passwd must point to the correct homedirectory.
|
||||||
*/
|
*/
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
if (getenv("MBSE_ROOT") == NULL) {
|
if (getenv("MBSE_ROOT") == NULL) {
|
||||||
envptr = xstrcpy((char *)"MBSE_ROOT=");
|
envptr = xstrcpy((char *)"MBSE_ROOT=");
|
||||||
envptr = xstrcat(envptr, pw->pw_dir);
|
envptr = xstrcat(envptr, pw->pw_dir);
|
||||||
putenv(envptr);
|
putenv(envptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage();
|
usage();
|
||||||
if (envptr)
|
if (envptr)
|
||||||
free(envptr);
|
free(envptr);
|
||||||
#ifdef MEMWATCH
|
#ifdef MEMWATCH
|
||||||
mwTerm();
|
mwTerm();
|
||||||
#endif
|
#endif
|
||||||
exit(MBERR_COMMANDLINE);
|
exit(MBERR_COMMANDLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitConfig();
|
InitConfig();
|
||||||
InitNode();
|
InitNode();
|
||||||
InitFidonet();
|
InitFidonet();
|
||||||
TermInit(1);
|
TermInit(1);
|
||||||
t_start = c_start = c_end = time(NULL);
|
t_start = c_start = c_end = time(NULL);
|
||||||
|
|
||||||
InitClient(pw->pw_name, (char *)"mbcico", CFG.location, CFG.logfile, CFG.cico_loglevel, CFG.error_log, CFG.mgrlog);
|
InitClient(pw->pw_name, (char *)"mbcico", CFG.location, CFG.logfile, CFG.cico_loglevel, CFG.error_log, CFG.mgrlog);
|
||||||
Syslog(' ', " ");
|
Syslog(' ', " ");
|
||||||
Syslog(' ', "MBCICO v%s", VERSION);
|
Syslog(' ', "MBCICO v%s", VERSION);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Catch all signals we can, and handle the rest.
|
* Catch all signals we can, and handle the rest.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < NSIG; i++) {
|
for (i = 0; i < NSIG; i++) {
|
||||||
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGFPE) || (i == SIGSEGV)) {
|
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGFPE) || (i == SIGSEGV)) {
|
||||||
signal(i, (void (*))die);
|
signal(i, (void (*))die);
|
||||||
} else
|
|
||||||
signal(i, SIG_DFL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if history file exists, if not create a new one.
|
|
||||||
*/
|
|
||||||
cmd = calloc(128, sizeof(char));
|
|
||||||
sprintf(cmd, "%s/var/mailer.hist", getenv("MBSE_ROOT"));
|
|
||||||
if ((fp = fopen(cmd, "r")) == NULL) {
|
|
||||||
if ((fp = fopen(cmd, "a")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", cmd);
|
|
||||||
} else {
|
|
||||||
memset(&history, 0, sizeof(history));
|
|
||||||
history.online = time(NULL);
|
|
||||||
history.offline = time(NULL);
|
|
||||||
fwrite(&history, sizeof(history), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
Syslog('+', "Created new %s", cmd);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fclose(fp);
|
signal(i, SIG_DFL);
|
||||||
}
|
}
|
||||||
free(cmd);
|
}
|
||||||
memset(&history, 0, sizeof(history));
|
|
||||||
|
|
||||||
cmd = xstrcpy((char *)"Cmd: mbcico");
|
/*
|
||||||
for (i = 1; i < argc; i++) {
|
* Check if history file exists, if not create a new one.
|
||||||
cmd = xstrcat(cmd, (char *)" ");
|
*/
|
||||||
cmd = xstrcat(cmd, argv[i]);
|
cmd = calloc(PATH_MAX, sizeof(char));
|
||||||
|
sprintf(cmd, "%s/var/mailer.hist", getenv("MBSE_ROOT"));
|
||||||
|
if ((fp = fopen(cmd, "r")) == NULL) {
|
||||||
|
if ((fp = fopen(cmd, "a")) == NULL) {
|
||||||
|
WriteError("$Can't create %s", cmd);
|
||||||
|
} else {
|
||||||
|
memset(&history, 0, sizeof(history));
|
||||||
|
history.online = time(NULL);
|
||||||
|
history.offline = time(NULL);
|
||||||
|
fwrite(&history, sizeof(history), 1, fp);
|
||||||
|
fclose(fp);
|
||||||
|
Syslog('+', "Created new %s", cmd);
|
||||||
}
|
}
|
||||||
Syslog(' ', cmd);
|
} else {
|
||||||
free(cmd);
|
fclose(fp);
|
||||||
|
}
|
||||||
|
free(cmd);
|
||||||
|
memset(&history, 0, sizeof(history));
|
||||||
|
|
||||||
setmyname(argv[0]);
|
cmd = xstrcpy((char *)"Cmd: mbcico");
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
cmd = xstrcat(cmd, (char *)" ");
|
||||||
|
cmd = xstrcat(cmd, argv[i]);
|
||||||
|
}
|
||||||
|
Syslog(' ', cmd);
|
||||||
|
free(cmd);
|
||||||
|
|
||||||
while ((c=getopt(argc,argv,"r:n:l:t:a:I:h")) != -1)
|
setmyname(argv[0]);
|
||||||
switch (c) {
|
|
||||||
case 'r': WriteError("commandline option -r is obsolete");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l': forcedline = optarg;
|
while ((c = getopt(argc,argv,"r:n:l:t:a:I:h")) != -1) {
|
||||||
break;
|
switch (c) {
|
||||||
|
case 'r': WriteError("commandline option -r is obsolete");
|
||||||
|
break;
|
||||||
|
|
||||||
case 't': p = xstrcpy(optarg);
|
case 'l': forcedline = optarg;
|
||||||
if (strncmp(p, "ifc", 3) == 0)
|
break;
|
||||||
tcp_mode = TCPMODE_IFC;
|
|
||||||
else if (strncmp(p, "itn", 3) == 0)
|
|
||||||
tcp_mode = TCPMODE_ITN;
|
|
||||||
else if (strncmp(p, "ibn", 3) == 0)
|
|
||||||
tcp_mode = TCPMODE_IBN;
|
|
||||||
else {
|
|
||||||
usage();
|
|
||||||
die(MBERR_COMMANDLINE);
|
|
||||||
}
|
|
||||||
free(p);
|
|
||||||
RegTCP();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'a': inetaddr = optarg;
|
case 't': p = xstrcpy(optarg);
|
||||||
break;
|
if (strncmp(p, "ifc", 3) == 0) {
|
||||||
|
tcp_mode = TCPMODE_IFC;
|
||||||
case 'n': forcedphone = optarg;
|
protocol = xstrcpy((char *)"fido");
|
||||||
break;
|
} else if (strncmp(p, "itn", 3) == 0) {
|
||||||
|
tcp_mode = TCPMODE_ITN;
|
||||||
default: usage();
|
protocol = xstrcpy((char *)"telnet");
|
||||||
die(MBERR_COMMANDLINE);
|
} else if (strncmp(p, "ibn", 3) == 0) {
|
||||||
}
|
tcp_mode = TCPMODE_IBN;
|
||||||
|
protocol = xstrcpy((char *)"binkp");
|
||||||
/*
|
} else {
|
||||||
* Load rest of the configuration
|
usage();
|
||||||
*/
|
die(MBERR_COMMANDLINE);
|
||||||
inbound = xstrcpy(CFG.inbound);
|
|
||||||
uxoutbound = xstrcpy(CFG.uxpath);
|
|
||||||
name = xstrcpy(CFG.bbs_name);
|
|
||||||
phone = xstrcpy(CFG.Phone);
|
|
||||||
flags = xstrcpy(CFG.Flags);
|
|
||||||
|
|
||||||
tmpl = &callist;
|
|
||||||
|
|
||||||
while (argv[optind]) {
|
|
||||||
|
|
||||||
for (p = argv[optind]; (*p) && (*p == '*'); p++);
|
|
||||||
#ifdef IEMSI
|
|
||||||
if (strncasecmp(p, "EMSI_NAKEEC3", 12) == 0) {
|
|
||||||
|
|
||||||
Syslog('+', "Detected IEMSI client, starting BBS");
|
|
||||||
sprintf(temp, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
|
|
||||||
socket_shutdown(mypid);
|
|
||||||
|
|
||||||
if (execl(temp, "mbsebbs", (char *)NULL) == -1)
|
|
||||||
perror("FATAL: Error loading BBS!");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this happens, nothing is logged!
|
|
||||||
*/
|
|
||||||
printf("\n\nFATAL: Loading of the BBS failed!\n\n");
|
|
||||||
sleep(3);
|
|
||||||
free_mem();
|
|
||||||
if (envptr)
|
|
||||||
free(envptr);
|
|
||||||
#ifdef MEMWATCH
|
|
||||||
mwTerm();
|
|
||||||
#endif
|
|
||||||
exit(MBERROR_EXEC_FAILED);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if ((strcasecmp(argv[optind],"tsync") == 0) ||
|
|
||||||
(strcasecmp(argv[optind],"yoohoo") == 0) ||
|
|
||||||
(strcasecmp(argv[optind],"ibn") == 0) ||
|
|
||||||
(strncasecmp(p,"EMSI_",5) == 0)) {
|
|
||||||
master = 0;
|
|
||||||
answermode = argv[optind];
|
|
||||||
Syslog('S', "Inbound \"%s\" mode", MBSE_SS(answermode));
|
|
||||||
} else {
|
|
||||||
Syslog('-', "Callist entry \"%s\"", argv[optind]);
|
|
||||||
if ((tmp = parsefaddr(argv[optind]))) {
|
|
||||||
*tmpl = (fa_list *)malloc(sizeof(fa_list));
|
|
||||||
(*tmpl)->next = NULL;
|
|
||||||
(*tmpl)->addr = tmp;
|
|
||||||
tmpl = &((*tmpl)->next);
|
|
||||||
immediatecall = TRUE;
|
|
||||||
} else
|
|
||||||
WriteError("Unrecognizable address \"%s\"", argv[optind]);
|
|
||||||
}
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callist) {
|
|
||||||
master = 1;
|
|
||||||
forcedcalls = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
The following witchkraft about uid-s is necessary to make
|
|
||||||
access() work right. Unforunately, access() checks the real
|
|
||||||
uid, if mbcico is invoked with supervisor real uid (as when
|
|
||||||
called by uugetty) it returns X_OK for the magic files that
|
|
||||||
even do not have `x' bit set. Therefore, `reference' magic
|
|
||||||
file requests are taken for `execute' requests (and the
|
|
||||||
actual execution natually fails). Here we set real uid equal
|
|
||||||
to effective. If real uid is not zero, all these fails, but
|
|
||||||
in this case it is not necessary anyway.
|
|
||||||
*/
|
|
||||||
|
|
||||||
uid=geteuid();
|
|
||||||
seteuid(0);
|
|
||||||
setuid(uid);
|
|
||||||
seteuid(uid);
|
|
||||||
|
|
||||||
umask(066); /* packets may contain confidential information */
|
|
||||||
|
|
||||||
p = xstrcpy(inbound);
|
|
||||||
p = xstrcat(p,(char *)"/tmp/fooinb");
|
|
||||||
mkdirs(p, 0700);
|
|
||||||
free(p);
|
|
||||||
|
|
||||||
maxrc=0;
|
|
||||||
if (master) {
|
|
||||||
/*
|
|
||||||
* Don't do outbound calls if low diskspace
|
|
||||||
*/
|
|
||||||
if (!diskfree(CFG.freespace))
|
|
||||||
die(MBERR_DISK_FULL);
|
|
||||||
|
|
||||||
if (callist == NULL) {
|
|
||||||
WriteError("Calling mbcico without node address not supported anymore");
|
|
||||||
die(MBERR_COMMANDLINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (tmpl = &callist; *tmpl; tmpl = &((*tmpl)->next)) {
|
|
||||||
callno++;
|
|
||||||
forcedcalls = (*tmpl)->force;
|
|
||||||
rc = call((*tmpl)->addr);
|
|
||||||
Syslog('+', "Call to %s %s (rc=%d)", ascfnode((*tmpl)->addr,0x1f), rc?"failed":"successful",rc);
|
|
||||||
if (rc > maxrc)
|
|
||||||
maxrc=rc;
|
|
||||||
if (rc == 0) {
|
|
||||||
succno++;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
free(p);
|
||||||
// if (callist == NULL)
|
RegTCP();
|
||||||
// if (IsSema((char *)"scanout"))
|
break;
|
||||||
// RemoveSema((char *)"scanout");
|
|
||||||
|
case 'a': inetaddr = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n': forcedphone = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: usage();
|
||||||
|
die(MBERR_COMMANDLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load rest of the configuration
|
||||||
|
*/
|
||||||
|
inbound = xstrcpy(CFG.inbound);
|
||||||
|
uxoutbound = xstrcpy(CFG.uxpath);
|
||||||
|
name = xstrcpy(CFG.bbs_name);
|
||||||
|
phone = xstrcpy(CFG.Phone);
|
||||||
|
flags = xstrcpy(CFG.Flags);
|
||||||
|
|
||||||
|
while (argv[optind]) {
|
||||||
|
|
||||||
|
for (p = argv[optind]; (*p) && (*p == '*'); p++);
|
||||||
|
#ifdef IEMSI
|
||||||
|
if (strncasecmp(p, "EMSI_NAKEEC3", 12) == 0) {
|
||||||
|
|
||||||
|
Syslog('+', "Detected IEMSI client, starting BBS");
|
||||||
|
sprintf(temp, "%s/bin/mbsebbs", getenv("MBSE_ROOT"));
|
||||||
|
socket_shutdown(mypid);
|
||||||
|
|
||||||
|
if (execl(temp, "mbsebbs", (char *)NULL) == -1)
|
||||||
|
perror("FATAL: Error loading BBS!");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this happens, nothing is logged!
|
||||||
|
*/
|
||||||
|
printf("\n\nFATAL: Loading of the BBS failed!\n\n");
|
||||||
|
sleep(3);
|
||||||
|
free_mem();
|
||||||
|
if (envptr)
|
||||||
|
free(envptr);
|
||||||
|
#ifdef MEMWATCH
|
||||||
|
mwTerm();
|
||||||
|
#endif
|
||||||
|
exit(MBERROR_EXEC_FAILED);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if ((strcasecmp(argv[optind],"tsync") == 0) ||
|
||||||
|
(strcasecmp(argv[optind],"yoohoo") == 0) ||
|
||||||
|
(strcasecmp(argv[optind],"ibn") == 0) ||
|
||||||
|
(strncasecmp(p,"EMSI_",5) == 0)) {
|
||||||
|
master = 0;
|
||||||
|
answermode = argv[optind];
|
||||||
|
Syslog('S', "Inbound \"%s\" mode", MBSE_SS(answermode));
|
||||||
} else {
|
} else {
|
||||||
/* slave */
|
if ((addr = parsefaddr(argv[optind]))) {
|
||||||
if (!answermode && tcp_mode == TCPMODE_IBN)
|
immediatecall = TRUE;
|
||||||
answermode = xstrcpy((char *)"ibn");
|
master = 1;
|
||||||
maxrc = answer(answermode);
|
} else {
|
||||||
callno = 1;
|
WriteError("Unrecognizable address \"%s\"", argv[optind]);
|
||||||
succno = (maxrc == 0);
|
}
|
||||||
|
}
|
||||||
|
optind++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The following witchkraft about uid-s is necessary to make
|
||||||
|
access() work right. Unforunately, access() checks the real
|
||||||
|
uid, if mbcico is invoked with supervisor real uid (as when
|
||||||
|
called by uugetty) it returns X_OK for the magic files that
|
||||||
|
even do not have `x' bit set. Therefore, `reference' magic
|
||||||
|
file requests are taken for `execute' requests (and the
|
||||||
|
actual execution natually fails). Here we set real uid equal
|
||||||
|
to effective. If real uid is not zero, all these fails, but
|
||||||
|
in this case it is not necessary anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uid=geteuid();
|
||||||
|
seteuid(0);
|
||||||
|
setuid(uid);
|
||||||
|
seteuid(uid);
|
||||||
|
|
||||||
|
umask(066); /* packets may contain confidential information */
|
||||||
|
|
||||||
|
p = xstrcpy(inbound);
|
||||||
|
p = xstrcat(p,(char *)"/tmp/fooinb");
|
||||||
|
mkdirs(p, 0700);
|
||||||
|
free(p);
|
||||||
|
|
||||||
|
maxrc=0;
|
||||||
|
if (master) {
|
||||||
|
/*
|
||||||
|
* Don't do outbound calls if low diskspace
|
||||||
|
*/
|
||||||
|
if (!diskfree(CFG.freespace))
|
||||||
|
die(MBERR_DISK_FULL);
|
||||||
|
|
||||||
|
if (addr == NULL) {
|
||||||
|
WriteError("Calling mbcico without node address not supported anymore");
|
||||||
|
die(MBERR_COMMANDLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callno)
|
rc = call(addr);
|
||||||
Syslog('+', "%d of %d calls, maxrc=%d",succno,callno,maxrc);
|
Syslog('+', "Call to %s %s (rc=%d)", ascfnode(addr, 0x1f), rc?"failed":"successful", rc);
|
||||||
|
if (rc > maxrc)
|
||||||
|
maxrc=rc;
|
||||||
|
} else {
|
||||||
|
/* slave */
|
||||||
|
if (!answermode && tcp_mode == TCPMODE_IBN)
|
||||||
|
answermode = xstrcpy((char *)"ibn");
|
||||||
|
rc = maxrc = answer(answermode);
|
||||||
|
Syslog('+', "Incoming call %s (rc=%d)", rc?"failed":"successful", rc);
|
||||||
|
}
|
||||||
|
|
||||||
tidy_falist(&callist);
|
tidy_faddr(addr);
|
||||||
|
if (maxrc)
|
||||||
if (maxrc)
|
die(maxrc);
|
||||||
die(maxrc);
|
else
|
||||||
else
|
die(MBERR_OK);
|
||||||
die(MBERR_OK);
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Fidonet mailer
|
* Purpose ...............: Fidonet mailer
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2002
|
* Copyright (C) 1997-2003
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -118,7 +118,7 @@ int opentcp(char *name)
|
|||||||
else
|
else
|
||||||
server.sin_port = htons(FIDOPORT);
|
server.sin_port = htons(FIDOPORT);
|
||||||
break;
|
break;
|
||||||
case TCPMODE_ITN: if ((se = getservbyname("tfido", "tcp")))
|
case TCPMODE_ITN: if ((se = getservbyname("telnet", "tcp")))
|
||||||
server.sin_port = se->s_port;
|
server.sin_port = se->s_port;
|
||||||
else
|
else
|
||||||
server.sin_port = htons(TELNPORT);
|
server.sin_port = htons(TELNPORT);
|
||||||
|
Reference in New Issue
Block a user