CC: | sam [...] cpanel.net |
Subject: | "su nobody -c" is a problem where nobody's shell is /bin/nologin |
Date: | Fri, 30 Mar 2007 15:37:33 -0500 |
To: | bug-Sys-Hostname-Long [...] rt.cpan.org |
From: | Sam Foster <sam [...] cpanel.net> |
Hello, I am submitting this via e-mail as I am having trouble logging
in to http://rt.cpan.org.
Thank you for producing this module. We are experiencing an issue
where Sys::Hostname::Long::hostname_long(); returns "This account is
currently not available" when the system's hostname does not comtaiin
a period (.), and when the user "nobody" exists with the shell of /
bin/nologin.
Our configuration is Fedora Core 5 Linux x86_64 with Perl 5.8.8.
Following the code, it appears that the line:
$hostlong = dispatcher('uname')
is in fact pulling the proper hostname for our system. However, if
the hostname does not contain a period (eg: is not a FQDN), the
module determines that this may not be the correct hostname and looks
to alternative methods.
When the OS checking "if" statements fail to find Linux, it falls
back on:
} else {
$hostlong = dispatcher('exec_hostname_fqdn');
}
However, exec_hostname_fqdn (if ran as root) attempts to execute
$tmp = `su nobody -c "hostname --fqdn"`;
In our system (and many others), the user nobody is set in /etc/
passwd to use the shell /bin/nologin. This is where the "This
account is currently not available" message comes from.
So, the script is first finding the correct hostname, erroneously
determining that it might not be correct, and then trying an
alternative method which fails to produce the hostname, and then
returns the value of the failed method, assuming that it's the best
possible guess.
One of our engineers J.D. Lightsey has suggested, as a fix, changing
the line
$tmp = `su nobody -c "hostname --fqdn"`;
to specify a shell, like so:
$tmp = `su nobody -s /bin/bash -c "hostname --fqdn"`;
or:
$tmp = `su nobody -s /bin/sh -c "hostname --fqdn"`;