Bug 304 - Pressing any key after doing 'sudo su -' executes a 'logout'
Pressing any key after doing 'sudo su -' executes a 'logout'
Status: RESOLVED INVALID
Product: Sudo
Classification: Unclassified
Component: Sudo
1.6.9
PC Linux
: normal normal
Assigned To: Todd C. Miller
https://bugs.launchpad.net/ubuntu/+so...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-06 14:02 MDT by Sérgio Durigan Júnior
Modified: 2009-03-14 08:41 MDT (History)
2 users (show)

See Also:


Attachments
diff to flush tty before executing command (931 bytes, patch)
2009-03-13 10:43 MDT, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sérgio Durigan Júnior 2008-10-06 14:02:07 MDT
Hello,

There's a full description of this bug in this URL:

https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/224802

Although I'm not using Ubuntu (I'm using Gentoo), I have the same bug with 'sudo'. My version:

Sudo version 1.6.9p16

Thanks.
Comment 1 Todd C. Miller 2008-10-06 14:11:01 MDT
Can you verify that sudo 1.6.9p17 still exhibits this problem?
Comment 2 Sérgio Durigan Júnior 2008-10-06 14:23:16 MDT
(In reply to comment #1)
> Can you verify that sudo 1.6.9p17 still exhibits this problem?
> 

Sure, I'll do that :-). Thanks.
Comment 3 Sérgio Durigan Júnior 2008-10-06 14:27:01 MDT
(In reply to comment #2)
> (In reply to comment #1)
> > Can you verify that sudo 1.6.9p17 still exhibits this problem?
> > 
> 
> Sure, I'll do that :-). Thanks.
> 

Hi Todd,

Unfortunately, sudo 1.6.9_p17 still has the problem.

Thanks.
Comment 4 Sérgio Durigan Júnior 2008-10-06 17:48:40 MDT
There's one interesting thing that I forgot to mention. This problem does NOT occur with the following kernel version:

linux-2.6.23-gentoo-r9

Currently, I'm using this kernel version:

sergio@miki ~ $ uname -a
Linux miki 2.6.25-gentoo-r8 #2 SMP Sun Oct 5 18:03:23 BRT 2008 i686 Genuine Intel(R) CPU T1300 @ 1.66GHz GenuineIntel GNU/Linux


Maybe that can help you. Please, let me know if there's something I can do to help you track this issue.

Thanks.
Comment 5 Todd C. Miller 2008-10-06 18:01:37 MDT
Have I read this correctly and the problem only occurs when you do _not_ have to enter a password?
Comment 6 Sérgio Durigan Júnior 2008-10-06 19:57:53 MDT
Todd,

By default, my sudoers is configured so that I can execute sudo without having to type the password. However, I have temporarily disabled this configuration and done a few tests. As far as I could observe, it seems that the problem doesn't occur when I have to type a password, indeed.
Comment 7 Todd C. Miller 2008-10-07 10:10:31 MDT
That makes me suspicious that this is actually a PAM-related problem.  Can you try running configure with the --disable-pam-session flag and see if the resulting sudo has the same issue.

If that's not it then the next thing is to try is to compare the terminal settings of the terminal running "sudo su -" both with an without a password.

To do this you'll want two terminal windows.  In the first, use the tty command to find the path to the controlling tty.  Then run "sudo -k; sudo su -" and enter your password to run su.

In the second window, run "stty -a -f "stty -a -f /path/to/tty" where /path/to/tty is the output of the tty command from the first window.

Then repeat the process with sudo not prompting you for a password, but be sure to run stty before you press a key (since that would exit the su process).

If the terminal settings from stty differ bewteen the two invocations of su, that should help point the way to the actual problem.
Comment 8 Guido Jäkel 2008-11-13 13:21:27 MST
Hi all,

I'm also don't observe this currently on my Unbutu 8.04 workstation at home, but with pure "su -" (not sudo!) on some of my Gentoo Server's, too. And this type of problem is also reported by users of other distributions!

After switching to another user via "su - foo" i eithter get kicked out immediately (the shell writes "exit" or "logout") or just after the first keypress, if this isn't CR. Pressing CR will proceed to the next prompt, any other will act like receiving a SIGHUP from somewhere. Note that the pressed key is displayed before logout.

But sometime after leaving the system alone for a while or after rebooting, all will work fine as expected for one try. With the next try, the problem occurs again.

And more, sometime it will work with user account a, but not with b and othertimes vice versa.

In addition, one of two nominal nearly-cloned boxes of one of my clusters show the problem, the other one works flawless.

Some other guys wrote, that this only will happen with bash -- i don't check it. But i don't think it's realy related to bash, su or sudo in core.

I also try to get a hint from 'strace su - foo'. But using this type of invocation, everythink works well, again! From this, i think it's some very strange kind of a race condition. Maybe on slow hardware, maybe just -- as another one reports -- on *single* (non-HT) CPU systems.

I observe it on my test boxes, which holds simple 1.6GHz P4 boards.

I get notice of this problems about two weeks after a general update of this Gentoo systems, pulling it from a software release time somewhere in 2007 (e.g. kernel 2.6.21) to our days (with a "conservative" kernel 2.6.25). One of the test boxes is still at 2.6.21, but have newer packages of other software already applied. This box seems to work fine, so maybe it's related to some kernel changes far back in time.
Comment 9 James Meyer 2009-03-12 20:51:30 MDT
Tom,
This bug also happens to me and I have the results of the stty test as described in comment #6
file #1 is results of running
stty -a -F /dev/pts/2 >1   after using sudo with a password.

file #2 is without a password and without pressing a key (so it didn't kick me out)


diff 1 2
6,7c6,7
< -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
< -iuclc -ixany -imaxbel iutf8
---
> -ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
> -iuclc -ixany imaxbel iutf8
Comment 10 Todd C. Miller 2009-03-13 10:43:08 MDT
Created attachment 250 [details]
diff to flush tty before executing command
Comment 11 Todd C. Miller 2009-03-13 10:44:46 MDT
Can you give the diff I just attached a try?  It really shouldn't make any difference but it's worth a shot.
Comment 12 James Meyer 2009-03-13 15:53:11 MDT
(In reply to comment #11)
> Can you give the diff I just attached a try?  It really shouldn't make
> any difference but it's worth a shot.

Updated to sudo 1.7.0 and applied the patch.

The patch did not fix the problem.
Also tried compiling without pam support, but that didn't help either.

Comment 13 James Meyer 2009-03-13 16:24:11 MDT
(In reply to comment #12)
> (In reply to comment #11)
> > Can you give the diff I just attached a try?  It really shouldn't make
> > any difference but it's worth a shot.
> 
> Updated to sudo 1.7.0 and applied the patch.
> 
> The patch did not fix the problem.
> Also tried compiling without pam support, but that didn't help either.
> 

Some more testing seems to indicate that sudo is not the source of the bug.

As root a "su $some_other_name" shows the same problem.
Any thoughts on where to look next?  Just updated core-utils to the latest version, but the problem remains.

-james
Comment 14 Todd C. Miller 2009-03-13 16:30:34 MDT
Seems like it has to either be a kernel or bash bug.  See the links in the ubuntu bug report listed in the description of this bug.
Comment 15 James Meyer 2009-03-13 16:46:13 MDT
(In reply to comment #14)
> Seems like it has to either be a kernel or bash bug.  See the links in
> the ubuntu bug report listed in the description of this bug.
> 
Todd,

Update:
Core-utils 6.12 seems to work for me, as does an unpatched 7.1 version.  

My initial update of coreutils was using the binary package that my distro provided.  However this version includes a PAM patch from Fedora that triggers this problem.
If the pkg is rebuilt without that PAM patch it works as expected.  If it's rebuilt with the patch then this annoying su bug shows up.

Thank you for your help on this.
-james



Comment 16 Guido Jäkel 2009-03-14 05:38:00 MDT
(In reply to comment #14)
> Seems like it has to either be a kernel or bash bug.  See the links in
> the ubuntu bug report listed in the description of this bug.
> 

For me, the problem have gone with applying some general Gentoo updates to my bunch of (different) boxes in the first two month of 2009.

But this neither include a kernel update, not even coreutils or pam. But e.g. bash and cracklib was refreshed.

As if the problem appears before, I have no idea what concrete package update now is "responsible" for fixing the problem.

My current version of coreutils is gentoo's  6.10-r2, last build here eg. at 2008-05-13. bash is at 3.2._p39, build here in 2009-01.
Comment 17 Todd C. Miller 2009-03-14 08:41:38 MDT
Closing, as this is not a sudo problem.