- Update copyright

- remove test on filename for xauth as we know what we send
- better names for variables in xauth
- if xauth fails, exit sesman
- g_bytes_to_hexstr returns a null-teminated string, don't set it twice.
This commit is contained in:
BLINDAUER Emmanuel 2016-12-15 22:45:12 +01:00
parent 480d6d37b7
commit 2927eed74c
2 changed files with 13 additions and 18 deletions

View File

@ -688,8 +688,11 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s)
g_snprintf(authfile, 255, "%s", ".Xauthority");
}
/* Add the entry in XAUTHORITY file */
add_xauth_cookie(display, authfile);
/* Add the entry in XAUTHORITY file or exit if error */
if (add_xauth_cookie(display, authfile) != 0)
{
g_exit(1);
}
if (type == SESMAN_SESSION_TYPE_XORG)
{

View File

@ -1,7 +1,8 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2013
* Copyright (C) Jay Sorg 2004-2017
* Copyright (C) Emmanuel Blindauer 2004-2017
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +21,6 @@
*
* @file xauth.c
* @brief XAUTHORITY handling code
* @author Emmaunel Blindauer
*
*/
@ -34,24 +34,16 @@ int DEFAULT_CC
add_xauth_cookie(int display, const char *file)
{
FILE *dp;
char cookie[33];
char char_cookie[16];
char cookie_str[33];
char cookie_bin[16];
char xauth_str[256];
int ret;
g_random(char_cookie, 16);
g_bytes_to_hexstr(char_cookie, 16, cookie, 33);
cookie[32] = '\0';
g_random(cookie_bin, 16);
g_bytes_to_hexstr(cookie_bin, 16, cookie_str, 33);
if (file == NULL)
{
g_sprintf(xauth_str, "xauth -q add :%d . %s", display, cookie);
}
else
{
g_sprintf(xauth_str, "xauth -q -f %s add :%d . %s",
file, display, cookie);
}
file, display, cookie_str);
dp = popen(xauth_str, "r");
if (dp == NULL)