2003-11-28 08:27:24

by Raj

[permalink] [raw]
Subject: Strange behavior observed w.r.t 'su' command

hi, i am not sure if this is a kernel problem or an 'su' related issue,
but this is what i have observed. Tried on 2.4.20-8 ( RH 9.0 kernel )
and latest 2.6.0-test11.

- log in as any normal user. ( on Console.).
- su - root
- from root prompt, run 'ps' and check the pid of 'su'.
- kill -9 <pid of su>
After the kill command, strangely my keyboard switches to unbuffered
mode ( a key press is processed immediately ). Also, i alternate between
the root prompt and the normal user prompt.
Every key press switches from root prompt to normal user prompt and vice
versa. Typing 'whoami' at the respective prompts displays 'normal user'
and 'root' for the respective prompts.

What could be wrong ? Or am i doing something which i shouldnt be doing ?

/Raj



2003-11-28 09:15:56

by Måns Rullgård

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Raj <[email protected]> writes:

> hi, i am not sure if this is a kernel problem or an 'su' related
> issue, but this is what i have observed. Tried on 2.4.20-8 ( RH 9.0
> kernel ) and latest 2.6.0-test11.
>
> - log in as any normal user. ( on Console.).
> - su - root
> - from root prompt, run 'ps' and check the pid of 'su'.
> - kill -9 <pid of su>
> After the kill command, strangely my keyboard switches to unbuffered
> mode ( a key press is processed immediately ). Also, i alternate
> between the root prompt and the normal user prompt.
> Every key press switches from root prompt to normal user prompt and
> vice versa. Typing 'whoami' at the respective prompts displays 'normal
> user' and 'root' for the respective prompts.

I can't reproduce it on Slackware running 2.6.0-test10. It's probably
a redhat thing.

--
M?ns Rullg?rd
[email protected]

2003-11-28 09:39:30

by Bradley Chapman

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Mr. Rullgard,

Confirmed. I have a Red Hat 9 system running 2.6.0-test11 with glibc 2.3.2-82
and coreutils 4.5.3-19.0.2. Killing su with SIGKILL does put the keyboard into
unbuffered mode and does alternate the prompts. No error messages appear in dmesg.

Brad

=====


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

2003-11-28 09:54:18

by Måns Rullgård

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Bradley Chapman <[email protected]> writes:

> Confirmed. I have a Red Hat 9 system running 2.6.0-test11 with glibc
> 2.3.2-82 and coreutils 4.5.3-19.0.2. Killing su with SIGKILL does
> put the keyboard into unbuffered mode and does alternate the
> prompts. No error messages appear in dmesg.

Does anyone know why redhat keeps doing these strange modifications?
Over the years, I've encountered quite a few problems caused by redhat
messing things up. A few examples:

- gcc 2.96
- A rather recent redhat version shipped with a broken 'sort'
command. It performed a seemingly random permutation.
- Redhat 9 perl doesn't treat rexexps the same way a clean perl of the
same version does.

Anyway, I guess it could be over soon, if only people would understand
to stay away from that fedora stuff.

--
M?ns Rullg?rd
[email protected]

2003-11-28 09:59:29

by Tim Cambrant

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

On Fri, Nov 28, 2003 at 10:15:50AM +0100, M?ns Rullg?rd wrote:
> I can't reproduce it on Slackware running 2.6.0-test10. It's probably
> a redhat thing.

This problem also appears on Gentoo 1.4 running 2.6.0-test11. I don't
know about the rest of the environment, but it's definately not just
a RedHat thing. Could it have something to do with some library-version
or something?

--
Tim Cambrant <[email protected]>
GPG KeyID 0x59518702
Fingerprint: 14FE 03AE C2D1 072A 87D0 BC4D FA9E 02D8 5951 8702

2003-11-28 09:56:31

by Raj

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

One more observation:

This time i wrote two shell functions, one for the user and another for
root. I placed them in the .bash_profile

for root
z()
{
touch /tmp/createdbyroot
}

for user
z()
{
touch /tmp/createdbyuser
}

I then reproduced the problem, and during the alternation of the
prompts, when i was on the user prompt, i ran 'whoami' and it showed me
as a normal user. Then i ran 'z'. I expected the filename in /tmp to be
'createdbyuser' but it is actually 'createdbyroot' !!!

/Raj

2003-11-28 10:33:54

by Andreas Schwab

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Raj <[email protected]> writes:

> hi, i am not sure if this is a kernel problem or an 'su' related issue,
> but this is what i have observed. Tried on 2.4.20-8 ( RH 9.0 kernel ) and
> latest 2.6.0-test11.
>
> - log in as any normal user. ( on Console.).
> - su - root
> - from root prompt, run 'ps' and check the pid of 'su'.
> - kill -9 <pid of su>
> After the kill command, strangely my keyboard switches to unbuffered mode
> ( a key press is processed immediately ). Also, i alternate between the
> root prompt and the normal user prompt.
> Every key press switches from root prompt to normal user prompt and vice
> versa. Typing 'whoami' at the respective prompts displays 'normal user'
> and 'root' for the respective prompts.

Nothing unusual, you just have two shells competing with each other on the
terminal. Don't use kill -9 unless you know what you are doing.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N?rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2003-11-28 10:47:24

by Måns Rullgård

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Andreas Schwab <[email protected]> writes:

>> hi, i am not sure if this is a kernel problem or an 'su' related issue,
>> but this is what i have observed. Tried on 2.4.20-8 ( RH 9.0 kernel ) and
>> latest 2.6.0-test11.
>>
>> - log in as any normal user. ( on Console.).
>> - su - root
>> - from root prompt, run 'ps' and check the pid of 'su'.
>> - kill -9 <pid of su>
>> After the kill command, strangely my keyboard switches to unbuffered mode
>> ( a key press is processed immediately ). Also, i alternate between the
>> root prompt and the normal user prompt.
>> Every key press switches from root prompt to normal user prompt and vice
>> versa. Typing 'whoami' at the respective prompts displays 'normal user'
>> and 'root' for the respective prompts.
>
> Nothing unusual, you just have two shells competing with each other on the
> terminal. Don't use kill -9 unless you know what you are doing.

It appears that my su exec()s the shell, whereas the redhat and gentoo
su fork() and exec().

--
M?ns Rullg?rd
[email protected]

2003-11-28 10:54:40

by Andre Tomt (LKML)

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

On Fri, 2003-11-28 at 11:57, Tim Cambrant wrote:
> On Fri, Nov 28, 2003 at 10:15:50AM +0100, M?ns Rullg?rd wrote:
> > I can't reproduce it on Slackware running 2.6.0-test10. It's probably
> > a redhat thing.
>
> This problem also appears on Gentoo 1.4 running 2.6.0-test11. I don't
> know about the rest of the environment, but it's definately not just
> a RedHat thing. Could it have something to do with some library-version
> or something?

For whatever it's worth, I can't reproduce this on a Debian Sid system
with kernel version 2.4.23-rc1. I guess RH/Gentoo isn't killing off the
forked shell when su dies brutally, leaving the root shell and the user
shell fighting for the terminal.


2003-11-28 11:02:28

by Andreas Schwab

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

[email protected] (M?ns Rullg?rd) writes:

> It appears that my su exec()s the shell, whereas the redhat and gentoo
> su fork() and exec().

Yes, your su probably does not support PAM.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N?rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2003-11-28 11:11:44

by Måns Rullgård

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Andreas Schwab <[email protected]> writes:

>> It appears that my su exec()s the shell, whereas the redhat and gentoo
>> su fork() and exec().
>
> Yes, your su probably does not support PAM.

I don't think it does. I still don't see the need to fork when using
PAM.

--
M?ns Rullg?rd
[email protected]

2003-11-28 11:18:49

by Raj

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Andreas Schwab wrote:

>[email protected] (M?ns Rullg?rd) writes:
>
>
>
>>It appears that my su exec()s the shell, whereas the redhat and gentoo
>>su fork() and exec().
>>
>>
>
>Yes, your su probably does not support PAM.
>
>Andreas.
>
>
>
But why is it that after 'su - root', running 'ps' shows 'su' as a
separate process, whereas, 'su - otheruser' and then 'ps' does not show
'su' in the process list ??
In plain words, why does this happen only for su to root ?

/Raj


2003-11-28 11:59:40

by Andreas Schwab

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

[email protected] (M?ns Rullg?rd) writes:

> Andreas Schwab <[email protected]> writes:
>
>>> It appears that my su exec()s the shell, whereas the redhat and gentoo
>>> su fork() and exec().
>>
>> Yes, your su probably does not support PAM.
>
> I don't think it does. I still don't see the need to fork when using
> PAM.

Because PAM needs to do some cleanup after the shell has exited.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N?rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."

2003-11-28 11:56:39

by Andreas Schwab

[permalink] [raw]
Subject: Re: Strange behavior observed w.r.t 'su' command

Raj <[email protected]> writes:

> But why is it that after 'su - root', running 'ps' shows 'su' as a
> separate process, whereas, 'su - otheruser' and then 'ps' does not show
> su' in the process list ??

Because you didn't list all processes.

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N?rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."