Comment 2 for bug 19553

Revision history for this message
jpkotta (jpkotta) wrote :

I can confirm the gethostbyname() stuff. There are several reports in the Ubuntu Forums of people locking themselves out of using sudo by removing the hostname (a search of "sudo gethostbyname" will confirm this). I've tried it myself; here's what I've found:
I used network-admin to set my hostname to nothing. It gave me a warning about not being able to open applications until I log in again, but nothing about screwing up sudo. Not that it should, because sudo should work without a hostname, or at least automatically fix itself if hostname is null. Anyway, after ignoring network-admin's warning, I tried to use sudo again, and it worked, albeit with errors (sudo: unable to lookup via gethostbyname()). I logged out and logged back in, and it worked (with errors). I rebooted and it failed. I think something in the shutdown sequence modifies /etc/hosts and /etc/hostname, because they didn't change immediately.

I think there should be a boot script that sets the hostname to the default if it is null. For example I made a script with "if [[ -z `hostname` ]] ; then hostname ubuntu ; fi" and made it run before all other boot scripts. I still got errors, but sudo worked. I think the script would have to make the first line of /etc/hosts and /etc/hostname agree in order to be successful, i.e. '127.0.0.1 localhost.localdomain localhost foobar' and 'foobar', respectively.

Should this be filed as a separate bug?