清空CGroup分组白名单;修改CGroup分组路径,解决无法弹出授权窗口的问题

This commit is contained in:
guopengfei 2023-01-31 09:35:54 +08:00
parent c3dec8ea7c
commit e67c5011d9
6 changed files with 39 additions and 8 deletions

View File

@ -2,6 +2,11 @@
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/com/kylin/ProcessManager">
<interface name="com.kylin.ProcessManager">
<method name="InitCGroup">
<arg name="rootPath" type="s" direction="in"/>
<arg name="result" type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QMap&lt;QString,QVariant>"/>
</method>
<method name="CreateProcessCGroup">
<arg name="appId" type="s" direction="in"/>
<arg name="pids" type="ai" direction="in"/>

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
kylin-app-manager (3.22.1.0-ok1.16) yangtze; urgency=medium
* 清空CGroup分组白名单;修改CGroup分组路径,解决无法弹出授权窗口的问题
-- guopengfei <guopengfei@kylinos.cn> Tue, 31 Jan 2023 09:04:29 +0800
kylin-app-manager (3.22.1.0-ok1.15) yangtze; urgency=medium
* 添加CGroup分组白名单

2
debian/install vendored
View File

@ -1,2 +1,2 @@
conf/com.kylin.AppManager.service /usr/share/dbus-1/services
conf/kylin-app-manager.json /etc/kylin-app-manager/
conf/kylin-app-manager.json /etc/kylin-app-manager

View File

@ -8,7 +8,7 @@ AppCGroup::AppCGroup(QObject *parent)
, m_processManagerInterface(new com::kylin::ProcessManager("com.kylin.ProcessManager",
"/com/kylin/ProcessManager", QDBusConnection::systemBus()))
{
initCGroup();
}
QString AppCGroup::createProcessCGroup(const QString &appId, const QList<int> &pids)
@ -62,7 +62,7 @@ QString AppCGroup::cgroupNameWithPid(int pid)
auto reply = m_processManagerInterface->CGroupNameWithPid(pid);
while (!reply.isFinished()) {
qApp->processEvents();
sleep(1);
usleep(1);
}
if (reply.isError()) {
qWarning() << __FUNCTION__ << "error, " << reply.error();
@ -70,3 +70,27 @@ QString AppCGroup::cgroupNameWithPid(int pid)
}
return reply.value().value(kDbusResult).toString();
}
void AppCGroup::initCGroup()
{
QProcess p;
p.start("id", QStringList() << "-u");
p.waitForFinished();
auto userId = p.readAll().toUInt();
auto rootPath = QString("user.slice/user-%1.slice/kylin-app-manager").arg(userId);
auto reply = m_processManagerInterface->InitCGroup(rootPath);
while (!reply.isFinished()) {
qApp->processEvents();
usleep(1);
}
if (reply.isError()) {
qWarning() << __FUNCTION__ << "error, " << reply.error();
return;
}
if (!reply.value().value(kDbusResult).toBool()) {
qWarning() << "Init CGroup failed, "
<< reply.value().value(kDbusErrMsg).toString()
<< "the root path is " << rootPath;
}
qDebug() << reply.value().value(kDbusResult) << rootPath;
}

View File

@ -21,6 +21,7 @@ public:
QString cgroupNameWithPid(int pid);
private:
void initCGroup();
private:
com::kylin::ProcessManager *m_processManagerInterface;

View File

@ -272,11 +272,6 @@ private:
"qaxbrowser-safe.desktop"
};
const QStringList kNoCgroupApps = {
"ukui-control-center.desktop",
"kylin-installer.desktop",
"biometric-manager.desktop",
"kylin-software-center.desktop",
"gparted.desktop"
};
};