dnsmasq: don't allow rogue config file screwing up connection sharing

dnsmasq may read from its default config file location, which if that
location is a valid config file, it will combine with the options here
and cause undesirable side-effects.  Like sending bogus IP addresses
as the gateway or whatever.  So give dnsmasq a bogus config file
location to avoid screwing up the configuration we're passing to it.
This commit is contained in:
Dan Williams 2010-06-09 16:58:06 -07:00
parent eb132ad897
commit 9d3eb7bbfa

View file

@ -251,8 +251,9 @@ create_dm_cmd_line (const char *iface,
GString *s;
NMIP4Address *tmp;
struct in_addr addr;
char buf[INET_ADDRSTRLEN + 1];
char buf[INET_ADDRSTRLEN + 15];
char localaddr[INET_ADDRSTRLEN + 1];
int i;
dm_binary = nm_find_dnsmasq ();
if (!dm_binary) {
@ -273,6 +274,21 @@ create_dm_cmd_line (const char *iface,
nm_cmd_line_add_string (cmd, "--log-queries");
}
/* dnsmasq may read from it's default config file location, which if that
* location is a valid config file, it will combine with the options here
* and cause undesirable side-effects. Like sending bogus IP addresses
* as the gateway or whatever. So give dnsmasq a bogus config file
* location to avoid screwing up the configuration we're passing to it.
*/
memset (buf, 0, sizeof (buf));
strcpy (buf, "/tmp/");
for (i = 5; i < 15; i++)
buf[i] = (char) (g_random_int_range ((guint32) 'a', (guint32) 'z') & 0xFF);
strcat (buf, ".conf");
nm_cmd_line_add_string (cmd, "--conf-file");
nm_cmd_line_add_string (cmd, buf);
nm_cmd_line_add_string (cmd, "--no-hosts");
nm_cmd_line_add_string (cmd, "--keep-in-foreground");
nm_cmd_line_add_string (cmd, "--bind-interfaces");