Hi list,

here is the version for the 2nd release candidate dnsmasq-2.61rc2. My
first patch was built against 2.60.

Have fun!

Regards,
Oliver

diff -u -r dnsmasq-2.61rc2/man/dnsmasq.8 dnsmasq-2.61rc2+locase/man/dnsmasq.8
--- dnsmasq-2.61rc2/man/dnsmasq.8	2012-04-16 18:26:19.000000000 +0200
+++ dnsmasq-2.61rc2+locase/man/dnsmasq.8	2012-04-17 16:41:44.917242903 +0200
@@ -1385,6 +1385,13 @@
 enabled, and certainly not without specifying --tftp-root. Doing so
 can expose any world-readable file on the server to any host on the net. 
 .TP
+.B --tftp-lowercase
+Enable converting filenames of TFTP-requests to lowercase. This is useful
+if you are having requests from MS-Windows (c) tftp-clients, because they
+require case-insensitive destinations. 
+This works great together i.e. with the mount -t lowntfs-3g .. command.
+Furthermore, dnsmasq-tftp converts "\\" to "/" per default.
+.TP
 .B --tftp-max=<connections>
 Set the maximum number of concurrent TFTP connections allowed. This
 defaults to 50. When serving a large number of TFTP connections,
diff -u -r dnsmasq-2.61rc2/src/dnsmasq.c dnsmasq-2.61rc2+locase/src/dnsmasq.c
--- dnsmasq-2.61rc2/src/dnsmasq.c	2012-04-16 18:26:19.000000000 +0200
+++ dnsmasq-2.61rc2+locase/src/dnsmasq.c	2012-04-17 15:19:49.977448358 +0200
@@ -634,11 +634,12 @@
 	max_fd = FD_SETSIZE;
 #endif
 
-      my_syslog(MS_TFTP | LOG_INFO, "TFTP %s%s %s", 
+      my_syslog(MS_TFTP | LOG_INFO, "TFTP %s%s %s%s", 
 		daemon->tftp_prefix ? _("root is ") : _("enabled"),
 		daemon->tftp_prefix ? daemon->tftp_prefix: "",
-		option_bool(OPT_TFTP_SECURE) ? _("secure mode") : "");
-      
+		option_bool(OPT_TFTP_SECURE) ? _("secure mode") : "",
+		option_bool(OPT_TFTP_LOCASE) ? _("(lowercase-mode)") : "");
+     
       /* This is a guess, it assumes that for small limits, 
 	 disjoint files might be served, but for large limits, 
 	 a single file will be sent to may clients (the file only needs
diff -u -r dnsmasq-2.61rc2/src/dnsmasq.h dnsmasq-2.61rc2+locase/src/dnsmasq.h
--- dnsmasq-2.61rc2/src/dnsmasq.h	2012-04-16 18:26:19.000000000 +0200
+++ dnsmasq-2.61rc2+locase/src/dnsmasq.h	2012-04-17 16:32:29.577266117 +0200
@@ -217,7 +217,8 @@
 #define OPT_CONNTRACK      35
 #define OPT_FQDN_UPDATE    36
 #define OPT_RA             37
-#define OPT_LAST           38
+#define OPT_TFTP_LOCASE    38
+#define OPT_LAST           39
 
 /* extra flags for my_syslog, we use a couple of facilities since they are known 
    not to occupy the same bits as priorities, no matter how syslog.h is set up. */
diff -u -r dnsmasq-2.61rc2/src/option.c dnsmasq-2.61rc2+locase/src/option.c
--- dnsmasq-2.61rc2/src/option.c	2012-04-16 18:26:19.000000000 +0200
+++ dnsmasq-2.61rc2+locase/src/option.c	2012-04-17 16:41:57.037242396 +0200
@@ -64,59 +64,60 @@
 #define OPTSTRING "951yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:6:7:8:0:3:"
 
 /* options which don't have a one-char version */
-#define LOPT_RELOAD    256
-#define LOPT_NO_NAMES  257
-#define LOPT_TFTP      258
-#define LOPT_SECURE    259
-#define LOPT_PREFIX    260
-#define LOPT_PTR       261
-#define LOPT_BRIDGE    262
-#define LOPT_TFTP_MAX  263
-#define LOPT_FORCE     264
-#define LOPT_NOBLOCK   265
-#define LOPT_LOG_OPTS  266
-#define LOPT_MAX_LOGS  267
-#define LOPT_CIRCUIT   268
-#define LOPT_REMOTE    269
-#define LOPT_SUBSCR    270
-#define LOPT_INTNAME   271
-#define LOPT_BANK      272
-#define LOPT_DHCP_HOST 273
-#define LOPT_APREF     274
-#define LOPT_OVERRIDE  275
-#define LOPT_TFTPPORTS 276
-#define LOPT_REBIND    277
-#define LOPT_NOLAST    278
-#define LOPT_OPTS      279
-#define LOPT_DHCP_OPTS 280
-#define LOPT_MATCH     281
-#define LOPT_BROADCAST 282
-#define LOPT_NEGTTL    283
-#define LOPT_ALTPORT   284
-#define LOPT_SCRIPTUSR 285
-#define LOPT_LOCAL     286
-#define LOPT_NAPTR     287
-#define LOPT_MINPORT   288
-#define LOPT_DHCP_FQDN 289
-#define LOPT_CNAME     290
-#define LOPT_PXE_PROMT 291
-#define LOPT_PXE_SERV  292
-#define LOPT_TEST      293
-#define LOPT_TAG_IF    294
-#define LOPT_PROXY     295
-#define LOPT_GEN_NAMES 296
-#define LOPT_MAXTTL    297
-#define LOPT_NO_REBIND 298
-#define LOPT_LOC_REBND 299
-#define LOPT_ADD_MAC   300
-#define LOPT_DNSSEC    301
-#define LOPT_INCR_ADDR 302
-#define LOPT_CONNTRACK 303
-#define LOPT_FQDN      304
-#define LOPT_LUASCRIPT 305
-#define LOPT_RA        306
-#define LOPT_DUID      307
-#define LOPT_HOST_REC  308
+#define LOPT_RELOAD      256
+#define LOPT_NO_NAMES    257
+#define LOPT_TFTP        258
+#define LOPT_SECURE      259
+#define LOPT_PREFIX      260
+#define LOPT_PTR         261
+#define LOPT_BRIDGE      262
+#define LOPT_TFTP_MAX    263
+#define LOPT_FORCE       264
+#define LOPT_NOBLOCK     265
+#define LOPT_LOG_OPTS    266
+#define LOPT_MAX_LOGS    267
+#define LOPT_CIRCUIT     268
+#define LOPT_REMOTE      269
+#define LOPT_SUBSCR      270
+#define LOPT_INTNAME     271
+#define LOPT_BANK        272
+#define LOPT_DHCP_HOST   273
+#define LOPT_APREF       274
+#define LOPT_OVERRIDE    275
+#define LOPT_TFTPPORTS   276
+#define LOPT_REBIND      277
+#define LOPT_NOLAST      278
+#define LOPT_OPTS        279
+#define LOPT_DHCP_OPTS   280
+#define LOPT_MATCH       281
+#define LOPT_BROADCAST   282
+#define LOPT_NEGTTL      283
+#define LOPT_ALTPORT     284
+#define LOPT_SCRIPTUSR   285
+#define LOPT_LOCAL       286
+#define LOPT_NAPTR       287
+#define LOPT_MINPORT     288
+#define LOPT_DHCP_FQDN   289
+#define LOPT_CNAME       290
+#define LOPT_PXE_PROMT   291
+#define LOPT_PXE_SERV    292
+#define LOPT_TEST        293
+#define LOPT_TAG_IF      294
+#define LOPT_PROXY       295
+#define LOPT_GEN_NAMES   296
+#define LOPT_MAXTTL      297
+#define LOPT_NO_REBIND   298
+#define LOPT_LOC_REBND   299
+#define LOPT_ADD_MAC     300
+#define LOPT_DNSSEC      301
+#define LOPT_INCR_ADDR   302
+#define LOPT_CONNTRACK   303
+#define LOPT_FQDN        304
+#define LOPT_LUASCRIPT   305
+#define LOPT_RA          306
+#define LOPT_DUID        307
+#define LOPT_HOST_REC    308
+#define LOPT_TFTP_LOCASE 309
 
 #ifdef HAVE_GETOPT_LONG
 static const struct option opts[] =  
@@ -196,6 +197,7 @@
     { "tftp-unique-root", 0, 0, LOPT_APREF },
     { "tftp-root", 1, 0, LOPT_PREFIX },
     { "tftp-max", 1, 0, LOPT_TFTP_MAX },
+    { "tftp-lowercase", 0, 0, LOPT_TFTP_LOCASE },
     { "ptr-record", 1, 0, LOPT_PTR },
     { "naptr-record", 1, 0, LOPT_NAPTR },
     { "bridge-interface", 1, 0 , LOPT_BRIDGE },
@@ -341,6 +343,7 @@
   { LOPT_APREF, OPT_TFTP_APREF, NULL, gettext_noop("Add client IP address to tftp-root."), NULL },
   { LOPT_SECURE, OPT_TFTP_SECURE, NULL, gettext_noop("Allow access only to files owned by the user running dnsmasq."), NULL },
   { LOPT_TFTP_MAX, ARG_ONE, "<integer>", gettext_noop("Maximum number of conncurrent TFTP transfers (defaults to %s)."), "#" },
+  { LOPT_TFTP_LOCASE, OPT_TFTP_LOCASE, NULL, gettext_noop("Convert TFTP-requests to lowercase"), NULL },
   { LOPT_NOBLOCK, OPT_TFTP_NOBLOCK, NULL, gettext_noop("Disable the TFTP blocksize extension."), NULL },
   { LOPT_TFTPPORTS, ARG_ONE, "<start>,<end>", gettext_noop("Ephemeral port range for use by TFTP transfers."), NULL },
   { LOPT_LOG_OPTS, OPT_LOG_OPTS, NULL, gettext_noop("Extra logging for DHCP."), NULL },
@@ -1903,6 +1906,10 @@
 	daemon->tftp_unlimited = 1;
       break;
 
+    case LOPT_TFTP_LOCASE:  /*  --tftp--lowercase */
+      set_option_bool(OPT_TFTP_LOCASE);
+      break;  
+
     case LOPT_TFTP_MAX:  /*  --tftp-max */
       if (!atoi_check(arg, &daemon->tftp_max))
 	option = '?';
diff -u -r dnsmasq-2.61rc2/src/tftp.c dnsmasq-2.61rc2+locase/src/tftp.c
--- dnsmasq-2.61rc2/src/tftp.c	2012-04-16 18:26:19.000000000 +0200
+++ dnsmasq-2.61rc2+locase/src/tftp.c	2012-04-17 16:41:57.053242395 +0200
@@ -347,6 +347,31 @@
       while ((p = strchr(filename, '\\')))
 	*p = '/';
 
+      if (option_bool(OPT_TFTP_LOCASE))
+      {
+        /* Convert tftp requests to lowercase.       */ 
+        /* This may be useful, if you work i.e. with */
+        /* ntfs-3g setting filenames to lowercase    */
+        /* like mount -t lowntfs-3g .. or            */
+        /* mount -t iso9660 -o norock,map=normal ..  */
+        /* or mount -t vfat -o shortname=lower ..    */
+        /* because MS-Windows on vfat, iso9660 or    */
+        /* ntfs isnt case-sensitive, but Linux is.   */
+        /* So requests from win-tftp-clients are     */
+        /* always right with lo-case-letters         */
+        p = filename;
+        while (*p)
+        {
+          if ('A'<=*p && *p<='Z')
+          {
+            *p = *p-'A'+'a'; 
+           /* Compiler will find a faster solution :-) */
+          }
+          p++;
+        }
+      }
+
+
       strcpy(daemon->namebuff, "/");
       if (prefix)
 	{
_______________________________________________
Dnsmasq-discuss mailing list
[email protected]
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to