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) {