Sudo up your app with the GRoot.class :)
Posted
#1
(In Topic #477)
Banned
Works on the same principal as my GRoot app , no messing about with pkexec policies or anything like that this time.
It just re-launches using sudo in it's own hidden terminal that closes when the app closes.
It checks if you're root
if not it pops open a password asker.
(attachment removed)
Just add this code to your Startup class or FMain
PS. As Cogier pointed out (Cheers dude) you also need to add the gb.form.terminal component in the project settings.
For a sudo only app…
for an app that can run without root as well…
Shimples
If anyone knows of a better way to make an app get it's own root access please tell me.
Posted
Guru


I can't get your program to work. I've added gb.form.terminal and copied the commented sub to the FMain, the program pops up the 'Enter password box' but I can't enter text or click on any of the buttons! What am I doing wrong?
Have a look at my effort regarding 'sudo' here. It's not quite what you are doing but might offer some insight.
Posted
Banned
I've no idea why it isn't working.
I just added it to one of my apps and it worked like a charm.
(I had to also add the TerminalView component) I better add that to the info i guess, cheers
but nothing should be disabled?
Only thing springs to mind is i have not tested on it on a non standard project that does not have FMain.class as it's startup class.
I'll do some tests…
Posted
Banned
In that case the Public Sub _new() method does not work and the Me.Close() fails as there's no form.
So instead it goes in the Main() Sub
and rather than "Me.Close" just Return
Posted
Banned
Have a look at my effort regarding 'sudo' here. It's not quite what you are doing but might offer some insight.
Nice , yes different goal though.
This class is for specifically allowing a gambas GUI to ask for root and elevate on launch.
Like so many apps do
I thought i'd cracked it,
maybe post me the project your trying it with so i can experiment and iron out the kinks
Cheers
Posted
Banned
Mostly i removed the Process pointer as it wasn't really being used.
I also added the Application.Daemon = True line so it works in a world of it's own.
Using that method stops any stdout or error messages though as it detaches from the calling terminal but to be fair it's designed to be used on a GUI app that would not return shell messages and generally be launched from a launcher not terminal. but if you're testing debugging your app you can comment out the line.
It puts out some warning messages i think because the TerminalView isn't visible but it seems to work okay regardless.
And I made a ReadMe file.
Posted
Guru


Posted
Banned
cogier said
OK this version works. What use have you in mind for this?
It allows any gambas app to launch as root without having to sudo from terminal. or if not launching from terminal setting up pkexec policies and stuff to enable GUI only sudo.
Just a double click of the app icon or setting up a menu item/desktop launcher will not need a prefix like sudo or pkexec.
App asks for root itself with this method.
An app like my GrubHack app that needs root , now i just launch it however i like and it asks for password and elevates
Posted
Banned
Then i think it'll be complete
1 guest and 0 members have just viewed this.



