Problems with sudo

Moderator: BarryK

Post Reply
Caramel
Posts: 476
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 100 times
Been thanked: 78 times

Problems with sudo

Post by Caramel »

(EasyOS 6.3.1)

First a remark.
The outputs of ls and sudo ls (executed as root) can be different. It is visible with ls /root.
The layout is different. Thereis no colour with sudo ls
The name of a file with a "é" is not correctly displayed ( '$'\303\251'' instead of é)

But here the main problem is with the use of sudo in a script:

Let's call "sudo line" a line beginning by sudo (sudo command...)
The line that follows a sudo line does not wait the end of the execution of this sudo line to execute (unless it is itself a sudo line)

Example with this script testsudo :

Code: Select all

#/bin/bash

sudo mkdir /testdir
sudo chown spot /testdir
touch /testdir/file

run-as-spot /path/to/testsudo fails:

touch: impossible de faire un touch '/testdir/file': Permission denied

For the script to succeed I changed

Code: Select all

exec sudo-sh ${PPID} ${C}

with

Code: Select all

sudo-sh ${PPID} ${C}
RETURNDLG=0
while [ $RETURNDLG -eq 0 ]
 do
  sleep 1
  ps | grep "gtkdialog --program=SUDOSH_DLG" | grep -v grep 1> /dev/null
  RETURNDLG=$?
 done

Note the deletion of the exec. I don't know if this causes any side effects.

Post Reply

Return to “EasyOS”