Results 1 to 5 of 5

Thread: 18.04 LTS Auto run script at start

  1. #1
    Join Date
    Aug 2006
    Location
    London, UK
    Beans
    Hidden!

    18.04 LTS Auto run script at start

    In Aug 2019 at https://ubuntuforums.org/showthread....4#post13790484 I raised a question and at the time the answer at #4 worked and I have just updated the vpn server switching software with a new version.

    I want the software to be automatically loaded on start up. At present that is almost happening except that upon startup I get a message that authentication is required for USR/BIN/ENV as super user.

    1. In the startup program I entered the run at start command:

    gnome-terminal --command="/usr/local/xxx.ac/bin/run_debian.sh"i

    2. I added a line to /etc/sudoers that looks like this:

    robin ALL=(root) NOPASSWD: /usr/local/xxx.ac/bin/run_debian.sh

    3. I made sure that run_debian.sh is owned by root:root
    sudo chown -c root:root /usr/local/xxx.ac/bin/run_debian.sh[/QUOTE]

    run_debian.sh contains the following:

    Code:
    BIN_PATH="/usr/local/xxx.ac/bin"
    xhost +
    xhost
    pkexec env LD_LIBRARY_PATH=$BIN_PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "$BIN_PATH/xxx.ac" "$@"
    sleep 5
    xhost -
    I expected that item 2 above adjusting sudoers would avoid the need for further authentication.

    Doing some further research I find that it is recommended "you should add admin:// prefix to the path of the file you want to edit." Does this mean that the requirement to re-enter the authentication password would go away, if I change the first line of the run_debian.sh to BIN_PATH="admin://usr/local/xxx.ac/bin" ? Is there a need to alter anything else?
    Last edited by slickymaster; 3 Weeks Ago at 06:08 PM. Reason: code tags

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    19,314
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: 18.04 LTS Auto run script at start

    I'm not familiar enough with everything you are doing, but LD_LIBRARY_PATH=$BIN_PATH would remove all the current search for libraries that you need.
    Also doubt that resetting the DISPLAY will help. It is already set. Same for XAUTHORITY.
    And the empty xhost shouldn't be needed. Doesn't make sense.

    I've never used pkexec. Usually, environment variables are set prior to calling the program that uses those variables.
    Code:
    export LD_LIBRARY_PATH=$BIN_PATH:$LD_LIBRARY_PATH
    pkexec  "$BIN_PATH/xxx.ac" "$@"
    is how I’d do it, knowing nothing about pkexec.

    I thought xhost arguments had changed recently. The xhost + stopped working sometime in 2016. From the xhost manpage:

    Code:
           The local family specifies  all  the  local  connections  at
           once.    However,    the    server    interpreted    address
           "si:localuser:username" can be  used  to  specify  a  single
           local  user.  (See  the  Xsecurity(7)  manual  page for more
           details.)
    BTW, fixing the code/quote tags above would be helpful, perhaps?
    Last edited by TheFu; 2 Weeks Ago at 12:32 AM. Reason: added missing "L" for 'LD"

  3. #3
    Join Date
    Aug 2006
    Location
    London, UK
    Beans
    Hidden!

    Re: 18.04 LTS Auto run script at start

    I regret that most of your explanation was above my knowledge, but I did understand that I had not made my request clear enough:

    What I am trying to do is to have the script run without asking for further authentication, because it should be automatically provided by the change in sudoers. I had added a line to /etc/sudoers that looks like this:

    robin ALL=(root) NOPASSWD: /usr/local/xxx.ac/bin/run_debian.sh
    (This change to sudoers was given to me in the Aug 19 query referred to in my first post.)

    In order to provide more information for this query, I added a debug command to the script quoted above:

    # R added to debug
    set -v
    trap "echo hit return;read x" DEBUG
    This stepped through the script without incident until

    ppkexec env LD_LIBRARY_PATH=$BIN_PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "$BIN_PATH/vpn.ac" "$@"
    The error message is:

    xhost: unable to open display "DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS "

    Error executing command as another user: Request dismissed
    Immediately after that error

    authentication is required for USR/BIN/ENV as super user.
    After that I have to enter my authentication password into a popup box on screen. Then the script continues without incident.

    Am I being any clearer as to what I am trying to do?

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    19,314
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: 18.04 LTS Auto run script at start

    Running GUI programs as root is a bad idea for many reasons. Learned that a few decades ago, so no, I cannot help. Sorry.

  5. #5
    Join Date
    Aug 2011
    Location
    Berlin, Germany
    Beans
    7,817
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: 18.04 LTS Auto run script at start

    Regularly (in the far, far past) you can add that "run" command with the full path into the file /etc/rc.local. Be aware that this file needs to end with "exit 0".

    Using asynchron upstart these scripts could be starting too early, then add a time delay as well

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •