summaryrefslogtreecommitdiffstats
path: root/sesman
diff options
context:
space:
mode:
authorBLINDAUER Emmanuel <e.blindauer@gmail.com>2016-12-15 22:45:12 +0100
committerBLINDAUER Emmanuel <e.blindauer@gmail.com>2016-12-15 22:45:12 +0100
commit2927eed74c882322dc34b91e656c13de424a1418 (patch)
tree3f35055162b6355bdbd938170c21620e7f7713f7 /sesman
parent480d6d37b7301f00c09eba9c9e3e9ca6db0fe512 (diff)
downloadxrdp-proprietary-2927eed74c882322dc34b91e656c13de424a1418.tar.gz
xrdp-proprietary-2927eed74c882322dc34b91e656c13de424a1418.zip
- 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.
Diffstat (limited to 'sesman')
-rw-r--r--sesman/session.c7
-rw-r--r--sesman/xauth.c24
2 files changed, 13 insertions, 18 deletions
diff --git a/sesman/session.c b/sesman/session.c
index 0540bc11..4e51867f 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -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)
{
diff --git a/sesman/xauth.c b/sesman/xauth.c
index b4375b4f..c019b782 100644
--- a/sesman/xauth.c
+++ b/sesman/xauth.c
@@ -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)