Re: Shell Command with Sudo

2010-06-13 Thread Peter Alcibiades


Richmond Mathewson-2 wrote:
 
 
 This is all very charming, but I wonder how one would
 effect this from a standalone on an end-user's machine . . .  :)
 
 

You'd have to write an install or first use shell script.  Get the user,
then the root password, then write an extra line to /etc/sudoers.  The
advantage, though it will not matter to many, is that you don't store the
password in the app and don't have to supply it at each use of the commands,
and that you have restricted your privileges to one named user and one
variant of one command.  

Justin's solution is very nice, agreed.  Probably more practical and
certainly easier to do.  But, you do end up storing the password, and what
commands can be executed is not limited, nor is which user limited.  

Or maybe this is wrong?  That is what the effect, I think, would be on
Debian, which ships without sudo built in.  Maybe these distros that ship
with sudo are preconfigured to allow any user to sudo with their own login
password?  In which case they can do sudo su -?  I don't much like that idea
either, that cannot be surely?

-- 
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/Shell-Command-with-Sudo-tp2251593p2253279.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-12 Thread Justin Sloan
Thanks to all who replied. With you help and some additional research
I came up with a solution.

Mac OS X bash shell only allows results from commands to be piped in
to another command, including sudo, not plain text. The solution is to
set a bash variable (pw=password) and echo the variable to pipe it
into sudo (echo $pw | sudo -S command). In Rev you must set the
variable and pipe it in on the same shell() call. Like this:

shell(pw=  tPassword  ; echo $pw | sudo -S command)

Works like a charm, and it's an elegant solution without a lot of
hashed code. I have not tested this on other Unix based systems but
the command should work on any system with bash as the default shell.


Happy coding!
 - Justin


On Fri, Jun 11, 2010 at 6:51 PM, David Bovill da...@vaudevillecourt.tv wrote:
 Don't think expect is the right way to do this - best would be to use an ssh
 key (seem to remember that is how I used to do this back when i was on Linux
 with Metacard), or else to write a bash script as a text file and then get
 rev to execute that.

 On 11 June 2010 16:33, Andre Garzia an...@andregarzia.com wrote:

 Justin,

 I always though you could not pipe passwords into sudo. One way to do this
 kind of stuff is to use the expect tool.

 http://expect.sourceforge.net/

 With expect you can automate many command line things.

 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-12 Thread Peter Alcibiades

Is there a reason you cannot use the NOPASSWD option in sudo?  Maybe this is
not how it works in OSX, but what you'd normally do is to edit /etc/sudoers
to allow this particular user to perform this particular command with the no
password option, and its done.  If you do this, the command can be limited
to one with specific options.  For instance, you can allow shutdown with the
-h option, but not the -r option.  No-one has to know the root password then
and it is not written anyplace.  Yes, you do have to know it to edit
/etc/sudoers.
-- 
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/Shell-Command-with-Sudo-tp2251593p2252593.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-12 Thread Richmond

On 06/12/2010 12:08 PM, Peter Alcibiades wrote:

Is there a reason you cannot use the NOPASSWD option in sudo?  Maybe this is
not how it works in OSX, but what you'd normally do is to edit /etc/sudoers
to allow this particular user to perform this particular command with the no
password option, and its done.  If you do this, the command can be limited
to one with specific options.  For instance, you can allow shutdown with the
-h option, but not the -r option.  No-one has to know the root password then
and it is not written anyplace.  Yes, you do have to know it to edit
/etc/sudoers.
   


This is all very charming, but I wonder how one would
effect this from a standalone on an end-user's machine . . .  :)
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-12 Thread Justin Sloan
Peter,

That is a good suggestion if the application was not meant for mass
deployment. Otherwise each machine's sudoers file would have to be
edited accordingly, which would be a bummer for users that do not know
how to do so. And that is likely the majority of Mac users. I would
venture to say that the majority of Mac users never even opened the
Terminal.

The solution is elegant, I believe, in that it will work on any Mac OS
X machine and takes advantage of Bash' s flexibility with Rev's shell
structure.

Happy coding!
 - Justin


On Sat, Jun 12, 2010 at 12:11 PM, Richmond richmondmathew...@gmail.com wrote:
 On 06/12/2010 12:08 PM, Peter Alcibiades wrote:

 Is there a reason you cannot use the NOPASSWD option in sudo?  Maybe this
 is
 not how it works in OSX, but what you'd normally do is to edit
 /etc/sudoers
 to allow this particular user to perform this particular command with the
 no
 password option, and its done.  If you do this, the command can be limited
 to one with specific options.  For instance, you can allow shutdown with
 the
 -h option, but not the -r option.  No-one has to know the root password
 then
 and it is not written anyplace.  Yes, you do have to know it to edit
 /etc/sudoers.


 This is all very charming, but I wonder how one would
 effect this from a standalone on an end-user's machine . . .  :)
 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-11 Thread Jim Sims

On Jun 11, 2010, at 12:35 PM, Justin Sloan wrote:

 Hello All,
 
 I am trying to run a shell() command in revStudio in order to execute some 
 terminal commands as the superuser on a Mac. An Ubuntu terminal will accept 
 the superuser password using a pipe, such as pass | sudo -S command, but 
 Mac's terminal will not accept the password on the same line.
 
 Is there a way to run multiple commands from a single rev shell() call? Or, 
 can I somehow followup a shell() call with the password?

I went to  http://www.mail-archive.com/use-revolution@lists.runrev.com/info.html
In the search field I put:multiple shell commands os x

It returned a few items that might be of help for you, at least worth a try:

---
As an alternative solution, one could use multiple shell commands
separated by a semi-colon:

get shell(cd /etc/ ; ls)
---
atb,
sims



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-11 Thread Andre Garzia
Justin,

I always though you could not pipe passwords into sudo. One way to do this
kind of stuff is to use the expect tool.

http://expect.sourceforge.net/

With expect you can automate many command line things.

HTH

Andre

On Fri, Jun 11, 2010 at 7:35 AM, Justin Sloan sloan.jus...@gmail.comwrote:

 Hello All,

 I am trying to run a shell() command in revStudio in order to execute some
 terminal commands as the superuser on a Mac. An Ubuntu terminal will accept
 the superuser password using a pipe, such as pass | sudo -S command, but
 Mac's terminal will not accept the password on the same line.

 Is there a way to run multiple commands from a single rev shell() call? Or,
 can I somehow followup a shell() call with the password?

 Thanks,

 Justin___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution




-- 
http://www.andregarzia.com All We Do Is Code.
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Shell Command with Sudo

2010-06-11 Thread David Bovill
Don't think expect is the right way to do this - best would be to use an ssh
key (seem to remember that is how I used to do this back when i was on Linux
with Metacard), or else to write a bash script as a text file and then get
rev to execute that.

On 11 June 2010 16:33, Andre Garzia an...@andregarzia.com wrote:

 Justin,

 I always though you could not pipe passwords into sudo. One way to do this
 kind of stuff is to use the expect tool.

 http://expect.sourceforge.net/

 With expect you can automate many command line things.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution