# Gentoo SU problem

## Anquietas

Hello again,

I've already mentioned this problem but I haven't got to much solutions.

I ask a Developer to Install Gentoo in a box and reproduce the same error as I have, because It's NOT tolerable.. I want a solution and I want it A.S.A.P., because I have serious problems at my Office with this, and I cannot reboot the system every time I su-

```

# su - admin        //root shell

$ llogout           // normal shell

#                        // root shell again

```

When I SU in another simple account, the first time works fine, but the rest, each time I type something it throws me out of the shell with a "logout" command... 

If I hit a couple of Enters, it works fine:

```

# su - admin         //root shell

$                         //here is an enter

$ ls                      // any command works

$ exit

logout

#                         // root shell again

```

Please Advice, this is terrible, please recompile bash on a test box to reproduce the error, check the portage for a younger Bash, DO SOMETHING please, this is terrifying ! I can't work like this

Thank you, and please, RESPOND...

Edit: the same problem can be found here: https://forums.gentoo.org/viewtopic-t-708761.html

I've posted it because it is also an installation problem, the same version of bash is on another computer of mine, and that works well...

Please do everything you can think of to resolve this problem !

----------

## notHerbert

What is the output of grep admin /etc/passwd 

----------

## Anquietas

admin:x:1000:100::/home/admin:/bin/bash

It is a global problem, with every user I might add...

If I hit a couple of enters, everything works... if not, bash automatically logs me out when I start typing one letter

----------

## notHerbert

Please post the output of emerge -av sys-auth/pambase 

----------

## Anquietas

```

maincore ~ # emerge -av sys-auth/pambase

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] sys-auth/pambase-20080318  USE="cracklib -consolekit -debug -gnome-keyring -mktemp -passwdqc (-selinux)" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] No

Quitting.

maincore ~ #

```

----------

## notHerbert

That looks in order, go ahead and emerge pambase

then run env-update && source /etc/profile

login to another shell and test.

----------

## Anquietas

```

maincore ~ # env-update && source /etc/profile

>>> Regenerating /etc/ld.so.cache...

maincore ~ # su - admin

admin@maincore ~ $ llogout

maincore ~ #

```

the same, after reinstalling pambase...

----------

## notHerbert

Okay, what is the output of echo $- like this

```
# su - admin         //root shell

$                         //here is an enter

$ echo $-
```

Also does this produce any output? 

```
grep onecmd /home/admin/.bash*
```

----------

## Anquietas

1.

```

maincore ~ # su - admin

admin@maincore ~ $

admin@maincore ~ $ echo $-

himBH

admin@maincore ~ $

```

2.

```

admin@maincore ~ $ grep onecmd /home/admin/.bash*

admin@maincore ~ $

```

----------

## notHerbert

Hmmm.  That is ok also.  Try re-emerging bash - but never unmerge bash.

```
emerge --sync

emerge bash
```

Also post output of 

```
# cat /etc/skel/.bash*
```

----------

## Anquietas

1.

Reinstall of Bash did not solve the problem...we have the same problem: 1st time working, 2nd time not

```

maincore ~ # su - admin

admin@maincore ~ $ pwd

/home/admin

admin@maincore ~ $ exit

logout

maincore ~ # su - admin

admin@maincore ~ $ plogout

maincore ~ # wd

-bash: wd: command not found

maincore ~ #

```

2. 

```

maincore ~ # cat /etc/skel/.bash*

# /etc/skel/.bash_logout

# This file is sourced when a login shell terminates.

# Clear the screen for security's sake.

clear

# /etc/skel/.bash_profile

# This file is sourced by bash for login shells.  The following line

# runs your .bashrc and is recommended by the bash info pages.

[[ -f ~/.bashrc ]] && . ~/.bashrc

# /etc/skel/.bashrc

#

# This file is sourced by all *interactive* bash shells on startup,

# including some apparently interactive shells such as scp and rcp

# that can't tolerate any output.  So make sure this doesn't display

# anything or bad things will happen !

# Test for an interactive shell.  There is no need to set anything

# past this point for scp and rcp, and it's important to refrain from

# outputting anything in those cases.

if [[ $- != *i* ]] ; then

        # Shell is non-interactive.  Be done now!

        return

fi

# Put your fun stuff here.

maincore ~ #

```

----------

## notHerbert

Is all this in an X session - xterm, or on a tty logged in as root?

----------

## Anquietas

TTY, using Local Login and PuTTy SSH Login, it's a server, it has no X interface, everything is textual

----------

## notHerbert

Well  that's different.  I was assuming that it was a regular session on a normal Gentoo.  

If you open a thread something like "PuTTy SSH Login problems" in the Networking & Security forum, and explain the context, I'm sure you will get the proper assistance.   :Razz: 

----------

## Anquietas

Hello again,

I've already mentioned this problem but I haven't got to much solutions...

At the advice of a Veteran Member, I've posted here in the Networking Category.

Problem happens in Network Enviroment (when I use putty to ssh on the server) and on Local Login (TTY).

I ask a Developer to Install Gentoo in a box and reproduce the same error as I have, because It's NOT tolerable.. I want a solution and I want it A.S.A.P., because I have serious problems at my Office with this, and I cannot reboot the system every time I su-

```

# su - admin        //root shell

$ llogout           // normal shell

#                        // root shell again

```

When I SU in another simple account, the first time works fine, but the rest, each time I type something it throws me out of the shell with a "logout" command... 

If I hit a couple of Enters, it works fine:

```

# su - admin         //root shell

$                         //here is an enter

$ ls                      // any command works

$ exit

logout

#                         // root shell again

```

Please Advice, this is terrible, please recompile bash on a test box to reproduce the error, check the portage for a younger Bash, DO SOMETHING please, this is terrifying ! I can't work like this

Thank you, and please, RESPOND...

Edit: the same problem can be found here:

https://forums.gentoo.org/viewtopic-t-708761.html

Also, before you tell me some things to do, please see here: https://forums.gentoo.org/viewtopic.php?p=5243611#5243611 . I've done all those things already and No Result.

Please do everything you can think of to resolve this problem !

----------

## VinzC

Some things you can try:PuTTY into another *NIX box and then SSH root from there

PuTTY as a simple user then su - and su - admin

EDIT: try su'ing without the hyphen

Install app-admin/sudo and use that instead; what does that produce?

what does scp to/from the problematic host do?

Check another remote shell than PuTTY.

It's all I can think of for the moment.

----------

## overkll

I never, ever have used the " - " option.  I've also never, ever have had a problem with su.  It just works.  Maybe it's an issue with putty?

----------

## Anquietas

SSH from another box is working, su- from other user accounts is working, the only case this is happening is if Root Sues into a normal user account.

Both "su -" and "su" commands are the same, with a small diference I won't detail now... but in both cases it logs me out on first typed letter.

This is deffinetly a server problem, not a client one

----------

## Hu

Since this is reproducible, I suggest logging system calls using dev-util/strace.  If that does not yield anything interesting, rebuild the shell with debug symbols and monitor it with sys-devel/gdb.

I routinely use su - user to switch down to unprivileged users for temporary work, and have never seen a problem.  Since you neglected to provide any information whatsoever about your system, it is rather unlikely anyone will be able to reproduce your problem.  At a minimum, we need to know your architecture, compilation options, and which shell is used by that user.  Start with the output of emerge --info ; grep admin /etc/passwd ; equery list app-shells/.

----------

## Anquietas

```

Portage 2.1.4.5 (default/linux/x86/2008.0, gcc-4.1.2, glibc-2.6.1-r0, 2.6.25-gentoo-r8 i686)

=================================================================

System uname: 2.6.25-gentoo-r8 i686 AMD Duron(tm)

Timestamp of tree: Fri, 10 Oct 2008 13:15:05 +0000

app-shells/bash:     3.2_p33

dev-lang/python:     2.4.4-r13

dev-python/pycrypto: 2.0.1-r6

sys-apps/baselayout: 1.12.11.1

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.61-r1

sys-devel/automake:  1.10.1

sys-devel/binutils:  2.18-r1

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.24

virtual/os-headers:  2.6.23-r3

ACCEPT_KEYWORDS="x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=i686 -pipe"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc"

CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/rc.d /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d /etc/wget"

CXXFLAGS="-O2 -march=i686 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://ftp.evolva.ro/gentoo/"

LDFLAGS="-Wl,-O1"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="acl apache2 berkdb bzip2 cli cracklib crypt dri fortran gdbm gpm iconv isdnlog ldap maildir midi mudflap mysql ncurses nptl nptlonly openmp pam pcre perl php5 png pppd python readline reflection session slang snmp spl ssl sysfs tcpd unicode winbind x86 xml xml2 xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY

admin:x:1000:100:Name OK:/:/bin/bash

[ Searching for all packages in 'app-shells' among: ]

 * installed packages

[I--] [  ] app-shells/bash-3.2_p33 (0)

```

I tried logging with the system logger, but in this case, the problem does not happen:

```

maincore ~ # strace -o log.txt su - admin

admin@maincore / $ pwd

/

admin@maincore / $ ls

arhivum  backups  bin  boot  deskbase  dev  etc  home  lib  lost+found  mnt  opt  proc  root  sbin  sys  tmp  usr  var

admin@maincore / $ logout

maincore ~ #

```

I can type and the shell does not exits me.... this is very odd... it only happens on plain "su - admin" ...

----------

## Anquietas

I tried on another server, the problem is GLOBAL, repeat, GLOBAL, on all servers, not only on mine, and can be reproduced:

Try logging in directly as Root on TTY1 or SSH and SU into a normal account. The first time it will work, but the second time not.

IT IS A GLOBAL GENTOO PROBLEM !

Also, this is very strange:

```

infosky ~ # su - admin

admin@infosky ~ $ ls

agenda  mail

admin@infosky ~ $ logout

infosky ~ # su admin

admin@infosky /root $ exit

infosky ~ #

```

As you can see, if I su with - , it allows me to remain on the shell, If I su without -, it automatically logs me out without typing anything.

```

infosky home # cd /home/admin/

infosky admin # su admin

admin@infosky ~ $ exit

infosky admin #

```

----------

## Chris W

 *overkll wrote:*   

> Maybe it's an issue with putty?

 

No, happens with openssh too, and the problem lies in su or bash.  I have this problem on one of two remote machines when I: 

```
me@here$ ssh there

me@there$ su -

root@there# su - user

user@there$ {type first char of command}logout

root@there# 
```

where the "logout" is added by the machine as it boots you out of the shell.  If I type a "space<enter>" then the user@there shell works fine.  Both the "here" and "there" machines are Gentoo, stable, and up-to-date.  The "there" machine was installed recently from profile 2008.0.  The "here" machine and the working remote machine are now 2008.0 profile but have been update to that from 2004 and 2005 vintage installs.

I had it working by rebuilding all the dependencies of "su" and "bash" the two programs directly involved 

```
#emerge -e sys-apps/shadow app-shells/bash
```

 I thought it was gone for good, but it happened again yesterday.  Intermittent race condition or something?

```

me@there$ equery list bash; equery list shadow

[ Searching for package 'bash' in all categories among: ]

 * installed packages

[I--] [  ] app-shells/bash-3.2_p33 (0)

[ Searching for package 'shadow' in all categories among: ]

 * installed packages

[I--] [  ] sys-apps/shadow-4.0.18.2 (0)

me@there$ emerge --info

Portage 2.1.4.4 (default/linux/x86/2008.0, gcc-4.1.2, glibc-2.6.1-r0, 2.6.25-gentoo-r8 i686)

=================================================================

System uname: 2.6.25-gentoo-r8 i686 Intel(R) Pentium(R) 4 CPU 2.66GHz

Timestamp of tree: Sun, 05 Oct 2008 16:45:01 +0000

distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [enabled]

app-shells/bash:     3.2_p33

dev-lang/python:     2.4.4-r13, 2.5.2-r7

dev-python/pycrypto: 2.0.1-r6

sys-apps/baselayout: 1.12.11.1

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.61-r2

sys-devel/automake:  1.7.9-r1, 1.9.6-r2, 1.10.1-r1

sys-devel/binutils:  2.18-r3

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.23-r3

ACCEPT_KEYWORDS="x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=pentium4 -pipe"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /home/mythtv/"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-O2 -march=pentium4 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="distcc distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="ftp://mirror.internode.on.net/pub/gentoo http://ftp.swin.edu.au/gentoo "

LDFLAGS="-Wl,-O1"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage"

SYNC="rsync://ptolemy/gentoo-portage"

USE="X acl acpi berkdb bzip2 cli cracklib crypt dri fortran gdbm gpm iconv ipv6 isdnlog lirc midi mudflap ncurses nls nptl nptlonly opengl openmp pam pcre perl pppd python readline reflection session spl ssl sysfs tcpd unicode x86 xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIRC_DEVICES="dvico" USERLAND="GNU" VIDEO_CARDS="nv nvidia"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

----------

## Anquietas

well, I hope this situation will be resolved soon with a patch or something....  it is very fustrating...

----------

## nixnut

 *Anquietas wrote:*   

> Hello again,
> 
> I've already mentioned this problem but I haven't got to much solutions...
> 
> At the advice of a Veteran Member, I've posted here in the Networking Category.
> ...

 

Merged above posts here. Cross posting is not allowed, so please don't do it again. If you think your post/thread would be better off in another forum, just ask here to move it.

----------

## Anquietas

ok, understood,...

still waiting for a solution for that problem...

----------

## studlyed

I just barely got chrooted ssh working last night at 4am, so this may be a little vague/odd.

i had to download and compile the coreutils

wget ftp://ftp.gnu.org/gnu/coreutils/coreutils-6.9.tar.bz2

which would not compile. it didn't like /usr/includes/sys/stat.h

I modified /usr/includes/sys/stat.h and change a line

in vi search for "extern int futimens "

and just above it you will see a #ifdef __USE_GNU

change that to #ifndef __USE_GNU

save

and compile it.

once it compiled i changed the stat.h back to the way it was.

And poof, it worked great.

By the way, i was also getting pam_start Error 26 when doing the chroot stuff until i did this.

I hope that helps out some

----------

## Chris W

 *Quote:*   

> I had it working by rebuilding all the dependencies of "su" and "bash" the two programs directly involved
> 
> ```
> #emerge -e sys-apps/shadow app-shells/bash
> ```
> ...

 

Are you able to try this?  Might take a while to complete although the absence of X will help.

----------

## Anquietas

I've compiled the core utils and everything using "emege --deep --update world" ... it updated every bit of information that was updateable from my server... the problem still exists... and I really don't want to recompile coreutils again, if gentoo already compiled me from the tree-source. If you can give me a serious guarantee that the SU-ing problem will work, I might be able to download the ebuild, and edit that file before recompiling... but please be sure of this, I don't want to do this for nothing...

----------

## Anquietas

A "quote" from a user from another forum

 *Quote:*   

> 
> 
> I have the same problem with one of my servers, which is running Gentoo 2.6.25-hardened-r7 and bash 3.2.33(1)-release. The only major difference between this machine and my other Gentoo machines is that it runs hardened Gentoo. Not sure how relevant that fact is.
> 
> On my machine, it only happens while running su as root. Normal users can su with no difficulties. Also, it happens regardless of the user that root tries to su to.
> ...

 

----------

## VinzC

Just a thought... Pressing Ctrl+D logs you out immediately. It's the only thing I'm considering, that relates to a keyboard action to log off. I'm thinking of a keyboard or key translator configuration problem -- possibly *not* on the target machine.

----------

## Anquietas

well.. It's not my keyboard, that's for sure  :Smile: ) I'm still waiting for someone to fix this...

----------

## VinzC

You'll probably have to fix it yourself... I gave that hint in the hope you could somehow sniff what keyboard codes the target machine receives; there might be a Ctrl+D that's sent in the meantime that forcibly logs you off at the first keystroke.

----------

## Anquietas

and how the hell do I intercept the command codes given by the Keyboard to the system ?... and .. I don't know why we should suspect the keyboard... the poor thing is behaving normally, I am positive it does not send "Control+D" unless I explicitly type "Control+D" ... however, I am willing to make a check, but please provide the means for intercepting Keystrokes...

----------

## VinzC

 *Anquietas wrote:*   

> please provide the means for intercepting Keystrokes...

 

I don't know any for I don't have that level of expertise. However I'm pretty sure such tools exist. Just trying to help.

EDIT: BTW I was not suspecting the keyboard directly rather than something between your keyboard and the target machine. Having a network trace between the target server and your machine during an SSH session would probably help but it leads to a very long trace.

----------

## Anquietas

it is happening on multiple computers, a general bug

----------

