KDESu

suprocess.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
8#ifndef KDESUSUPROCESS_H
9#define KDESUSUPROCESS_H
10
11#include <kdesu/kdesu_export.h>
12
13#include "stubprocess.h"
14
15namespace KDESu
16{
17class SuProcessPrivate;
18
19/** \class SuProcess suprocess.h KDESu/SuProcess
20 * Executes a command under elevated privileges, using su.
21 */
22
23class KDESU_EXPORT SuProcess : public StubProcess
24{
25public:
26 enum Errors {
27 SuNotFound = 1,
28 SuNotAllowed,
29 SuIncorrectPassword,
30 };
31
32 /**
33 * Executes the command. This will wait for the command to finish.
34 */
35 enum checkMode {
36 NoCheck = 0,
37 Install = 1,
38 NeedPassword = 2,
39 };
40
41 explicit SuProcess(const QByteArray &user = nullptr, const QByteArray &command = nullptr);
42 ~SuProcess() override;
43
44 int exec(const char *password, int check = NoCheck);
45
46 /**
47 * Checks if the stub is installed and the password is correct.
48 * @return Zero if everything is correct, nonzero otherwise.
49 */
50 int checkInstall(const char *password);
51
52 /**
53 * Checks if a password is needed.
54 */
55 int checkNeedPassword();
56
57 /**
58 * Checks what the default super user command is, e.g. sudo, su, etc
59 * @return the default super user command
60 */
61 QString superUserCommand();
62
63 /**
64 * Checks whether or not the user's password is being asked for or another
65 * user's password. Due to usage of systems such as sudo, even when attempting
66 * to switch to another user one may need to enter their own password.
67 */
68 bool useUsersOwnPassword();
69
70protected:
71 void virtual_hook(int id, void *data) override;
72
73private:
74 enum SuErrors {
75 error = -1,
76 ok = 0,
77 killme = 1,
78 notauthorized = 2,
79 };
80
81 KDESU_NO_EXPORT int converseSU(const char *password);
82
83private:
84 Q_DECLARE_PRIVATE(SuProcess)
85};
86
87}
88
89#endif // KDESUSUPROCESS_H
Chat with kdesu_stub.
Definition stubprocess.h:33
Executes a command under elevated privileges, using su.
Definition suprocess.h:24
checkMode
Executes the command.
Definition suprocess.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 11:55:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.