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
This commit is contained in:
Koichiro IWAO 2014-03-12 08:13:51 +00:00
parent 92f10c5e9c
commit 481653e5f3

View File

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