Blame SOURCES/tftp-enhanced-logging.patch

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