[Gambas-user] sudo or gksudo in SHELL?
Stefano Palmeri
rospolosco at ...152...
Sat Feb 23 17:15:18 CET 2008
Alle 16:35, sabato 23 febbraio 2008, Stefano Palmeri ha scritto:
> Alle 13:39, sabato 23 febbraio 2008, Maximillian Von Kloisterheim ha
scritto:
> > Stefano Palmeri wrote:
> > > I've attached an example. It shows how to send the password to sudo.
> > > You have to change the "your_commad_here" in the code.
> > >
> > > Stefano
> >
> > Thanks Stefano, that works a treat. However, Iv asked about this before
> > (Not in relation to Gambas) and was told that doing this would leave an
> > unencrypted copy of my password in the .bash-history file.
> >
> > That's why I was trying to get gksudo to ask me for a password, so the
> > system is still dealing with the security and I'm simply passing along
> > the commands.
> >
> > Failing this as an option, is there a way to force the program itself to
> > be run only under sudo/gksudo, so that the system asks for the password
> > before the program runs? (In the same way as I always have to enter my
> > password before I can open Synaptic for example)
> >
> > I know this can be done with a command line once the program is compiled
> > and installed, but can this be done from within the development
> > environment?
> >
> > Thanks
> >
> > Max
>
> Oh, well. It seems you are running Ubuntu, so you have to do a little
> testing because I don't know sudo works under Ubuntu.
> On Slackware, when I run a program under sudo, the user of that
> program becomes "root" so it's really easy to check:
>
> IF User.Name <> "root" THEN
> PRINT "You must be root or use sudo"
> QUIT
> ENDIF
>
> but I don't know Ubuntu policy for sudo. Try this
> little test:
>
> run:
>
> sudo gedit (be sure there's only a gedit process)
>
> and leave the editor open
>
> then on terminal run:
>
> ps aux | grep gedit | grep -v grep
>
> and check who is the owner/user (first field) of the gedit
> process. It could be something (root, admin) that you can use for the
> checking as above.
>
> Bye,
>
> Stefano
>
Also, you could do :
IF User.Name <> "root" THEN
SHELL "gksudo " & Application.Args[0] WAIT
QUIT
ENDIF
but this works after the project was compiled as executable.
Stefano
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list