diff --git a/common/os_calls.c b/common/os_calls.c index 524d8190..592d7d6d 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2233,6 +2233,18 @@ g_file_exist(const char *filename) #endif } +/*****************************************************************************/ +/* returns boolean, non zero if the file is readable */ +int +g_file_readable(const char *filename) +{ +#if defined(_WIN32) + return 0; /* TODO: what should be done here? */ +#else + return access(filename, R_OK) == 0; +#endif +} + /*****************************************************************************/ /* returns boolean, non zero if the directory exists */ int diff --git a/common/os_calls.h b/common/os_calls.h index 4e93558d..90db706d 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -109,6 +109,7 @@ int g_mkdir(const char* dirname); char* g_get_current_dir(char* dirname, int maxlen); int g_set_current_dir(const char *dirname); int g_file_exist(const char* filename); +int g_file_readable(const char *filename); int g_directory_exist(const char* dirname); int g_create_dir(const char* dirname); int g_create_path(const char* path); diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 0409f96c..75b8768c 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -269,6 +269,12 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info) /* use user defined certificate */ g_strncpy(client_info->certificate, value, 1023); } + + if (!g_file_readable(client_info->certificate)) + { + log_message(LOG_LEVEL_ERROR, "Cannot open certificate file %s: %s", + client_info->certificate, g_get_strerror()); + } } else if (g_strcasecmp(item, "key_file") == 0) { @@ -293,6 +299,12 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info) /* use user defined key_file */ g_strncpy(client_info->key_file, value, 1023); } + + if (!g_file_readable(client_info->key_file)) + { + log_message(LOG_LEVEL_ERROR, "Cannot open private key file %s: %s", + client_info->key_file, g_get_strerror()); + } } }