Workaround dhclient/resolvconf problem in Ubuntu 16.
This replaces the first attempt, which just masked the race condition, since I didn't understand what tmcc bossinfo was really doing. This appears to fix it satisfactorily for now; it doesn't seem that we will run into the case where the file exists but has no nameserver. resolvconf on Linux also breaks DNS momentarily via dhclient exit hook, or something. On Ubuntu 16, resolvconf is setup to run via dhclient enter hook (the hook redefines make_resolv_conf, which dhclient-script eventually executes prior to the exit hook execution). For whatever reason, though, sometimes when our exit hook (this script) runs, /etc/resolv.conf is a dangling symlink. I was not able to find the source of the asynch behavior, so I can't say for sure. But sethostname.dhclient is an immediate casualty, because it calls tmcc bossinfo(), and the tmcc binary attempts to use res_init and read the resolver and use that as boss. If there is no /etc/resolv.conf (or it is a broken symlink into /run, as it is on resolvconf systems before resolvconf runs for the first time on boot), res_init will return localhost, and there is no way for us in tmcc to know that is inappropriate (taking the res_init resolver might not be the best choice, but we do not dare to add a special-case rejection of localhost in tmcc).
Showing with 32 additions and 4 deletions