/
platform_lin_suprogram.h
73 lines (60 loc) · 1.7 KB
/
platform_lin_suprogram.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SUPROGRAM_H
#define SUPROGRAM_H
#include <QString>
#include <QStringList>
// Auxiliary set of classes for handling different kinds of su-applications
// Base class
class SuProgram
{
protected:
// Name of the su-application
const QString m_binaryName;
// Full path to the executable (if present)
QString m_binaryPath;
// Additional arguments
const QStringList m_suArgs;
// Whether it accepts target command line as separate arguments or single argument
const bool m_splitArgs;
// Constructor
SuProgram(QString binaryName, QStringList suArgs, bool splitArgs);
public:
// Destructor
virtual ~SuProgram() {}
// Check if the program is present in the system; by default searching in PATH is used
virtual bool isPresent() const;
// Check whether the su-application is native to the current desktop environment
virtual bool isNative() const = 0;
// Restarts the current application with the specified arguments using the GUI su program
// Returns only if error occurred (execv() is used)
virtual void restartAsRoot(const QStringList& args);
};
// Derivative classes for specific su-applications
class XdgSu : public SuProgram
{
public:
XdgSu();
virtual ~XdgSu() {}
virtual bool isNative() const;
};
class KdeSu : public SuProgram
{
public:
KdeSu();
virtual ~KdeSu() {}
virtual bool isNative() const;
};
class GkSu : public SuProgram
{
public:
GkSu();
virtual ~GkSu() {}
virtual bool isNative() const;
};
class BeeSu : public SuProgram
{
public:
BeeSu();
virtual ~BeeSu() {}
virtual bool isNative() const;
};
#endif // SUPROGRAM_H