Blame SOURCES/tftp-enhanced-logging.patch

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