Bug#611487: xterm: immediately exits upon running: exec login USER
On Thu, Feb 03, 2011 at 05:47:46AM -0500, Thomas Dickey wrote:
> Looks like a possible workaround would be to use sudo or other
> wrapper that holds the setuid behavior.
Hi Thomas,
I tried your above suggestion, in my case I used su like this,
$ su -l jsroot
to get a user "jsroot" login shell.
I have decided it is not appropriate to expect "exec login jsroot" to work,
even though it seemed to work when /bin/login is setuid 0 and xterm 235-2 was
installed. I say seemed to work because, actually, the count of logged in
users on my system was always off by +1 when I used this technique.
Now, when I get a "jsroot" login shell via "su -l jsroot", the following
situation exists,
# tty
/dev/pts/2
# logname
jeff
# var user logname
export USER='jsroot'
export LOGNAME='jsroot'
# who | grep pts/2
jeff pts/2 Mar 26 09:18 (:0.0)
And when I then launch an xterm from this "jsroot" login shell on pts/2,
I have problems with xterm 261-1 & 276-2, like this,
# tty
/dev/pts/6
# logname
root
# var user logname
export USER='jsroot'
export LOGNAME='root'
# who | grep pts/6
root pts/6 Mar 26 16:12 (:0.0)
while xterm 235-2 works correctly, like this,
# tty
/dev/pts/6
# logname
jsroot
# var user logname
export USER='jsroot'
export LOGNAME='jsroot'
# who | grep pts/6
jsroot pts/6 Mar 26 16:02 (:0.0)
Note that both lxterminal 0.1.8-2 and xfce4-terminal 0.4.5-1 exibit the same
(IMO, correct) behavior as xterm 235-2 in this case.
I believe that the behavior exhibited by xterm 235-2, lxterminal 0.1.8-2, and
xfce4-terminal 0.4.5-1, in the above typescripts, is in accordance with the use
of "su -l USER", while the behavior of xterm 261-1 and xterm 276-2 is not in
accordance with "su -l USER", because I have previously su-ed to a login
sub-shell as user "jsroot", not as user "root".
Here is what POSIX $xcu/getlogin.html says,
...
The login name shall be the string that would be returned by the getlogin()
function defined in the System Interfaces volume of POSIX.1-2008.
and POSIX $xsh/getlogin.html says,
...
Three names associated with the current process can be determined: getpwuid
( geteuid()) shall return the name associated with the effective user ID of
the process; getlogin() shall return the name associated with the current
login activity; and getpwuid( getuid()) shall return the name associated
with the real user ID of the process.
...
The getlogin() function returns a pointer to the user's login name. The
same user ID may be shared by several login names. If it is desired to get
the user database entry that is used during login, the result of getlogin()
should be used to provide the argument to the getpwnam() function. (This
might be used to determine the user's login shell, particularly where a
single user has multiple login shells with distinct login names, but the
same user ID.)
In other words, xterm 261-1 and xterm 276-2 should set the utmp entry for the
newly launched xterm so that getlogin() works properly. As long as the uid of
the user database entry for the USER environmental variable is the same as the
value returned by getuid(), then USER should be set in the utmp entry for the
xterm. Otherwise, the same logic would apply for the LOGNAME variable. Only
when both of these alternatives fail, then xterm should fallback to setting the
utmp entry to getpwuid( getuid()).
Thanks,
--
Jeffrey Sheinberg
Reply to: