|
|
6ed84f |
--- a/tftpd/tftpd.c 2016-03-02 11:32:30.710775130 +0100
|
|
|
6ed84f |
+++ b/tftpd/tftpd.c 2016-03-02 11:36:24.086541019 +0100
|
|
|
6ed84f |
@@ -1056,14 +1056,14 @@ int main(int argc, char **argv)
|
|
|
6ed84f |
|
|
|
6ed84f |
static char *rewrite_access(char *, int, const char **);
|
|
|
6ed84f |
static int validate_access(char *, int, const struct formats *, const char **);
|
|
|
6ed84f |
-static void tftp_sendfile(const struct formats *, struct tftphdr *, int);
|
|
|
6ed84f |
+static void tftp_sendfile(const struct formats *, struct tftphdr *, int, char *);
|
|
|
6ed84f |
static void tftp_recvfile(const struct formats *, struct tftphdr *, int);
|
|
|
6ed84f |
|
|
|
6ed84f |
struct formats {
|
|
|
6ed84f |
const char *f_mode;
|
|
|
6ed84f |
char *(*f_rewrite) (char *, int, const char **);
|
|
|
6ed84f |
int (*f_validate) (char *, int, const struct formats *, const char **);
|
|
|
6ed84f |
- void (*f_send) (const struct formats *, struct tftphdr *, int);
|
|
|
6ed84f |
+ void (*f_send) (const struct formats *, struct tftphdr *, int, char *);
|
|
|
6ed84f |
void (*f_recv) (const struct formats *, struct tftphdr *, int);
|
|
|
6ed84f |
int f_convert;
|
|
|
6ed84f |
};
|
|
|
6ed84f |
@@ -1129,6 +1129,9 @@ int tftp(struct tftphdr *tp, int size)
|
|
|
6ed84f |
nak(EACCESS, errmsgptr); /* File denied by mapping rule */
|
|
|
6ed84f |
exit(0);
|
|
|
6ed84f |
}
|
|
|
6ed84f |
+ ecode =
|
|
|
6ed84f |
+ (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr);
|
|
|
6ed84f |
+
|
|
|
6ed84f |
if (verbosity >= 1) {
|
|
|
6ed84f |
tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from),
|
|
|
6ed84f |
tmpbuf, INET6_ADDRSTRLEN);
|
|
|
6ed84f |
@@ -1147,9 +1150,14 @@ int tftp(struct tftphdr *tp, int size)
|
|
|
6ed84f |
tp_opcode == WRQ ? "WRQ" : "RRQ",
|
|
|
6ed84f |
tmp_p, origfilename,
|
|
|
6ed84f |
filename);
|
|
|
6ed84f |
+
|
|
|
6ed84f |
+ if (ecode == 1) {
|
|
|
6ed84f |
+ syslog(LOG_NOTICE, "Client %s File not found %s\n",
|
|
|
6ed84f |
+ tmp_p,filename);
|
|
|
6ed84f |
+ }
|
|
|
6ed84f |
+
|
|
|
6ed84f |
}
|
|
|
6ed84f |
- ecode =
|
|
|
6ed84f |
- (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr);
|
|
|
6ed84f |
+
|
|
|
6ed84f |
if (ecode) {
|
|
|
6ed84f |
nak(ecode, errmsgptr);
|
|
|
6ed84f |
exit(0);
|
|
|
6ed84f |
@@ -1172,12 +1180,12 @@ int tftp(struct tftphdr *tp, int size)
|
|
|
6ed84f |
if (tp_opcode == WRQ)
|
|
|
6ed84f |
(*pf->f_recv) (pf, (struct tftphdr *)ackbuf, ap - ackbuf);
|
|
|
6ed84f |
else
|
|
|
6ed84f |
- (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf);
|
|
|
6ed84f |
+ (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf, origfilename);
|
|
|
6ed84f |
} else {
|
|
|
6ed84f |
if (tp_opcode == WRQ)
|
|
|
6ed84f |
(*pf->f_recv) (pf, NULL, 0);
|
|
|
6ed84f |
else
|
|
|
6ed84f |
- (*pf->f_send) (pf, NULL, 0);
|
|
|
6ed84f |
+ (*pf->f_send) (pf, NULL, 0, origfilename);
|
|
|
6ed84f |
}
|
|
|
6ed84f |
exit(0); /* Request completed */
|
|
|
6ed84f |
}
|
|
|
6ed84f |
@@ -1557,7 +1565,7 @@ static int validate_access(char *filenam
|
|
|
6ed84f |
/*
|
|
|
6ed84f |
* Send the requested file.
|
|
|
6ed84f |
*/
|
|
|
6ed84f |
-static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen)
|
|
|
6ed84f |
+static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen, char *filename)
|
|
|
6ed84f |
{
|
|
|
6ed84f |
struct tftphdr *dp;
|
|
|
6ed84f |
struct tftphdr *ap; /* ack packet */
|
|
|
6ed84f |
@@ -1648,6 +1656,13 @@ static void tftp_sendfile(const struct f
|
|
|
6ed84f |
if (!++block)
|
|
|
6ed84f |
block = rollover_val;
|
|
|
6ed84f |
} while (size == segsize);
|
|
|
6ed84f |
+ tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from),
|
|
|
6ed84f |
+ tmpbuf, INET6_ADDRSTRLEN);
|
|
|
6ed84f |
+ if (!tmp_p) {
|
|
|
6ed84f |
+ tmp_p = tmpbuf;
|
|
|
6ed84f |
+ strcpy(tmpbuf, "???");
|
|
|
6ed84f |
+ }
|
|
|
6ed84f |
+ syslog(LOG_NOTICE, "Client %s finished %s",tmp_p,filename);
|
|
|
6ed84f |
abort:
|
|
|
6ed84f |
(void)fclose(file);
|
|
|
6ed84f |
}
|