Re: [Vala] Execute command as root
- From: Evan Nemerson <evan polussystems com>
- To: Brian Vidal <dael99 gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Execute command as root
- Date: Fri, 28 Aug 2009 15:52:29 -0700
Brian,
You have several different options. Here are a few, in ascending order
of difficulty:
1. Use the process spawning API in glib [1] to spawn gksudo. I have
a feeling this is what you'll end up doing.
2. Use the process spawning API to spawn sudo with the -S argument,
and pass the password to stdin. #1 is easier and more secure.
3. Create Vala bindings for libgksu [2]. You might be able to
generate them [3], or you might need to write them by hand.
Either way, it's a simple library, so it should be relatively
easy to do.
4. Move the code you need to run with elevated privileges to a
separate executable. Use PolicyKit (I think you would need to
write bindings), and perhaps D-Bus activation.
Also, you gave the example of modifying the sources list. If that is
your goal, I believe there is an interface for doing that in PackageKit.
Probably also libapt-pkg, rpmlib, etc.
What the right choice is depends a lot on your application.
-Evan
[1] http://references.valadoc.org/glib-2.0/GLib.Process.html
[2] http://www.nongnu.org/gksu/
[3] http://live.gnome.org/Vala/Bindings
On Fri, 2009-08-28 at 16:38 -0400, Brian Vidal wrote:
but how could I do that??
i've read that gksu will have a D-bus interface (or something) in Vala.
But, if I want to develop something that needs to modify system settings,
how can i do that now.
e.g.: modifying the sources list
or copy files to /usr/bin directory.
I want to avoid users to have to start the app from a command line and type
sudo appname.
I want, when the app is started, give the user the choice to desist from the
changes, and exit. Otherwise, ask the password and act.
2009/8/28 David Keijser <keijser gmail com>
2009/8/28 Brian Vidal <dael99 gmail com>:
> I really need to execute commands trough gksu
I'm developing a GTK based app, so i can't use spawn... sudo.
Maybe could there be a way to ask for password and pass to sudo??
Any ideas?
--
Brian Vidal
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
hmm, you mean gksu does not suite you for some reason?
it's a GObject library so getting bindings should be easy.
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]