how to run a wx program as root in linux/unix?

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
freepro
Experienced Solver
Experienced Solver
Posts: 63
Joined: Fri Nov 16, 2012 11:52 am

how to run a wx program as root in linux/unix?

Post by freepro » Wed Oct 09, 2013 12:59 am

Hi,
My a wx program must do some root work, so I want to run as root in Linux/Unix, how I should to do?
thanks!

DavidHart
Site Admin
Site Admin
Posts: 4005
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: how to run a wx program as root in linux/unix?

Post by DavidHart » Wed Oct 09, 2013 9:27 am

Hi,

I presume you mean that your program should run as a normal user, but sometimes be able to do something requiring superuser permissions. (If you mean that you want to run the whole program as root, just open a terminal and use su or sudo.)

In Linux there are various small gui programs that let you run other apps as root. Examples are kde/kdesu, gksu. Your program would simply use wxExecute to call e.g. gksu, and pass the app-to-run as gksu's parameter. That works, but it does mean that you depend on those programs being available, which seems decreasingly common.

So for my program, 4Pane I finally wrote my own, which you're welcome to copy (wxWindows licence): see Misc.cpp starting at line 453, and Misc.h.

Regards,

David

Post Reply