Added check for user login

This commit is contained in:
Michiel Broek 2003-05-12 18:31:51 +00:00
parent 4d2e8e6da5
commit cfbe03bde1
2 changed files with 60 additions and 27 deletions

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* $Id$ * $Id$
* Purpose .................: Fidonet binkd protocol * Purpose .................: Fidonet binkp protocol
* Binkp protocol copyright : Dima Maloff. * Binkp protocol copyright : Dima Maloff.
* *
***************************************************************************** *****************************************************************************
@ -63,17 +63,27 @@
static char rbuf[2048]; 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_data(char *, int);
void binkp_send_control(int id, ...); void binkp_send_control(int id, ...);
int binkp_recv_frame(char *, int *, int *); int binkp_recv_frame(char *, int *, int *);
void binkp_settimer(int); void binkp_settimer(int);
int resync(off_t); int resync(off_t);
static int orgbinkp(void); static int orgbinkp(void);
static int ansbinkp(void); static int ansbinkp(void);
static int binkp_batch(file_list *, int); static int binkp_batch(file_list *, int);
extern char *ttystat[]; extern char *ttystat[];
extern int Loaded; extern int Loaded;
extern pid_t mypid; extern pid_t mypid;
@ -102,20 +112,6 @@ int transferred = FALSE;
int batchnr = 0, crc_errors = 0; 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) 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]; static char buf[PATH_MAX];
char *p, *q; 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 * Transmit data frame
*/ */
@ -838,7 +870,7 @@ void fill_binkp_list(binkp_list **bll, file_list *fal, off_t offs)
(*tmpl)->state = NoState; (*tmpl)->state = NoState;
(*tmpl)->get = FALSE; (*tmpl)->get = FALSE;
(*tmpl)->local = xstrcpy(fal->local); (*tmpl)->local = xstrcpy(fal->local);
(*tmpl)->remote = xstrcpy(unix2binkd(fal->remote)); (*tmpl)->remote = xstrcpy(unix2binkp(fal->remote));
(*tmpl)->offset = offs; (*tmpl)->offset = offs;
(*tmpl)->size = tstat.st_size; (*tmpl)->size = tstat.st_size;
(*tmpl)->date = tstat.st_mtime; (*tmpl)->date = tstat.st_mtime;
@ -1268,6 +1300,7 @@ int binkp_batch(file_list *to_send, int role)
else else
Syslog('+', "Binkp: receive file \"%s\" date %s size %ld offset %ld", Syslog('+', "Binkp: receive file \"%s\" date %s size %ld offset %ld",
rname, date(rtime), rsize, roffs); rname, date(rtime), rsize, roffs);
(void)binkp2unix(rname);
rxfp = openfile(rname, rtime, rsize, &rxbytes, resync); rxfp = openfile(rname, rtime, rsize, &rxbytes, resync);
gettimeofday(&rxtvstart, &tz); gettimeofday(&rxtvstart, &tz);
rxpos = 0; rxpos = 0;

View File

@ -218,20 +218,20 @@ void user()
/* /*
* Copy username, split first and lastname. * Copy username, split first and lastname.
*/ */
strcpy(UserName, usrconfig.sUserName); strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
if ((strchr(UserName,' ') == NULL && !CFG.iOneName)) { if ((strchr(UserName,' ') == NULL) && !CFG.iOneName) {
token = strtok(UserName, " "); token = strtok(UserName, " ");
strcpy(FirstName, token); strncpy(FirstName, token, sizeof(FirstName)-1);
token = strtok(NULL, "\0"); token = strtok(NULL, "\0");
i = strlen(token); i = strlen(token);
for (x = 2; x < i; x++) { for (x = 2; x < i; x++) {
if (token[x] == ' ') if (token[x] == ' ')
token[x] = '\0'; token[x] = '\0';
} }
strcpy(LastName, token); strncpy(LastName, token, sizeof(LastName)-1);
} else } else
strcpy(FirstName, UserName); strncpy(FirstName, UserName, sizeof(FirstName)-1);
strcpy(UserName, usrconfig.sUserName); strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
Syslog('+', "%s On-Line at %s", UserName, ttyinfo.comment); Syslog('+', "%s On-Line at %s", UserName, ttyinfo.comment);
IsDoing("Just Logged In"); IsDoing("Just Logged In");