ppurka / easy_e17

script to compile and install enlightenment-DR17
4 stars 2 forks source link

archlinux su related issue #1

Closed ghost closed 11 years ago

ghost commented 11 years ago

Hi, there!

Please change the script. It's broken by initial design.

It won't run by sued user. It's a wrong idea to check original login name.

On Archlinux variable $LOGNAME is giving original name after doing su.

So the whoami is the only right working command.

ghost commented 11 years ago

Please consider this patch to make the script more reliable:

1109a1110

NAME=whoami 1113c1114

< <---->if [ ! "$LOGNAME" == "root" ]; then

<---->if [ ! "$NAME" == "root" ]; then 1115c1116

< <----><------><------>echo "$LOGNAME (as user)"

<----><------><------>echo "$NAME (as user)" 1118c1119

< <----><------><------>echo "$LOGNAME (non-root)"

<----><------><------>echo "$NAME (non-root)"

ghost commented 11 years ago

sry. that is better:

1109a1110

NAME=whoami 1113c1114

< if [ ! "$LOGNAME" == "root" ]; then

  if [ ! "$NAME" == "root" ]; then

1115c1116

< echo "$LOGNAME (as user)"

                  echo "$NAME (as user)"

1118c1119

< echo "$LOGNAME (non-root)"

                  echo "$NAME (non-root)"
ghost commented 11 years ago

LGNAME=whoami

ppurka commented 11 years ago

I don't understand. I am getting this on Gentoo

~» su -c 'echo $LOGNAME'
Password: 
root

And the same on a 10.04 Ubuntu system. Can you check whether you are getting root as the answer on Arch? It would be quite strange if Arch is not setting this variable to root. According to the wiki it is a really old unix construct.

EDIT Be careful with those quotes I used - please use only single quotes and not double quotes.

ppurka commented 11 years ago

Can you also let me know what output you get for this command on Arch? Then we can perhaps make a different patch.

su -c 'echo $UID'
ghost commented 11 years ago

It gives me 0.

ghost commented 11 years ago

su -c 'echo $LOGNAME'

gives me my user name. Not root.

ppurka commented 11 years ago

Thanks for the replies. After some thought, I think I will take your advice and just change LOGNAME. I have emailed upstream morlenxus, so hopefully he will also implement this change.

ppurka commented 11 years ago

Fixed in cdad61f

ghost commented 11 years ago

see manual for SU !

man su

For backward compatibility su defaults to not change the current directory and to only set the environment variables HOME and SHELL (plus USER and LOGNAME IF THE TARGET USER IS NOT ROOT)

last line is an explanation.