View | Details | Raw Unified | Return to bug 241519
Collapse All | Expand All

(-)./x11/sddm/files/patch-src_helper_Backend.cpp (+33 lines)
Line 0 Link Here
1
--- ./src/helper/Backend.cpp.ORIG	2017-12-05 17:00:16.000000000 +0100
2
+++ ./src/helper/Backend.cpp	2019-10-27 09:09:12.407454000 +0100
3
@@ -29,6 +29,10 @@
4
 #include <QtCore/QProcessEnvironment>
5
 
6
 #include <pwd.h>
7
+#if defined(Q_OS_FREEBSD)
8
+#include <sys/types.h>
9
+#include <login_cap.h>
10
+#endif /* defined(Q_OS_FREEBSD) */
11
 
12
 namespace SDDM {
13
     Backend::Backend(HelperApp* parent)
14
@@ -70,6 +74,19 @@
15
                         .arg(mainConfig.X11.UserAuthFile.get());
16
                 env.insert(QStringLiteral("XAUTHORITY"), value);
17
             }
18
+#if defined(Q_OS_FREEBSD)
19
+	    /* get additional environment variables via setclassenvironment();
20
+	       this needs to be done here instead of in UserSession::setupChildProcess
21
+	       as the environment for execve() is prepared here */
22
+	    login_cap_t *lc;
23
+
24
+	    if ((lc = login_getpwclass(pw)) != 0) {
25
+		setclassenvironment(lc, pw, 1);		/* path variables */
26
+		setclassenvironment(lc, pw, 0);		/* non-path variables */
27
+		/* copy all environment variables that are now set */
28
+		env.insert(QProcessEnvironment::systemEnvironment());
29
+	    }
30
+#endif /* defined(Q_OS_FREEBSD) */
31
             // TODO: I'm fairly sure this shouldn't be done for PAM sessions, investigate!
32
             m_app->session()->setProcessEnvironment(env);
33
         }
(-)./x11/sddm/files/patch-src_helper_CMakeLists.txt (+12 lines)
Line 0 Link Here
1
--- ./src/helper/CMakeLists.txt.ORIG	2017-12-05 17:00:16.000000000 +0100
2
+++ ./src/helper/CMakeLists.txt	2019-10-26 13:31:46.619098000 +0200
3
@@ -37,6 +37,9 @@
4
 else()
5
     target_link_libraries(sddm-helper crypt)
6
 endif()
7
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
8
+    target_link_libraries(sddm-helper util)
9
+endif()
10
 
11
 if(JOURNALD_FOUND)
12
     target_link_libraries(sddm-helper ${JOURNALD_LIBRARIES})
(-)./x11/sddm/files/patch-src_helper_UserSession2.cpp (+35 lines)
Line 0 Link Here
1
--- ./src/helper/UserSession.cpp.ORIG	2019-10-27 09:01:43.058761000 +0100
2
+++ ./src/helper/UserSession.cpp	2019-10-27 09:05:06.270407000 +0100
3
@@ -32,6 +32,9 @@
4
 #include <grp.h>
5
 #include <unistd.h>
6
 #include <fcntl.h>
7
+#if defined(Q_OS_FREEBSD)
8
+#include <login_cap.h>
9
+#endif /* defined(Q_OS_FREEBSD) */
10
 
11
 namespace SDDM {
12
     UserSession::UserSession(HelperApp *parent)
13
@@ -110,6 +113,14 @@
14
 
15
         const QByteArray username = qobject_cast<HelperApp*>(parent())->user().toLocal8Bit();
16
         struct passwd *pw = getpwnam(username.constData());
17
+#if defined(Q_OS_FREEBSD)
18
+	/* execve() uses the environment prepared in Backend::openSession(),
19
+	   therefore environment variables which are set here are ignored. */
20
+	if (setusercontext(NULL, pw, pw->pw_uid, LOGIN_SETALL) != 0) {
21
+            qCritical() << "setusercontext(NULL, *, " << pw->pw_uid << ", LOGIN_SETALL) failed for user: " << username;
22
+            exit(Auth::HELPER_OTHER_ERROR);
23
+        }
24
+#else /* defined(Q_OS_FREEBSD) */
25
         if (setgid(pw->pw_gid) != 0) {
26
             qCritical() << "setgid(" << pw->pw_gid << ") failed for user: " << username;
27
             exit(Auth::HELPER_OTHER_ERROR);
28
@@ -122,6 +133,7 @@
29
             qCritical() << "setuid(" << pw->pw_uid << ") failed for user: " << username;
30
             exit(Auth::HELPER_OTHER_ERROR);
31
         }
32
+#endif /* defined(Q_OS_FREEBSD) */
33
         if (chdir(pw->pw_dir) != 0) {
34
             qCritical() << "chdir(" << pw->pw_dir << ") failed for user: " << username;
35
             qCritical() << "verify directory exist and has sufficient permissions";
(-)./x11/sddm/pkg-message (-8 lines)
Lines 1-8 Link Here
1
[
2
{ type: install
3
  message: <<EOM
4
SDDM does not support login.conf(5), and no special restrictions
5
or settings from login.conf are enforced or applied.
6
EOM
7
}
8
]

Return to bug 241519