su or not to su :-)

hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jörg

=====================================================================
Dr. Jörg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: http://www.qnx.com ====

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <joerg.kampmann@ibk-consult.de> wrote:

hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

aha some success like other UNIXes, but still I want to stay within the
directory where I did the “su” :frowning:(

will this be possible somehow ?
Jörg

Kris Eric Warkentin schrieb:

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

Dr. Jörg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: http://www.qnx.com ====

Well, if it helps you:

su otherUser - changes the user, but not all environment variables (like
PATH) nor the current directory and the new shell is not the Login shell
(can leave with exit, logout is not neccessary)

su - otherUser - changes the user logging in as the one → changes the
login shell, all environment variables and of course changes current
directory to the home directory of the “otherUser”

Marek

Kris Eric Warkentin wrote:

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

Sadly, not that I know of. :frowning:

Kris

Joerg Kampmann <joerg.kampmann@ibk-consult.de> wrote:

aha some success like other UNIXes, but still I want to stay within the
directory where I did the “su” > :frowning:> (

will this be possible somehow ?
Jorg

Kris Eric Warkentin schrieb:

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

ok - thanks for all that. it helps - my problem is: what does ‘su’ do
besides switching the user (mostly root) and starting a new shell? and
whenever a new shell is started the $ENV of the already existing
environment should be sourced - right ? At least that was what QNX 4
did. I know from Digital UNIX (DUNIX) that the way 6.1.0 does it is the
was DUNIX does it. And this one is certified as POSIX compliant :slight_smile: -
you see: I seem to have a dilemma :wink:

cheers
Jörg



Marek Pasovsky schrieb:

su otherUser - changes the user, but not all environment variables (like
PATH) nor the current directory and the new shell is not the Login shell
(can leave with exit, logout is not neccessary)

su - otherUser - changes the user logging in as the one → changes the
login shell, all environment variables and of course changes current
directory to the home directory of the “otherUser”

Marek

Kris Eric Warkentin wrote:

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

Dr. Jörg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: http://www.qnx.com ====

Well,
concerning my knowledge of the “su” command:
su - otherUser

  1. switches to the other user
  2. performes complete log-in procedure of the appropriate user e.g.
    a) changes to the other user’s home directory
    b) starts a shell under the other user (with appropriate rights)
    c) sets enviroment according to the started ~/.shellrc
    su newUser
  3. switches to the other user
  4. starts a shell under the other user (with appropriate rights)
  5. does not change the environment variables at all

it can never source the $ENV of the old (“su.performing”) user because
in the first case (su - …) it does a complete login procedure $ENV
also contains the shellrc of the other (“su.started”) user, in the other
case it just changes permissions and the other (“su.called”) user has no
right to source the shellrc from $ENV - it belong to a different
user…

try to unset some enviroment variable and compare the result of su - and
su.

so my experiences (*BSD,Linux)
my oppinion - QNX 6.1.0 does it right, because the other user has no
rights on the old $ENV

Marek

Joerg Kampmann wrote:

ok - thanks for all that. it helps - my problem is: what does ‘su’ do
besides switching the user (mostly root) and starting a new shell? and
whenever a new shell is started the $ENV of the already existing
environment should be sourced - right ? At least that was what QNX 4
did. I know from Digital UNIX (DUNIX) that the way 6.1.0 does it is the
was DUNIX does it. And this one is certified as POSIX compliant > :slight_smile: > -
you see: I seem to have a dilemma > :wink:

cheers
Jörg

Marek Pasovsky schrieb:

su otherUser - changes the user, but not all environment variables (like
PATH) nor the current directory and the new shell is not the Login shell
(can leave with exit, logout is not neccessary)

su - otherUser - changes the user logging in as the one → changes the
login shell, all environment variables and of course changes current
directory to the home directory of the “otherUser”

Marek

Kris Eric Warkentin wrote:

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

Dr. Jörg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====

thank you all - I think things I want were possible under QNX 4 - when I
was in some dircurrent as userold and input “su” I got the privileges of
root (newuser) and it sourced ~/.kshrc (b’cause I had something like
“export ENV=~/.kshrc”). within ~/.kshrc (of root) I had a statement
“export LOGNAME=root”. So the result was: I stayed in the dircurrent
with root privileges.

moreover I had a shel prompt resulting from “export
PS1=’$LOGNAME@$(hostname):$PWD->’” which resulted now in
“root@thisnode:/home/userold/dircurrent->” having been before
“userold@thisnode:/home/userold/dircurrent->”.

Now under QNX 6 I had the same approach but after su I still had the
prompt “userold@thisnode:/home/userold/dircurrent->”

My suspicion is: su does not source ~/.kshrc (of root) - am I right ?

Where could be the differences then ?

Jörg

Marek Pasovsky schrieb:

Well,
concerning my knowledge of the “su” command:
su - otherUser

  1. switches to the other user
  2. performes complete log-in procedure of the appropriate user e.g.
    a) changes to the other user’s home directory
    b) starts a shell under the other user (with appropriate rights)
    c) sets enviroment according to the started ~/.shellrc
    su newUser
  3. switches to the other user
  4. starts a shell under the other user (with appropriate rights)
  5. does not change the environment variables at all

it can never source the $ENV of the old (“su.performing”) user because
in the first case (su - …) it does a complete login procedure $ENV
also contains the shellrc of the other (“su.started”) user, in the other
case it just changes permissions and the other (“su.called”) user has no
right to source the shellrc from $ENV - it belong to a different
user…

try to unset some enviroment variable and compare the result of su - and
su.

so my experiences (*BSD,Linux)
my oppinion - QNX 6.1.0 does it right, because the other user has no
rights on the old $ENV

Marek

Joerg Kampmann wrote:

ok - thanks for all that. it helps - my problem is: what does ‘su’ do
besides switching the user (mostly root) and starting a new shell? and
whenever a new shell is started the $ENV of the already existing
environment should be sourced - right ? At least that was what QNX 4
did. I know from Digital UNIX (DUNIX) that the way 6.1.0 does it is the
was DUNIX does it. And this one is certified as POSIX compliant > :slight_smile: > -
you see: I seem to have a dilemma > :wink:

cheers
Jörg

Marek Pasovsky schrieb:

su otherUser - changes the user, but not all environment variables (like
PATH) nor the current directory and the new shell is not the Login shell
(can leave with exit, logout is not neccessary)

su - otherUser - changes the user logging in as the one → changes the
login shell, all environment variables and of course changes current
directory to the home directory of the “otherUser”

Marek

Kris Eric Warkentin wrote:

Did you try ‘su - otherUser’? The dash causes su to behave differently.

cheers,

Kris

Joerg Kampmann <> joerg.kampmann@ibk-consult.de> > wrote:
hi,

under QNX 4 when entering “su otherUser” this user’s shell sourced the
file which was in the environment variable ENV (e.g. export
ENV=~/.kshrc) - It seems that this is no more the case with 6.1.0 -

It is very helpful because then within the .kshrc I changed the LOGNAME
variable and could use it e.g. within a export
PS1=’$LOGNAME@$(hostname):$PWD->’ - and I immediately could see what
user (normal or superuser) was working …

It should be easy to fix - or ?
Anybody aware of this stuff ?

cheers Jorg

=====================================================================
Dr. Jorg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x9368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth

Dr. Jörg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: > http://www.qnx.com > ====

Dr. Jörg Kampmann - IBK-Consult for Real-Time and Embedded Systems
D-31228 Peine - Tel.:+49-177-276-3140 - Fax: +49-5171-13385
http://www.ibk-consult.de
===== QNX is the better Choice for Real-Time: http://www.qnx.com ====