user3388384
user3388384

Reputation: 233

Python sudo in new terminal window without passing password

I have a problem. I'm trying to run sudo command in new terminal window from python script but every time I have to put password in new window. Here is my code:

import subprocess
import sys
import os
def run_lirc():
    subprocess.call(['x-terminal-emulator','-e','sudo lircd'])
run_lirc()

Is any solution which allow me not to pass my root password? I have to open it lirc in new terminal window.

Upvotes: 2

Views: 245

Answers (1)

user3035850
user3035850

Reputation:

Apart from calling some subcommand in another "terminal window" being a bad idea, that is an issue with the sudo configuration.

Sudo assigns tty cookies to sessions, effectively limiting the session timeout to the tty that got the authentication.

You can prevent this from happening by disabling the tty_tickets option in /etc/sudoers:

Defaults !tty_tickets

Upvotes: 1

Related Questions