tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

extra option to tftpd



I found adding an option to tftpd essentially to do s/\\/\// on a filename
useful for booting windows.

Comments?

Cheers,

Patrick

(pop
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot -p \
in inetd.conf)

Oct  2 18:21:14 quantz tftpd[28269]: 10.111.52.39: read request for /Boot/BCD: 
success
Oct  2 18:21:14 quantz tftpd[28269]: 10.111.52.39: read request for /Boot/BCD: 
success
Oct  2 18:21:14 quantz tftpd[21914]: 10.111.52.39: read request for 
/Boot/winpe.wim: success
Oct  2 18:21:14 quantz tftpd[19606]: 10.111.52.39: read request for 
/Boot/boot.sdi: success
Oct  2 18:21:14 quantz tftpd[19606]: 10.111.52.39: read request for 
/Boot/boot.sdi: success
Oct  2 18:21:14 quantz tftpd[4379]: 10.111.52.39: read request for 
/Boot/winpe.wim: success

Index: tftpd.8
===================================================================
RCS file: /cvsroot/src/libexec/tftpd/tftpd.8,v
retrieving revision 1.21
diff -u -r1.21 tftpd.8
--- tftpd.8     7 Aug 2003 09:46:53 -0000       1.21
+++ tftpd.8     2 Oct 2009 17:21:45 -0000
@@ -29,7 +29,7 @@
 .\"
 .\"    from: @(#)tftpd.8       8.1 (Berkeley) 6/4/93
 .\"
-.Dd June 11, 2003
+.Dd October 1, 2009
 .Dt TFTPD 8
 .Os
 .Sh NAME
@@ -43,6 +43,7 @@
 .Op Fl g Ar group
 .Op Fl l
 .Op Fl n
+.Op Fl p Ar path separator
 .Op Fl s Ar directory
 .Op Fl u Ar user
 .Op Ar directory ...
@@ -107,6 +108,10 @@
 .It Fl n
 Suppresses negative acknowledgement of requests for nonexistent
 relative filenames.
+.It Fl p Ar path separator
+All occurances of the single character
+.Ar path separator
+in the requested filename are replaced with '/'.
 .It Fl s Ar directory
 .Nm
 will
Index: tftpd.c
===================================================================
RCS file: /cvsroot/src/libexec/tftpd/tftpd.c,v
retrieving revision 1.32
diff -u -r1.32 tftpd.c
--- tftpd.c     16 Mar 2009 01:56:21 -0000      1.32
+++ tftpd.c     2 Oct 2009 17:21:45 -0000
@@ -107,6 +107,7 @@
 static int     suppress_naks;
 static int     logging;
 static int     secure;
+static char    pathsep = '\0';
 static char    *securedir;
 
 struct formats;
@@ -170,7 +171,7 @@
        curuid = getuid();
        curgid = getgid();
 
-       while ((ch = getopt(argc, argv, "dg:lns:u:")) != -1)
+       while ((ch = getopt(argc, argv, "dg:lnp:s:u:")) != -1)
                switch (ch) {
                case 'd':
                        debug++;
@@ -188,6 +189,11 @@
                        suppress_naks = 1;
                        break;
 
+               case 'p':
+                       pathsep = optarg[0];
+                       if (optarg[1] != '\0') usage();
+                       break;
+
                case 's':
                        secure = 1;
                        securedir = optarg;
@@ -662,6 +668,15 @@
                        exit(1);
                }
        }
+       /*
+        * Globally replace the path separator with / to cope with
+        * broken tftp clients.
+        */
+       if (pathsep != '\0') {
+               for (cp = filename; *cp != '\0'; ++cp) {
+                       if (*cp == pathsep) *cp = '/';
+               }
+       }
        ecode = (*pf->f_validate)(&filename, tp->th_opcode);
        if (logging) {
                syslog(LOG_INFO, "%s: %s request for %s: %s",


Home | Main Index | Thread Index | Old Index