From 5ef61b88185298de3230b902c7380167f27416f8 Mon Sep 17 00:00:00 2001 From: Jan Synacek Date: Mar 03 2016 08:40:47 +0000 Subject: enhance in.tftpd logging capabilities --- diff --git a/tftp-enhanced-logging.patch b/tftp-enhanced-logging.patch new file mode 100644 index 0000000..dce9ef9 --- /dev/null +++ b/tftp-enhanced-logging.patch @@ -0,0 +1,84 @@ +--- a/tftpd/tftpd.c 2016-03-02 11:32:30.710775130 +0100 ++++ b/tftpd/tftpd.c 2016-03-02 11:36:24.086541019 +0100 +@@ -1056,14 +1056,14 @@ int main(int argc, char **argv) + + static char *rewrite_access(char *, int, const char **); + static int validate_access(char *, int, const struct formats *, const char **); +-static void tftp_sendfile(const struct formats *, struct tftphdr *, int); ++static void tftp_sendfile(const struct formats *, struct tftphdr *, int, char *); + static void tftp_recvfile(const struct formats *, struct tftphdr *, int); + + struct formats { + const char *f_mode; + char *(*f_rewrite) (char *, int, const char **); + int (*f_validate) (char *, int, const struct formats *, const char **); +- void (*f_send) (const struct formats *, struct tftphdr *, int); ++ void (*f_send) (const struct formats *, struct tftphdr *, int, char *); + void (*f_recv) (const struct formats *, struct tftphdr *, int); + int f_convert; + }; +@@ -1129,6 +1129,9 @@ int tftp(struct tftphdr *tp, int size) + nak(EACCESS, errmsgptr); /* File denied by mapping rule */ + exit(0); + } ++ ecode = ++ (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr); ++ + if (verbosity >= 1) { + tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from), + tmpbuf, INET6_ADDRSTRLEN); +@@ -1147,9 +1150,14 @@ int tftp(struct tftphdr *tp, int size) + tp_opcode == WRQ ? "WRQ" : "RRQ", + tmp_p, origfilename, + filename); ++ ++ if (ecode == 1) { ++ syslog(LOG_NOTICE, "Client %s File not found %s\n", ++ tmp_p,filename); ++ } ++ + } +- ecode = +- (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr); ++ + if (ecode) { + nak(ecode, errmsgptr); + exit(0); +@@ -1172,12 +1180,12 @@ int tftp(struct tftphdr *tp, int size) + if (tp_opcode == WRQ) + (*pf->f_recv) (pf, (struct tftphdr *)ackbuf, ap - ackbuf); + else +- (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf); ++ (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf, origfilename); + } else { + if (tp_opcode == WRQ) + (*pf->f_recv) (pf, NULL, 0); + else +- (*pf->f_send) (pf, NULL, 0); ++ (*pf->f_send) (pf, NULL, 0, origfilename); + } + exit(0); /* Request completed */ + } +@@ -1557,7 +1565,7 @@ static int validate_access(char *filenam + /* + * Send the requested file. + */ +-static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen) ++static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen, char *filename) + { + struct tftphdr *dp; + struct tftphdr *ap; /* ack packet */ +@@ -1648,6 +1656,13 @@ static void tftp_sendfile(const struct f + if (!++block) + block = rollover_val; + } while (size == segsize); ++ tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from), ++ tmpbuf, INET6_ADDRSTRLEN); ++ if (!tmp_p) { ++ tmp_p = tmpbuf; ++ strcpy(tmpbuf, "???"); ++ } ++ syslog(LOG_NOTICE, "Client %s finished %s",tmp_p,filename); + abort: + (void)fclose(file); + } diff --git a/tftp.spec b/tftp.spec index 874e9d8..93a9381 100644 --- a/tftp.spec +++ b/tftp.spec @@ -4,7 +4,7 @@ Summary: The client for the Trivial File Transfer Protocol (TFTP) Name: tftp Version: 5.2 -Release: 17%{?dist} +Release: 18%{?dist} License: BSD Group: Applications/Internet URL: http://www.kernel.org/pub/software/network/tftp/ @@ -21,6 +21,7 @@ Patch6: tftp-0.49-cmd_arg.patch Patch7: tftp-hpa-0.49-stats.patch Patch8: tftp-hpa-5.2-pktinfo.patch Patch9: tftp-doc.patch +Patch10: tftp-enhanced-logging.patch BuildRequires: tcp_wrappers-devel readline-devel autoconf systemd-units @@ -57,6 +58,7 @@ systemd socket activation, and is disabled by default. %patch7 -p1 -b .stats %patch8 -p1 -b .pktinfo %patch9 -p1 -b .doc +%patch10 -p1 -b .logging %build autoreconf @@ -102,6 +104,9 @@ rm -rf ${RPM_BUILD_ROOT} %{_unitdir}/* %changelog +* Thu Mar 3 2016 Jan Synáček - 5.2-18 +- enhance in.tftpd logging capabilities + * Fri Feb 05 2016 Fedora Release Engineering - 5.2-17 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild