From 0a54d3abbb896d652bac7a495ed98b0617306a6c Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Mon, 6 Feb 2023 10:49:05 +0100 Subject: [PATCH] Add config files for systemd-tmpfiles and systemd-sysusers Let systemd handle user creation, let it create the runtime dir and clean up files in /tmp. --- CMakeLists.txt | 11 +++++++++-- services/CMakeLists.txt | 12 ++++++++++-- services/sddm-sysuser.conf.in | 2 ++ services/sddm-tmpfiles.conf.in | 8 ++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 services/sddm-sysuser.conf.in create mode 100644 services/sddm-tmpfiles.conf.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f9412505..8974a848 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,8 +139,15 @@ if(SYSTEMD_FOUND) endif() if (NOT DEFINED SYSTEMD_SYSTEM_UNIT_DIR) - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemdsystemunitdir systemd OUTPUT_VARIABLE SYSTEMD_SYSTEM_UNIT_DIR) - string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SYSTEM_UNIT_DIR ${SYSTEMD_SYSTEM_UNIT_DIR}) + pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir) + endif() + + if (NOT DEFINED SYSTEMD_SYSUSERS_DIR) + pkg_get_variable(SYSTEMD_SYSUSERS_DIR systemd sysusersdir) + endif() + + if (NOT DEFINED SYSTEMD_TMPFILES_DIR) + pkg_get_variable(SYSTEMD_TMPFILES_DIR systemd tmpfilesdir) endif() set(HALT_COMMAND "/usr/bin/systemctl poweroff") diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt index 5032f335..6faae598 100644 --- a/services/CMakeLists.txt +++ b/services/CMakeLists.txt @@ -1,7 +1,15 @@ - if(SYSTEMD_FOUND) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sddm.service.in" "${CMAKE_CURRENT_BINARY_DIR}/sddm.service") + configure_file(sddm.service.in sddm.service) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sddm.service" DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}") + + configure_file(sddm-sysuser.conf.in sddm-sysuser.conf) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sddm-sysuser.conf" DESTINATION "${SYSTEMD_SYSUSERS_DIR}" RENAME sddm.conf) +endif() + +# systemd-tmpfiles can be used standalone without other systemd parts +if(DEFINED SYSTEMD_TMPFILES_DIR) + configure_file(sddm-tmpfiles.conf.in sddm-tmpfiles.conf) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sddm-tmpfiles.conf" DESTINATION "${SYSTEMD_TMPFILES_DIR}" RENAME sddm.conf) endif() if(USE_ELOGIND) diff --git a/services/sddm-sysuser.conf.in b/services/sddm-sysuser.conf.in new file mode 100644 index 00000000..d35500a4 --- /dev/null +++ b/services/sddm-sysuser.conf.in @@ -0,0 +1,2 @@ +#Type Name ID GECOS Home directory Shell +u sddm - "SDDM Greeter Account" ${STATE_DIR} - diff --git a/services/sddm-tmpfiles.conf.in b/services/sddm-tmpfiles.conf.in new file mode 100644 index 00000000..fb45553b --- /dev/null +++ b/services/sddm-tmpfiles.conf.in @@ -0,0 +1,8 @@ +# Home dir of the sddm user, also contains state.conf +d ${STATE_DIR} 0750 sddm sddm +# This contains X11 auth files passed to Xorg and the greeter +d ${RUNTIME_DIR} 0711 root root +# Sockets for IPC +r! /tmp/sddm-auth* +# xauth files passed to user sessions +r! /tmp/xauth_*