skip to Main Content

I am trying to build a test package for a Synology DSM using their toolkit and one of the steps requires to execute a Python script. When I execute it an exception is thrown:

/pkgscripts-ng/include/check: line 93: /dev/null: Permission denied
ERROR: This script must be run as root

Here is the function responsible for this error:

CheckPermission()
{
    # Only root can run this
    id | grep "uid=0" >/dev/null
    if [ $? != "0" ]; then
        echo "ERROR: This script must be run as root";
        echo "";
        exit 1;
    fi

    # Stop!! If /root/.chroot does not exit
    if [ ! -f /root/.chroot ]; then
        echo "ERROR: Please chroot first!!"
        echo ""
        exit 1;
    fi
}

My dev virtual machine runs on Ubuntu 22.04.3. Installed version of Python: 3.10.12

I am executing the script as a root user (executed sudo -i in the terminal window, then double checked with whoami), so my understanding is that all the required privileges are there. If I execute id | grep "uid=0" >/dev/null in the same terminal window I don’t get any error.

Unfortunately I am not a Python developer and googling didn’t bring me much.

2

Answers


  1. This may not be the best way, but try running that python script with sudo (don’t change user to sudo by using sudo -i).
    For example:
    sudo python myPythonScript.py
    If its shell script, then run that also with sudo.

    Login or Signup to reply.
  2. This looks like a bash script, rather than a Python script. So a bit unclear whether the bash bit is executed by the Python or vice versa. Can you please show what command you used to execute the actual bit that triggers the error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search