gksudo 16.10

Ralf Mardorf silver.bullet at zoho.com
Sun Nov 6 11:05:49 UTC 2016


On Sat, 05 Nov 2016 12:15:02 +0100, Nils Kassube wrote:
>Ralf Mardorf wrote:
>> you could either use
>> 
>>   sudo -i
>>   appname
>> 
>> or
>> 
>>   sudo HOME=/root appname  
>
>Another option:
>
>sudo -i appname

A note regarding

  sudo -u username command

A test with gksudo is included:

Arch Linux and Ubuntu using sudo.
=================================

[rocketmouse at archlinux ~]$ sudo -i
[sudo] password for rocketmouse: 
[root at archlinux ~]# sudo -u rocketmouse echo $HOME
/root
[root at archlinux ~]# sudo -i -u rocketmouse echo $HOME
/root
[root at archlinux ~]# sudo -s -u rocketmouse echo $HOME
/root
[root at archlinux ~]# sudo -u rocketmouse HOME=/home/rocketmouse echo $HOME 
/root
[root at archlinux ~]# HOME=/home/rocketmouse sudo -u rocketmouse echo $HOME 
/root
[root at archlinux ~]# HOME=/home/rocketmouse
[root at archlinux root]# sudo -u rocketmouse echo $HOME
/home/rocketmouse
[root at archlinux root]# HOME=/root
[root at archlinux ~]# lmount -w moonstudio && systemd-nspawn -qD /mnt/moonstudio
[root at moonstudio ~]# sudo -u weremouse echo $HOME
/root
[root at moonstudio ~]# sudo -i -u weremouse echo $HOME 
/root
[root at moonstudio ~]# sudo -s -u weremouse echo $HOME 
/root
[root at moonstudio ~]# sudo -u weremouse HOME=/home/weremouse echo $HOME 
/root
[root at moonstudio ~]# HOME=/home/weremouse sudo -u weremouse echo $HOME
/root
[root at moonstudio ~]# HOME=/home/weremouse                             
[root at moonstudio root]# sudo -u weremouse echo $HOME
/home/weremouse
[root at moonstudio root]# HOME=/root          
[root at moonstudio ~]# lsb_release -c
Codename:	xenial
[root at moonstudio ~]# logout
[root at archlinux ~]# cat /etc/issue 
Arch Linux \r (\l)





Now the bomb drops.
===================

[rocketmouse at archlinux ~]$ sudo -u mary_jane_doe echo $HOME
[sudo] password for rocketmouse: 
/home/rocketmouse
[rocketmouse at archlinux ~]$ sudo -u chuser echo $HOME
/home/rocketmouse
[rocketmouse at archlinux ~]$ cat /usr/local/bin/chuser 
#!/bin/sh

# /usr/local/bin/chuser -> /.chuser/bin/chuser

xhost +
gksudo -u chuser "$*"
xhost -
exit

[rocketmouse at archlinux ~]$ chuser echo $HOME
access control disabled, clients can connect from any host
/home/rocketmouse
access control enabled, only authorized clients can connect





It's strange, since the apps I run with this script do use the home of
chuser and not of rocketmouse.

However, for a script I'm using with an ubuntu-mate DVD I'll stay with

[rocketmouse at archlinux ~]$ grep flavour= lumatic.sh; grep "userset()" -A17 lumatic.sh 
flavour="ubuntu-mate"  # user name
userset() # Usage: userset <schema> <key> <value>
{
  HOME="/home/$flavour"
  sudo -u $flavour gsettings set $@
  HOME="/root"
}

rootset() # Usage: rootset <schema> <key> <value>
{
  gsettings set $@
}

userdcl() # Usage: userdcl <subpath>
{
  HOME="/home/$flavour"
  $(echo $1 | sed "s/\//_/g" | sed "s/-/_/g") | sudo -u $flavour dconf load $1
  HOME="/root"
}




Regards,
Ralf




More information about the ubuntu-users mailing list