Added check for user login
This commit is contained in:
parent
4d2e8e6da5
commit
cfbe03bde1
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
* Purpose .................: Fidonet binkd protocol
|
||||
* Purpose .................: Fidonet binkp protocol
|
||||
* Binkp protocol copyright : Dima Maloff.
|
||||
*
|
||||
*****************************************************************************
|
||||
@ -63,17 +63,27 @@
|
||||
|
||||
static char rbuf[2048];
|
||||
|
||||
|
||||
/*
|
||||
* Local prototypes
|
||||
*/
|
||||
char *unix2binkp(char *);
|
||||
char *binkp2unix(char *);
|
||||
int binkp_expired(void);
|
||||
void b_banner(int);
|
||||
void b_nul(char *);
|
||||
void fill_binkp_list(binkp_list **, file_list *, off_t);
|
||||
void debug_binkp_list(binkp_list **);
|
||||
void binkp_send_data(char *, int);
|
||||
void binkp_send_control(int id, ...);
|
||||
int binkp_recv_frame(char *, int *, int *);
|
||||
void binkp_settimer(int);
|
||||
int resync(off_t);
|
||||
|
||||
|
||||
static int orgbinkp(void);
|
||||
static int ansbinkp(void);
|
||||
static int binkp_batch(file_list *, int);
|
||||
|
||||
|
||||
extern char *ttystat[];
|
||||
extern int Loaded;
|
||||
extern pid_t mypid;
|
||||
@ -102,20 +112,6 @@ int transferred = FALSE;
|
||||
int batchnr = 0, crc_errors = 0;
|
||||
|
||||
|
||||
int resync(off_t);
|
||||
char *unix2binkd(char *);
|
||||
void binkp_send_data(char *, int);
|
||||
void binkp_send_control(int,...);
|
||||
int binkp_recv_frame(char *, int *, int *);
|
||||
void binkp_settimer(int);
|
||||
int binkp_expired(void);
|
||||
void b_banner(int);
|
||||
void b_nul(char *);
|
||||
void fill_binkp_list(binkp_list **, file_list *, off_t);
|
||||
void debug_binkp_list(binkp_list **);
|
||||
int binkp_batch(file_list *, int);
|
||||
|
||||
|
||||
|
||||
int binkp(int role)
|
||||
{
|
||||
@ -221,9 +217,9 @@ int resync(off_t off)
|
||||
|
||||
|
||||
/*
|
||||
* Translate filename to binkd filename, unsafe characters are escaped.
|
||||
* Translate filename to binkp filename, unsafe characters are escaped.
|
||||
*/
|
||||
char *unix2binkd(char *fn)
|
||||
char *unix2binkp(char *fn)
|
||||
{
|
||||
static char buf[PATH_MAX];
|
||||
char *p, *q;
|
||||
@ -250,6 +246,42 @@ char *unix2binkd(char *fn)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Translate escaped binkp filename to unix.
|
||||
*/
|
||||
char *binkp2unix(char *fn)
|
||||
{
|
||||
static char buf[PATH_MAX];
|
||||
char *p, *q, hex[3];
|
||||
int c;
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
p = fn;
|
||||
q = buf;
|
||||
|
||||
while (*p) {
|
||||
if (p[0] == '\\') {
|
||||
hex[0] = *p++;
|
||||
hex[1] = *p++;
|
||||
hex[2] = '\0';
|
||||
Syslog('b', "binkp2unix hex=%s", hex);
|
||||
sscanf(hex, "%2x", &c);
|
||||
*q++ = c;
|
||||
*q = '\0';
|
||||
} else {
|
||||
*q++ = *p;
|
||||
*q = '\0';
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*q = '\0';
|
||||
|
||||
Syslog('b', "binkp2unix \"%s\"", printable(buf, 0));
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Transmit data frame
|
||||
*/
|
||||
@ -838,7 +870,7 @@ void fill_binkp_list(binkp_list **bll, file_list *fal, off_t offs)
|
||||
(*tmpl)->state = NoState;
|
||||
(*tmpl)->get = FALSE;
|
||||
(*tmpl)->local = xstrcpy(fal->local);
|
||||
(*tmpl)->remote = xstrcpy(unix2binkd(fal->remote));
|
||||
(*tmpl)->remote = xstrcpy(unix2binkp(fal->remote));
|
||||
(*tmpl)->offset = offs;
|
||||
(*tmpl)->size = tstat.st_size;
|
||||
(*tmpl)->date = tstat.st_mtime;
|
||||
@ -1268,6 +1300,7 @@ int binkp_batch(file_list *to_send, int role)
|
||||
else
|
||||
Syslog('+', "Binkp: receive file \"%s\" date %s size %ld offset %ld",
|
||||
rname, date(rtime), rsize, roffs);
|
||||
(void)binkp2unix(rname);
|
||||
rxfp = openfile(rname, rtime, rsize, &rxbytes, resync);
|
||||
gettimeofday(&rxtvstart, &tz);
|
||||
rxpos = 0;
|
||||
|
@ -218,20 +218,20 @@ void user()
|
||||
/*
|
||||
* Copy username, split first and lastname.
|
||||
*/
|
||||
strcpy(UserName, usrconfig.sUserName);
|
||||
if ((strchr(UserName,' ') == NULL && !CFG.iOneName)) {
|
||||
strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
|
||||
if ((strchr(UserName,' ') == NULL) && !CFG.iOneName) {
|
||||
token = strtok(UserName, " ");
|
||||
strcpy(FirstName, token);
|
||||
strncpy(FirstName, token, sizeof(FirstName)-1);
|
||||
token = strtok(NULL, "\0");
|
||||
i = strlen(token);
|
||||
for(x = 2; x < i; x++) {
|
||||
for (x = 2; x < i; x++) {
|
||||
if (token[x] == ' ')
|
||||
token[x] = '\0';
|
||||
}
|
||||
strcpy(LastName, token);
|
||||
strncpy(LastName, token, sizeof(LastName)-1);
|
||||
} else
|
||||
strcpy(FirstName, UserName);
|
||||
strcpy(UserName, usrconfig.sUserName);
|
||||
strncpy(FirstName, UserName, sizeof(FirstName)-1);
|
||||
strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
|
||||
Syslog('+', "%s On-Line at %s", UserName, ttyinfo.comment);
|
||||
IsDoing("Just Logged In");
|
||||
|
||||
|
Reference in New Issue
Block a user