2012-12-05 21:12:18 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* FreeRDP Client Compatibility
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2017-02-20 20:31:58 +03:00
|
|
|
* Copyright 2017 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2017 Thincast Technologies GmbH
|
2012-12-05 21:12:18 +04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
#include <errno.h>
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/cmdline.h>
|
|
|
|
|
|
|
|
#include <freerdp/addin.h>
|
|
|
|
#include <freerdp/settings.h>
|
|
|
|
#include <freerdp/client/channels.h>
|
2014-09-12 19:13:01 +04:00
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
#include <freerdp/locale/keyboard.h>
|
|
|
|
|
|
|
|
#include <freerdp/client/cmdline.h>
|
2014-09-12 19:13:01 +04:00
|
|
|
#include <freerdp/log.h>
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
#include "compatibility.h"
|
|
|
|
|
2014-09-12 19:13:01 +04:00
|
|
|
#define TAG CLIENT_TAG("common.compatibility")
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static const COMMAND_LINE_ARGUMENT_A old_args[] = {
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "0", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "connect to console session" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"set color depth in bits, default is 16" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "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" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "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" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "k", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set keyboard layout ID" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "K", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"do not interfere with window manager bindings" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "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" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "t", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"alternative port number, default is 3389" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "u", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "username" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "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." },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "z", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable compression" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "app", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"RemoteApp connection. This implies -g workarea" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "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" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "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" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "no-fastpath", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable fast-path" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "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)" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "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" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "plugin", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"load a virtual channel plugin" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable RemoteFX" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"RemoteFX operational flags (v[ideo], i[mage]), default is video" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "nsc", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable NSCodec (experimental)" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "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" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "disable-theming", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables theming" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "no-rdp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
|
|
|
|
"disable Standard RDP encryption" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ "no-tls", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable TLS encryption" },
|
2019-11-06 17:24:51 +03:00
|
|
|
{ "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" },
|
2012-12-05 21:12:18 +04:00
|
|
|
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
static BOOL freerdp_client_old_parse_hostname(char* str, char** ServerHostname, UINT32* ServerPort)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
char* p;
|
2017-11-14 18:10:52 +03:00
|
|
|
char* host = NULL;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (str[0] == '[' && (p = strchr(str, ']')) &&
|
|
|
|
(p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
/* Either "[...]" or "[...]:..." with at most one : after the brackets */
|
2017-11-14 18:10:52 +03:00
|
|
|
if (!(host = _strdup(str + 1)))
|
2015-06-18 14:00:10 +03:00
|
|
|
return FALSE;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
if ((p = strchr(host, ']')))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
if (p[1] == ':')
|
2017-11-14 18:10:52 +03:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Port number is cut off and used if exactly one : in the string */
|
2017-11-14 18:10:52 +03:00
|
|
|
if (!(host = _strdup(str)))
|
2015-06-18 14:00:10 +03:00
|
|
|
return FALSE;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
if ((p = strchr(host, ':')) && !strchr(p + 1, ':'))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val;
|
|
|
|
errno = 0;
|
|
|
|
val = strtoul(p + 1, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
|
|
|
{
|
|
|
|
free(host);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
*p = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
*ServerPort = val;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
*ServerHostname = host;
|
2015-06-18 14:00:10 +03:00
|
|
|
return TRUE;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
static int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
int args_handled = 0;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
if (strcmp(args->argv[0], "cliprdr") == 0)
|
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2012-12-05 23:00:49 +04:00
|
|
|
settings->RedirectClipboard = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--plugin cliprdr -> +clipboard");
|
2012-12-05 23:00:49 +04:00
|
|
|
}
|
|
|
|
else if (strcmp(args->argv[0], "rdpdr") == 0)
|
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-08-29 17:30:22 +04:00
|
|
|
if (args->argc < 2)
|
2015-01-15 19:14:29 +03:00
|
|
|
return 1;
|
2013-08-29 17:30:22 +04:00
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((strcmp(args->argv[1], "disk") == 0) || (strcmp(args->argv[1], "drive") == 0))
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
|
|
|
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]);
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
else if ((strcmp(args->argv[1], "scard") == 0) || (strcmp(args->argv[1], "smartcard") == 0))
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
|
|
|
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") == 0)
|
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2012-12-05 23:00:49 +04:00
|
|
|
freerdp_client_add_dynamic_channel(settings, args->argc - 1, &args->argv[1]);
|
|
|
|
}
|
|
|
|
else if (strcmp(args->argv[0], "rdpsnd") == 0)
|
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-08-29 17:30:22 +04:00
|
|
|
if (args->argc < 2)
|
2015-01-15 19:14:29 +03:00
|
|
|
return 1;
|
2013-08-29 17:30:22 +04:00
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2012-12-05 23:00:49 +04:00
|
|
|
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") == 0)
|
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-08-29 17:30:22 +04:00
|
|
|
if (args->argc < 2)
|
2015-01-15 19:14:29 +03:00
|
|
|
return 1;
|
2013-08-29 17:30:22 +04:00
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled++;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationProgram = _strdup(args->argv[1])))
|
|
|
|
return -1;
|
2012-12-05 23:00:49 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
freerdp_client_add_static_channel(settings, args->argc, args->argv);
|
|
|
|
}
|
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
return args_handled;
|
2012-12-05 23:00:49 +04:00
|
|
|
}
|
2017-11-30 18:56:45 +03:00
|
|
|
static int freerdp_client_old_command_line_pre_filter(void* context, int index, int argc,
|
2019-11-06 17:24:51 +03:00
|
|
|
LPSTR* argv)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpSettings* settings = (rdpSettings*)context;
|
2012-12-05 23:00:49 +04:00
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
if (index == (argc - 1))
|
|
|
|
{
|
|
|
|
if (argv[index][0] != '-')
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((strcmp(argv[index - 1], "-v") == 0) || (strcmp(argv[index - 1], "/v") == 0))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
|
|
|
if (_stricmp(&(argv[index])[strlen(argv[index]) - 4], ".rdp") == 0)
|
2013-03-16 03:33:58 +04:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2013-11-10 22:29:20 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (!freerdp_client_old_parse_hostname(argv[index], &settings->ServerHostname,
|
|
|
|
&settings->ServerPort))
|
2015-06-18 14:00:10 +03:00
|
|
|
return -1;
|
2015-01-15 15:56:54 +03:00
|
|
|
|
|
|
|
return 2;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
if (strcmp("--plugin", argv[index]) == 0)
|
|
|
|
{
|
2015-01-15 19:14:29 +03:00
|
|
|
int args_handled = 0;
|
2012-12-05 23:00:49 +04:00
|
|
|
int length;
|
2019-11-06 17:24:51 +03:00
|
|
|
char *a, *p;
|
2012-12-05 23:00:49 +04:00
|
|
|
int i, j, t;
|
|
|
|
int old_index;
|
|
|
|
old_index = index;
|
|
|
|
index++;
|
|
|
|
t = index;
|
|
|
|
|
|
|
|
if (index == argc)
|
|
|
|
return -1;
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
|
|
|
|
if ((index < argc - 1) && strcmp("--data", argv[index + 1]) == 0)
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
index += 2;
|
|
|
|
|
|
|
|
while ((index < argc) && (strcmp("--", argv[index]) != 0))
|
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL);
|
|
|
|
|
|
|
|
if (!args)
|
|
|
|
return -1;
|
2015-06-18 14:00:10 +03:00
|
|
|
args_handled++;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!freerdp_addin_argv_add_argument(args, argv[t]))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(args);
|
2015-06-18 14:00:10 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2012-12-05 23:00:49 +04:00
|
|
|
|
2018-06-06 17:43:09 +03:00
|
|
|
for (j = 0, p = argv[index]; (j < 4) && (p != NULL); j++)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
|
|
|
if (*p == '\'')
|
|
|
|
{
|
|
|
|
a = p + 1;
|
|
|
|
p = strchr(p + 1, '\'');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
2013-08-29 12:49:19 +04:00
|
|
|
p = strchr(p, ':');
|
2015-01-15 16:08:33 +03:00
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-01-15 16:08:33 +03:00
|
|
|
if (p != NULL)
|
|
|
|
{
|
2017-02-20 20:31:58 +03:00
|
|
|
length = (int)(p - a);
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!freerdp_addin_argv_add_argument_ex(args, a, length))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(args);
|
2015-06-18 14:00:10 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
if (!freerdp_addin_argv_add_argument(args, a))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(args);
|
2015-06-18 14:00:10 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2012-12-05 23:00:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
if (settings)
|
2012-12-05 23:00:49 +04:00
|
|
|
{
|
|
|
|
freerdp_client_old_process_plugin(settings, args);
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(args);
|
2012-12-05 23:00:49 +04:00
|
|
|
index++;
|
|
|
|
i++;
|
|
|
|
}
|
2013-11-10 22:29:20 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (settings)
|
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL);
|
|
|
|
|
|
|
|
if (!args)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!freerdp_addin_argv_add_argument(args, argv[t]))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(args);
|
2015-06-18 14:00:10 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
args_handled = freerdp_client_old_process_plugin(settings, args);
|
2021-04-12 11:38:40 +03:00
|
|
|
freerdp_addin_argv_free(args);
|
2013-11-10 22:29:20 +04:00
|
|
|
}
|
2012-12-05 23:00:49 +04:00
|
|
|
}
|
|
|
|
|
2015-01-15 19:14:29 +03:00
|
|
|
return (index - old_index) + args_handled;
|
2012-12-05 23:00:49 +04:00
|
|
|
}
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2017-11-30 18:56:45 +03:00
|
|
|
static int freerdp_client_old_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT_A* arg)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2019-02-07 19:53:21 +03:00
|
|
|
WINPR_UNUSED(context);
|
|
|
|
WINPR_UNUSED(arg);
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2019-02-07 16:38:16 +03:00
|
|
|
int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
DWORD flags;
|
|
|
|
int detect_status;
|
|
|
|
rdpSettings* settings;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
2019-10-28 12:10:14 +03:00
|
|
|
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(old_args)];
|
|
|
|
memcpy(largs, old_args, sizeof(old_args));
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
*count = 0;
|
|
|
|
detect_status = 0;
|
2018-12-11 12:25:44 +03:00
|
|
|
flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER;
|
2012-12-05 21:12:18 +04:00
|
|
|
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
2013-09-10 12:29:45 +04:00
|
|
|
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
|
2019-11-06 17:24:51 +03:00
|
|
|
settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
|
2015-03-16 16:26:38 +03:00
|
|
|
|
|
|
|
if (!settings)
|
|
|
|
return -1;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
CommandLineClearArgumentsA(largs);
|
|
|
|
status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
|
2017-02-20 20:31:58 +03:00
|
|
|
freerdp_client_old_command_line_pre_filter, NULL);
|
2013-11-01 05:12:06 +04:00
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
if (status < 0)
|
2013-11-01 05:12:06 +04:00
|
|
|
{
|
|
|
|
free(settings);
|
2013-09-09 18:07:14 +04:00
|
|
|
return status;
|
2013-11-01 05:12:06 +04:00
|
|
|
}
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = largs;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "a")
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
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))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
detect_status = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
CommandLineSwitchEnd(arg)(*count)++;
|
|
|
|
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
|
|
|
|
detect_status = -1;
|
|
|
|
|
|
|
|
if (detect_status == 0)
|
|
|
|
{
|
|
|
|
if (settings->ServerHostname)
|
|
|
|
detect_status = 1;
|
|
|
|
}
|
|
|
|
|
2015-05-11 10:07:39 +03:00
|
|
|
free(settings->ServerHostname);
|
2012-12-05 21:12:18 +04:00
|
|
|
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;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
2019-10-28 12:10:14 +03:00
|
|
|
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(old_args)];
|
|
|
|
memcpy(largs, old_args, sizeof(old_args));
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
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;
|
2013-09-10 12:29:45 +04:00
|
|
|
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
|
2019-10-28 12:10:14 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
|
2019-11-06 17:24:51 +03:00
|
|
|
freerdp_client_old_command_line_pre_filter,
|
|
|
|
freerdp_client_old_command_line_post_filter);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
freerdp_client_print_version();
|
|
|
|
return COMMAND_LINE_STATUS_PRINT_VERSION;
|
|
|
|
}
|
|
|
|
else if (status == COMMAND_LINE_STATUS_PRINT)
|
|
|
|
{
|
|
|
|
return COMMAND_LINE_STATUS_PRINT;
|
|
|
|
}
|
2013-09-09 18:07:14 +04:00
|
|
|
else if (status < 0)
|
|
|
|
{
|
|
|
|
if (status != COMMAND_LINE_STATUS_PRINT_HELP)
|
|
|
|
{
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
freerdp_client_print_command_line_help(argc, argv);
|
|
|
|
return COMMAND_LINE_STATUS_PRINT_HELP;
|
|
|
|
}
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = largs;
|
2017-11-14 18:10:52 +03:00
|
|
|
errno = 0;
|
2018-12-14 13:51:50 +03:00
|
|
|
settings->BitmapCacheEnabled = TRUE;
|
|
|
|
settings->OffscreenSupportLevel = TRUE;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "0")
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
settings->ConsoleSession = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-0 -> /admin");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "a")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > INT8_MAX))
|
2017-11-30 18:56:45 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
|
|
|
settings->ColorDepth = val;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-a %s -> /bpp:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "c")
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-c %s -> /shell-dir:%s", arg->Value, arg->Value);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ShellWorkingDirectory = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "D")
|
|
|
|
{
|
|
|
|
settings->Decorations = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-D -> -decorations");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "T")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->WindowTitle = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-T %s -> /title:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "d")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->Domain = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-d %s -> /d:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "f")
|
|
|
|
{
|
|
|
|
settings->Fullscreen = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-f -> /f");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "g")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(str = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
p = strchr(str, 'x');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long h, w = strtoul(str, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (w == 0) || (w > UINT16_MAX))
|
|
|
|
{
|
|
|
|
free(str);
|
2017-11-30 18:56:45 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-14 18:10:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
h = strtoul(&p[1], NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (h == 0) || (h > UINT16_MAX))
|
|
|
|
{
|
|
|
|
free(str);
|
2017-11-30 18:56:45 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-14 18:10:52 +03:00
|
|
|
}
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
*p = '\0';
|
2017-11-14 18:10:52 +03:00
|
|
|
settings->DesktopWidth = w;
|
|
|
|
settings->DesktopHeight = h;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
free(str);
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-g %s -> /size:%s or /w:%" PRIu32 " /h:%" PRIu32 "", arg->Value,
|
|
|
|
arg->Value, settings->DesktopWidth, settings->DesktopHeight);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "k")
|
|
|
|
{
|
|
|
|
sscanf(arg->Value, "%X", &(settings->KeyboardLayout));
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-k %s -> /kbd:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "K")
|
|
|
|
{
|
|
|
|
settings->GrabKeyboard = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-K -> -grab-keyboard");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "n")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ClientHostname = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-n -> /client-hostname:%s", arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "o")
|
|
|
|
{
|
|
|
|
settings->RemoteConsoleAudio = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-o -> /audio-mode:1");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "p")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->Password = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-p ****** -> /p:******");
|
2013-07-30 02:50:38 +04:00
|
|
|
/* Hide the value from 'ps'. */
|
|
|
|
FillMemory(arg->Value, strlen(arg->Value), '*');
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "s")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AlternateShell = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-s %s -> /shell:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "t")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long p = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (p == 0) || (p > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->ServerPort = p;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-t %s -> /port:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "u")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->Username = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-u %s -> /u:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "x")
|
|
|
|
{
|
2019-01-29 18:22:46 +03:00
|
|
|
unsigned long type;
|
2012-12-05 21:12:18 +04:00
|
|
|
char* pEnd;
|
2019-01-29 18:22:46 +03:00
|
|
|
type = strtoul(arg->Value, &pEnd, 16);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
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;
|
2013-09-17 22:56:23 +04:00
|
|
|
freerdp_performance_flags_split(settings);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-x %s -> /network:", arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
if (type == CONNECTION_TYPE_MODEM)
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "modem");
|
2012-12-05 21:12:18 +04:00
|
|
|
else if (CONNECTION_TYPE_BROADBAND_HIGH)
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "broadband");
|
2012-12-05 21:12:18 +04:00
|
|
|
else if (CONNECTION_TYPE_LAN)
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "lan");
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "X")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
settings->ParentWindowId = _strtoui64(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-X %s -> /parent-window:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "z")
|
|
|
|
{
|
|
|
|
settings->CompressionEnabled = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "-z -> /compression");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app")
|
|
|
|
{
|
|
|
|
settings->RemoteApplicationMode = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--app -> /app: + program name or alias");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "ext")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-auth")
|
|
|
|
{
|
|
|
|
settings->Authentication = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-auth -> -authentication");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "authonly")
|
|
|
|
{
|
|
|
|
settings->AuthenticationOnly = TRUE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "from-stdin")
|
|
|
|
{
|
|
|
|
settings->CredentialsFromStdin = TRUE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-fastpath")
|
|
|
|
{
|
|
|
|
settings->FastPathInput = FALSE;
|
|
|
|
settings->FastPathOutput = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-fastpath -> -fast-path");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-motion")
|
|
|
|
{
|
|
|
|
settings->MouseMotion = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-motion -> -mouse-motion");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gdi")
|
|
|
|
{
|
|
|
|
if (strcmp(arg->Value, "sw") == 0)
|
|
|
|
settings->SoftwareGdi = TRUE;
|
|
|
|
else if (strcmp(arg->Value, "hw") == 0)
|
|
|
|
settings->SoftwareGdi = FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--gdi %s -> /gdi:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-osb")
|
|
|
|
{
|
|
|
|
settings->OffscreenSupportLevel = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-osb -> -offscreen-cache");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-bmp-cache")
|
|
|
|
{
|
|
|
|
settings->BitmapCacheEnabled = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-bmp-cache -> -bitmap-cache");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "plugin")
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--plugin -> /a, /vc, /dvc and channel-specific options");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "rfx")
|
|
|
|
{
|
|
|
|
settings->RemoteFxCodec = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--rfx -> /rfx");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "rfx-mode")
|
|
|
|
{
|
|
|
|
if (arg->Value[0] == 'v')
|
|
|
|
settings->RemoteFxCodecMode = 0x00;
|
|
|
|
else if (arg->Value[0] == 'i')
|
|
|
|
settings->RemoteFxCodecMode = 0x02;
|
2013-02-18 16:49:52 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--rfx-mode -> /rfx-mode:%s",
|
|
|
|
settings->RemoteFxCodecMode ? "image" : "video");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "nsc")
|
|
|
|
{
|
|
|
|
settings->NSCodec = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--nsc -> /nsc");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "disable-wallpaper")
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--disable-wallpaper -> -wallpaper");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "composition")
|
|
|
|
{
|
|
|
|
settings->AllowDesktopComposition = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--composition -> +composition");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "disable-full-window-drag")
|
|
|
|
{
|
|
|
|
settings->DisableFullWindowDrag = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--disable-full-window-drag -> -window-drag");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "disable-menu-animations")
|
|
|
|
{
|
|
|
|
settings->DisableMenuAnims = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--disable-menu-animations -> -menu-anims");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "disable-theming")
|
|
|
|
{
|
|
|
|
settings->DisableThemes = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--disable-theming -> -themes");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "ntlm")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "ignore-certificate")
|
|
|
|
{
|
|
|
|
settings->IgnoreCertificate = TRUE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--ignore-certificate -> /cert-ignore");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec")
|
|
|
|
{
|
|
|
|
if (strncmp("rdp", arg->Value, 1) == 0) /* Standard RDP */
|
|
|
|
{
|
|
|
|
settings->RdpSecurity = TRUE;
|
|
|
|
settings->TlsSecurity = FALSE;
|
|
|
|
settings->NlaSecurity = FALSE;
|
Standard RDP Security Layer Levels/Method Overhaul
[MS-RDPBCGR] Section 5.3 describes the encryption level and method values for
standard RDP security.
Looking at the current usage of these values in the FreeRDP code gives me
reason to believe that there is a certain lack of understanding of how these
values should be handled.
The encryption level is only configured on the server side in the "Encryption
Level" setting found in the Remote Desktop Session Host Configuration RDP-Tcp
properties dialog and this value is never transferred from the client to the
server over the wire.
The possible options are "None", "Low", "Client Compatible", "High" and
"FIPS Compliant". The client receices this value in the Server Security Data
block (TS_UD_SC_SEC1), probably only for informational purposes and maybe to
give the client the possibility to verify if the server's decision for the
encryption method confirms to the server's encryption level.
The possible encryption methods are "NONE", "40BIT", "56BIT", "128BIT" and
"FIPS" and the RDP client advertises the ones it supports to the server in the
Client Security Data block (TS_UD_CS_SEC).
The server's configured encryption level value restricts the possible final
encryption method.
Something that I was not able to find in the documentation is the priority
level of the individual encryption methods based on which the server makes its
final method decision if there are several options.
My analysis with Windows Servers reveiled that the order is 128, 56, 40, FIPS.
The server only chooses FIPS if the level is "FIPS Comliant" or if it is the
only method advertised by the client.
Bottom line:
* FreeRDP's client side does not need to set settings->EncryptionLevel
(which was done quite frequently).
* FreeRDP's server side does not have to set the supported encryption methods
list in settings->EncryptionMethods
Changes in this commit:
Removed unnecessary/confusing changes of EncryptionLevel/Methods settings
Refactor settings->DisableEncryption
* This value actually means "Advanced RDP Encryption (NLA/TLS) is NOT used"
* The old name caused lots of confusion among developers
* Renamed it to "UseRdpSecurityLayer" (the compare logic stays untouched)
Any client's setting of settings->EncryptionMethods were annihilated
* All clients "want" to set all supported methods
* Some clients forgot 56bit because 56bit was not supported at the time the
code was written
* settings->EncryptionMethods was overwritten anyways in nego_connect()
* Removed all client side settings of settings->EncryptionMethods
The default is "None" (0)
* Changed nego_connect() to advertise all supported methods if
settings->EncryptionMethods is 0 (None)
* Added a commandline option /encryption-methods:comma separated list of the
values "40", "56", "128", "FIPS". E.g. /encryption-methods:56,128
* Print warning if server chooses non-advertised method
Verify received level and method in client's gcc_read_server_security_data
* Only accept valid/known encryption methods
* Verify encryption level/method combinations according to MS-RDPBCGR 5.3.2
Server implementations can now set settings->EncryptionLevel
* The default for settings->EncryptionLevel is 0 (None)
* nego_send_negotiation_response() changes it to ClientCompatible in that case
* default to ClientCompatible if the server implementation set an invalid level
Fix server's gcc_write_server_security_data
* Verify server encryption level value set by server implementations
* Choose rdp encryption method based on level and supported client methods
* Moved FIPS to the lowest priority (only used if other methods are possible)
Updated sample server
* Support RDP Security (RdpKeyFile was not set)
* Added commented sample code for setting the security level
2014-12-12 04:17:12 +03:00
|
|
|
settings->UseRdpSecurityLayer = FALSE;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--sec %s -> /sec:%s", arg->Value, arg->Value);
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-rdp")
|
|
|
|
{
|
|
|
|
settings->RdpSecurity = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-rdp -> -sec-rdp");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-tls")
|
|
|
|
{
|
|
|
|
settings->TlsSecurity = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-tls -> -sec-tls");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "no-nla")
|
|
|
|
{
|
|
|
|
settings->NlaSecurity = FALSE;
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "--no-nla -> -sec-nla");
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "secure-checksum")
|
|
|
|
{
|
|
|
|
settings->SaltedChecksum = TRUE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CommandLineSwitchEnd(arg)
|
2019-11-06 17:24:51 +03:00
|
|
|
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "%s -> /v:%s", settings->ServerHostname, settings->ServerHostname);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
if (settings->ServerPort != 3389)
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, " /port:%" PRIu32 "", settings->ServerPort);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_WARN(TAG, "");
|
2017-11-30 18:56:45 +03:00
|
|
|
return 0;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|