glu script and sudo

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

glu script and sudo

travikk
Hello,

So my script requires to exec unix command with sudo. When I try doing that, I get following error: "sudo: sorry, you must have a tty to run sudo"

This is obviously due to not having tty when running the script by agent. Is there a way to work around this, without modyfing /etc/sudoers? To use sudo I don't really need password.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: glu script and sudo

frenchyan
Administrator
There was this thread about it: http://glu.977617.n3.nabble.com/root-deployments-td4024760.html

Not sure if this helps

Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: glu script and sudo

travikk
Thing is, if I do try to execute any sudo command ( shell.exec("sudo xxx") ) I get this error:
"sudo: sorry, you must have a tty to run sudo"

which, tells me I should disable tty requirement, but that is a security violation. Essentially I'm trying to execute various tasks as various users (using su username). Is there any other suggested way to do that?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: glu script and sudo

sodul
This really is a Unix question not a Glu question. Here is a potential workaround for you:
http://www.doxer.org/resolved-sudo-sorry-you-must-have-a-tty-to-run-sudo/

<code>shell.exec("echo | sudo -S xxx")</code>
Or more efficiently pass an empty string with the triple "less than" input feed:
<code>shell.exec("sudo -S xxx <<< ''")</code>

       -S          The -S (stdin) option causes sudo to read the password from the standard input instead of the
                   terminal device.  The password must be followed by a newline character.
What happen here is that -S will make sudo use stdin and bypass the tty check and since you have password-less sudo then you feed it a blank line.
Loading...