diff --git a/CMakeLists.txt b/CMakeLists.txt index 4053e1c..7e67709 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ include(FeatureSummary) # Options option(BUILD_MAN_PAGES "Build man pages" OFF) -option(ENABLE_JOURNALD "Enable logging to journald" ON) +option(WERROR "Build with -Werror" OFF) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -32,6 +32,9 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH};${ECM_MODU # Definitions add_definitions(-Wall -Wextra) +if (WERROR) + add_definitions(-Werror) +endif() # Default build type if(NOT CMAKE_BUILD_TYPE) @@ -56,21 +59,28 @@ if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) endif() # PKG-CONFIG -find_package(PkgConfig) +find_package(PkgConfig REQUIRED) # PAM -find_package(PAM REQUIRED) +pkg_search_module(Pam REQUIRED IMPORTED_TARGET pam) # Systemd -pkg_check_modules(Systemd REQUIRED systemd) +pkg_search_module(Systemd REQUIRED IMPORTED_TARGET systemd) + +# libsystemd +pkg_search_module(LibSystemd REQUIRED IMPORTED_TARGET libsystemd) # XAU -pkg_check_modules(LIBXAU REQUIRED "xau") +pkg_search_module(LibXau REQUIRED IMPORTED_TARGET xau) + +# Wayland client +pkg_search_module(WaylandClient REQUIRED IMPORTED_TARGET wayland-client) # TreelandProtocols find_package(TreelandProtocols 0.5.3 REQUIRED) -find_package(Qt6 CONFIG REQUIRED Core DBus Gui Qml Quick QuickControls2 LinguistTools Test QuickTest) +# Qt6 +find_package(Qt6 CONFIG REQUIRED Core DBus Network) qt_standard_project_setup(REQUIRES 6.6) # Uninstall target @@ -81,21 +91,6 @@ if ("${ECM_VERSION}" VERSION_LESS "1.7.0") add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") endif() -add_definitions(-DHAVE_SYSTEMD) -set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_SYSTEMD) - -# libsystemd-journal was merged into libsystemd in 209 -pkg_check_modules(JOURNALD "libsystemd") - -if(ENABLE_JOURNALD) - if(JOURNALD_FOUND) - add_definitions(-DHAVE_JOURNALD) - set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_JOURNALD) - else() - message(WARNING "Disable journald support for lack of libsystemd-journal") - endif() -endif() - if (NOT DEFINED SYSTEMD_SYSTEM_UNIT_DIR) pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir) endif() @@ -111,8 +106,6 @@ endif() set(HALT_COMMAND "/usr/bin/systemctl poweroff") set(REBOOT_COMMAND "/usr/bin/systemctl reboot") -add_feature_info("journald" JOURNALD_FOUND "journald support") - set(RUNTIME_DIR_DEFAULT "/run/ddm") # Set constants @@ -120,7 +113,6 @@ set(DATA_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/ddm" set(DBUS_CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/dbus-1/system.d" CACHE PATH "DBus config files directory") set(STATE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/ddm" CACHE PATH "State directory") set(RUNTIME_DIR "${RUNTIME_DIR_DEFAULT}" CACHE PATH "Runtime data storage directory") -set(QML_INSTALL_DIR "${QT_IMPORTS_DIR}" CACHE PATH "QML component installation directory") set(SESSION_COMMAND "${DATA_INSTALL_DIR}/scripts/Xsession" CACHE PATH "Script to execute when starting the X11 desktop session") set(WAYLAND_SESSION_COMMAND "${DATA_INSTALL_DIR}/scripts/wayland-session" CACHE PATH "Script to execute when starting the Wayland desktop session") diff --git a/cmake/FindPAM.cmake b/cmake/FindPAM.cmake deleted file mode 100644 index a64680b..0000000 --- a/cmake/FindPAM.cmake +++ /dev/null @@ -1,75 +0,0 @@ -# - Try to find the PAM libraries -# Once done this will define -# -# PAM_FOUND - system has pam -# PAM_INCLUDE_DIR - the pam include directory -# PAM_LIBRARIES - libpam library - -if (PAM_INCLUDE_DIR AND PAM_LIBRARY) - # Already in cache, be silent - set(PAM_FIND_QUIETLY TRUE) -endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) - -find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h) -find_library(PAM_LIBRARY pam) -find_library(DL_LIBRARY dl) -find_library(HAVE_PAM_FAILLOCK NAME pam_faillock.so PATH_SUFFIXES security) - -if (PAM_INCLUDE_DIR AND PAM_LIBRARY) - set(PAM_FOUND TRUE) - if (DL_LIBRARY) - set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY}) - else (DL_LIBRARY) - set(PAM_LIBRARIES ${PAM_LIBRARY}) - endif (DL_LIBRARY) - - if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) - # darwin claims to be something special - set(HAVE_PAM_PAM_APPL_H 1) - endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) - - if (NOT DEFINED PAM_MESSAGE_CONST) - include(CheckCXXSourceCompiles) - # XXX does this work with plain c? - check_cxx_source_compiles(" -#if ${HAVE_PAM_PAM_APPL_H}+0 -# include -#else -# include -#endif - -static int PAM_conv( - int num_msg, - const struct pam_message **msg, /* this is the culprit */ - struct pam_response **resp, - void *ctx) -{ - return 0; -} - -int main(void) -{ - struct pam_conv PAM_conversation = { - &PAM_conv, /* this bombs out if the above does not match */ - 0 - }; - - return 0; -} -" PAM_MESSAGE_CONST) - endif (NOT DEFINED PAM_MESSAGE_CONST) - set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message") - -endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) - -if (PAM_FOUND) - if (NOT PAM_FIND_QUIETLY) - message(STATUS "Found PAM: ${PAM_LIBRARIES}") - endif (NOT PAM_FIND_QUIETLY) -else (PAM_FOUND) - if (PAM_FIND_REQUIRED) - message(FATAL_ERROR "PAM was not found") - endif(PAM_FIND_REQUIRED) -endif (PAM_FOUND) - -mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST) \ No newline at end of file diff --git a/debian/control b/debian/control index e5f73c8..1dd480e 100644 --- a/debian/control +++ b/debian/control @@ -3,20 +3,15 @@ Priority: optional Maintainer: justforlxz Build-Depends: debhelper-compat (= 13), cmake (>= 3.4~), - pkg-config, extra-cmake-modules (>= 1.4.0~), libpam0g-dev, libsystemd-dev [linux-any], + libwayland-dev, libxau-dev, + pkg-config, qt6-base-dev (>= 6.6.1~), - qt6-declarative-dev (>= 6.6.1~), - qt6-tools-dev, - qt6-tools-dev-tools (>= 6.6.1~), - qt6-wayland, - qt6-wayland-dev, - qt6-wayland-private-dev, - treeland-protocols, systemd [linux-any], + treeland-protocols, Standards-Version: 4.6.0 Section: libs Homepage: https://github.com/linuxdeepin/ddm.git @@ -29,22 +24,9 @@ Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends}, - qml6-module-qtquick, - qml6-module-qtquick-controls, - qml6-module-qtquick-layouts, - qml6-module-qtqml-workerscript, - qml6-module-qtquick-templates, - qml6-module-qtquick-particles, - qml6-module-qtquick-dialogs, - qml6-module-qtquick-window, - qml6-module-qt5compat-graphicaleffects, - qml6-module-qtquick-effects, - qml6-module-qt-labs-folderlistmodel, - adduser, seatd, - qt6-wayland, - libqt6svg6, -Recommends: libpam-systemd, xwayland + treeland, + libpam-systemd, Description: a modern display manager for Wayland sessions aiming to be fast, simple and beautiful. Package: libddm diff --git a/debian/ddm.postinst b/debian/ddm.postinst index 7cd4274..9e02dc4 100644 --- a/debian/ddm.postinst +++ b/debian/ddm.postinst @@ -7,38 +7,11 @@ set -e THIS_PACKAGE=ddm DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager -# creating dde group if he isn't already there -if ! getent group dde >/dev/null; then - addgroup --system dde -fi - -# creating dde user if he isn't already there -if ! getent passwd dde >/dev/null; then - adduser --system --ingroup dde --home /var/lib/ddm dde - usermod -c "Simple Wayland Display Manager" dde - usermod -d "/var/lib/ddm" dde - usermod -g "dde" dde - usermod -s "/bin/false" dde -fi - -# ensure dde is in dde video render groups -# required for upgrading from v23 -for group in dde video render; do - usermod -a -G $group dde -done +# creating dde user & group if he isn't already there +systemd-sysusers -if [ ! -e /var/lib/ddm ]; then - # If dde was purged while running, the home dir gets removed but the user - # remains (as deluser refuses to delete a user that's in use). - mkdir -p /var/lib/ddm -fi - -if [ -d /var/lib/ddm ]; then - # There has been a -R in version prior to 0.19 - # but this opens up symlink attacks. Remove it. - chown dde:dde /var/lib/ddm - chmod 0750 /var/lib/ddm -fi +# creating directories required +systemd-tmpfiles --create # debconf is not a registry, so we only fiddle with the default file if it # does not exist diff --git a/debian/rules b/debian/rules index 578de37..0e76946 100755 --- a/debian/rules +++ b/debian/rules @@ -16,10 +16,6 @@ include /usr/share/dpkg/architecture.mk DDM_CMAKE_ARGS = -DDBUS_CONFIG_FILENAME="ddm_org.freedesktop.DisplayManager.conf" -ifneq ($(DEB_HOST_ARCH_OS),linux) - DDM_CMAKE_ARGS += -DNO_SYSTEMD=ON -DENABLE_JOURNALD=OFF -endif - %: dh $@ diff --git a/flake.nix b/flake.nix index 2aa6dde..847f62b 100644 --- a/flake.nix +++ b/flake.nix @@ -39,14 +39,10 @@ shellHook = let makeQtpluginPath = pkgs.lib.makeSearchPathOutput "out" pkgs.qt6.qtbase.qtPluginPrefix; - makeQmlpluginPath = pkgs.lib.makeSearchPathOutput "out" pkgs.qt6.qtbase.qtQmlPrefix; in '' #export WAYLAND_DEBUG=1 - export QT_PLUGIN_PATH=${makeQtpluginPath (with pkgs.qt6; [ qtbase qtdeclarative qtquick3d qtimageformats qtwayland qt5compat qtsvg ])} - export QML2_IMPORT_PATH=${makeQmlpluginPath (with pkgs.qt6; [ qtdeclarative qtquick3d qt5compat ] - ++ [ dde-nixos.packages.${system}.qt6.dtkdeclarative ] )} - export QML_IMPORT_PATH=$QML2_IMPORT_PATH + export QT_PLUGIN_PATH=${makeQtpluginPath (with pkgs.qt6; [ qtbase ])} ''; }; } diff --git a/nix/default.nix b/nix/default.nix index 8892614..f82aec0 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -8,7 +8,6 @@ , qttools , wrapQtAppsHook , qtbase -, pixman , pam , libxcrypt , treeland-protocols @@ -51,7 +50,6 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ qtbase - pixman pam libxcrypt treeland-protocols @@ -72,9 +70,8 @@ stdenv.mkDerivation (finalAttrs: { # we still want to run the DM on VT 7 for the time being, as 1-6 are # occupied by getties by default - "-DSDDM_INITIAL_VT=7" + "-DDDM_INITIAL_VT=7" - "-DQT_IMPORTS_DIR=${placeholder "out"}/${qtbase.qtQmlPrefix}" "-DCMAKE_INSTALL_SYSCONFDIR=${placeholder "out"}/etc" "-DSYSTEMD_SYSTEM_UNIT_DIR=${placeholder "out"}/lib/systemd/system" "-DSYSTEMD_SYSUSERS_DIR=${placeholder "out"}/lib/sysusers.d" diff --git a/services/ddm.pam b/services/ddm.pam index df11003..e7a8e76 100644 --- a/services/ddm.pam +++ b/services/ddm.pam @@ -11,5 +11,6 @@ password include system-login session optional pam_keyinit.so force revoke session include system-login +session required pam_systemd.so -session optional pam_gnome_keyring.so auto_start -session optional pam_kwallet5.so auto_start diff --git a/services/debian.ddm.pam b/services/debian.ddm.pam index de7fd79..bbf4019 100644 --- a/services/debian.ddm.pam +++ b/services/debian.ddm.pam @@ -20,6 +20,7 @@ session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux session optional pam_keyinit.so force revoke session required pam_limits.so session required pam_loginuid.so +session required pam_systemd.so @include common-session # SELinux needs to intervene at login time to ensure that the process starts # in the proper default security context. Only sessions which are intended diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6fb938..bf56561 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,2 @@ -if (QT_KNOWN_POLICY_QTP0001) - qt_policy(SET QTP0001 NEW) -endif() - add_subdirectory(common) add_subdirectory(daemon) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 765b00a..2b91efc 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -33,10 +33,9 @@ set_target_properties(common PROPERTIES target_link_libraries(common PRIVATE - Qt${QT_MAJOR_VERSION}::DBus - Qt${QT_MAJOR_VERSION}::Network - Qt${QT_MAJOR_VERSION}::Qml - ${LIBXAU_LINK_LIBRARIES} + Qt6::DBus + Qt6::Network + PkgConfig::LibXau ) target_include_directories(common INTERFACE diff --git a/src/common/Constants.h.in b/src/common/Constants.h.in index 1139fbd..098daee 100644 --- a/src/common/Constants.h.in +++ b/src/common/Constants.h.in @@ -24,7 +24,6 @@ #define LIBEXEC_INSTALL_DIR "@CMAKE_INSTALL_FULL_LIBEXECDIR@" #define DATA_INSTALL_DIR "@DATA_INSTALL_DIR@" #define SYS_CONFIG_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@" -#define IMPORTS_INSTALL_DIR "@QML_INSTALL_DIR@" #define COMPONENTS_TRANSLATION_DIR "@COMPONENTS_TRANSLATION_DIR@" #define RUNTIME_DIR "@RUNTIME_DIR@" #define STATE_DIR "@STATE_DIR@" diff --git a/src/common/MessageHandler.h b/src/common/MessageHandler.h index 5e5244e..1b1c72a 100644 --- a/src/common/MessageHandler.h +++ b/src/common/MessageHandler.h @@ -31,12 +31,9 @@ #include #include -#ifdef HAVE_JOURNALD #include -#endif namespace DDM { -#ifdef HAVE_JOURNALD static void journaldLogger(QtMsgType type, const QMessageLogContext &context, const QString &msg) { int priority = LOG_INFO; switch (type) { @@ -67,7 +64,6 @@ namespace DDM { context.function ? context.function : "unknown", "%s", qPrintable(msg)); } -#endif static void standardLogger(QtMsgType type, const QString &msg) { static QFile file(QStringLiteral(LOG_FILE)); @@ -126,7 +122,6 @@ namespace DDM { } static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &prefix, const QString &msg) { -#ifdef HAVE_JOURNALD // don't log to journald if running interactively, this is likely // the case when running ddm in test mode static bool isInteractive = isatty(STDERR_FILENO) && qgetenv("USER") != "dde"; @@ -135,7 +130,6 @@ namespace DDM { journaldLogger(type, context, msg); return; } -#endif // prepend program name QString logMessage = prefix + msg; @@ -146,14 +140,6 @@ namespace DDM { void DaemonMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { messageHandler(type, context, QStringLiteral("DAEMON: "), msg); } - - void HelperMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { - messageHandler(type, context, QStringLiteral("HELPER: "), msg); - } - - void GreeterMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { - messageHandler(type, context, QStringLiteral("GREETER: "), msg); - } } #endif // DDM_MESSAGEHANDLER_H diff --git a/src/daemon/Auth.cpp b/src/daemon/Auth.cpp index bae0a16..9aa6654 100644 --- a/src/daemon/Auth.cpp +++ b/src/daemon/Auth.cpp @@ -280,7 +280,10 @@ namespace DDM { qCritical() << "[SessionLeader] Invalid XDG_SESSION_ID from pam_open_session()"; exit(1); } - write(pipefd[1], &xdgSessionId, sizeof(int)); + if (write(pipefd[1], &xdgSessionId, sizeof(int)) != sizeof(int)) { + qCritical() << "[SessionLeader] Failed to write XDG_SESSION_ID to parent process!"; + exit(1); + } // RUN!!! UserSession session(this); @@ -293,7 +296,10 @@ namespace DDM { // Send session PID to parent sessionPid = session.processId(); - write(pipefd[1], &sessionPid, sizeof(qint64)); + if (write(pipefd[1], &sessionPid, sizeof(qint64)) != sizeof(qint64)) { + qCritical() << "[SessionLeader] Failed to write session PID to parent process!"; + exit(1); + } qInfo() << "[SessionLeader] Session started with PID" << sessionPid; session.waitForFinished(-1); diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 4a7e7fd..5347f96 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -1,9 +1,3 @@ -include_directories( - ${LIBXAU_INCLUDE_DIRS} -) - -pkg_search_module(WAYLAND REQUIRED IMPORTED_TARGET wayland-client) - # Generate treeland-ddm protocol files set(TREELAND_DDM_HEADER ${CMAKE_CURRENT_BINARY_DIR}/treeland-ddm-v1.h) set(TREELAND_DDM_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/treeland-ddm-v1.c) @@ -69,18 +63,11 @@ target_link_libraries(ddm PRIVATE common PUBLIC - Qt${QT_MAJOR_VERSION}::DBus - Qt${QT_MAJOR_VERSION}::Network - Qt${QT_MAJOR_VERSION}::Qml - ${PAM_LIBRARIES} - PkgConfig::WAYLAND + Qt6::DBus + Qt6::Network + PkgConfig::Pam + PkgConfig::LibSystemd + PkgConfig::WaylandClient ) -if(JOURNALD_FOUND) - target_link_libraries(ddm - PUBLIC - ${JOURNALD_LIBRARIES} - ) -endif() - install(TARGETS ddm DESTINATION "${CMAKE_INSTALL_BINDIR}")