Dash:
[t2-trunk.git] / package / network / dnsmasq / no-file-override.patch
blobc93aaac717de9233fae5ce384f118f0c808641c5
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/*/dnsmasq/no-file-override.patch
5 # Copyright (C) 2020 - 2021 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 --- dnsmasq-2.85/src/rfc2131.c.orig 2021-04-07 22:39:39.000000000 +0200
18 +++ dnsmasq-2.85/src/rfc2131.c 2021-08-30 17:49:48.447435549 +0200
19 @@ -55,7 +55,8 @@
20 time_t now,
21 unsigned int lease_time,
22 unsigned short fuzz,
23 - const char *pxevendor);
24 + const char *pxevendor,
25 + const char *filename);
28 static void match_vendor_opts(unsigned char *opt, struct dhcp_opt *dopt);
29 @@ -100,6 +101,8 @@
30 struct dhcp_opt *o;
31 unsigned char pxe_uuid[17];
32 unsigned char *oui = NULL, *serial = NULL;
33 + char filename[sizeof(((struct dhcp_packet*)0)->file)]; filename[sizeof(filename) - 1] = 0;
35 #ifdef HAVE_SCRIPT
36 unsigned char *class = NULL;
37 #endif
38 @@ -559,6 +562,9 @@
39 /* Match incoming filename field as a netid. */
40 if (mess->file[0])
42 + strncpy(filename, (char*)mess->file, sizeof(filename)); filename[sizeof(filename) - 1] = 0;
43 + fprintf(stderr, "filename: %s\n", filename);
45 memcpy(daemon->dhcp_buff2, mess->file, sizeof(mess->file));
46 daemon->dhcp_buff2[sizeof(mess->file) + 1] = 0; /* ensure zero term. */
47 id.net = (char *)daemon->dhcp_buff2;
48 @@ -650,7 +656,7 @@
50 clear_packet(mess, end);
51 do_options(context, mess, end, NULL, hostname, get_domain(mess->yiaddr),
52 - netid, subnet_addr, 0, 0, -1, NULL, vendor_class_len, now, 0xffffffff, 0, NULL);
53 + netid, subnet_addr, 0, 0, -1, NULL, vendor_class_len, now, 0xffffffff, 0, NULL, filename);
57 @@ -898,6 +904,7 @@
58 else
59 snprintf((char *)mess->file, sizeof(mess->file),
60 "%s.%d", service->basename, layer);
61 + if (filename[0]) snprintf((char *)mess->file, sizeof(mess->file), "%s", filename);
63 option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
64 option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, htonl(context->local.s_addr));
65 @@ -976,6 +983,7 @@
67 if (boot->file)
68 safe_strncpy((char *)mess->file, boot->file, sizeof(mess->file));
69 + if (filename[0]) safe_strncpy((char *)mess->file, filename, sizeof(mess->file));
72 option_put(mess, end, OPTION_MESSAGE_TYPE, 1,
73 @@ -1152,7 +1160,7 @@
74 option_put(mess, end, OPTION_LEASE_TIME, 4, time);
75 /* T1 and T2 are required in DHCPOFFER by HP's wacky Jetdirect client. */
76 do_options(context, mess, end, req_options, offer_hostname, get_domain(mess->yiaddr),
77 - netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, time, fuzz, pxevendor);
78 + netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, time, fuzz, pxevendor, filename);
80 return dhcp_packet_size(mess, agent_id, real_end);
82 @@ -1501,7 +1509,7 @@
83 if (rapid_commit)
84 option_put(mess, end, OPTION_RAPID_COMMIT, 0, 0);
85 do_options(context, mess, end, req_options, hostname, get_domain(mess->yiaddr),
86 - netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, time, fuzz, pxevendor);
87 + netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, time, fuzz, pxevendor, filename);
90 return dhcp_packet_size(mess, agent_id, real_end);
91 @@ -1568,7 +1576,7 @@
94 do_options(context, mess, end, req_options, hostname, get_domain(mess->ciaddr),
95 - netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, 0xffffffff, 0, pxevendor);
96 + netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now, 0xffffffff, 0, pxevendor, filename);
98 *is_inform = 1; /* handle reply differently */
99 return dhcp_packet_size(mess, agent_id, real_end);
100 @@ -2367,7 +2375,8 @@
101 time_t now,
102 unsigned int lease_time,
103 unsigned short fuzz,
104 - const char *pxevendor)
105 + const char *pxevendor,
106 + const char *filename)
108 struct dhcp_opt *opt, *config_opts = daemon->dhcp_opts;
109 struct dhcp_boot *boot;
110 @@ -2437,9 +2446,9 @@
111 if (!option_bool(OPT_NO_OVERRIDE) &&
112 req_options &&
113 in_list(req_options, OPTION_FILENAME))
114 - option_put_string(mess, end, OPTION_FILENAME, boot->file, 1);
115 + option_put_string(mess, end, OPTION_FILENAME, filename[0] ? filename : boot->file, 1);
116 else
117 - safe_strncpy((char *)mess->file, boot->file, sizeof(mess->file));
118 + safe_strncpy((char *)mess->file, filename[0] ? filename : boot->file, sizeof(mess->file));
121 if (boot->next_server.s_addr)