7.09.2008

logname and utmp/utmpd problem

I've encountered the following problem a number of times:
ssh (or telnet) into a box, sometimes only occurs on a particular tty, like /dev/pts/1
$ logname logname: could not get login name
even though:
$ id
uid=101(me) gid=102(mygroup)

UPDATE for sshd issues:
update your version of SSH or HP patches; see the last couple comment on this ITRC Forum posting.
try changing UsePrivilegeSeparation to no in sshd_config: /etc/opt/ssh/sshd_config
UsePrivilegeSeparation no

then send a SIGHUP to sshd:
kill -s SIGHUP $(cat /var/run/sshd.pid)
end update

It seems like the utmp database is corrupt or not functioning properly. When logname gives the error message "could not get login name", then system doesn't know who I am, so it thinks I'm root (it writes root-root in the sulog file).

To fix it, I just stopped and restarted the utmpd daemon process: /sbin/init.d/utmpd stop ; /sbin/init.d/utmpd start

This problem sometimes causes logins to hang when processing /etc/profile, if logname is used in /etc/profile or another login script.

No comments: