You are not logged in.

#1 2016-06-11 04:56:03

folatt
Member
Registered: 2015-08-01
Posts: 96

[Sloved] How can I best run an eclipse app that needs root permission?

So I've got an eclipse project that makes heavy use of pacman and thus needs to have root permissions.

Finding VM's to CPU intense I bought a small computer specifically for this project and remotely connect to it using NX.

The project (and thus eclipse) is installed and run on the remote computer.



The three options for running an eclipse project with root permissions I have come across so far are:

  1. Don't

  2. Run eclipse with `gksu`

  3. Run sudo with external tools.

The first one is not an option.

The second one I've had success running the project with.
However, this causes the problem that I also run other applications with it that specifically needs a non-root user to run
which is impossible if I can run the application only by root.

The third one I am currently trying out, but run into the wall with.

My external tools settings:

https://i.snag.gy/W03195.jpg

When I try to run this I get the following error message in the console:

sudo: no tty present and no askpass program specified

I've tried solving this problem by adding a no password exception for the script I'm trying to run in the sudoers config files, but to no avail.

/etc/sudoers.d/arkos.sudo

folatt   ALL=(ALL) NOPASSWD:/home/folatt/workspace/arkos/kraken/krakend

Mod note: Converted img to url, Please see the Community Code of Conduct for acceptable image sizes -- WorMzy

Last edited by folatt (2016-06-12 14:52:46)

Offline

#2 2016-06-11 05:04:30

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,681

Re: [Sloved] How can I best run an eclipse app that needs root permission?

Did you try replacing /usr/bin/sudo with /usr/bin/gksu

Offline

#3 2016-06-11 12:19:15

folatt
Member
Registered: 2015-08-01
Posts: 96

Re: [Sloved] How can I best run an eclipse app that needs root permission?

Did you try replacing /usr/bin/sudo with /usr/bin/gksu

Great! I think this works, but I probably need to adjust my arguments.
...
Got it!:

"python2 krakend -e dev --config /etc/arkos/settings.json"

Last edited by folatt (2016-06-11 12:51:32)

Offline

#4 2016-06-11 13:54:30

zerophase
Member
Registered: 2015-09-03
Posts: 239

Re: [Sloved] How can I best run an eclipse app that needs root permission?

Can't you mock out pacman with a wrapper for development, and just run integration tests to make sure the real implementation works?

Offline

#5 2016-06-11 18:27:52

folatt
Member
Registered: 2015-08-01
Posts: 96

Re: [Sloved] How can I best run an eclipse app that needs root permission?

zerophase wrote:

Can't you mock out pacman with a wrapper for development, and just run integration tests to make sure the real implementation works?

The project is an app store, so no.

I quickly figured out that I could run the subprocess.Popen pacman function with an added "gksu", as well. So now I can run the project in debug mode smile.
I didn't make the project and I haven't gotten an answer yet from the author what his intentions are, but I can leave it like this, because the piece of code below is not part of the subproject I intend to work on.

def pacman(flags, pkgs=[], eflgs=[]):
    # Subprocess wrapper, get all data
    if not pkgs:
        cmd = ["gksu", "pacman --noconfirm %s" % (flags)]
    elif type(pkgs) == list:
        cmd = ["gksu", "pacman --noconfirm %s" % flags]
        cmd += pkgs
    else:
        cmd = ["gksu", "pacman --noconfirm %s %s" % (flags, pkgs)]
    if eflgs and any(eflgs):
        eflgs = [x for x in eflgs if x]
        cmd += eflgs
    p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    data = p.communicate()
    data = {"code": p.returncode, "stdout": data[0], 
        "stderr": data[1].rstrip('\n')}
    return data

[UPDATE]

I just discovered that this doesnt work and returns the gksu help message as if it were asked to run `gksu -h`.

[UPDATE]

I think I've got it fixed now by treating gksu as the main program and pacman as an argument.

Last edited by folatt (2016-06-12 14:52:29)

Offline

Board footer

Powered by FluxBB