Added T-Mail support to mbcico

This commit is contained in:
Michiel Broek 2004-01-13 22:04:25 +00:00
parent f0fe1e3378
commit c4eea97ff1
6 changed files with 201 additions and 88 deletions

View File

@ -6,6 +6,7 @@ v0.39.6 11-Jan-2004
New binkp/1.1 driver fixes for Sun NetBSD. New binkp/1.1 driver fixes for Sun NetBSD.
Removed TCP ignore check in EOB state. Removed TCP ignore check in EOB state.
Transmiter file close now right after last block. Transmiter file close now right after last block.
Added support for T-Mail fileboxes.
mbsetup: mbsetup:
Reorganised menu 1.4 screen 1 and 2. Reorganised menu 1.4 screen 1 and 2.

View File

@ -9,7 +9,7 @@ SRCS = zmmisc.c zmrle.c zmrecv.c zmsend.c binkp.c binkpnew.c md5b.c \
answer.c chat.c dial.c dietifna.c emsidat.c filelist.c \ answer.c chat.c dial.c dietifna.c emsidat.c filelist.c \
openfile.c openport.c opentcp.c rdoptions.c yoohoo.c \ openfile.c openport.c opentcp.c rdoptions.c yoohoo.c \
recvbark.c respfreq.c sendbark.c tcp.c tcpproto.c wazoo.c \ recvbark.c respfreq.c sendbark.c tcp.c tcpproto.c wazoo.c \
filetime.c ftsc.c atoul.c portsel.c \ filetime.c ftsc.c atoul.c portsel.c shortbox.c \
ttyio.c lutil.c scanout.c emsi.c ulock.c \ ttyio.c lutil.c scanout.c emsi.c ulock.c \
callstat.c session.c call.c mbcico.c \ callstat.c session.c call.c mbcico.c \
outstat.c nlinfo.c mbout.c mbtelind.c mbtelout.c outstat.c nlinfo.c mbout.c mbtelind.c mbtelout.c
@ -18,7 +18,7 @@ HDRS = zmodem.h binkp.h binkpnew.h config.h statetbl.h md5b.h \
answer.h chat.h dial.h dietifna.h emsidat.h filelist.h \ answer.h chat.h dial.h dietifna.h emsidat.h filelist.h \
openfile.h openport.h opentcp.h rdoptions.h yoohoo.h \ openfile.h openport.h opentcp.h rdoptions.h yoohoo.h \
recvbark.h respfreq.h sendbark.h tcp.h tcpproto.h wazoo.h \ recvbark.h respfreq.h sendbark.h tcp.h tcpproto.h wazoo.h \
filetime.h ftsc.h atoul.h portsel.h \ filetime.h ftsc.h atoul.h portsel.h shortbox.h \
ttyio.h lutil.h scanout.h emsi.h ulock.h \ ttyio.h lutil.h scanout.h emsi.h ulock.h \
callstat.h session.h call.h mbcico.h \ callstat.h session.h call.h mbcico.h \
outstat.h nlinfo.h mbtelind.h mbtelout.h outstat.h nlinfo.h mbtelind.h mbtelout.h
@ -27,7 +27,7 @@ MBCICO_OBJS = zmmisc.o zmrle.o zmrecv.o zmsend.o binkp.o binkpnew.o md5b.o \
answer.o chat.o dial.o dietifna.o emsidat.o filelist.o \ answer.o chat.o dial.o dietifna.o emsidat.o filelist.o \
openfile.o openport.o opentcp.o rdoptions.o yoohoo.o \ openfile.o openport.o opentcp.o rdoptions.o yoohoo.o \
recvbark.o respfreq.o sendbark.o tcp.o tcpproto.o wazoo.o \ recvbark.o respfreq.o sendbark.o tcp.o tcpproto.o wazoo.o \
filetime.o ftsc.o atoul.o portsel.o \ filetime.o ftsc.o atoul.o portsel.o shortbox.o \
ttyio.o lutil.o scanout.o emsi.o ulock.o \ ttyio.o lutil.o scanout.o emsi.o ulock.o \
callstat.o session.o call.o mbcico.o callstat.o session.o call.o mbcico.o
MBOUT_OBJS = outstat.o nlinfo.o mbout.o scanout.o callstat.o MBOUT_OBJS = outstat.o nlinfo.o mbout.o scanout.o callstat.o
@ -113,7 +113,7 @@ chat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records
dial.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h config.h chat.h ttyio.h session.h dial.h dial.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h config.h chat.h ttyio.h session.h dial.h
dietifna.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ttyio.h session.h emsi.h dietifna.h respfreq.h filelist.h xmrecv.h xmsend.h dietifna.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ttyio.h session.h emsi.h dietifna.h respfreq.h filelist.h xmrecv.h xmsend.h
emsidat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h emsidat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h
filelist.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h config.h session.h filelist.h filelist.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h config.h shortbox.h session.h filelist.h
openfile.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h ../lib/users.h ../lib/records.h config.h lutil.h openfile.h openfile.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h ../lib/users.h ../lib/records.h config.h lutil.h openfile.h
openport.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h mbcico.h openport.h openport.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h mbcico.h openport.h
opentcp.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h opentcp.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h
@ -129,6 +129,7 @@ filetime.o: ../config.h ../lib/libs.h filetime.h
ftsc.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/mberrors.h session.h ttyio.h statetbl.h config.h ftsc.h rdoptions.h recvbark.h filelist.h sendbark.h respfreq.h xmrecv.h xmsend.h inbound.h ftsc.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/mberrors.h session.h ttyio.h statetbl.h config.h ftsc.h rdoptions.h recvbark.h filelist.h sendbark.h respfreq.h xmrecv.h xmsend.h inbound.h
atoul.o: ../config.h ../lib/libs.h atoul.h atoul.o: ../config.h ../lib/libs.h atoul.h
portsel.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h portsel.h portsel.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h portsel.h
shortbox.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h shortbox.h
ttyio.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ttyio.h lutil.h ttyio.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ttyio.h lutil.h
lutil.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h lutil.h lutil.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h lutil.h
scanout.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbftn.h config.h scanout.h lutil.h scanout.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbftn.h config.h scanout.h lutil.h

View File

@ -4,7 +4,7 @@
* Purpose ...............: fidonet mailer * Purpose ...............: fidonet mailer
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2003 * Copyright (C) 1997-2004
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -37,6 +37,7 @@
#include "../lib/common.h" #include "../lib/common.h"
#include "../lib/nodelist.h" #include "../lib/nodelist.h"
#include "config.h" #include "config.h"
#include "shortbox.h"
#include "session.h" #include "session.h"
#include "filelist.h" #include "filelist.h"
@ -219,6 +220,70 @@ static void check_flo(file_list **lst, char *nm)
void check_filebox(char *, file_list *);
void check_filebox(char *boxpath, file_list *st)
{
char *temp;
DIR *dp;
struct dirent *de;
struct passwd *pw;
struct stat stbuf;
if ((dp = opendir(boxpath)) == NULL) {
Syslog('o', "\"%s\" cannot be opened, proceed", MBSE_SS(boxpath));
} else {
Syslog('o', "checking filebox \"%s\"", boxpath);
temp = calloc(PATH_MAX, sizeof(char));
pw = getpwnam((char *)"mbse");
while ((de = readdir(dp))) {
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
sprintf(temp, "%s/%s", boxpath, de->d_name);
if (stat(temp, &stbuf) == 0) {
Syslog('o' ,"checking file \"%s\"", de->d_name);
if (S_ISREG(stbuf.st_mode)) {
if (pw->pw_uid == stbuf.st_uid) {
/*
* We own the file
*/
if ((stbuf.st_mode & S_IRUSR) && (stbuf.st_mode & S_IWUSR)) {
add_list(&st, temp, de->d_name, KFS, 0L, NULL, 1);
} else {
Syslog('+', "No R/W permission on %s", temp);
}
} else if (pw->pw_gid == stbuf.st_gid) {
/*
* We own the file group
*/
if ((stbuf.st_mode & S_IRGRP) && (stbuf.st_mode & S_IWGRP)) {
add_list(&st, temp, de->d_name, KFS, 0L, NULL, 1);
} else {
Syslog('+', "No R/W permission on %s", temp);
}
} else {
/*
* No owner of file
*/
if ((stbuf.st_mode & S_IROTH) && (stbuf.st_mode & S_IWOTH)) {
add_list(&st, temp, de->d_name, KFS, 0L, NULL, 1);
} else {
Syslog('+', "No R/W permission on %s", temp);
}
}
} else {
Syslog('+', "Not a regular file %s", temp);
}
} else {
WriteError("Can't stat %s", temp);
}
}
}
closedir(dp);
free(temp);
}
}
file_list *create_filelist(fa_list *al, char *fl, int create) file_list *create_filelist(fa_list *al, char *fl, int create)
{ {
file_list *st = NULL, *tmpf; file_list *st = NULL, *tmpf;
@ -227,10 +292,7 @@ file_list *create_filelist(fa_list *al, char *fl, int create)
struct stat stbuf; struct stat stbuf;
int packets = 0; int packets = 0;
FILE *fp; FILE *fp;
DIR *dp;
struct dirent *de;
unsigned char buffer[2]; unsigned char buffer[2];
struct passwd *pw;
Syslog('o', "Create_filelist(%s,\"%s\",%d)", al?ascfnode(al->addr,0x1f):"<none>", MBSE_SS(fl), create); Syslog('o', "Create_filelist(%s,\"%s\",%d)", al?ascfnode(al->addr,0x1f):"<none>", MBSE_SS(fl), create);
made_request = 0; made_request = 0;
@ -244,64 +306,38 @@ file_list *create_filelist(fa_list *al, char *fl, int create)
if ((tmpa->addr) && Loaded && strlen(nodes.OutBox) && if ((tmpa->addr) && Loaded && strlen(nodes.OutBox) &&
(tmpa->addr->zone == nodes.Aka[0].zone) && (tmpa->addr->net == nodes.Aka[0].net) && (tmpa->addr->zone == nodes.Aka[0].zone) && (tmpa->addr->net == nodes.Aka[0].net) &&
(tmpa->addr->node == nodes.Aka[0].node) && (tmpa->addr->point == nodes.Aka[0].point)) { (tmpa->addr->node == nodes.Aka[0].node) && (tmpa->addr->point == nodes.Aka[0].point)) {
Syslog('o', "checking outbox %s", nodes.OutBox);
if (nodes.Crash) if (nodes.Crash)
flavor = 'c'; flavor = 'c';
else if (nodes.Hold) else if (nodes.Hold)
flavor = 'h'; flavor = 'h';
else else
flavor = 'o'; flavor = 'o';
if ((dp = opendir(nodes.OutBox)) == NULL) { check_filebox(nodes.OutBox, st);
Syslog('o', "\"%s\" cannot be opened, proceed", MBSE_SS(nodes.OutBox)); }
} else {
temp = calloc(PATH_MAX, sizeof(char)); /*
pw = getpwnam((char *)"mbse"); * Check T-Mail style fileboxes
while ((de = readdir(dp))) { */
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) { temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/%s", nodes.OutBox, de->d_name); if (strlen(CFG.tmailshort)) {
if (stat(temp, &stbuf) == 0) { sprintf(temp, "%s/%s", CFG.tmailshort, shortboxname(tmpa->addr));
Syslog('o' ,"checking file \"%s\"", de->d_name); check_filebox(temp, st);
if (S_ISREG(stbuf.st_mode)) { if (strchr(fl, 'h')) {
if (pw->pw_uid == stbuf.st_uid) { sprintf(temp, "%s/%sh", CFG.tmailshort, shortboxname(tmpa->addr));
/* check_filebox(temp, st);
* We own the file
*/
if ((stbuf.st_mode & S_IRUSR) && (stbuf.st_mode & S_IWUSR)) {
add_list(&st, temp, de->d_name, KFS, 0L, NULL, 1);
} else {
Syslog('+', "No R/W permission on %s", temp);
}
} else if (pw->pw_gid == stbuf.st_gid) {
/*
* We own the file group
*/
if ((stbuf.st_mode & S_IRGRP) && (stbuf.st_mode & S_IWGRP)) {
add_list(&st, temp, de->d_name, KFS, 0L, NULL, 1);
} else {
Syslog('+', "No R/W permission on %s", temp);
}
} else {
/*
* No owner of file
*/
if ((stbuf.st_mode & S_IROTH) && (stbuf.st_mode & S_IWOTH)) {
add_list(&st, temp, de->d_name, KFS, 0L, NULL, 1);
} else {
Syslog('+', "No R/W permission on %s", temp);
}
}
} else {
Syslog('+', "Not a regular file %s", temp);
}
} else {
WriteError("Can't stat %s", temp);
}
}
}
closedir(dp);
free(temp);
} }
} }
if (strlen(CFG.tmaillong)) {
sprintf(temp, "%s/%d.%d.%d.%d", CFG.tmaillong, tmpa->addr->zone,
tmpa->addr->net, tmpa->addr->node, tmpa->addr->point);
check_filebox(temp, st);
if (strchr(fl, 'h')) {
sprintf(temp, "%s/%d.%d.%d.%d.h", CFG.tmaillong, tmpa->addr->zone,
tmpa->addr->net, tmpa->addr->node, tmpa->addr->point);
check_filebox(temp, st);
}
}
free(temp);
/* /*
* Check spool files, these are more or less useless but they * Check spool files, these are more or less useless but they

View File

@ -67,36 +67,6 @@ static struct _alist
/*
* Returns name of T-Mail filebox in Dos format (8+3).
* I know, this code looks ungly, but it works. - MiCHA :-)
*/
const char* shortboxname(const faddr *fa) {
static char dirname[12];
unsigned z=fa->zone, n=fa->net, f=fa->node, p=fa->point;
unsigned u,v;
u=z%32; z/=32; if (z>=32) return NULL;
dirname[0]=z<10?z+'0':z-10+'a';
dirname[1]=u<10?u+'0':u-10+'a';
u=n%32; n/=32; v=n%32; n/=32; if (n>=32) return NULL;
dirname[2]=n<10?n+'0':n-10+'a';
dirname[3]=v<10?v+'0':v-10+'a';
dirname[4]=u<10?u+'0':u-10+'a';
u=f%32; f/=32; v=f%32; f/=32; if (f>=32) return NULL;
dirname[5]=f<10?f+'0':f-10+'a';
dirname[6]=v<10?v+'0':v-10+'a';
dirname[7]=u<10?u+'0':u-10+'a';
dirname[8]='.';
u=p%32; p/=32; if (p>=32) return NULL;
dirname[9]=p<10?p+'0':p-10+'a';
dirname[10]=u<10?u+'0':u-10+'a';
dirname[11]=0;
return dirname;
}
int outstat() int outstat()
{ {
int rc; int rc;
@ -220,6 +190,34 @@ int outstat()
} }
fclose(fp); fclose(fp);
/*
* Start checking T-Mail fileboxes
*/
if (strlen(CFG.tmailshort) && (dp = opendir(CFG.tmailshort))) {
Syslog('o', "Checking T-Mail short box \"%s\"", CFG.tmailshort);
while ((de = readdir(dp))) {
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
sprintf(temp, "%s/%s", CFG.tmailshort, de->d_name);
if (stat(temp, &sb) == 0) {
Syslog('o' ,"checking \"%s\"", de->d_name);
}
}
}
closedir(dp);
}
if (strlen(CFG.tmaillong) && (dp = opendir(CFG.tmaillong))) {
Syslog('o', "Checking T-Mail long box \"%s\"", CFG.tmaillong);
while ((de = readdir(dp))) {
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
sprintf(temp, "%s/%s", CFG.tmailshort, de->d_name);
if (stat(temp, &sb) == 0) {
Syslog('o' ,"checking \"%s\"", de->d_name);
}
}
}
closedir(dp);
}
if (!do_quiet) { if (!do_quiet) {
colour(10, 0); colour(10, 0);
printf("flavor try size age address\n"); printf("flavor try size age address\n");

69
mbcico/shortbox.c Normal file
View File

@ -0,0 +1,69 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
* 1971 BV IJmuiden
* the Netherlands
*
* This file is part of MBSE BBS.
*
* This BBS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* MBSE BBS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MBSE BBS; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/libs.h"
#include "../lib/structs.h"
#include "../lib/users.h"
#include "../lib/records.h"
#include "../lib/clcomm.h"
#include "../lib/common.h"
#include "shortbox.h"
/*
* Returns name of T-Mail filebox in Dos format (8+3).
* I know, this code looks ungly, but it works. - MiCHA :-)
*/
char* shortboxname(faddr *fa) {
static char dirname[12];
unsigned z=fa->zone, n=fa->net, f=fa->node, p=fa->point;
unsigned u,v;
u=z%32; z/=32; if (z>=32) return NULL;
dirname[0]=z<10?z+'0':z-10+'a';
dirname[1]=u<10?u+'0':u-10+'a';
u=n%32; n/=32; v=n%32; n/=32; if (n>=32) return NULL;
dirname[2]=n<10?n+'0':n-10+'a';
dirname[3]=v<10?v+'0':v-10+'a';
dirname[4]=u<10?u+'0':u-10+'a';
u=f%32; f/=32; v=f%32; f/=32; if (f>=32) return NULL;
dirname[5]=f<10?f+'0':f-10+'a';
dirname[6]=v<10?v+'0':v-10+'a';
dirname[7]=u<10?u+'0':u-10+'a';
dirname[8]='.';
u=p%32; p/=32; if (p>=32) return NULL;
dirname[9]=p<10?p+'0':p-10+'a';
dirname[10]=u<10?u+'0':u-10+'a';
dirname[11]=0;
return dirname;
}

8
mbcico/shortbox.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef _SHORTBOX_H
#define _SHORTBOX_H
/* $Id$ */
char *shortboxname(faddr *);
#endif