10#include "stubprocess.h"
12#include "stubprocess_p.h"
14#include <config-kdesu.h>
19extern int kdesuDebugArea();
23using namespace KDESuPrivate;
25StubProcess::StubProcess()
26 : StubProcess(*new StubProcessPrivate)
30StubProcess::StubProcess(StubProcessPrivate &dd)
34 m_scheduler = SchedNormal;
36 m_cookie =
new KCookie;
40StubProcess::~StubProcess()
55void StubProcess::setXOnly(
bool xonly)
60void StubProcess::setPriority(
int prio)
64 }
else if (prio < 0) {
71void StubProcess::setScheduler(
int sched)
76void StubProcess::writeString(
const QByteArray &str)
80 for (
const uchar c : str) {
84 }
else if (c ==
'\\') {
104 typedef qint16 PID_t;
108 typedef qint32 PID_t;
117int StubProcess::converseStub(
int check)
128 if (line ==
"kdesu_stub") {
130 enableLocalEcho(
false);
146 if (line ==
"display") {
147 writeLine(display());
148 }
else if (line ==
"display_auth") {
150 writeLine(displayAuth());
154 }
else if (line ==
"command") {
155 writeString(m_command);
156 }
else if (line ==
"path") {
158 if (!path.
isEmpty() && path[0] ==
':') {
161 if (m_user ==
"root") {
163 path =
"/sbin:/bin:/usr/sbin:/usr/bin:" + path;
165 path =
"/sbin:/bin:/usr/sbin:/usr/bin";
169 }
else if (line ==
"user") {
171 }
else if (line ==
"priority") {
174 }
else if (line ==
"scheduler") {
175 if (m_scheduler == SchedRealtime) {
176 writeLine(
"realtime");
180 }
else if (line ==
"xwindows_only") {
186 }
else if (line ==
"app_startup_id") {
189 static const char startup_env[] =
"DESKTOP_STARTUP_ID=";
190 static const std::size_t size =
sizeof(startup_env);
191 for (
const auto &var : env) {
192 if (var.startsWith(startup_env)) {
193 tmp = var.
mid(size - 1);
200 }
else if (line ==
"app_start_pid") {
204 tmp.
setNum((PIDType<
sizeof(pid_t)>::PID_t)(getpid()));
206 }
else if (line ==
"environment") {
208 for (
const auto &var : env) {
212 }
else if (line ==
"end") {
215 qCWarning(KSU_LOG) <<
"[" << __FILE__ <<
":" << __LINE__ <<
"] "
216 <<
"Unknown request:" << line;
226 return m_cookie->display();
232 return m_cookie->displayAuth();
238void StubProcess::virtual_hook(
int id,
void *data)
240 PtyProcess::virtual_hook(
id, data);
QByteArray & append(QByteArrayView data)
bool isEmpty() const const
bool isNull() const const
QByteArray mid(qsizetype pos, qsizetype len) const const
void reserve(qsizetype size)
QByteArray & setNum(double n, char format, int precision)
qsizetype size() const const
bool isEmpty() const const
QString mid(qsizetype position, qsizetype n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:38 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.