KDESu 5.99.0
|
Executes a command under elevated privileges, using su. More...
#include <KDESu/SuProcess>
Public Types | |
enum | checkMode { NoCheck = 0 , Install = 1 , NeedPassword = 2 } |
Executes the command. More... | |
enum | Errors { SuNotFound = 1 , SuNotAllowed , SuIncorrectPassword } |
![]() | |
enum | Scheduler { SchedNormal , SchedRealtime } |
Different schedulers. More... | |
![]() | |
enum | checkPidStatus { Error = -1 , NotExited = -2 , Killed = -3 } |
Error return values for checkPidExited() More... | |
Public Member Functions | |
SuProcess (const QByteArray &user=nullptr, const QByteArray &command=nullptr) | |
int | checkInstall (const char *password) |
Checks if the stub is installed and the password is correct. More... | |
int | checkNeedPassword () |
Checks if a password is needed. More... | |
int | exec (const char *password, int check=NoCheck) |
QString | superUserCommand () |
Checks what the default super user command is, e.g. More... | |
bool | useUsersOwnPassword () |
Checks whether or not the user's password is being asked for or another user's password. More... | |
![]() | |
void | setCommand (const QByteArray &command) |
Set the command. More... | |
void | setPriority (int prio) |
Set the priority of the process. More... | |
void | setScheduler (int sched) |
Set the scheduler type. More... | |
void | setUser (const QByteArray &user) |
Set the target user. More... | |
void | setXOnly (bool xonly) |
Set to "X only mode": Sycoca is not built and kdeinit is not launched. More... | |
![]() | |
int | enableLocalEcho (bool enable=true) |
Enables/disables local echo on the pseudo tty. More... | |
int | exec (const QByteArray &command, const QList< QByteArray > &args) |
Forks off and execute a command. More... | |
int | fd () const |
Returns the filedescriptor of the process. More... | |
int | pid () const |
Returns the pid of the process. More... | |
QByteArray | readAll (bool block=true) |
Read all available output from the program's standard out. More... | |
QByteArray | readLine (bool block=true) |
Reads a line from the program's standard out. More... | |
void | setEnvironment (const QList< QByteArray > &env) |
Set additinal environment variables. More... | |
void | setErase (bool erase) |
Overwrites the password as soon as it is used. More... | |
void | setExitString (const QByteArray &exit) |
Sets the exit string. More... | |
void | setTerminal (bool terminal) |
Enables/disables terminal output. More... | |
void | unreadLine (const QByteArray &line, bool addNewline=true) |
Puts back a line of input. More... | |
int | waitForChild () |
Waits for the child to exit. More... | |
int | waitSlave () |
Waits until the pty has cleared the ECHO flag. More... | |
int | WaitSlave () |
void | writeLine (const QByteArray &line, bool addNewline=true) |
Writes a line of text to the program's standard in. More... | |
Protected Member Functions | |
void | virtual_hook (int id, void *data) override |
Standard hack to add virtual methods in a BC way. More... | |
![]() | |
StubProcess (StubProcessPrivate &dd) | |
int | converseStub (int check) |
Exchange all parameters with kdesu_stub. More... | |
virtual QByteArray | display () |
This virtual function can be overloaded when special behavior is desired. More... | |
virtual QByteArray | displayAuth () |
See display. More... | |
void | virtual_hook (int id, void *data) override |
Standard hack to add virtual methods in a BC way. More... | |
![]() | |
PtyProcess (PtyProcessPrivate &dd) | |
QList< QByteArray > | environment () const |
virtual void | virtual_hook (int id, void *data) |
Standard hack to add virtual methods in a BC way. More... | |
Additional Inherited Members | |
![]() | |
static bool | checkPid (pid_t pid) |
Basic check for the existence of pid . More... | |
static int | checkPidExited (pid_t pid) |
Check process exit status for process pid . More... | |
static int | waitMS (int fd, int ms) |
Wait ms milliseconds (ie. More... | |
![]() | |
QByteArray | m_command |
KDESuPrivate::KCookie * | m_cookie |
int | m_priority |
int | m_scheduler |
QByteArray | m_user |
bool | m_XOnly |
![]() | |
QByteArray | m_command |
Unused. More... | |
bool | m_erase |
QByteArray | m_exitString |
String to scan for in output that indicates child has exited. More... | |
int | m_pid |
PID of child process. More... | |
bool | m_terminal |
Indicates running in a terminal, causes additional newlines to be printed after output. More... | |
Executes a command under elevated privileges, using su.
Executes the command.
This will wait for the command to finish.
int KDESu::SuProcess::checkInstall | ( | const char * | password | ) |
Checks if the stub is installed and the password is correct.
int KDESu::SuProcess::checkNeedPassword | ( | ) |
Checks if a password is needed.
QString KDESu::SuProcess::superUserCommand | ( | ) |
Checks what the default super user command is, e.g.
sudo, su, etc
bool KDESu::SuProcess::useUsersOwnPassword | ( | ) |
Checks whether or not the user's password is being asked for or another user's password.
Due to usage of systems such as sudo, even when attempting to switch to another user one may need to enter their own password.
|
overrideprotectedvirtual |