Why does sudo need the loopback interface?

We were trying to install our software on an Ubuntu machine. To do so, we needed root privileges. Basically, all we needed to do was run a runnable jar like: sudo java -jar runnableJar.jar.
All such commands would return: Unable to resolve host xxxxx.

The /etc/hosts file had the incorrect hostname listed against the loopback interface which was causing this error. All commands which did not require sudo ran well.

I have been reading up on the loopback interface and my understanding is that it sets up localhost and is a virtual network interface. However, why does sudo need it at all?

Asked By: Sriram

||

Since the sudoers file permits the specifying of hostnames in the rules, sudo needs to know what the name of your Ubuntu machine is.

Because of this, sudo collects a list of all interfaces on your Ubuntu machine (loopback and “real”). See relevant section from sudo source code for interfaces.c, at the link below.

http://www.sudo.ws/repos/sudo/file/d8150a3fd577/interfaces.c

Answered By: steve
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.