[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KAuth and root running program
From:       Christian Jann <christian_jann () yahoo ! de>
Date:       2010-03-26 20:26:19
Message-ID: 201003262126.19568.christian_jann () yahoo ! de
[Download RAW message or body]

On Fri March 26 2010 17:09:08 Giovanni Venturi wrote:
> Hello,
> I was studying the KAuth framework examples on techbase. My question is
> this: what really I can do with KAuth? How does it work?
> I mean I need to start a command line application as root If I click on a
> KPushButton on my KDE application. Is it possible? When I implements KAuth
> manage into my GUI what happen will happen. Will appear a windows where it
> asks to me password for root user?

If I understand it right your program will be divided in two parts, some kind 
of library with functions which will run as root and your main application

you will see some window like here "user@host $ pkexec touch /testfile" asking 
for a password

I also tried KAuth but ... see the mail with subject 
"kdeexamples/authorization does not work"

If you get it working please tell me

another possibility:

//ask if something is unclear
QProcess m_process;
kDebug()<<"start new shell";
m_process.start("sh");
m_process.write(sudo());
m_process.write("\"");
//Executable: "/usr/bin/something"
m_process.write(Executable.toAscii());
m_process.write(" ");
m_process.write(device.toAscii());
m_process.write(" "); 
m_process.write(mount_dir.toAscii());
m_process.write(" "); 
m_process.write(additonalargs.toAscii());
kDebug()<<"execute the command, hit enter on the shell";
m_process.write("\"\n"); //newline


const char* sudo()
{
    switch (Settings::sudoCommand())
    {
	case 0:
	    //-d Do not show the command to be run in the dialog
	    return "kdesu -t -d -i appname -c ";
	case 1:
	    return "kdesudo";
	case 2:
	    return "gksu";
    }
    return "kdesu";
}
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic