Fix for newsserver authorisation

This commit is contained in:
Michiel Broek 2004-01-04 12:35:50 +00:00
parent 39dbfe3daa
commit 57868f7093
7 changed files with 186 additions and 109 deletions

View File

@ -22,6 +22,10 @@ v0.39.5 24-Dec-2003
Poll, remove poll and request failed to points which had no Poll, remove poll and request failed to points which had no
point directory in the outbound, now the directory is created. point directory in the outbound, now the directory is created.
mbfido:
With scannews after a GROUP command when authorisation was
asked we did not perform a login.
mbsetup: mbsetup:
Added setting in menu 1.14 to allow zero bytes lockfiles Added setting in menu 1.14 to allow zero bytes lockfiles
created by another OS. created by another OS.

2
TODO
View File

@ -156,6 +156,8 @@ mbnewusr:
-- Currently no access to my old Sun Sparcstation. -- Currently no access to my old Sun Sparcstation.
mbsetup: mbsetup:
N: Add check for reasonable settings for message split.
N: Add a check for double areatag names. N: Add a check for double areatag names.
N: Use some sort of sorting for the system aka's and make sure the N: Use some sort of sorting for the system aka's and make sure the

View File

@ -1,6 +1,7 @@
#ifndef _MBINET_H #ifndef _MBINET_H
#define _MBINET_H #define _MBINET_H
/* $Id$ */
int smtp_connect(void); int smtp_connect(void);
int smtp_send(char *); int smtp_send(char *);
@ -13,6 +14,7 @@ int nntp_send(char *);
char *nntp_receive(void); char *nntp_receive(void);
int nntp_close(void); int nntp_close(void);
int nntp_cmd(char *, int); int nntp_cmd(char *, int);
int nntp_auth(void);
int pop3_connect(void); int pop3_connect(void);
int pop3_send(char *); int pop3_send(char *);
@ -21,4 +23,3 @@ int pop3_close(void);
int pop3_cmd(char *); int pop3_cmd(char *);
#endif #endif

View File

@ -4,7 +4,7 @@
* Purpose ...............: MBSE BBS Internet Library * Purpose ...............: MBSE BBS Internet Library
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2004
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -44,7 +44,6 @@ struct sockaddr_in nntp_loc; /* For local socket address */
struct sockaddr_in nntp_rem; /* For remote socket address */ struct sockaddr_in nntp_rem; /* For remote socket address */
int nntp_auth(void);
int nntp_connect(void) int nntp_connect(void)

View File

@ -164,6 +164,7 @@ struct binkprec {
unsigned long nethold; /* Netmail on hold */ unsigned long nethold; /* Netmail on hold */
unsigned long mailhold; /* Packed mail on hold */ unsigned long mailhold; /* Packed mail on hold */
int batchnr;
int msgs_on_queue; /* Messages on the queue */ int msgs_on_queue; /* Messages on the queue */
}; };
@ -192,7 +193,7 @@ char *binkp2unix(char *); /* Unix -> Binkp escape */
void fill_binkp_list(binkp_list **, file_list *, off_t); /* Build pending files */ void fill_binkp_list(binkp_list **, file_list *, off_t); /* Build pending files */
void debug_binkp_list(binkp_list **); /* Debug pending files list */ void debug_binkp_list(binkp_list **); /* Debug pending files list */
int binkp_pendingfiles(void); /* Count pending files */ int binkp_pendingfiles(void); /* Count pending files */
void binkp_clear_filelist(void); /* Clear current filelist */
static int orgbinkp(void); /* Originate session state */ static int orgbinkp(void); /* Originate session state */
static int ansbinkp(void); /* Answer session state */ static int ansbinkp(void); /* Answer session state */
@ -814,9 +815,8 @@ SM_RETURN
*/ */
int file_transfer(void) int file_transfer(void)
{ {
int rc = 0, complete = FALSE; int rc = 0;
TrType Trc = Ok; TrType Trc = Ok;
binkp_list *tmp;
for (;;) { for (;;) {
Syslog('B', "Binkp: FileTransfer state %s", ftstate[bp.FtState]); Syslog('B', "Binkp: FileTransfer state %s", ftstate[bp.FtState]);
@ -830,10 +830,6 @@ int file_transfer(void)
break; break;
case Switch: if ((bp.RxState == RxDone) && (bp.TxState == TxDone)) { case Switch: if ((bp.RxState == RxDone) && (bp.TxState == TxDone)) {
complete = TRUE;
}
if (complete) {
Syslog('+', "Binkp: file transfer complete rc=%d", bp.rc); Syslog('+', "Binkp: file transfer complete rc=%d", bp.rc);
bp.FtState = DeinitTransfer; bp.FtState = DeinitTransfer;
break; break;
@ -844,9 +840,16 @@ int file_transfer(void)
*/ */
rc = binkp_poll_frame(); rc = binkp_poll_frame();
if (rc == -1) { if (rc == -1) {
bp.rc = rc; if (bp.local_EOB && bp.remote_EOB) {
bp.FtState = DeinitTransfer; Syslog('b', "Binkp: ignore TCP error in EOB state");
break; } else {
/*
* Only check if not in EOB state
*/
bp.rc = rc;
bp.FtState = DeinitTransfer;
break;
}
} else if (rc == 1) { } else if (rc == 1) {
bp.FtState = Receive; bp.FtState = Receive;
break; break;
@ -898,20 +901,7 @@ int file_transfer(void)
case DeinitTransfer:/* case DeinitTransfer:/*
* In case of a transfer error the filelist is not yet cleared * In case of a transfer error the filelist is not yet cleared
*/ */
if (tosend != NULL) { binkp_clear_filelist();
Syslog('b', "Clear current filelist");
for (tmp = bll; bll; bll = tmp) {
tmp = bll->next;
if (bll->local)
free(bll->local);
if (bll->remote)
free(bll->remote);
free(bll);
}
tidy_filelist(tosend, TRUE);
tosend = NULL;
}
if (bp.rc) if (bp.rc)
return MBERR_FTRANSFER; return MBERR_FTRANSFER;
else else
@ -964,8 +954,20 @@ TrType binkp_receiver(void)
return Ok; return Ok;
} else if (bcmd == MM_EOB) { } else if (bcmd == MM_EOB) {
Syslog('+', "Binkp: got M_EOB"); Syslog('+', "Binkp: got M_EOB");
if ((bp.Major == 1) && (bp.Minor != 0) && bp.local_EOB && bp.remote_EOB && ((bp.local_msgs + bp.remote_msgs) > 2)) {
Syslog('b', "Binkp: 1.1 mode, stay in RxWaitF");
bp.batchnr++;
bp.local_EOB = FALSE;
bp.remote_EOB = FALSE;
bp.local_msgs = 0;
bp.remote_msgs = 0;
bp.TxState = TxGNF;
bp.RxState = RxWaitF;
Syslog('+', "Binkp: start batch %d", bp.batchnr + 1);
binkp_clear_filelist();
return Ok;
}
bp.RxState = RxEOB; bp.RxState = RxEOB;
bp.remote_EOB = TRUE;
return Ok; return Ok;
} else if (bcmd == MM_FILE) { } else if (bcmd == MM_FILE) {
bp.RxState = RxAccF; bp.RxState = RxAccF;
@ -1168,6 +1170,7 @@ TrType binkp_receiver(void)
bp.RxState = RxDone; bp.RxState = RxDone;
return Failure; return Failure;
} }
} else if (bp.RxState == RxDone) { } else if (bp.RxState == RxDone) {
return Ok; return Ok;
} }
@ -1226,10 +1229,12 @@ TrType binkp_transmitter(void)
} }
debug_binkp_list(&bll); debug_binkp_list(&bll);
Syslog('+', "Binkp: mail %ld, files %ld bytes", bp.nethold, bp.mailhold); if ((bp.nethold || bp.mailhold) || (bp.batchnr == 0)) {
if ((rc = binkp_send_command(MM_NUL, "TRF %ld %ld", bp.nethold, bp.mailhold))) { Syslog('+', "Binkp: mail %ld, files %ld bytes", bp.nethold, bp.mailhold);
bp.TxState = TxDone; if ((rc = binkp_send_command(MM_NUL, "TRF %ld %ld", bp.nethold, bp.mailhold))) {
return Failure; bp.TxState = TxDone;
return Failure;
}
} }
} }
@ -1285,11 +1290,9 @@ TrType binkp_transmitter(void)
/* /*
* No more files * No more files
*/ */
Syslog('+', "Binkp: sending M_EOB"); Syslog('+', "Binkp: sending M_EOB");
rc = binkp_send_command(MM_EOB, ""); rc = binkp_send_command(MM_EOB, "");
bp.TxState = TxWLA; bp.TxState = TxWLA;
bp.local_EOB = TRUE;
if (rc) if (rc)
return Failure; return Failure;
else else
@ -1359,36 +1362,59 @@ TrType binkp_transmitter(void)
} else if (bp.TxState == TxWLA) { } else if (bp.TxState == TxWLA) {
if ((bp.msgs_on_queue == 0) && (binkp_pendingfiles() == 0) && (bp.RxState >= RxEOB)) { if ((bp.msgs_on_queue == 0) && (binkp_pendingfiles() == 0)) {
Syslog('b', "The queue is empty and RxState >= RxEOB");
bp.TxState = TxDone;
Syslog('+', "Binkp: there were %d messages sent", bp.local_msgs);
Syslog('+', "Binkp: there were %d messages received", bp.remote_msgs);
if (bp.local_EOB && bp.remote_EOB) {
Syslog('b', "Binkp: transmitter puts receiver state to RxDone");
bp.RxState = RxDone; /* Not in FSP-1018 rev.1 */
}
if (tosend != NULL) {
Syslog('b', "Clear current filelist");
for (tmp = bll; bll; bll = tmp) { if ((bp.RxState >= RxEOB) && (bp.Major == 1) && (bp.Minor == 0)) {
tmp = bll->next; bp.TxState = TxDone;
if (bll->local) if (bp.local_EOB && bp.remote_EOB) {
free(bll->local); Syslog('b', "Binkp: binkp/1.0 session seems complete");
if (bll->remote) bp.RxState = RxDone; /* Not in FSP-1018 rev.1 */
free(bll->remote);
free(bll);
} }
tidy_filelist(tosend, TRUE); binkp_clear_filelist();
tosend = NULL; return Ok;
} }
return Ok;
}
if ((bp.msgs_on_queue == 0) && (binkp_pendingfiles() == 0) && (bp.RxState < RxEOB)) { if ((bp.RxState < RxEOB) && (bp.Major == 1) && (bp.Minor == 0)) {
bp.TxState = TxWLA; bp.TxState = TxWLA;
return Ok; return Ok;
}
if ((bp.Major == 1) && (bp.Minor != 0)) {
Syslog('b', "Binkp: 1.1 check local_EOB=%s remote_EOB=%s local_msgs=%d remote_msgs=%d",
bp.local_EOB?"True":"False", bp.remote_EOB?"True":"False", bp.local_msgs, bp.remote_msgs);
if (bp.local_EOB && bp.remote_EOB) {
/*
* We did send EOB and got a EOB
*/
if ((bp.local_msgs < 2) && (bp.remote_msgs < 2)) {
/*
* Nothing sent anymore, finish
*/
Syslog('b', "Binkp: binkp/1.1 session seems complete");
bp.RxState = RxDone;
bp.TxState = TxDone;
} else {
/*
* Start new batch
*/
bp.batchnr++;
bp.local_EOB = FALSE;
bp.remote_EOB = FALSE;
bp.local_msgs = 0;
bp.remote_msgs = 0;
bp.TxState = TxGNF;
bp.RxState = RxWaitF;
Syslog('+', "Binkp: start batch %d", bp.batchnr + 1);
binkp_clear_filelist();
return Continue;
}
}
binkp_clear_filelist();
return Ok;
}
} }
if (bp.msgs_on_queue) { if (bp.msgs_on_queue) {
@ -1429,6 +1455,9 @@ int binkp_send_frame(int cmd, char *buf, int len)
if (cmd) { if (cmd) {
header = ((BINKP_CONTROL_BLOCK + len) & 0xffff); header = ((BINKP_CONTROL_BLOCK + len) & 0xffff);
bp.local_msgs++; bp.local_msgs++;
if (buf[0] == MM_EOB) {
bp.local_EOB = TRUE;
}
} else { } else {
header = ((BINKP_DATA_BLOCK + len) & 0xffff); header = ((BINKP_DATA_BLOCK + len) & 0xffff);
} }
@ -1704,6 +1733,9 @@ int binkp_poll_frame(void)
bp.remote_msgs++; bp.remote_msgs++;
bcmd = bp.rxbuf[0]; bcmd = bp.rxbuf[0];
Syslog('b', "Binkp: got %s %s", bstate[bcmd], printable(bp.rxbuf+1, 0)); Syslog('b', "Binkp: got %s %s", bstate[bcmd], printable(bp.rxbuf+1, 0));
if (bcmd == MM_EOB) {
bp.remote_EOB = TRUE;
}
} }
rc = 1; rc = 1;
break; break;
@ -2060,4 +2092,30 @@ void debug_binkp_list(binkp_list **bkll)
} }
/*
* Clear current filelist
*/
void binkp_clear_filelist(void)
{
binkp_list *tmp;
if (tosend != NULL) {
Syslog('b', "Clear current filelist");
for (tmp = bll; bll; bll = tmp) {
tmp = bll->next;
if (bll->local)
free(bll->local);
if (bll->remote)
free(bll->remote);
free(bll);
}
tidy_filelist(tosend, TRUE);
tosend = NULL;
}
}
#endif #endif

View File

@ -23,7 +23,7 @@
/* protocol version */ /* protocol version */
#define PRTCLNAME "binkp" #define PRTCLNAME "binkp"
#define PRTCLVER "1.0" #define PRTCLVER "1.1"
#define MAX_BLKSIZE 0x7fff /* Don't change! */ #define MAX_BLKSIZE 0x7fff /* Don't change! */
#define BLK_HDR_SIZE 2 /* 2 bytes header */ #define BLK_HDR_SIZE 2 /* 2 bytes header */

View File

@ -4,7 +4,7 @@
* Purpose ...............: Scan for new News * Purpose ...............: Scan for new News
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2004
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -251,64 +251,77 @@ void ScanNews(void)
int do_one_group(List **art, char *grpname, char *ftntag, int maxarticles) int do_one_group(List **art, char *grpname, char *ftntag, int maxarticles)
{ {
List *tmp; List *tmp;
char temp[128], *resp; char temp[128], *resp;
int retval, fetched = 0; int retval, fetched = 0;
long total, start, end; long total, start, end;
Syslog('M', "do_one_group(%s, %s)", grpname, ftntag); Syslog('M', "do_one_group(%s, %s)", grpname, ftntag);
IsDoing((char *)"Scan %s", grpname); IsDoing((char *)"Scan %s", grpname);
sprintf(temp, "GROUP %s\r\n", grpname); sprintf(temp, "GROUP %s\r\n", grpname);
nntp_send(temp);
resp = nntp_receive();
retval = atoi(strtok(resp, " "));
if (retval == 480) {
/*
* We must login
*/
if (nntp_auth() == FALSE) {
WriteError("Authorisation failure");
nntp_close();
return RETVAL_NOAUTH;
}
nntp_send(temp); nntp_send(temp);
resp = nntp_receive(); resp = nntp_receive();
retval = atoi(strtok(resp, " ")); retval = atoi(strtok(resp, " "));
if (retval != 211) { }
if (retval == 411) { if (retval != 211) {
WriteError("No such newsgroup: %s", grpname); if (retval == 411) {
return RETVAL_UNEXPECTEDANS; WriteError("No such newsgroup: %s", grpname);
} return RETVAL_UNEXPECTEDANS;
WriteError("Unknown response %d to GROUP command", retval);
return RETVAL_ERROR;
} }
WriteError("Unknown response %d to GROUP command", retval);
return RETVAL_ERROR;
}
total = atol(strtok(NULL, " ")); total = atol(strtok(NULL, " "));
start = atol(strtok(NULL, " ")); start = atol(strtok(NULL, " "));
end = atol(strtok(NULL, " '\0'")); end = atol(strtok(NULL, " '\0'"));
Syslog('m', "GROUP total %d, start %d, end %d, max %d", total, start, end, maxarticles); Syslog('m', "GROUP total %d, start %d, end %d, max %d", total, start, end, maxarticles);
if ((maxarticles) && (total > maxarticles)) { if ((maxarticles) && (total > maxarticles)) {
start = end - maxarticles; start = end - maxarticles;
total = maxarticles; total = maxarticles;
Syslog('m', "NEW: total %d, start %d, end %d", total, start, end); Syslog('m', "NEW: total %d, start %d, end %d", total, start, end);
} }
if (!total) { if (!total) {
Syslog('M', "No articles"); Syslog('M', "No articles");
return RETVAL_NOARTICLES; return RETVAL_NOARTICLES;
} }
retval = get_xover(grpname, start, end, art);
if (retval != RETVAL_OK) {
tidy_artlist(art);
return retval;
}
if (!do_learn) {
for (tmp = *art; tmp; tmp = tmp->next) {
if (!tmp->isdupe) {
/*
* If the message isn't a dupe, it must be new for us.
*/
get_article(tmp->msgid, ftntag);
fetched++;
}
}
}
retval = get_xover(grpname, start, end, art);
if (retval != RETVAL_OK) {
tidy_artlist(art); tidy_artlist(art);
return retval;
}
if ((maxarticles) && (fetched == maxarticles)) if (!do_learn) {
Syslog('!', "Warning: the max. articles value in newsgroup %s might be to low", grpname); for (tmp = *art; tmp; tmp = tmp->next) {
if (!tmp->isdupe) {
/*
* If the message isn't a dupe, it must be new for us.
*/
get_article(tmp->msgid, ftntag);
fetched++;
}
}
}
return RETVAL_OK; tidy_artlist(art);
if ((maxarticles) && (fetched == maxarticles))
Syslog('!', "Warning: the max. articles value in newsgroup %s might be to low", grpname);
return RETVAL_OK;
} }