dhclient: fallback to /var/resolv.conf if /etc is read-only
This commit is contained in:
parent
783e6d69d6
commit
64bfcce029
@ -389,6 +389,7 @@ static int configure_interface(const char * if_name) {
|
||||
ip_ntoa(ntohl(ip_data), addr);
|
||||
printf("%s: %s: nameserver %s\n", _argv_0, if_name, addr);
|
||||
FILE * resolve = fopen("/etc/resolv.conf","w");
|
||||
if (!resolve) resolve = fopen("/var/resolv.conf","w");
|
||||
if (resolve) {
|
||||
fprintf(resolve, "nameserver %s\n", addr);
|
||||
fclose(resolve);
|
||||
|
@ -237,6 +237,7 @@ struct hostent * gethostbyname(const char * name) {
|
||||
|
||||
/* Try to open /etc/resolv.conf */
|
||||
FILE * resolv = fopen("/etc/resolv.conf","r");
|
||||
if (!resolv) resolv = fopen("/var/resolv.conf","r");
|
||||
if (!resolv) {
|
||||
fprintf(stderr, "gethostbyname: no resolver\n");
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user