Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-service-group@.service.system
RENAME deepin-service-group@.service
)

# Install drop-in configuration for deepin-daemon group
configure_file(deepin-service-group@deepin-daemon.service.d/override.conf.in
deepin-service-group@deepin-daemon.service.d/override.conf @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-service-group@deepin-daemon.service.d/override.conf
DESTINATION lib/systemd/system/deepin-service-group@deepin-daemon.service.d/
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-service-plugin@.service.system
DESTINATION lib/systemd/system/
RENAME deepin-service-plugin@.service
Expand Down
5 changes: 5 additions & 0 deletions misc/deepin-service-group@.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ ExecStart=/usr/bin/deepin-service-manager -g %i
Restart=on-failure
RestartSec=3
@SYSTEMD_SLICE@
# 如果 group 是 deepin-daemon,使用 deepin-daemon 用户启动
# 可以通过 systemd drop-in 配置覆盖: /etc/systemd/system/deepin-service-group@deepin-daemon.service.d/override.conf
# 内容: [Service]
# User=deepin-daemon
# Group=deepin-daemon

@SYSTEMD_INSTALL@
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Override configuration for deepin-daemon group
# This file specifies that the deepin-daemon group should run as deepin-daemon user
[Service]
User=deepin-daemon
Group=deepin-daemon
15 changes: 12 additions & 3 deletions src/deepin-service-manager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@
#include <QDebug>
#include <QLoggingCategory>
#include <QProcess>
#include <DLog>

Check warning on line 15 in src/deepin-service-manager/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DLog> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <unistd.h>

Check warning on line 17 in src/deepin-service-manager/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <pwd.h>

Check warning on line 18 in src/deepin-service-manager/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
Q_LOGGING_CATEGORY(dsm_Main, "[Main]")

int main(int argc, char *argv[])
{
// 声明一个指向 QCoreApplication 或 QGuiApplication 的指针
QCoreApplication *a;
uid_t euid = geteuid();
if (euid != 0) {
a = new QGuiApplication(argc, argv);
} else {
bool useCoreApp = (euid == 0);

// 检查是否是deepin-daemon 用户
if (!useCoreApp) {
struct passwd *pw = getpwuid(euid);
useCoreApp = (pw && QString::fromUtf8(pw->pw_name) == "deepin-daemon");
}

if (useCoreApp) {
a = new QCoreApplication(argc, argv);
} else {
a = new QGuiApplication(argc, argv);
}
a->setApplicationName("org.deepin.service.manager");

Expand Down
2 changes: 1 addition & 1 deletion src/deepin-service-manager/servicemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

Q_LOGGING_CATEGORY(dsm_ServiceManager, "[ServiceManager]")

static const QStringList GroupSiral{ "core", "dde", "app" };
static const QStringList GroupSiral{ "core", "dde", "app", "deepin-daemon" };

ServiceManager::ServiceManager(QObject *parent)
: QObject(parent)
Expand Down