summaryrefslogtreecommitdiffstats
path: root/sesman/session.c
diff options
context:
space:
mode:
authorKoichiro IWAO <meta@vmeta.jp>2014-03-12 08:13:51 +0000
committerKoichiro IWAO <meta@vmeta.jp>2015-06-16 05:44:07 +0000
commit481653e5f31cf96332e50b8404ab67d123d2498e (patch)
tree4f5414b50137fa36cc114acac6713361b36f4ab5 /sesman/session.c
parent92f10c5e9cb1c4aabe28345e19b8a3bea172b018 (diff)
downloadxrdp-proprietary-481653e5f31cf96332e50b8404ab67d123d2498e.tar.gz
xrdp-proprietary-481653e5f31cf96332e50b8404ab67d123d2498e.zip
sesman: merge FreeBSD local patch for session.c
net/xrdp: effective login name is not set by xrdp-sesman https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=157282
Diffstat (limited to 'sesman/session.c')
-rw-r--r--sesman/session.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/sesman/session.c b/sesman/session.c
index 4ea48d35..b16d217e 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -525,6 +525,42 @@ session_start_fork(int width, int height, int bpp, char *username,
g_sprintf(geometry, "%dx%d", width, height);
g_sprintf(depth, "%d", bpp);
g_sprintf(screen, ":%d", display);
+#ifdef __FreeBSD__
+ /*
+ * FreeBSD bug
+ * ports/157282: effective login name is not set by xrdp-sesman
+ * http://www.freebsd.org/cgi/query-pr.cgi?pr=157282
+ *
+ * from:
+ * $OpenBSD: session.c,v 1.252 2010/03/07 11:57:13 dtucker Exp $
+ * with some ideas about BSD process grouping to xrdp
+ */
+ pid_t bsdsespid = g_fork();
+
+ if (bsdsespid == -1)
+ {
+ }
+ else if (bsdsespid == 0) /* BSD session leader */
+ {
+ /**
+ * Create a new session and process group since the 4.4BSD
+ * setlogin() affects the entire process group
+ */
+ if (setsid() < 0)
+ {
+ log_message(LOG_LEVEL_ERROR,
+ "setsid failed - pid %d", g_getpid());
+ }
+
+ if (setlogin(username) < 0)
+ {
+ log_message(LOG_LEVEL_ERROR,
+ "setlogin failed for user %s - pid %d", username, g_getpid());
+ }
+ }
+
+ g_waitpid(bsdsespid);
+#endif
wmpid = g_fork();
if (wmpid == -1)
{