KDESu 5.99.0
client.h
1/*
2 This file is part of the KDE project, module kdesu.
3 SPDX-FileCopyrightText: 1999, 2000 Geert Jansen <jansen@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-only
6
7 client.h: client to access kdesud.
8*/
9
10#ifndef KDESUCLIENT_H
11#define KDESUCLIENT_H
12
13#include <kdesu/kdesu_export.h>
14
15#include <QByteArray>
16#include <QList>
17#include <memory>
18
19#ifdef Q_OS_UNIX
20
21namespace KDESu
22{
41class KDESU_EXPORT KDEsuClient
42{
43public:
46
47 KDEsuClient(const KDEsuClient &) = delete;
48 KDEsuClient &operator=(const KDEsuClient &) = delete;
49
60 int exec(const QByteArray &command, const QByteArray &user, const QByteArray &options = nullptr, const QList<QByteArray> &env = QList<QByteArray>());
61
66 int exitCode();
67
75 int setPass(const char *pass, int timeout);
76
80 int setHost(const QByteArray &host);
81
85 int setPriority(int priority);
86
90 int setScheduler(int scheduler);
91
98 int delCommand(const QByteArray &command, const QByteArray &user);
99
109 int setVar(const QByteArray &key, const QByteArray &value, int timeout = 0, const QByteArray &group = nullptr);
110
116 QByteArray getVar(const QByteArray &key);
117
123 QList<QByteArray> getKeys(const QByteArray &group);
124
132 bool findGroup(const QByteArray &group);
133
139 int delVar(const QByteArray &key);
140
156 int delVars(const QByteArray &special_key);
157
164 int delGroup(const QByteArray &group);
165
170 int ping();
171
176
181
186
187private:
188 int connect();
189
190 int command(const QByteArray &cmd, QByteArray *result = nullptr);
191 QByteArray escape(const QByteArray &str);
192
193private:
194 std::unique_ptr<class KDEsuClientPrivate> const d;
195};
196
197} // END namespace KDESu
198
199#endif // Q_OS_UNIX
200
201#endif // KDESUCLIENT_H
A client class to access kdesud, the KDE su daemon.
Definition: client.h:42
int setScheduler(int scheduler)
Set the desired scheduler (optional), see StubProcess.
int delVars(const QByteArray &special_key)
Delete all persistent variables with the given key.
int delCommand(const QByteArray &command, const QByteArray &user)
Remove a password for a user/command.
int ping()
Ping kdesud.
QList< QByteArray > getKeys(const QByteArray &group)
Gets all the keys that are membes of the given group.
int setHost(const QByteArray &host)
Set the target host (optional).
int setPass(const char *pass, int timeout)
Set root's password, lasts one session.
int delGroup(const QByteArray &group)
Delete all persistent variables in a group.
QByteArray getVar(const QByteArray &key)
Get a persistent variable.
int exec(const QByteArray &command, const QByteArray &user, const QByteArray &options=nullptr, const QList< QByteArray > &env=QList< QByteArray >())
Lets kdesud execute a command.
int setPriority(int priority)
Set the desired priority (optional), see StubProcess.
int stopServer()
Stop the daemon.
bool isServerSGID()
Returns true if the server is safe (installed setgid), false otherwise.
int exitCode()
Wait for the last command to exit and return the exit code.
bool findGroup(const QByteArray &group)
Returns true if the specified group exists is cached.
int startServer()
Try to start up kdesud.
int setVar(const QByteArray &key, const QByteArray &value, int timeout=0, const QByteArray &group=nullptr)
Set a persistent variable.
int delVar(const QByteArray &key)
Delete a persistent variable.