KDESu 5.99.0
|
A client class to access kdesud, the KDE su daemon. More...
#include <KDESu/Client>
Public Member Functions | |
KDEsuClient (const KDEsuClient &)=delete | |
int | delCommand (const QByteArray &command, const QByteArray &user) |
Remove a password for a user/command. More... | |
int | delGroup (const QByteArray &group) |
Delete all persistent variables in a group. More... | |
int | delVar (const QByteArray &key) |
Delete a persistent variable. More... | |
int | delVars (const QByteArray &special_key) |
Delete all persistent variables with the given key. More... | |
int | exec (const QByteArray &command, const QByteArray &user, const QByteArray &options=nullptr, const QList< QByteArray > &env=QList< QByteArray >()) |
Lets kdesud execute a command. More... | |
int | exitCode () |
Wait for the last command to exit and return the exit code. More... | |
bool | findGroup (const QByteArray &group) |
Returns true if the specified group exists is cached. More... | |
QList< QByteArray > | getKeys (const QByteArray &group) |
Gets all the keys that are membes of the given group. More... | |
QByteArray | getVar (const QByteArray &key) |
Get a persistent variable. More... | |
bool | isServerSGID () |
Returns true if the server is safe (installed setgid), false otherwise. More... | |
KDEsuClient & | operator= (const KDEsuClient &)=delete |
int | ping () |
Ping kdesud. More... | |
int | setHost (const QByteArray &host) |
Set the target host (optional). More... | |
int | setPass (const char *pass, int timeout) |
Set root's password, lasts one session. More... | |
int | setPriority (int priority) |
Set the desired priority (optional), see StubProcess. More... | |
int | setScheduler (int scheduler) |
Set the desired scheduler (optional), see StubProcess. More... | |
int | setVar (const QByteArray &key, const QByteArray &value, int timeout=0, const QByteArray &group=nullptr) |
Set a persistent variable. More... | |
int | startServer () |
Try to start up kdesud. More... | |
int | stopServer () |
Stop the daemon. More... | |
A client class to access kdesud, the KDE su daemon.
Kdesud can assist in password caching in two ways:
int KDESu::KDEsuClient::delCommand | ( | const QByteArray & | command, |
const QByteArray & | user | ||
) |
Remove a password for a user/command.
command | The command. |
user | The user. |
int KDESu::KDEsuClient::delGroup | ( | const QByteArray & | group | ) |
Delete all persistent variables in a group.
group | the group name. See setVar. |
int KDESu::KDEsuClient::delVar | ( | const QByteArray & | key | ) |
Delete a persistent variable.
key | The name of the variable. |
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 variables 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
special_key | the name of the variable. |
int KDESu::KDEsuClient::exec | ( | const QByteArray & | command, |
const QByteArray & | user, | ||
const QByteArray & | options = nullptr , |
||
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().
command | The command to execute. |
user | The user to run the command as. |
options | Extra options. |
env | Extra environment variables. |
int KDESu::KDEsuClient::exitCode | ( | ) |
Wait for the last command to exit and return the exit code.
bool KDESu::KDEsuClient::findGroup | ( | const QByteArray & | group | ) |
Returns true if the specified group exists is cached.
group | the group key |
QList< QByteArray > KDESu::KDEsuClient::getKeys | ( | const QByteArray & | group | ) |
Gets all the keys that are membes of the given group.
group | the group name of the variables. |
QByteArray KDESu::KDEsuClient::getVar | ( | const QByteArray & | key | ) |
Get a persistent variable.
key | The name of the variable. |
bool KDESu::KDEsuClient::isServerSGID | ( | ) |
Returns true if the server is safe (installed setgid), false otherwise.
int KDESu::KDEsuClient::ping | ( | ) |
Ping kdesud.
This can be used for diagnostics.
int KDESu::KDEsuClient::setHost | ( | const QByteArray & | host | ) |
Set the target host (optional).
int KDESu::KDEsuClient::setPass | ( | const char * | pass, |
int | timeout | ||
) |
Set root's password, lasts one session.
pass | Root's password. |
timeout | The time that a password will live. |
int KDESu::KDEsuClient::setPriority | ( | int | priority | ) |
Set the desired priority (optional), see StubProcess.
int KDESu::KDEsuClient::setScheduler | ( | int | scheduler | ) |
Set the desired scheduler (optional), see StubProcess.
int KDESu::KDEsuClient::setVar | ( | const QByteArray & | key, |
const QByteArray & | value, | ||
int | timeout = 0 , |
||
const QByteArray & | group = nullptr |
||
) |
Set a persistent variable.
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. |
int KDESu::KDEsuClient::startServer | ( | ) |
Try to start up kdesud.
int KDESu::KDEsuClient::stopServer | ( | ) |
Stop the daemon.