- 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.
master
BLINDAUER Emmanuel 8 years ago
parent 480d6d37b7
commit 2927eed74c

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

@ -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);
}
g_sprintf(xauth_str, "xauth -q -f %s add :%d . %s",
file, display, cookie_str);
dp = popen(xauth_str, "r");
if (dp == NULL)

Loading…
Cancel
Save