Skip to contentSkip to conversation

Strange behavior observed w.r.t 'su' command

DISCUSSION Raj 5 participants 11 messages Nov 28, 2003

lore
Share & tools
lore

Raj

author
#0 lore raw

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

#1 lore raw
Quoted 4 lines · Raj

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.

Quoted 10 lines

- 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.

Signature · 2 lines
Måns Rullgård
[email protected]
#2 lore raw
Quoted 2 lines · M?ns Rullg?rd

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?

Signature · 3 lines
Tim Cambrant <[email protected]> 
GPG KeyID 0x59518702
Fingerprint: 14FE 03AE C2D1 072A 87D0  BC4D FA9E 02D8 5951 8702
#3 lore raw
Quoted 8 lines · Tim Cambrant
Quoted 2 lines · M?ns Rullg?rd

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.

#4 lore raw
In reply to Raj
Quoted 4 lines · Raj

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.

Quoted 10 lines

- 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.

Signature · 4 lines
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."
#5 lore raw
Quoted 15 lines · Andreas Schwab
Quoted 4 lines

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.

Quoted 10 lines

- 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.

Quoted 2 lines

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().

Signature · 2 lines
Måns Rullgård
[email protected]
#6 lore raw
Quoted 2 lines · [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.

Signature · 4 lines
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."
#7 lore raw
Quoted 4 lines · Andreas Schwab
Quoted 2 lines

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.

Signature · 2 lines
Måns Rullgård
[email protected]
#8 lore raw
Quoted 9 lines · [email protected] (Måns Rullgård) writes:
Quoted 4 lines · Andreas Schwab
Quoted 2 lines

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.

Signature · 4 lines
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."
author
#9 lore raw
In reply to Andreas Schwab
Quoted 4 lines · Andreas Schwab

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

Quoted 11 lines
Quoted 4 lines

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

#10 lore raw
Quoted 3 lines · Raj

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.

Signature · 4 lines
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."