Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd unit to setup application scope and add hardening. #27325

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,7 @@ if (LINUX AND DESKTOP_APP_USE_PACKAGED)
include(GNUInstallDirs)
configure_file("../lib/xdg/org.telegram.desktop.service" "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.service" @ONLY)
configure_file("../lib/xdg/org.telegram.desktop.metainfo.xml" "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.metainfo.xml" @ONLY)
configure_file("../lib/xdg/telegram-desktop.service" "${CMAKE_CURRENT_BINARY_DIR}/telegram-desktop.service" @ONLY)
generate_appdata_changelog(Telegram "${CMAKE_SOURCE_DIR}/changelog.txt" "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.metainfo.xml")
install(TARGETS Telegram RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "Resources/art/icon16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "telegram.png")
Expand All @@ -1888,4 +1889,11 @@ if (LINUX AND DESKTOP_APP_USE_PACKAGED)
install(FILES "../lib/xdg/org.telegram.desktop.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.service" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.metainfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")

find_package(PkgConfig REQUIRED)
pkg_get_variable(SYSTEMD_USER_UNIT_DIR systemd systemduserunitdir)
if (NOT ${SYSTEMD_USER_UNIT_DIR} STREQUAL "")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/telegram-desktop.service" DESTINATION "${SYSTEMD_USER_UNIT_DIR}")
endif()

endif()
1 change: 1 addition & 0 deletions lib/xdg/org.telegram.desktop.service
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[D-BUS Service]
Name=org.telegram.desktop
Exec=@CMAKE_INSTALL_FULL_BINDIR@/telegram-desktop
SystemdService=telegram-desktop.service
13 changes: 13 additions & 0 deletions lib/xdg/telegram-desktop.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Official desktop version of Telegram messaging app

[Service]
Type=dbus
BusName=org.telegram.desktop
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/telegram-desktop
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
SystemCallArchitectures=native
Slice=app.slice