From 98977336fddcc7baced96db9a1c9f824490d8b69 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 14 Oct 2021 08:25:46 +0200 Subject: [PATCH] Drop legacy command line (#7348) --- client/common/CMakeLists.txt | 2 - client/common/cmdline.c | 28 +- client/common/compatibility.c | 874 ------------------------- client/common/compatibility.h | 30 - client/common/test/TestClientCmdLine.c | 24 +- 5 files changed, 13 insertions(+), 945 deletions(-) delete mode 100644 client/common/compatibility.c delete mode 100644 client/common/compatibility.h diff --git a/client/common/CMakeLists.txt b/client/common/CMakeLists.txt index 77364e330..b291476a4 100644 --- a/client/common/CMakeLists.txt +++ b/client/common/CMakeLists.txt @@ -28,8 +28,6 @@ endif() set(${MODULE_PREFIX}_SRCS client.c cmdline.c - compatibility.c - compatibility.h file.c geometry.c) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 87d1513f3..ac33c2153 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -49,7 +49,6 @@ #include #include -#include "compatibility.h" #include "cmdline.h" #include @@ -1337,26 +1336,23 @@ static int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv, static BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags) { - int old_cli_status; - size_t old_cli_count; int posix_cli_status; size_t posix_cli_count; int windows_cli_status; size_t windows_cli_count; - BOOL compatibility = FALSE; const BOOL ignoreUnknown = TRUE; windows_cli_status = freerdp_detect_windows_style_command_line_syntax( argc, argv, &windows_cli_count, ignoreUnknown); posix_cli_status = freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count, ignoreUnknown); - old_cli_status = freerdp_detect_old_command_line_syntax(argc, argv, &old_cli_count); + /* Default is POSIX syntax */ *flags = COMMAND_LINE_SEPARATOR_SPACE; *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH; *flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE; if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT) - return compatibility; + return FALSE; /* Check, if this may be windows style syntax... */ if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) || @@ -1366,20 +1362,10 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* fla *flags = COMMAND_LINE_SEPARATOR_COLON; *flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS; } - else if (old_cli_status >= 0) - { - /* Ignore legacy parsing in case there is an error in the command line. */ - if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count) && (old_cli_status != -1))) - { - *flags = COMMAND_LINE_SEPARATOR_SPACE; - *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH; - compatibility = TRUE; - } - } - WLog_DBG(TAG, "windows: %d/%d posix: %d/%d compat: %d/%d", windows_cli_status, - windows_cli_count, posix_cli_status, posix_cli_count, old_cli_status, old_cli_count); - return compatibility; + WLog_DBG(TAG, "windows: %d/%d posix: %d/%d", windows_cli_status, windows_cli_count, + posix_cli_status, posix_cli_count); + return FALSE; } int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc, @@ -1597,8 +1583,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, if (compatibility) { - WLog_WARN(TAG, "Using deprecated command-line interface!"); - return freerdp_client_parse_old_command_line_arguments(argc, argv, settings); + WLog_WARN(TAG, "Unsupported command line syntax!"); + return -1; } else { diff --git a/client/common/compatibility.c b/client/common/compatibility.c deleted file mode 100644 index f97a86835..000000000 --- a/client/common/compatibility.c +++ /dev/null @@ -1,874 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * FreeRDP Client Compatibility - * - * Copyright 2012 Marc-Andre Moreau - * Copyright 2017 Armin Novak - * Copyright 2017 Thincast Technologies GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "compatibility.h" - -#define TAG CLIENT_TAG("common.compatibility") - -static const COMMAND_LINE_ARGUMENT_A old_args[] = { - { "0", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "connect to console session" }, - { "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "set color depth in bits, default is 16" }, - { "c", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "shell working directory" }, - { "D", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "hide window decorations" }, - { "T", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Window title" }, - { "d", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "domain" }, - { "f", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "fullscreen mode" }, - { "g", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "set geometry, using format WxH or X%% or 'workarea', default is 1024x768" }, - { "h", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "help", - "print this help" }, - { "k", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set keyboard layout ID" }, - { "K", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "do not interfere with window manager bindings" }, - { "n", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "hostname" }, - { "o", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "console audio" }, - { "p", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "password" }, - { "s", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set startup-shell" }, - { "t", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "alternative port number, default is 3389" }, - { "u", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "username" }, - { "x", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "performance flags (m[odem], b[roadband] or l[an])" }, - { "X", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "embed into another window with a given XID." }, - { "z", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable compression" }, - { "app", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "RemoteApp connection. This implies -g workarea" }, - { "ext", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "load an extension" }, - { "no-auth", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable authentication" }, - { "authonly", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "authentication only, no UI" }, - { "from-stdin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "unspecified username, password, domain and hostname params are prompted" }, - { "no-fastpath", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable fast-path" }, - { "no-motion", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "don't send mouse motion events" }, - { "gdi", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "graphics rendering (hw, sw)" }, - { "no-osb", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable offscreen bitmaps" }, - { "no-bmp-cache", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable bitmap cache" }, - { "plugin", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "load a virtual channel plugin" }, - { "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable RemoteFX" }, - { "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "RemoteFX operational flags (v[ideo], i[mage]), default is video" }, - { "nsc", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable NSCodec (experimental)" }, - { "disable-wallpaper", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "disables wallpaper" }, - { "composition", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "enable desktop composition" }, - { "disable-full-window-drag", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "disables full window drag" }, - { "disable-menu-animations", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "disables menu animations" }, - { "disable-theming", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables theming" }, - { "no-rdp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "disable Standard RDP encryption" }, - { "no-tls", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable TLS encryption" }, - { "no-nla", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "disable network level authentication" }, - { "ntlm", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "force NTLM authentication protocol version (1 or 2)" }, - { "ignore-certificate", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "ignore verification of logon certificate" }, - { "sec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, - "force protocol security (rdp, tls or nla)" }, - { "secure-checksum", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, - "use salted checksums with Standard RDP encryption" }, - { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL, - "print version information" }, - { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } -}; - -static BOOL freerdp_client_old_parse_hostname(char* str, char** ServerHostname, UINT32* ServerPort) -{ - char* p; - char* host = NULL; - - if (str[0] == '[' && (p = strchr(str, ']')) && - (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':')))) - { - /* Either "[...]" or "[...]:..." with at most one : after the brackets */ - if (!(host = _strdup(str + 1))) - return FALSE; - - if ((p = strchr(host, ']'))) - { - *p = 0; - - if (p[1] == ':') - { - unsigned long val; - errno = 0; - val = strtoul(p + 2, NULL, 0); - - if ((errno != 0) || (val == 0) || (val > UINT16_MAX)) - { - free(host); - return FALSE; - } - - *ServerPort = val; - } - } - } - else - { - /* Port number is cut off and used if exactly one : in the string */ - if (!(host = _strdup(str))) - return FALSE; - - if ((p = strchr(host, ':')) && !strchr(p + 1, ':')) - { - unsigned long val; - errno = 0; - val = strtoul(p + 1, NULL, 0); - - if ((errno != 0) || (val == 0) || (val > UINT16_MAX)) - { - free(host); - return FALSE; - } - - *p = 0; - *ServerPort = val; - } - } - - *ServerHostname = host; - return TRUE; -} - -static int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args) -{ - int args_handled = 0; - - if (strcmp(args->argv[0], CLIPRDR_SVC_CHANNEL_NAME) == 0) - { - args_handled++; - settings->RedirectClipboard = TRUE; - WLog_WARN(TAG, "--plugin cliprdr -> +clipboard"); - } - else if (strcmp(args->argv[0], "rdpdr") == 0) - { - args_handled++; - - if (args->argc < 2) - return 1; - - args_handled++; - - if ((strcmp(args->argv[1], "disk") == 0) || (strcmp(args->argv[1], "drive") == 0)) - { - freerdp_addin_replace_argument(args, "disk", "drive"); - freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]); - } - else if (strcmp(args->argv[1], "printer") == 0) - { - freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]); - } - else if ((strcmp(args->argv[1], "scard") == 0) || (strcmp(args->argv[1], "smartcard") == 0)) - { - freerdp_addin_replace_argument(args, "scard", "smartcard"); - freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]); - } - else if (strcmp(args->argv[1], "serial") == 0) - { - freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]); - } - else if (strcmp(args->argv[1], "parallel") == 0) - { - freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]); - } - } - else if (strcmp(args->argv[0], DRDYNVC_SVC_CHANNEL_NAME) == 0) - { - args_handled++; - freerdp_client_add_dynamic_channel(settings, args->argc - 1, &args->argv[1]); - } - else if (strcmp(args->argv[0], RDPSND_CHANNEL_NAME) == 0) - { - args_handled++; - - if (args->argc < 2) - return 1; - - args_handled++; - freerdp_addin_replace_argument_value(args, args->argv[1], "sys", args->argv[1]); - freerdp_client_add_static_channel(settings, args->argc, args->argv); - } - else if (strcmp(args->argv[0], RAIL_SVC_CHANNEL_NAME) == 0) - { - args_handled++; - - if (args->argc < 2) - return 1; - - args_handled++; - - if (!(settings->RemoteApplicationProgram = _strdup(args->argv[1]))) - return -1; - } - else - { - freerdp_client_add_static_channel(settings, args->argc, args->argv); - } - - return args_handled; -} -static int freerdp_client_old_command_line_pre_filter(void* context, int index, int argc, - LPSTR* argv) -{ - rdpSettings* settings = (rdpSettings*)context; - - if (index == (argc - 1)) - { - if (argv[index][0] != '-') - { - if ((strcmp(argv[index - 1], "-v") == 0) || (strcmp(argv[index - 1], "/v") == 0)) - { - return -1; - } - - if (_stricmp(&(argv[index])[strlen(argv[index]) - 4], ".rdp") == 0) - { - return -1; - } - - if (!freerdp_client_old_parse_hostname(argv[index], &settings->ServerHostname, - &settings->ServerPort)) - return -1; - - return 2; - } - else - { - return -1; - } - } - - if (strcmp("--plugin", argv[index]) == 0) - { - int args_handled = 0; - size_t length; - char *a, *p; - int i, j, t; - int old_index; - old_index = index; - index++; - t = index; - - if (index == argc) - return -1; - - - - if ((index < argc - 1) && strcmp("--data", argv[index + 1]) == 0) - { - i = 0; - index += 2; - - while ((index < argc) && (strcmp("--", argv[index]) != 0)) - { - ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL); - - if (!args) - return -1; - args_handled++; - - if (!freerdp_addin_argv_add_argument(args, argv[t])) - { - freerdp_addin_argv_free(args); - return -1; - } - - for (j = 0, p = argv[index]; (j < 4) && (p != NULL); j++) - { - if (*p == '\'') - { - a = p + 1; - p = strchr(p + 1, '\''); - - if (p) - *p++ = 0; - } - else - { - a = p; - } - - if (p != NULL) - { - p = strchr(p, ':'); - } - - if (p != NULL) - { - length = (size_t)(p - a); - - if (!freerdp_addin_argv_add_argument_ex(args, a, length)) - { - freerdp_addin_argv_free(args); - return -1; - } - - p++; - } - else - { - if (!freerdp_addin_argv_add_argument(args, a)) - { - freerdp_addin_argv_free(args); - return -1; - } - } - } - - if (settings) - { - freerdp_client_old_process_plugin(settings, args); - } - - freerdp_addin_argv_free(args); - index++; - i++; - } - } - else - { - if (settings) - { - ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL); - - if (!args) - return -1; - - if (!freerdp_addin_argv_add_argument(args, argv[t])) - { - freerdp_addin_argv_free(args); - return -1; - } - - args_handled = freerdp_client_old_process_plugin(settings, args); - freerdp_addin_argv_free(args); - } - } - - return (index - old_index) + args_handled; - } - - return 0; -} -static int freerdp_client_old_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT_A* arg) -{ - WINPR_UNUSED(context); - WINPR_UNUSED(arg); - - return 0; -} -int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count) -{ - int status; - DWORD flags; - int detect_status; - rdpSettings* settings; - const COMMAND_LINE_ARGUMENT_A* arg; - COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(old_args)]; - memcpy(largs, old_args, sizeof(old_args)); - - *count = 0; - detect_status = 0; - flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER; - flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH; - flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED; - settings = freerdp_settings_new(0); - - if (!settings) - return -1; - - CommandLineClearArgumentsA(largs); - status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings, - freerdp_client_old_command_line_pre_filter, NULL); - - if (status < 0) - { - freerdp_settings_free(settings); - return status; - } - - arg = largs; - - do - { - if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)) - continue; - - CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "a") - { - if ((strcmp(arg->Value, "8") == 0) || (strcmp(arg->Value, "15") == 0) || - (strcmp(arg->Value, "16") == 0) || (strcmp(arg->Value, "24") == 0) || - (strcmp(arg->Value, "32") == 0)) - { - detect_status = 1; - } - } - CommandLineSwitchDefault(arg) - { - } - CommandLineSwitchEnd(arg)(*count)++; - } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); - - if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST)) - detect_status = -1; - - if (detect_status == 0) - { - if (settings->ServerHostname) - detect_status = 1; - } - - freerdp_settings_free(settings); - return detect_status; -} -int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings) -{ - char* p; - char* str; - int status; - DWORD flags; - const COMMAND_LINE_ARGUMENT_A* arg; - COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(old_args)]; - memcpy(largs, old_args, sizeof(old_args)); - - freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0); - flags = COMMAND_LINE_SEPARATOR_SPACE; - flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH; - flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE; - flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED; - status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings, - freerdp_client_old_command_line_pre_filter, - freerdp_client_old_command_line_post_filter); - - if (status == COMMAND_LINE_STATUS_PRINT_VERSION) - { - freerdp_client_print_version(); - return COMMAND_LINE_STATUS_PRINT_VERSION; - } - else if (status == COMMAND_LINE_STATUS_PRINT) - { - return COMMAND_LINE_STATUS_PRINT; - } - else if (status < 0) - { - if (status != COMMAND_LINE_STATUS_PRINT_HELP) - { - } - - freerdp_client_print_command_line_help(argc, argv); - return COMMAND_LINE_STATUS_PRINT_HELP; - } - - arg = largs; - errno = 0; - settings->BitmapCacheEnabled = TRUE; - settings->OffscreenSupportLevel = TRUE; - - do - { - if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)) - continue; - - CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "0") - { - settings->ConsoleSession = TRUE; - WLog_WARN(TAG, "-0 -> /admin"); - } - CommandLineSwitchCase(arg, "a") - { - unsigned long val = strtoul(arg->Value, NULL, 0); - - if ((errno != 0) || (val > INT8_MAX)) - return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - - settings->ColorDepth = val; - WLog_WARN(TAG, "-a %s -> /bpp:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "c") - { - WLog_WARN(TAG, "-c %s -> /shell-dir:%s", arg->Value, arg->Value); - - if (!(settings->ShellWorkingDirectory = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - } - CommandLineSwitchCase(arg, "D") - { - settings->Decorations = FALSE; - WLog_WARN(TAG, "-D -> -decorations"); - } - CommandLineSwitchCase(arg, "T") - { - if (!(settings->WindowTitle = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - WLog_WARN(TAG, "-T %s -> /title:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "d") - { - if (!(settings->Domain = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - WLog_WARN(TAG, "-d %s -> /d:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "f") - { - settings->Fullscreen = TRUE; - WLog_WARN(TAG, "-f -> /f"); - } - CommandLineSwitchCase(arg, "g") - { - if (!(str = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - p = strchr(str, 'x'); - - if (p) - { - unsigned long h, w = strtoul(str, NULL, 0); - - if ((errno != 0) || (w == 0) || (w > UINT16_MAX)) - { - free(str); - return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - } - - h = strtoul(&p[1], NULL, 0); - - if ((errno != 0) || (h == 0) || (h > UINT16_MAX)) - { - free(str); - return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - } - - *p = '\0'; - settings->DesktopWidth = w; - settings->DesktopHeight = h; - } - - free(str); - WLog_WARN(TAG, "-g %s -> /size:%s or /w:%" PRIu32 " /h:%" PRIu32 "", arg->Value, - arg->Value, settings->DesktopWidth, settings->DesktopHeight); - } - CommandLineSwitchCase(arg, "k") - { - sscanf(arg->Value, "%X", &(settings->KeyboardLayout)); - WLog_WARN(TAG, "-k %s -> /kbd:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "K") - { - settings->GrabKeyboard = FALSE; - WLog_WARN(TAG, "-K -> -grab-keyboard"); - } - CommandLineSwitchCase(arg, "n") - { - if (!(settings->ClientHostname = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - WLog_WARN(TAG, "-n -> /client-hostname:%s", arg->Value); - } - CommandLineSwitchCase(arg, "o") - { - settings->RemoteConsoleAudio = TRUE; - WLog_WARN(TAG, "-o -> /audio-mode:1"); - } - CommandLineSwitchCase(arg, "p") - { - if (!(settings->Password = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - WLog_WARN(TAG, "-p ****** -> /p:******"); - /* Hide the value from 'ps'. */ - FillMemory(arg->Value, strlen(arg->Value), '*'); - } - CommandLineSwitchCase(arg, "s") - { - if (!(settings->AlternateShell = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - WLog_WARN(TAG, "-s %s -> /shell:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "t") - { - unsigned long cp = strtoul(arg->Value, NULL, 0); - - if ((errno != 0) || (cp == 0) || (cp > UINT16_MAX)) - return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - - settings->ServerPort = cp; - WLog_WARN(TAG, "-t %s -> /port:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "u") - { - if (!(settings->Username = _strdup(arg->Value))) - return COMMAND_LINE_ERROR_MEMORY; - - WLog_WARN(TAG, "-u %s -> /u:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "x") - { - unsigned long type; - char* pEnd; - type = strtoul(arg->Value, &pEnd, 16); - - if (errno != 0) - return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - - if (type == 0) - { - type = CONNECTION_TYPE_LAN; - - if (_stricmp(arg->Value, "m") == 0) - type = CONNECTION_TYPE_MODEM; - else if (_stricmp(arg->Value, "b") == 0) - type = CONNECTION_TYPE_BROADBAND_HIGH; - else if (_stricmp(arg->Value, "l") == 0) - type = CONNECTION_TYPE_LAN; - - freerdp_set_connection_type(settings, type); - } - else - { - settings->PerformanceFlags = type; - freerdp_performance_flags_split(settings); - } - - WLog_WARN(TAG, "-x %s -> /network:", arg->Value); - - if (type == CONNECTION_TYPE_MODEM) - WLog_WARN(TAG, "modem"); - else if (CONNECTION_TYPE_BROADBAND_HIGH) - WLog_WARN(TAG, "broadband"); - else if (CONNECTION_TYPE_LAN) - WLog_WARN(TAG, "lan"); - - WLog_WARN(TAG, ""); - } - CommandLineSwitchCase(arg, "X") - { - settings->ParentWindowId = _strtoui64(arg->Value, NULL, 0); - - if (errno != 0) - return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - - WLog_WARN(TAG, "-X %s -> /parent-window:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "z") - { - settings->CompressionEnabled = TRUE; - WLog_WARN(TAG, "-z -> /compression"); - } - CommandLineSwitchCase(arg, "app") - { - settings->RemoteApplicationMode = TRUE; - WLog_WARN(TAG, "--app -> /app: + program name or alias"); - } - CommandLineSwitchCase(arg, "ext") - { - } - CommandLineSwitchCase(arg, "no-auth") - { - settings->Authentication = FALSE; - WLog_WARN(TAG, "--no-auth -> -authentication"); - } - CommandLineSwitchCase(arg, "authonly") - { - settings->AuthenticationOnly = TRUE; - } - CommandLineSwitchCase(arg, "from-stdin") - { - settings->CredentialsFromStdin = TRUE; - } - CommandLineSwitchCase(arg, "no-fastpath") - { - settings->FastPathInput = FALSE; - settings->FastPathOutput = FALSE; - WLog_WARN(TAG, "--no-fastpath -> -fast-path"); - } - CommandLineSwitchCase(arg, "no-motion") - { - settings->MouseMotion = FALSE; - WLog_WARN(TAG, "--no-motion -> -mouse-motion"); - } - CommandLineSwitchCase(arg, "gdi") - { - if (strcmp(arg->Value, "sw") == 0) - settings->SoftwareGdi = TRUE; - else if (strcmp(arg->Value, "hw") == 0) - settings->SoftwareGdi = FALSE; - - WLog_WARN(TAG, "--gdi %s -> /gdi:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "no-osb") - { - settings->OffscreenSupportLevel = FALSE; - WLog_WARN(TAG, "--no-osb -> -offscreen-cache"); - } - CommandLineSwitchCase(arg, "no-bmp-cache") - { - settings->BitmapCacheEnabled = FALSE; - WLog_WARN(TAG, "--no-bmp-cache -> -bitmap-cache"); - } - CommandLineSwitchCase(arg, "plugin") - { - WLog_WARN(TAG, "--plugin -> /a, /vc, /dvc and channel-specific options"); - } - CommandLineSwitchCase(arg, "rfx") - { - settings->RemoteFxCodec = TRUE; - WLog_WARN(TAG, "--rfx -> /rfx"); - } - CommandLineSwitchCase(arg, "rfx-mode") - { - if (arg->Value[0] == 'v') - settings->RemoteFxCodecMode = 0x00; - else if (arg->Value[0] == 'i') - settings->RemoteFxCodecMode = 0x02; - - WLog_WARN(TAG, "--rfx-mode -> /rfx-mode:%s", - settings->RemoteFxCodecMode ? "image" : "video"); - } - CommandLineSwitchCase(arg, "nsc") - { - freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE); - WLog_WARN(TAG, "--nsc -> /nsc"); - } - CommandLineSwitchCase(arg, "disable-wallpaper") - { - settings->DisableWallpaper = TRUE; - WLog_WARN(TAG, "--disable-wallpaper -> -wallpaper"); - } - CommandLineSwitchCase(arg, "composition") - { - settings->AllowDesktopComposition = TRUE; - WLog_WARN(TAG, "--composition -> +composition"); - } - CommandLineSwitchCase(arg, "disable-full-window-drag") - { - settings->DisableFullWindowDrag = TRUE; - WLog_WARN(TAG, "--disable-full-window-drag -> -window-drag"); - } - CommandLineSwitchCase(arg, "disable-menu-animations") - { - settings->DisableMenuAnims = TRUE; - WLog_WARN(TAG, "--disable-menu-animations -> -menu-anims"); - } - CommandLineSwitchCase(arg, "disable-theming") - { - settings->DisableThemes = TRUE; - WLog_WARN(TAG, "--disable-theming -> -themes"); - } - CommandLineSwitchCase(arg, "ntlm") - { - } - CommandLineSwitchCase(arg, "ignore-certificate") - { - settings->IgnoreCertificate = TRUE; - WLog_WARN(TAG, "--ignore-certificate -> /cert-ignore"); - } - CommandLineSwitchCase(arg, "sec") - { - if (strncmp("rdp", arg->Value, 1) == 0) /* Standard RDP */ - { - settings->RdpSecurity = TRUE; - settings->TlsSecurity = FALSE; - settings->NlaSecurity = FALSE; - settings->UseRdpSecurityLayer = FALSE; - } - else if (strncmp("tls", arg->Value, 1) == 0) /* TLS */ - { - settings->RdpSecurity = FALSE; - settings->TlsSecurity = TRUE; - settings->NlaSecurity = FALSE; - } - else if (strncmp("nla", arg->Value, 1) == 0) /* NLA */ - { - settings->RdpSecurity = FALSE; - settings->TlsSecurity = FALSE; - settings->NlaSecurity = TRUE; - } - - WLog_WARN(TAG, "--sec %s -> /sec:%s", arg->Value, arg->Value); - } - CommandLineSwitchCase(arg, "no-rdp") - { - settings->RdpSecurity = FALSE; - WLog_WARN(TAG, "--no-rdp -> -sec-rdp"); - } - CommandLineSwitchCase(arg, "no-tls") - { - settings->TlsSecurity = FALSE; - WLog_WARN(TAG, "--no-tls -> -sec-tls"); - } - CommandLineSwitchCase(arg, "no-nla") - { - settings->NlaSecurity = FALSE; - WLog_WARN(TAG, "--no-nla -> -sec-nla"); - } - CommandLineSwitchCase(arg, "secure-checksum") - { - settings->SaltedChecksum = TRUE; - } - CommandLineSwitchDefault(arg) - { - } - CommandLineSwitchEnd(arg) - } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); - - WLog_WARN(TAG, "%s -> /v:%s", settings->ServerHostname, settings->ServerHostname); - - if (settings->ServerPort != 3389) - WLog_WARN(TAG, " /port:%" PRIu32 "", settings->ServerPort); - - WLog_WARN(TAG, ""); - return 0; -} diff --git a/client/common/compatibility.h b/client/common/compatibility.h deleted file mode 100644 index b512a40da..000000000 --- a/client/common/compatibility.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * FreeRDP Client Compatibility - * - * Copyright 2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FREERDP_CLIENT_COMMON_COMPATIBILITY_H -#define FREERDP_CLIENT_COMMON_COMPATIBILITY_H - -#include -#include - -FREERDP_LOCAL int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count); -FREERDP_LOCAL int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, - rdpSettings* settings); - -#endif /* FREERDP_CLIENT_COMMON_COMPATIBILITY_H */ diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index 34ad64806..03e61f865 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -117,7 +117,7 @@ typedef struct } modified_arguments[8]; } test; -static test tests[] = { +static const test tests[] = { { COMMAND_LINE_STATUS_PRINT_HELP, check_settings_smartcard_no_redirection, { "testfreerdp", "--help", 0 }, @@ -142,10 +142,6 @@ static test tests[] = { check_settings_smartcard_no_redirection, { "testfreerdp", "-version", 0 }, { { 0 } } }, - { 0, - check_settings_smartcard_no_redirection, - { "testfreerdp", "test.freerdp.com", 0 }, - { { 0 } } }, { 0, check_settings_smartcard_no_redirection, { "testfreerdp", "-v", "test.freerdp.com", 0 }, @@ -158,19 +154,10 @@ static test tests[] = { check_settings_smartcard_no_redirection, { "testfreerdp", "/v:test.freerdp.com", 0 }, { { 0 } } }, - { 0, - check_settings_smartcard_no_redirection, - { "testfreerdp", "--plugin", "rdpsnd", "--plugin", "rdpdr", "--data", - "disk:media:" DRIVE_REDIRECT_PATH, "--", "test.freerdp.com", 0 }, - { { 0 } } }, { 0, check_settings_smartcard_no_redirection, { "testfreerdp", "/sound", "/drive:media," DRIVE_REDIRECT_PATH, "/v:test.freerdp.com", 0 }, { { 0 } } }, - { 0, - check_settings_smartcard_no_redirection, - { "testfreerdp", "-u", "test", "-p", "test", "test.freerdp.com", 0 }, - { { 4, "****" }, { 0 } } }, { 0, check_settings_smartcard_no_redirection, { "testfreerdp", "-u", "test", "-p", "test", "-v", "test.freerdp.com", 0 }, @@ -213,7 +200,7 @@ static test tests[] = { #endif }; -static void check_modified_arguments(test* test, char** command_line, int* rc) +static void check_modified_arguments(const test* test, char** command_line, int* rc) { int k; const char* expected_argument; @@ -243,18 +230,19 @@ int TestClientCmdLine(int argc, char* argv[]) WINPR_UNUSED(argv); for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + const test* current = &tests[i]; int failure = 0; - char** command_line = string_list_copy(tests[i].command_line); + char** command_line = string_list_copy(current->command_line); if (!testcase(__FUNCTION__, command_line, string_list_length((const char* const*)command_line), - tests[i].expected_status, tests[i].validate_settings)) + current->expected_status, current->validate_settings)) { TEST_FAILURE("parsing arguments.\n"); failure = 1; } - check_modified_arguments(&tests[i], command_line, &failure); + check_modified_arguments(current, command_line, &failure); if (failure) {