KDEsu
#include <kdesu/client.h>
Public Member Functions | |
KDEsuClient () | |
~KDEsuClient () | |
int | delCommand (const QByteArray &command, const QByteArray &user) |
int | delGroup (const QByteArray &group) |
int | delVar (const QByteArray &key) |
int | delVars (const QByteArray &special_key) |
int | exec (const QByteArray &command, const QByteArray &user, const QByteArray &options=0, const QList< QByteArray > &env=QList< QByteArray >()) |
int | exitCode () |
bool | findGroup (const QByteArray &group) |
QList< QByteArray > | getKeys (const QByteArray &group) |
QByteArray | getVar (const QByteArray &key) |
bool | isServerSGID () |
int | ping () |
int | setHost (const QByteArray &host) |
int | setPass (const char *pass, int timeout) |
int | setPriority (int priority) |
int | setScheduler (int scheduler) |
int | setVar (const QByteArray &key, const QByteArray &value, int timeout=0, const QByteArray &group=0) |
int | startServer () |
int | stopServer () |
Detailed Description
A client class to access kdesud, the KDE su daemon.
Kdesud can assist in password caching in two ways:
- For high security passwords, like for su and ssh, it executes the password requesting command for you. It feeds the password to the command, without ever returning it to you, the user. The daemon should be installed setgid nogroup, in order to be able to act as an inaccessible, trusted 3rd party. See exec, setPass, delCommand.
- For lower security passwords, like web and ftp passwords, it can act as a persistent storage for string variables. These variables are returned to the user, and the daemon doesn't need to be setgid nogroup for this. See setVar, delVar, delGroup.
Constructor & Destructor Documentation
KDESu::KDEsuClient::KDEsuClient | ( | ) |
Definition at line 56 of file client.cpp.
KDESu::KDEsuClient::~KDEsuClient | ( | ) |
Definition at line 81 of file client.cpp.
Member Function Documentation
int KDESu::KDEsuClient::delCommand | ( | const QByteArray & | command, |
const QByteArray & | user | ||
) |
Remove a password for a user/command.
- Parameters
-
command The command. user The user.
- Returns
- zero on success, -1 on an error
Definition at line 280 of file client.cpp.
int KDESu::KDEsuClient::delGroup | ( | const QByteArray & | group | ) |
Delete all persistent variables in a group.
- Parameters
-
group the group name. See setVar.
- Returns
Definition at line 365 of file client.cpp.
int KDESu::KDEsuClient::delVar | ( | const QByteArray & | key | ) |
Delete a persistent variable.
- Parameters
-
key The name of the variable.
- Returns
- zero on success, -1 on failure.
Definition at line 357 of file client.cpp.
int KDESu::KDEsuClient::delVars | ( | const QByteArray & | special_key | ) |
Delete all persistent variables with the given key.
A specicalized variant of delVar(QByteArray) that removes all subsets of the cached varaibles given by key
. In order for all cached variables related to this key to be deleted properly, the value given to the group
argument when the setVar function was called, must be a subset of the argument given here and the key
- Note
- Simply supplying the group key here WILL not necessarily work. If you only have a group key, then use delGroup instead.
- Parameters
-
special_key the name of the variable.
- Returns
- zero on success, -1 on failure.
Definition at line 373 of file client.cpp.
int KDESu::KDEsuClient::exec | ( | const QByteArray & | command, |
const QByteArray & | user, | ||
const QByteArray & | options = 0 , |
||
const QList< QByteArray > & | env = QList<QByteArray>() |
||
) |
Lets kdesud execute a command.
If the daemon does not have a password for this command, this will fail and you need to call setPass().
- Parameters
-
command The command to execute. user The user to run the command as. options Extra options. env Extra environment variables.
- Returns
- Zero on success, -1 on failure.
Definition at line 233 of file client.cpp.
int KDESu::KDEsuClient::exitCode | ( | ) |
Wait for the last command to exit and return the exit code.
- Returns
- Exit code of last command, -1 on failure.
Definition at line 386 of file client.cpp.
bool KDESu::KDEsuClient::findGroup | ( | const QByteArray & | group | ) |
Returns true if the specified group exists is cached.
- Parameters
-
group the group key
- Returns
- true if the group is found
Definition at line 347 of file client.cpp.
QList< QByteArray > KDESu::KDEsuClient::getKeys | ( | const QByteArray & | group | ) |
Gets all the keys that are membes of the given group.
- Parameters
-
group the group name of the variables.
- Returns
- a list of the keys in the group.
Definition at line 314 of file client.cpp.
QByteArray KDESu::KDEsuClient::getVar | ( | const QByteArray & | key | ) |
Get a persistent variable.
- Parameters
-
key The name of the variable.
- Returns
- Its value.
Definition at line 304 of file client.cpp.
bool KDESu::KDEsuClient::isServerSGID | ( | ) |
Returns true if the server is safe (installed setgid), false otherwise.
Definition at line 413 of file client.cpp.
int KDESu::KDEsuClient::ping | ( | ) |
Ping kdesud.
This can be used for diagnostics.
- Returns
- Zero on success, -1 on failure
Definition at line 381 of file client.cpp.
int KDESu::KDEsuClient::setHost | ( | const QByteArray & | host | ) |
Set the target host (optional).
Definition at line 254 of file client.cpp.
int KDESu::KDEsuClient::setPass | ( | const char * | pass, |
int | timeout | ||
) |
Set root's password, lasts one session.
- Parameters
-
pass Root's password. timeout The time that a password will live.
- Returns
- Zero on success, -1 on failure.
Definition at line 223 of file client.cpp.
int KDESu::KDEsuClient::setPriority | ( | int | priority | ) |
Set the desired priority (optional), see StubProcess.
Definition at line 262 of file client.cpp.
int KDESu::KDEsuClient::setScheduler | ( | int | scheduler | ) |
Set the desired scheduler (optional), see StubProcess.
Definition at line 271 of file client.cpp.
int KDESu::KDEsuClient::setVar | ( | const QByteArray & | key, |
const QByteArray & | value, | ||
int | timeout = 0 , |
||
const QByteArray & | group = 0 |
||
) |
Set a persistent variable.
- Parameters
-
key The name of the variable. value Its value. timeout The timeout in seconds for this key. Zero means no timeout. group Make the key part of a group. See delGroup.
- Returns
- zero on success, -1 on failure.
Definition at line 289 of file client.cpp.
int KDESu::KDEsuClient::startServer | ( | ) |
Try to start up kdesud.
Definition at line 429 of file client.cpp.
int KDESu::KDEsuClient::stopServer | ( | ) |
Stop the daemon.
Definition at line 395 of file client.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.