mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
[client,x11] add global config file support
This commit is contained in:
@@ -93,6 +93,7 @@ include(InstallFreeRDPMan)
|
||||
include(GetGitRevisionDescription)
|
||||
include(SetFreeRDPCMakeInstallDir)
|
||||
include(Doxygen)
|
||||
include(GetSysconfDir)
|
||||
|
||||
# Soname versioning
|
||||
set(BUILD_NUMBER 0)
|
||||
|
||||
@@ -4,5 +4,7 @@ set(DEPS
|
||||
../../common/man/sdl-freerdp-examples.1 ../../../common/man/freerdp-global-links.1
|
||||
)
|
||||
|
||||
set(VAR_NAMES "VENDOR" "PRODUCT" "VENDOR_PRODUCT" "CMAKE_INSTALL_FULL_SYSCONFDIR")
|
||||
include(GetSysconfDir)
|
||||
get_sysconf_dir("" SYSCONF_DIR)
|
||||
set(VAR_NAMES "VENDOR" "PRODUCT" "VENDOR_PRODUCT" "SYSCONF_DIR")
|
||||
generate_and_install_freerdp_man_from_xml(${MODULE_NAME} "1" "${DEPS}" "${VAR_NAMES}")
|
||||
|
||||
@@ -4,5 +4,7 @@ set(DEPS
|
||||
../../common/man/sdl-freerdp-examples.1 ../../../common/man/freerdp-global-links.1
|
||||
)
|
||||
|
||||
set(VAR_NAMES "VENDOR" "PRODUCT" "VENDOR_PRODUCT" "CMAKE_INSTALL_FULL_SYSCONFDIR")
|
||||
include(GetSysconfDir)
|
||||
get_sysconf_dir("" SYSCONF_DIR)
|
||||
set(VAR_NAMES "VENDOR" "PRODUCT" "VENDOR_PRODUCT" "SYSCONF_DIR")
|
||||
generate_and_install_freerdp_man_from_xml(${MODULE_NAME} "1" "${DEPS}" "${VAR_NAMES}")
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
set(DEPS ../../common/man/freerdp-global-options.1 xfreerdp-shortcuts.1 ../../common/man/freerdp-global-envvar.1
|
||||
../../common/man/freerdp-global-config.1 xfreerdp-examples.1 ../../common/man/freerdp-global-links.1
|
||||
set(DEPS
|
||||
../../common/man/freerdp-global-options.1
|
||||
xfreerdp-shortcuts.1
|
||||
../../common/man/freerdp-global-envvar.1
|
||||
../../common/man/freerdp-global-config.1
|
||||
xfreerdp-global-config.1
|
||||
xfreerdp-examples.1
|
||||
../../common/man/freerdp-global-links.1
|
||||
)
|
||||
|
||||
include(GetSysconfDir)
|
||||
get_sysconf_dir("" SYSCONF_DIR)
|
||||
set(SDL_WIKI_BASE_URL "https://wiki.libsdl.org/SDL2")
|
||||
set(VAR_NAMES "VENDOR" "PRODUCT" "VENDOR_PRODUCT" "CMAKE_INSTALL_FULL_SYSCONFDIR" "SDL_WIKI_BASE_URL")
|
||||
set(VAR_NAMES "VENDOR" "PRODUCT" "VENDOR_PRODUCT" "SYSCONF_DIR" "SDL_WIKI_BASE_URL")
|
||||
generate_and_install_freerdp_man_from_xml(${MODULE_NAME} "1" "${DEPS}" "${VAR_NAMES}")
|
||||
|
||||
22
client/X11/man/xfreerdp-global-config.1.in
Normal file
22
client/X11/man/xfreerdp-global-config.1.in
Normal file
@@ -0,0 +1,22 @@
|
||||
.SH "GLOBAL CONFIGURATION (X11 client)"
|
||||
.PP
|
||||
The X11 client configuration location is
|
||||
\fI@SYSCONF_DIR@/xfreerdp\&.json\fR
|
||||
.br
|
||||
|
||||
File format is JSON
|
||||
.RE
|
||||
.PP
|
||||
Supported options:
|
||||
.RS 4
|
||||
.PP
|
||||
\fIisActionScriptAllowed\fR
|
||||
.RS 4
|
||||
.PP
|
||||
.RS 4
|
||||
\fIJSON boolean\fR
|
||||
.br
|
||||
|
||||
Allow or block action scripts. Default (if option is not set) is to allow action scripts.
|
||||
.RE
|
||||
.RE
|
||||
@@ -190,6 +190,15 @@ BOOL xf_event_action_script_init(xfContext* xfc)
|
||||
|
||||
xf_event_action_script_free(xfc);
|
||||
|
||||
char* val = getConfigOption(TRUE, "isActionScriptAllowed");
|
||||
|
||||
/* We default to enabled if there is no global config file. */
|
||||
xfc->isActionScriptAllowed = !val || (_stricmp(val, "true") == 0);
|
||||
free(val);
|
||||
|
||||
if (!xfc->isActionScriptAllowed)
|
||||
return TRUE;
|
||||
|
||||
xfc->xevents = ArrayList_New(TRUE);
|
||||
|
||||
if (!xfc->xevents)
|
||||
@@ -216,6 +225,9 @@ static BOOL action_script_run(xfContext* xfc, const char* buffer, size_t size, v
|
||||
const char* what, const char* arg)
|
||||
{
|
||||
WINPR_UNUSED(xfc);
|
||||
if (!xfc->isActionScriptAllowed)
|
||||
return TRUE;
|
||||
|
||||
WINPR_UNUSED(what);
|
||||
WINPR_UNUSED(arg);
|
||||
WINPR_ASSERT(user);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "xf_utils.h"
|
||||
#include "xfreerdp.h"
|
||||
|
||||
#include <freerdp/utils/helpers.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#define TAG CLIENT_TAG("xfreerdp.utils")
|
||||
@@ -732,3 +733,22 @@ int LogDynAndXReparentWindow_ex(wLog* log, const char* file, const char* fkt, si
|
||||
return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XReparentWindow",
|
||||
rc);
|
||||
}
|
||||
|
||||
char* getConfigOption(BOOL system, const char* option)
|
||||
{
|
||||
char* res = NULL;
|
||||
WINPR_JSON* file = freerdp_GetJSONConfigFile(system, "xfreerdp.json");
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
WINPR_JSON* obj = WINPR_JSON_GetObjectItem(file, option);
|
||||
if (obj)
|
||||
{
|
||||
const char* val = WINPR_JSON_GetStringValue(obj);
|
||||
if (val)
|
||||
res = _strdup(val);
|
||||
}
|
||||
WINPR_JSON_Delete(file);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -289,3 +289,5 @@ extern int LogDynAndXSetFunction_ex(wLog* log, const char* file, const char* fkt
|
||||
Display* display, GC gc, int function);
|
||||
|
||||
BOOL IsGnome(void);
|
||||
|
||||
char* getConfigOption(BOOL system, const char* option);
|
||||
|
||||
@@ -318,6 +318,7 @@ struct xf_context
|
||||
FREERDP_REMAP_TABLE* remap_table;
|
||||
DWORD X11_KEYCODE_TO_VIRTUAL_SCANCODE[256];
|
||||
bool isCursorHidden;
|
||||
bool isActionScriptAllowed;
|
||||
};
|
||||
|
||||
BOOL xf_create_window(xfContext* xfc);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
.SH "GLOBAL CONFIGURATION"
|
||||
.SH "GLOBAL CONFIGURATION (client common)"
|
||||
.PP
|
||||
Format and Location:
|
||||
.RS 4
|
||||
The configuration file is stored in global system configuration\&.
|
||||
The configuration files are stored in global system configuration\&.
|
||||
.br
|
||||
|
||||
The location is
|
||||
\fI@CMAKE_INSTALL_FULL_SYSCONFDIR@/@VENDOR@/@PRODUCT@/certificates\&.json\fR
|
||||
The common certificate settings location is
|
||||
\fI@SYSCONF_DIR@/certificates\&.json\fR
|
||||
.br
|
||||
|
||||
File format is JSON
|
||||
|
||||
14
cmake/GetSysconfDir.cmake
Normal file
14
cmake/GetSysconfDir.cmake
Normal file
@@ -0,0 +1,14 @@
|
||||
option(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR "Use <vendor>/<product> path for resources" OFF)
|
||||
|
||||
function(get_sysconf_dir name result)
|
||||
set(CONF_FILE ${PRODUCT})
|
||||
if(WITH_RESOURCE_VERSIONING)
|
||||
string(APPEND CONF_FILE "${FREERDP_VERSION_MAJOR}")
|
||||
endif()
|
||||
if(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR)
|
||||
string(PREPEND CONF_FILE "${VENDOR}/")
|
||||
endif()
|
||||
string(PREPEND CONF_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/")
|
||||
string(APPEND CONF_FILE "${name}")
|
||||
set(${result} ${CONF_FILE} PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -18,7 +18,6 @@
|
||||
set(MODULE_NAME "freerdp")
|
||||
set(MODULE_PREFIX "FREERDP")
|
||||
|
||||
option(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR "Use <vendor>/<product> path for resources" OFF)
|
||||
set(FREERDP_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR})
|
||||
if(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR)
|
||||
string(APPEND FREERDP_RESOURCE_ROOT "/${VENDOR}")
|
||||
|
||||
Reference in New Issue
Block a user