Hi all,

last month I read a question at gambas-club.de about how to relaunch one's
program with root privileges if it was running without them. This was the
straw to break the camel's back :-) [*]

As far as I can remember back, it was always a problem for the most to get
sudo or su do the right things when controlled manually (and even to decide
whether to use sudo or su).

The other option was to use gb.desktop's Desktop.RunAsRoot() which but only
supports su and needs pre-installed graphical tools. This was inherently
buggy on my system because gb.desktop does not recognise my DE. For some
reason, it always started "kdesvn" instead of "kdesu" to ask for my
password and kdesvn is, as you might guess from the name, not suited as a
replacement for kdesu. (I might as well have screwed up some configuration
files on my system to confuse the xdg scripts. I don't know/care. The main
point of this mail is:)

So I sat down and wrote some classes which do the stuff in pure Gambas:
 - ask for the user's preferred method of authentication (su or sudo) (which
   is also saved as of version 0.1.2 if gb.settings is available);
 - ask for the password;
 - restart the program with root privileges giving feedback about the
   operation (user cancelled password input, user gave wrong password - or
   new process started successfully) to the old process which may then
   take an action like terminating itself or, e.g., run with reduced
   functionality if the user cancelled input, etc..

I hope these classes can make the "can you give me (please)" kind of
questions about this topic answered quicker in the future ;-)

If you think it's good enough and know a good place in the docs where I can
put this, please tell me. I think (but try to convince me of the contrary):

 - people won't find it in "Application Repository";
 - "Tutorials" just doesn't look right;
 - "How To..." seems to target auxiliary topics like desktop integration and
   using unicode - in a "code snippet" manner.

I cannot promise to fix bugs you encountered but opinions are welcome ;-)

Regards,
Tobi

[*] Is this really how the english-speaking world knows that idiom? Sounds
pretty strange. In German it is the "drop that makes the vat overflow". But
googling a bit showed me that you english guys do other strange things with
our German "vats" like "this hits the bottom out of the vat" - literally
translated from German - is known as "this takes the biscuit" in English :-)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

Attachment: relaunch-root-0.1.2.tar.gz
Description: Binary data

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to