I've consolidated the rest of my patches down to this - Next step is for me
to remember how the rest of the DHCP process works, so I can get the other
parameters that things expect to see in resolv.conf. Left the TODOs where
appropriate.
--- ./core/dhcp.cc~ 2019-02-07 04:35:11.187450000 -0500
+++ ./core/dhcp.cc 2019-02-07 05:12:14.322673000 -0500
@@ -266,6 +266,9 @@
}
options = add_option(options, DHCP_OPTION_PARAMETER_REQUEST_LIST,
sizeof(requested_options), requested_options);
+
+ // TODO: need to request domain, search settings for resolv.conf
file.
+
*options++ = DHCP_OPTION_END;
dhcp_len += options - options_start;
@@ -720,6 +723,23 @@
});
osv::set_dns_config(dm.get_dns_ips(),
std::vector<std::string>());
+
+ // ISC dhcp-client creates this file as a part of the standard
startup
+ // process on all UNIX-based platforms. Some software expects
this
+ // behavior (Go, Erlang, Haproxy).
+ int fd = open( "/etc/resolv.conf", O_RDONLY|O_TRUNC);
+ if (fd>=0) {
+ dprintf(fd, "## Autoconfigured by DHCP\n");
+ for (auto &ip: dm.get_dns_ips()) {
+ dprintf(fd,"server %s\n", ip.to_string().c_str());
+ dhcp_i("Added DNS server: %s", ip.to_string().c_str());
+ }
+ // TODO: domain, search parameters need to be retrieved
and added here.
+ close(fd);
+ } else {
+ printf("dhcp: Failed creating /etc/resolv.conf (error
%d)\n",errno);
+ }
+
if (dm.get_hostname().size()) {
sethostname(dm.get_hostname().c_str(),
dm.get_hostname().size());
dhcp_i("Set hostname to: %s", dm.get_hostname().c_str());
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.