jbublitz at nwinternet.com
Sun Aug 1 23:30:00 BST 2004
On Sunday 01 August 2004 09:34, Lionel Roubeyrie wrote:
> Ok Jim, I use Sip 3 and now the import is good, but :
> >>> import kdesu
> >>> k=kdesu.KDEsuClient()
> Erreur de segmentation
> I don't understand how kdesu works or shall I have to switch to Sip4?
I was wrong about the dialog part earlier. There are some problems with kdesu
that I don't quite understand still, but here's one way to run a program as
from kdesu import SuProcess
su = SuProcess ("root", "konqueror")
su.exec_ ("rootpassword", 0)
will run konqueror as root (if root's password is rootpassword and kdesud is
running). You can get the password (plain text) from the user using
KPasswordEdit in a dialog. Python uses exec_ instead of exec because the name
clashes with a Python keyword. The above will work in the interpreter too.
You can check a password with:
su = SuProcess ("root", "")
Returns 0 if valid, or one of SuProcess.Errors (1, 2, or 3) if not.
The empty string ("" - second arg) is REQUIRED or the constructor segfaults
(I'll have to check that problem too).
Would be nice to find some docs on this from KDE.
More information about the PyQt