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"; |