From 6875dbe8607a6a7354988b97ba60e987a7708705 Mon Sep 17 00:00:00 2001 From: BLINDAUER Emmanuel Date: Tue, 13 Dec 2016 18:53:07 +0100 Subject: [PATCH] use functions from os_call.h --- sesman/env.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sesman/env.c b/sesman/env.c index c29db8f9..5bc4e17d 100644 --- a/sesman/env.c +++ b/sesman/env.c @@ -207,24 +207,27 @@ env_set_user(const char *username, char **passwd_file, int display, int DEFAULT_CC env_add_xauth_user(int display, char *cookie, char *file) { - FILE *dp, *fd; + FILE *dp; char xauth_str[256]; + int fd; if ( file == NULL ) { - fd=fopen(".Xauthority", "a"); - if (fd == NULL) - freopen(".Xauthority", "a", fd); - fclose(fd); + if (!g_file_exist(".Xauthority")) + { + fd = g_file_open(".Xauthority"); + g_file_close(fd); + } g_sprintf(xauth_str, "xauth -q add :%d . %s", display, cookie); } else { - fd=fopen(file, "a"); - if (fd == NULL) - freopen(file, "a", fd); - fclose(fd); + if (!g_file_exist(file)) + { + fd = g_file_open(file); + g_file_close(fd); + } g_sprintf(xauth_str, "xauth -q -f %s add :%d . %s", file, display, cookie); }