2012-11-06 07:11:13 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* FreeRDP Client Command-Line Interface
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
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
|
|
|
* Copyright 2014 Norbert Federa <norbert.federa@thincast.com>
|
2016-02-26 16:50:27 +03:00
|
|
|
* Copyright 2016 Armin Novak <armin.novak@gmail.com>
|
2012-11-06 07:11:13 +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
|
|
|
|
|
2016-12-11 01:13:35 +03:00
|
|
|
#include <ctype.h>
|
2013-10-02 11:48:25 +04:00
|
|
|
#include <assert.h>
|
2017-11-14 18:10:52 +03:00
|
|
|
#include <errno.h>
|
2013-10-02 11:48:25 +04:00
|
|
|
|
2012-11-06 07:11:13 +04:00
|
|
|
#include <winpr/crt.h>
|
2016-01-23 17:16:13 +03:00
|
|
|
#include <winpr/wlog.h>
|
2017-11-30 18:56:45 +03:00
|
|
|
#include <winpr/path.h>
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2012-11-18 07:03:04 +04:00
|
|
|
#include <freerdp/addin.h>
|
2012-11-09 23:35:21 +04:00
|
|
|
#include <freerdp/settings.h>
|
2012-11-09 04:01:52 +04:00
|
|
|
#include <freerdp/client/channels.h>
|
2013-10-22 19:14:29 +04:00
|
|
|
#include <freerdp/crypto/crypto.h>
|
2012-11-27 01:49:12 +04:00
|
|
|
#include <freerdp/locale/keyboard.h>
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2017-11-10 13:52:23 +03:00
|
|
|
#include <freerdp/utils/passphrase.h>
|
2014-09-12 19:13:01 +04:00
|
|
|
|
2012-11-06 07:11:13 +04:00
|
|
|
#include <freerdp/client/cmdline.h>
|
2013-11-06 20:29:33 +04:00
|
|
|
#include <freerdp/version.h>
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2012-12-05 21:12:18 +04:00
|
|
|
#include "compatibility.h"
|
2018-02-01 18:59:55 +03:00
|
|
|
#include "cmdline.h"
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2014-09-12 19:13:01 +04:00
|
|
|
#include <freerdp/log.h>
|
|
|
|
#define TAG CLIENT_TAG("common.cmdline")
|
|
|
|
|
2017-05-04 15:46:58 +03:00
|
|
|
BOOL freerdp_client_print_version(void)
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
2017-10-06 14:52:10 +03:00
|
|
|
printf("This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL,
|
2016-08-04 17:13:37 +03:00
|
|
|
GIT_REVISION);
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
|
2017-05-04 15:46:58 +03:00
|
|
|
BOOL freerdp_client_print_buildconfig(void)
|
2016-01-11 18:18:40 +03:00
|
|
|
{
|
2016-01-28 16:26:50 +03:00
|
|
|
printf("%s", freerdp_get_build_config());
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2016-01-11 18:18:40 +03:00
|
|
|
}
|
|
|
|
|
2017-05-04 15:46:58 +03:00
|
|
|
static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* arg)
|
2012-11-07 03:49:02 +04:00
|
|
|
{
|
2017-05-04 15:46:58 +03:00
|
|
|
if (!arg)
|
|
|
|
return;
|
2012-11-07 03:49:02 +04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_FLAG)
|
|
|
|
{
|
2014-09-16 23:07:38 +04:00
|
|
|
printf(" %s", "/");
|
|
|
|
printf("%-20s", arg->Name);
|
|
|
|
printf("\t%s\n", arg->Text);
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
else if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED)
|
|
|
|
|| (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
2012-11-07 03:49:02 +04:00
|
|
|
{
|
2017-09-25 12:44:07 +03:00
|
|
|
BOOL overlong = FALSE;
|
2014-09-16 23:07:38 +04:00
|
|
|
printf(" %s", "/");
|
2012-11-07 03:49:02 +04:00
|
|
|
|
|
|
|
if (arg->Format)
|
|
|
|
{
|
2017-05-04 15:46:58 +03:00
|
|
|
size_t length = (strlen(arg->Name) + strlen(arg->Format) + 2);
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-09-25 12:44:07 +03:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
|
|
|
|
length += 2;
|
|
|
|
|
|
|
|
if (length >= 20 + 8 + 8)
|
|
|
|
overlong = TRUE;
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
|
2017-05-04 15:46:58 +03:00
|
|
|
printf("%s[:%s]", arg->Name, overlong ? "..." : arg->Format);
|
2017-09-25 12:44:07 +03:00
|
|
|
else
|
2017-05-04 15:46:58 +03:00
|
|
|
printf("%s:%s", arg->Name, overlong ? "..." : arg->Format);
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("%-20s", arg->Name);
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\t%s\n", arg->Text);
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
|
|
|
else if (arg->Flags & COMMAND_LINE_VALUE_BOOL)
|
|
|
|
{
|
2014-09-16 23:07:38 +04:00
|
|
|
printf(" %s", arg->Default ? "-" : "+");
|
2017-09-25 12:44:07 +03:00
|
|
|
printf("%-20s", arg->Name);
|
2018-05-17 11:08:05 +03:00
|
|
|
printf("\t%s %s\n", arg->Default ? "Disable" : "Enable", arg->Text);
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2017-05-04 15:46:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
|
|
|
{
|
|
|
|
return freerdp_client_print_command_line_help_ex(argc, argv, NULL);
|
|
|
|
}
|
2012-11-07 03:49:02 +04:00
|
|
|
|
2017-05-04 15:46:58 +03:00
|
|
|
BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
|
|
|
COMMAND_LINE_ARGUMENT_A* custom)
|
|
|
|
{
|
|
|
|
printf("\n");
|
|
|
|
printf("FreeRDP - A Free Remote Desktop Protocol Implementation\n");
|
|
|
|
printf("See www.freerdp.com for more information\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
|
|
|
|
printf("\n");
|
|
|
|
printf("Syntax:\n");
|
|
|
|
printf(" /flag (enables flag)\n");
|
|
|
|
printf(" /option:<value> (specifies option with value)\n");
|
|
|
|
printf(" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n");
|
|
|
|
printf("\n");
|
|
|
|
freerdp_client_print_command_line_args(custom);
|
|
|
|
freerdp_client_print_command_line_args(args);
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\n");
|
|
|
|
printf("Examples:\n");
|
|
|
|
printf(" xfreerdp connection.rdp /p:Pwd123! /f\n");
|
|
|
|
printf(" xfreerdp /u:CONTOSO\\JohnDoe /p:Pwd123! /v:rdp.contoso.com\n");
|
|
|
|
printf(" xfreerdp /u:JohnDoe /p:Pwd123! /w:1366 /h:768 /v:192.168.1.100:4489\n");
|
|
|
|
printf(" xfreerdp /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 /v:192.168.1.100\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("Clipboard Redirection: +clipboard\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("Drive Redirection: /drive:home,/home/user\n");
|
|
|
|
printf("Smartcard Redirection: /smartcard:<device>\n");
|
2014-09-16 14:08:33 +04:00
|
|
|
printf("Serial Port Redirection: /serial:<name>,<device>,[SerCx2|SerCx|Serial],[permissive]\n");
|
|
|
|
printf("Serial Port Redirection: /serial:COM1,/dev/ttyS0\n");
|
2017-12-21 17:19:29 +03:00
|
|
|
printf("Parallel Port Redirection: /parallel:<name>,<device>\n");
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("Printer Redirection: /printer:<device>,<driver>\n");
|
|
|
|
printf("\n");
|
2015-03-17 05:10:58 +03:00
|
|
|
printf("Audio Output Redirection: /sound:sys:oss,dev:1,format:1\n");
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("Audio Output Redirection: /sound:sys:alsa\n");
|
2015-03-17 05:10:58 +03:00
|
|
|
printf("Audio Input Redirection: /microphone:sys:oss,dev:1,format:1\n");
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("Audio Input Redirection: /microphone:sys:alsa\n");
|
|
|
|
printf("\n");
|
2015-03-17 05:10:58 +03:00
|
|
|
printf("Multimedia Redirection: /multimedia:sys:oss,dev:/dev/dsp1,decoder:ffmpeg\n");
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("Multimedia Redirection: /multimedia:sys:alsa\n");
|
|
|
|
printf("USB Device Redirection: /usb:id,dev:054c:0268\n");
|
|
|
|
printf("\n");
|
2014-03-22 04:24:43 +04:00
|
|
|
printf("For Gateways, the https_proxy environment variable is respected:\n");
|
2014-03-22 18:58:16 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
printf(" set HTTPS_PROXY=http://proxy.contoso.com:3128/\n");
|
|
|
|
#else
|
2014-03-22 04:24:43 +04:00
|
|
|
printf(" export https_proxy=http://proxy.contoso.com:3128/\n");
|
2014-03-22 18:58:16 +04:00
|
|
|
#endif
|
2014-03-22 04:24:43 +04:00
|
|
|
printf(" xfreerdp /g:rdp.contoso.com ...\n");
|
|
|
|
printf("\n");
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("More documentation is coming, in the meantime consult source files\n");
|
|
|
|
printf("\n");
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
static int freerdp_client_command_line_pre_filter(void* context, int index,
|
2018-08-01 12:56:04 +03:00
|
|
|
int argc, LPSTR* argv)
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
|
|
|
if (index == 1)
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
rdpSettings* settings;
|
2014-02-10 10:06:11 +04:00
|
|
|
length = (int) strlen(argv[index]);
|
2012-11-07 07:08:09 +04:00
|
|
|
|
|
|
|
if (length > 4)
|
|
|
|
{
|
2012-12-05 21:12:18 +04:00
|
|
|
if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
|
|
|
settings = (rdpSettings*) context;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ConnectionFile = _strdup(argv[index])))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-12-05 23:00:49 +04:00
|
|
|
|
|
|
|
return 1;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
}
|
2014-06-29 02:33:46 +04:00
|
|
|
|
|
|
|
if (length > 13)
|
|
|
|
{
|
|
|
|
if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
|
|
|
|
{
|
|
|
|
settings = (rdpSettings*) context;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AssistanceFile = _strdup(argv[index])))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2014-06-29 02:33:46 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
|
2012-12-05 23:00:49 +04:00
|
|
|
return 0;
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
BOOL freerdp_client_add_device_channel(rdpSettings* settings, int count,
|
|
|
|
char** params)
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
|
|
|
if (strcmp(params[0], "drive") == 0)
|
|
|
|
{
|
|
|
|
RDPDR_DRIVE* drive;
|
|
|
|
|
|
|
|
if (count < 3)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
settings->DeviceRedirection = TRUE;
|
2014-03-26 19:05:12 +04:00
|
|
|
drive = (RDPDR_DRIVE*) calloc(1, sizeof(RDPDR_DRIVE));
|
|
|
|
|
|
|
|
if (!drive)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
|
|
|
drive->Type = RDPDR_DTYP_FILESYSTEM;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (count > 1)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(drive->Name = _strdup(params[1])))
|
|
|
|
{
|
|
|
|
free(drive);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (count > 2)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2017-12-28 16:05:11 +03:00
|
|
|
const BOOL isPath = PathFileExistsA(params[2]);
|
|
|
|
const BOOL isSpecial = (strncmp(params[2], "*", 2) == 0) ||
|
|
|
|
(strncmp(params[2], "%", 2) == 0) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if ((!isPath && !isSpecial) || !(drive->Path = _strdup(params[2])))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
free(drive->Name);
|
|
|
|
free(drive);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) drive))
|
|
|
|
{
|
|
|
|
free(drive->Path);
|
|
|
|
free(drive->Name);
|
|
|
|
free(drive);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
else if (strcmp(params[0], "printer") == 0)
|
|
|
|
{
|
|
|
|
RDPDR_PRINTER* printer;
|
|
|
|
|
2013-05-20 23:50:22 +04:00
|
|
|
if (count < 1)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
settings->RedirectPrinters = TRUE;
|
|
|
|
settings->DeviceRedirection = TRUE;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
if (count > 1)
|
|
|
|
{
|
|
|
|
printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
if (!printer)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2013-05-20 23:50:22 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
printer->Type = RDPDR_DTYP_PRINT;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
if (count > 1)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(printer->Name = _strdup(params[1])))
|
|
|
|
{
|
|
|
|
free(printer);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
if (count > 2)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(printer->DriverName = _strdup(params[2])))
|
|
|
|
{
|
|
|
|
free(printer->Name);
|
|
|
|
free(printer);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer))
|
|
|
|
{
|
|
|
|
free(printer->DriverName);
|
|
|
|
free(printer->Name);
|
|
|
|
free(printer);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
2014-04-28 05:29:44 +04:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
else if (strcmp(params[0], "smartcard") == 0)
|
|
|
|
{
|
|
|
|
RDPDR_SMARTCARD* smartcard;
|
|
|
|
|
2013-09-12 14:18:35 +04:00
|
|
|
if (count < 1)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
settings->RedirectSmartCards = TRUE;
|
|
|
|
settings->DeviceRedirection = TRUE;
|
2017-12-11 16:00:09 +03:00
|
|
|
smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2017-12-11 16:00:09 +03:00
|
|
|
if (!smartcard)
|
|
|
|
return FALSE;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2017-12-11 16:00:09 +03:00
|
|
|
smartcard->Type = RDPDR_DTYP_SMARTCARD;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2017-12-11 16:00:09 +03:00
|
|
|
if (count > 1 && strlen(params[1]))
|
|
|
|
{
|
|
|
|
if (!(smartcard->Name = _strdup(params[1])))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
free(smartcard);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
2014-04-28 05:29:44 +04:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2017-12-11 16:00:09 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard))
|
|
|
|
{
|
|
|
|
free(smartcard->Name);
|
|
|
|
free(smartcard);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
else if (strcmp(params[0], "serial") == 0)
|
|
|
|
{
|
|
|
|
RDPDR_SERIAL* serial;
|
|
|
|
|
2013-09-12 14:18:35 +04:00
|
|
|
if (count < 1)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
settings->RedirectSerialPorts = TRUE;
|
|
|
|
settings->DeviceRedirection = TRUE;
|
2014-03-26 19:05:12 +04:00
|
|
|
serial = (RDPDR_SERIAL*) calloc(1, sizeof(RDPDR_SERIAL));
|
|
|
|
|
|
|
|
if (!serial)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
|
|
|
serial->Type = RDPDR_DTYP_SERIAL;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2013-09-12 14:18:35 +04:00
|
|
|
if (count > 1)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(serial->Name = _strdup(params[1])))
|
|
|
|
{
|
|
|
|
free(serial);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2013-09-12 14:18:35 +04:00
|
|
|
if (count > 2)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(serial->Path = _strdup(params[2])))
|
|
|
|
{
|
|
|
|
free(serial->Name);
|
|
|
|
free(serial);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-06-18 20:20:21 +04:00
|
|
|
if (count > 3)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(serial->Driver = _strdup(params[3])))
|
|
|
|
{
|
|
|
|
free(serial->Path);
|
|
|
|
free(serial->Name);
|
|
|
|
free(serial);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2014-06-18 20:20:21 +04:00
|
|
|
|
2014-09-16 14:08:33 +04:00
|
|
|
if (count > 4)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(serial->Permissive = _strdup(params[4])))
|
|
|
|
{
|
|
|
|
free(serial->Driver);
|
|
|
|
free(serial->Path);
|
|
|
|
free(serial->Name);
|
|
|
|
free(serial);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2014-09-16 14:08:33 +04:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial))
|
|
|
|
{
|
|
|
|
free(serial->Permissive);
|
|
|
|
free(serial->Driver);
|
|
|
|
free(serial->Path);
|
|
|
|
free(serial->Name);
|
|
|
|
free(serial);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
else if (strcmp(params[0], "parallel") == 0)
|
|
|
|
{
|
|
|
|
RDPDR_PARALLEL* parallel;
|
|
|
|
|
2013-09-12 14:18:35 +04:00
|
|
|
if (count < 1)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
settings->RedirectParallelPorts = TRUE;
|
|
|
|
settings->DeviceRedirection = TRUE;
|
2014-03-26 19:05:12 +04:00
|
|
|
parallel = (RDPDR_PARALLEL*) calloc(1, sizeof(RDPDR_PARALLEL));
|
|
|
|
|
|
|
|
if (!parallel)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
|
|
|
parallel->Type = RDPDR_DTYP_PARALLEL;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2013-09-12 14:18:35 +04:00
|
|
|
if (count > 1)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(parallel->Name = _strdup(params[1])))
|
|
|
|
{
|
|
|
|
free(parallel);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2014-04-08 21:23:02 +04:00
|
|
|
if (count > 2)
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
if (!(parallel->Path = _strdup(params[2])))
|
|
|
|
{
|
|
|
|
free(parallel->Name);
|
|
|
|
free(parallel);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) parallel))
|
|
|
|
{
|
|
|
|
free(parallel->Path);
|
|
|
|
free(parallel->Name);
|
|
|
|
free(parallel);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
BOOL freerdp_client_add_static_channel(rdpSettings* settings, int count,
|
|
|
|
char** params)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
|
|
|
int index;
|
2012-11-19 22:26:56 +04:00
|
|
|
ADDIN_ARGV* args;
|
2017-02-22 15:46:47 +03:00
|
|
|
|
|
|
|
if (!settings || !params || !params[0])
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (freerdp_static_channel_collection_find(settings, params[0]))
|
|
|
|
return TRUE;
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
args = (ADDIN_ARGV*) calloc(1, sizeof(ADDIN_ARGV));
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!args)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
args->argc = count;
|
2015-03-23 18:07:40 +03:00
|
|
|
args->argv = (char**) calloc(args->argc, sizeof(char*));
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!args->argv)
|
|
|
|
goto error_argv;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
for (index = 0; index < args->argc; index++)
|
2015-06-16 16:42:07 +03:00
|
|
|
{
|
2012-11-19 22:26:56 +04:00
|
|
|
args->argv[index] = _strdup(params[index]);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!args->argv[index])
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
for (--index; index >= 0; --index)
|
|
|
|
free(args->argv[index]);
|
|
|
|
|
|
|
|
goto error_argv_strdup;
|
|
|
|
}
|
2015-06-16 16:42:07 +03:00
|
|
|
}
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!freerdp_static_channel_collection_add(settings, args))
|
|
|
|
goto error_argv_index;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2015-06-16 16:42:07 +03:00
|
|
|
error_argv_index:
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
for (index = 0; index < args->argc; index++)
|
|
|
|
free(args->argv[index]);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
error_argv_strdup:
|
2015-06-16 16:42:07 +03:00
|
|
|
free(args->argv);
|
|
|
|
error_argv:
|
|
|
|
free(args);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, int count,
|
|
|
|
char** params)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
|
|
|
int index;
|
2012-11-19 22:26:56 +04:00
|
|
|
ADDIN_ARGV* args;
|
2017-02-22 15:46:47 +03:00
|
|
|
|
|
|
|
if (!settings || !params || !params[0])
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (freerdp_dynamic_channel_collection_find(settings, params[0]))
|
|
|
|
return TRUE;
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!args)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
args->argc = count;
|
2015-03-23 18:07:40 +03:00
|
|
|
args->argv = (char**) calloc(args->argc, sizeof(char*));
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!args->argv)
|
|
|
|
goto error_argv;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
for (index = 0; index < args->argc; index++)
|
2015-06-16 16:42:07 +03:00
|
|
|
{
|
2012-11-19 22:26:56 +04:00
|
|
|
args->argv[index] = _strdup(params[index]);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!args->argv[index])
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
|
|
|
for (--index; index >= 0; --index)
|
|
|
|
free(args->argv[index]);
|
|
|
|
|
|
|
|
goto error_argv_strdup;
|
|
|
|
}
|
2015-06-16 16:42:07 +03:00
|
|
|
}
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
if (!freerdp_dynamic_channel_collection_add(settings, args))
|
|
|
|
goto error_argv_index;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2015-06-16 16:42:07 +03:00
|
|
|
error_argv_index:
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-16 16:42:07 +03:00
|
|
|
for (index = 0; index < args->argc; index++)
|
|
|
|
free(args->argv[index]);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
error_argv_strdup:
|
2015-06-16 16:42:07 +03:00
|
|
|
free(args->argv);
|
|
|
|
error_argv:
|
|
|
|
free(args);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2017-12-28 16:05:11 +03:00
|
|
|
static char** freerdp_command_line_parse_comma_separated_values_ex(const char* name,
|
|
|
|
const char* list,
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t* count)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
|
|
|
char** p;
|
|
|
|
char* str;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t nArgs;
|
|
|
|
size_t index;
|
|
|
|
size_t nCommas;
|
|
|
|
size_t prefix, len;
|
2015-01-15 15:57:28 +03:00
|
|
|
nCommas = 0;
|
2013-10-02 11:48:25 +04:00
|
|
|
assert(NULL != count);
|
|
|
|
*count = 0;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2013-09-12 16:55:25 +04:00
|
|
|
if (!list)
|
2017-11-30 18:56:45 +03:00
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
{
|
2018-06-19 13:55:29 +03:00
|
|
|
size_t len = strlen(name);
|
|
|
|
p = (char**) calloc(1UL + len, sizeof(char*));
|
2017-11-30 18:56:45 +03:00
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2018-06-19 13:55:29 +03:00
|
|
|
char* dst = (char*)&p[1];
|
|
|
|
p[0] = dst;
|
|
|
|
strncpy(dst, name, len);
|
2017-11-30 18:56:45 +03:00
|
|
|
*count = 1;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 16:55:25 +04:00
|
|
|
return NULL;
|
2017-11-30 18:56:45 +03:00
|
|
|
}
|
2013-09-12 16:55:25 +04:00
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
{
|
|
|
|
const char* it = list;
|
2017-12-28 16:05:11 +03:00
|
|
|
|
|
|
|
while ((it = strchr(it, ',')) != NULL)
|
2017-11-30 18:56:45 +03:00
|
|
|
{
|
|
|
|
it++;
|
|
|
|
nCommas++;
|
|
|
|
}
|
|
|
|
}
|
2012-11-18 09:08:03 +04:00
|
|
|
|
|
|
|
nArgs = nCommas + 1;
|
2017-11-30 18:56:45 +03:00
|
|
|
|
|
|
|
if (name)
|
|
|
|
nArgs++;
|
|
|
|
|
|
|
|
prefix = (nArgs + 1UL) * sizeof(char*);
|
|
|
|
len = strlen(list);
|
2017-12-21 11:34:35 +03:00
|
|
|
p = (char**) calloc(len + prefix + 1, sizeof(char*));
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!p)
|
|
|
|
return NULL;
|
2012-11-19 02:32:18 +04:00
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
str = &((char*)p)[prefix];
|
|
|
|
memcpy(str, list, len);
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
p[0] = (char*)name;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
for (index = name ? 1 : 0; index < nArgs; index++)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2017-11-30 18:56:45 +03:00
|
|
|
char* comma = strchr(str, ',');
|
|
|
|
p[index] = str;
|
|
|
|
|
|
|
|
if (comma)
|
|
|
|
{
|
|
|
|
str = comma + 1;
|
|
|
|
*comma = '\0';
|
|
|
|
}
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*count = nArgs;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
static char** freerdp_command_line_parse_comma_separated_values(char* list,
|
|
|
|
size_t* count)
|
2013-02-18 16:32:15 +04:00
|
|
|
{
|
2017-11-30 18:56:45 +03:00
|
|
|
return freerdp_command_line_parse_comma_separated_values_ex(NULL, list, count);
|
|
|
|
}
|
2013-02-18 16:32:15 +04:00
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
static char** freerdp_command_line_parse_comma_separated_values_offset(
|
|
|
|
const char* name, char* list, size_t* count)
|
|
|
|
{
|
|
|
|
return freerdp_command_line_parse_comma_separated_values_ex(name, list, count);
|
2013-02-18 16:32:15 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
static int freerdp_client_command_line_post_filter(void* context,
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg)
|
2012-11-07 08:07:03 +04:00
|
|
|
{
|
2013-02-19 04:29:50 +04:00
|
|
|
rdpSettings* settings = (rdpSettings*) context;
|
2017-11-30 18:56:45 +03:00
|
|
|
BOOL status = TRUE;
|
2012-11-07 08:07:03 +04:00
|
|
|
CommandLineSwitchStart(arg)
|
2016-08-04 17:13:37 +03:00
|
|
|
CommandLineSwitchCase(arg, "a")
|
2012-11-07 08:07:03 +04:00
|
|
|
{
|
2012-11-18 09:08:03 +04:00
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
2012-11-18 09:08:03 +04:00
|
|
|
p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if ((status = freerdp_client_add_device_channel(settings, count, p)))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2012-11-18 09:08:03 +04:00
|
|
|
settings->DeviceRedirection = TRUE;
|
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2012-11-18 09:08:03 +04:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "vc")
|
|
|
|
{
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
2012-11-18 09:08:03 +04:00
|
|
|
p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
|
2015-06-16 16:42:07 +03:00
|
|
|
status = freerdp_client_add_static_channel(settings, count, p);
|
2012-11-18 09:08:03 +04:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "dvc")
|
|
|
|
{
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
2012-11-18 09:08:03 +04:00
|
|
|
p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
|
2016-02-01 17:09:51 +03:00
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, p);
|
2012-11-18 09:08:03 +04:00
|
|
|
free(p);
|
2012-11-07 08:07:03 +04:00
|
|
|
}
|
2013-02-18 16:49:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "drive")
|
|
|
|
{
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
|
2016-08-04 17:13:37 +03:00
|
|
|
&count);
|
2016-02-01 17:09:51 +03:00
|
|
|
status = freerdp_client_add_device_channel(settings, count, p);
|
2013-02-18 16:49:52 +04:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "serial")
|
|
|
|
{
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
|
2016-08-04 17:13:37 +03:00
|
|
|
&count);
|
2016-02-01 17:09:51 +03:00
|
|
|
status = freerdp_client_add_device_channel(settings, count, p);
|
2013-02-18 16:49:52 +04:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "parallel")
|
|
|
|
{
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
|
2016-08-04 17:13:37 +03:00
|
|
|
&count);
|
2016-02-01 17:09:51 +03:00
|
|
|
status = freerdp_client_add_device_channel(settings, count, p);
|
2013-02-18 16:49:52 +04:00
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "smartcard")
|
|
|
|
{
|
2017-05-04 15:46:58 +03:00
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
|
2017-05-04 15:46:58 +03:00
|
|
|
&count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, p);
|
|
|
|
free(p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "printer")
|
|
|
|
{
|
2017-11-30 18:56:45 +03:00
|
|
|
char** p;
|
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset(arg->Name, arg->Value,
|
|
|
|
&count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, p);
|
|
|
|
free(p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "usb")
|
|
|
|
{
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset("urbdrc", arg->Value,
|
2016-08-04 17:13:37 +03:00
|
|
|
&count);
|
2016-02-01 17:09:51 +03:00
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, p);
|
2013-02-18 16:49:52 +04:00
|
|
|
free(p);
|
|
|
|
}
|
2013-05-09 06:14:16 +04:00
|
|
|
CommandLineSwitchCase(arg, "multitouch")
|
|
|
|
{
|
|
|
|
settings->MultiTouchInput = TRUE;
|
|
|
|
}
|
2013-06-20 02:43:24 +04:00
|
|
|
CommandLineSwitchCase(arg, "gestures")
|
|
|
|
{
|
|
|
|
settings->MultiTouchGestures = TRUE;
|
|
|
|
}
|
2013-03-13 03:23:59 +04:00
|
|
|
CommandLineSwitchCase(arg, "echo")
|
|
|
|
{
|
2014-09-26 01:31:05 +04:00
|
|
|
settings->SupportEchoChannel = TRUE;
|
2013-03-13 03:23:59 +04:00
|
|
|
}
|
2017-06-26 23:16:22 +03:00
|
|
|
CommandLineSwitchCase(arg, "ssh-agent")
|
|
|
|
{
|
|
|
|
settings->SupportSSHAgentChannel = TRUE;
|
|
|
|
}
|
2013-07-10 00:10:59 +04:00
|
|
|
CommandLineSwitchCase(arg, "disp")
|
|
|
|
{
|
2014-09-26 01:31:05 +04:00
|
|
|
settings->SupportDisplayControl = TRUE;
|
2013-07-10 00:10:59 +04:00
|
|
|
}
|
2017-12-06 15:51:45 +03:00
|
|
|
CommandLineSwitchCase(arg, "geometry")
|
|
|
|
{
|
|
|
|
settings->SupportGeometryTracking = TRUE;
|
|
|
|
}
|
2017-12-08 00:50:29 +03:00
|
|
|
CommandLineSwitchCase(arg, "video")
|
|
|
|
{
|
|
|
|
settings->SupportGeometryTracking = TRUE; /* this requires geometry tracking */
|
|
|
|
settings->SupportVideoOptimized = TRUE;
|
|
|
|
}
|
2013-02-18 16:49:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "sound")
|
|
|
|
{
|
2017-11-30 18:56:45 +03:00
|
|
|
char** p;
|
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset("rdpsnd", arg->Value,
|
|
|
|
&count);
|
|
|
|
status = freerdp_client_add_static_channel(settings, count, p);
|
|
|
|
free(p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "microphone")
|
|
|
|
{
|
2017-11-30 18:56:45 +03:00
|
|
|
char** p;
|
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset("audin", arg->Value,
|
|
|
|
&count);
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, p);
|
|
|
|
free(p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "multimedia")
|
|
|
|
{
|
2017-11-30 18:56:45 +03:00
|
|
|
char** p;
|
|
|
|
size_t count;
|
|
|
|
p = freerdp_command_line_parse_comma_separated_values_offset("tsmf", arg->Value,
|
|
|
|
&count);
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, p);
|
|
|
|
free(p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
2014-01-30 07:53:32 +04:00
|
|
|
CommandLineSwitchCase(arg, "heartbeat")
|
|
|
|
{
|
|
|
|
settings->SupportHeartbeatPdu = TRUE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "multitransport")
|
|
|
|
{
|
|
|
|
settings->SupportMultitransport = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
settings->MultitransportFlags = (TRANSPORT_TYPE_UDP_FECR |
|
|
|
|
TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
|
2014-01-30 07:53:32 +04:00
|
|
|
}
|
2017-09-23 15:26:38 +03:00
|
|
|
CommandLineSwitchCase(arg, "password-is-pin")
|
|
|
|
{
|
|
|
|
settings->PasswordIsSmartcardPin = TRUE;
|
|
|
|
}
|
2012-11-07 08:07:03 +04:00
|
|
|
CommandLineSwitchEnd(arg)
|
2017-11-30 18:56:45 +03:00
|
|
|
return status ? 1 : -1;
|
2012-11-07 08:07:03 +04:00
|
|
|
}
|
|
|
|
|
2018-03-08 15:46:46 +03:00
|
|
|
BOOL freerdp_parse_username(const char* username, char** user, char** domain)
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
|
|
|
char* p;
|
2015-06-15 10:47:16 +03:00
|
|
|
int length = 0;
|
2012-11-26 23:31:31 +04:00
|
|
|
p = strchr(username, '\\');
|
2015-06-18 13:24:22 +03:00
|
|
|
*user = NULL;
|
|
|
|
*domain = NULL;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
length = (int)(p - username);
|
2015-06-15 10:47:16 +03:00
|
|
|
*user = _strdup(&p[1]);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-15 10:47:16 +03:00
|
|
|
if (!*user)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-15 10:47:16 +03:00
|
|
|
|
2015-03-23 18:07:40 +03:00
|
|
|
*domain = (char*) calloc(length + 1UL, sizeof(char));
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-15 10:47:16 +03:00
|
|
|
if (!*domain)
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(*user);
|
2015-06-15 10:47:16 +03:00
|
|
|
*user = NULL;
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-15 10:47:16 +03:00
|
|
|
}
|
|
|
|
|
2012-11-26 23:31:31 +04:00
|
|
|
strncpy(*domain, username, length);
|
|
|
|
(*domain)[length] = '\0';
|
2015-06-15 10:47:16 +03:00
|
|
|
}
|
2015-06-18 13:24:22 +03:00
|
|
|
else if (username)
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
2014-08-16 01:45:06 +04:00
|
|
|
/* Do not break up the name for '@'; both credSSP and the
|
|
|
|
* ClientInfo PDU expect 'user@corp.net' to be transmitted
|
2015-06-18 13:24:22 +03:00
|
|
|
* as username 'user@corp.net', domain empty (not NULL!).
|
2014-08-16 01:45:06 +04:00
|
|
|
*/
|
|
|
|
*user = _strdup(username);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-15 10:47:16 +03:00
|
|
|
if (!*user)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-15 10:47:16 +03:00
|
|
|
|
2015-06-18 17:07:09 +03:00
|
|
|
*domain = _strdup("\0");
|
2015-06-18 13:24:22 +03:00
|
|
|
|
|
|
|
if (!*domain)
|
|
|
|
{
|
|
|
|
free(*user);
|
|
|
|
*user = NULL;
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2015-06-18 13:24:22 +03:00
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
2015-06-18 13:24:22 +03:00
|
|
|
else
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
|
|
|
|
2018-03-08 15:46:46 +03:00
|
|
|
BOOL freerdp_parse_hostname(const char* hostname, char** host, int* port)
|
2014-06-12 18:49:29 +04:00
|
|
|
{
|
|
|
|
char* p;
|
|
|
|
p = strrchr(hostname, ':');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val;
|
|
|
|
SSIZE_T length = (p - hostname);
|
|
|
|
errno = 0;
|
|
|
|
val = strtoul(p + 1, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
|
|
|
|
return FALSE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2015-03-23 18:07:40 +03:00
|
|
|
*host = (char*) calloc(length + 1UL, sizeof(char));
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
|
|
if (!(*host))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
|
|
CopyMemory(*host, hostname, length);
|
|
|
|
(*host)[length] = '\0';
|
2017-11-14 18:10:52 +03:00
|
|
|
*port = val;
|
2014-06-12 18:49:29 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*host = _strdup(hostname);
|
|
|
|
|
|
|
|
if (!(*host))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2014-06-12 18:49:29 +04:00
|
|
|
|
|
|
|
*port = -1;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2014-06-12 18:49:29 +04:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
BOOL freerdp_set_connection_type(rdpSettings* settings, int type)
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
2013-04-23 00:08:47 +04:00
|
|
|
settings->ConnectionType = type;
|
2014-09-25 01:23:12 +04:00
|
|
|
|
2012-11-26 23:31:31 +04:00
|
|
|
if (type == CONNECTION_TYPE_MODEM)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = TRUE;
|
|
|
|
settings->AllowFontSmoothing = FALSE;
|
|
|
|
settings->AllowDesktopComposition = FALSE;
|
|
|
|
settings->DisableFullWindowDrag = TRUE;
|
|
|
|
settings->DisableMenuAnims = TRUE;
|
|
|
|
settings->DisableThemes = TRUE;
|
|
|
|
}
|
|
|
|
else if (type == CONNECTION_TYPE_BROADBAND_LOW)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = TRUE;
|
|
|
|
settings->AllowFontSmoothing = FALSE;
|
|
|
|
settings->AllowDesktopComposition = FALSE;
|
|
|
|
settings->DisableFullWindowDrag = TRUE;
|
|
|
|
settings->DisableMenuAnims = TRUE;
|
|
|
|
settings->DisableThemes = FALSE;
|
|
|
|
}
|
|
|
|
else if (type == CONNECTION_TYPE_SATELLITE)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = TRUE;
|
|
|
|
settings->AllowFontSmoothing = FALSE;
|
|
|
|
settings->AllowDesktopComposition = TRUE;
|
|
|
|
settings->DisableFullWindowDrag = TRUE;
|
|
|
|
settings->DisableMenuAnims = TRUE;
|
|
|
|
settings->DisableThemes = FALSE;
|
|
|
|
}
|
|
|
|
else if (type == CONNECTION_TYPE_BROADBAND_HIGH)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = TRUE;
|
|
|
|
settings->AllowFontSmoothing = FALSE;
|
|
|
|
settings->AllowDesktopComposition = TRUE;
|
|
|
|
settings->DisableFullWindowDrag = TRUE;
|
|
|
|
settings->DisableMenuAnims = TRUE;
|
|
|
|
settings->DisableThemes = FALSE;
|
|
|
|
}
|
|
|
|
else if (type == CONNECTION_TYPE_WAN)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = FALSE;
|
|
|
|
settings->AllowFontSmoothing = TRUE;
|
|
|
|
settings->AllowDesktopComposition = TRUE;
|
|
|
|
settings->DisableFullWindowDrag = FALSE;
|
|
|
|
settings->DisableMenuAnims = FALSE;
|
|
|
|
settings->DisableThemes = FALSE;
|
|
|
|
}
|
|
|
|
else if (type == CONNECTION_TYPE_LAN)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = FALSE;
|
|
|
|
settings->AllowFontSmoothing = TRUE;
|
|
|
|
settings->AllowDesktopComposition = TRUE;
|
|
|
|
settings->DisableFullWindowDrag = FALSE;
|
|
|
|
settings->DisableMenuAnims = FALSE;
|
|
|
|
settings->DisableThemes = FALSE;
|
|
|
|
}
|
|
|
|
else if (type == CONNECTION_TYPE_AUTODETECT)
|
|
|
|
{
|
|
|
|
settings->DisableWallpaper = FALSE;
|
|
|
|
settings->AllowFontSmoothing = TRUE;
|
|
|
|
settings->AllowDesktopComposition = TRUE;
|
|
|
|
settings->DisableFullWindowDrag = FALSE;
|
|
|
|
settings->DisableMenuAnims = FALSE;
|
|
|
|
settings->DisableThemes = FALSE;
|
|
|
|
settings->NetworkAutoDetect = TRUE;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
int freerdp_map_keyboard_layout_name_to_id(char* name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int id = 0;
|
|
|
|
RDP_KEYBOARD_LAYOUT* layouts;
|
|
|
|
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!layouts)
|
|
|
|
return -1;
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
for (i = 0; layouts[i].code; i++)
|
|
|
|
{
|
|
|
|
if (_stricmp(layouts[i].name, name) == 0)
|
|
|
|
id = layouts[i].code;
|
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
free(layouts);
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
return id;
|
|
|
|
|
|
|
|
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!layouts)
|
|
|
|
return -1;
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
for (i = 0; layouts[i].code; i++)
|
|
|
|
{
|
|
|
|
if (_stricmp(layouts[i].name, name) == 0)
|
|
|
|
id = layouts[i].code;
|
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
free(layouts);
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
return id;
|
|
|
|
|
|
|
|
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-17 23:08:02 +03:00
|
|
|
if (!layouts)
|
|
|
|
return -1;
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
for (i = 0; layouts[i].code; i++)
|
|
|
|
{
|
|
|
|
if (_stricmp(layouts[i].name, name) == 0)
|
|
|
|
id = layouts[i].code;
|
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
free(layouts);
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
return id;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
static int freerdp_detect_command_line_pre_filter(void* context, int index,
|
2018-06-06 17:43:09 +03:00
|
|
|
int argc, LPSTR* argv)
|
2013-09-18 01:03:35 +04:00
|
|
|
{
|
|
|
|
int length;
|
|
|
|
|
|
|
|
if (index == 1)
|
|
|
|
{
|
2014-02-10 10:06:11 +04:00
|
|
|
length = (int) strlen(argv[index]);
|
2013-09-18 01:03:35 +04:00
|
|
|
|
|
|
|
if (length > 4)
|
|
|
|
{
|
|
|
|
if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
|
|
|
if (length > 13)
|
|
|
|
{
|
|
|
|
if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2013-09-18 01:03:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:56:45 +03:00
|
|
|
static int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv,
|
|
|
|
size_t* count, BOOL ignoreUnknown)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
DWORD flags;
|
|
|
|
int detect_status;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
|
|
|
flags = COMMAND_LINE_SEPARATOR_COLON;
|
|
|
|
flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2015-03-16 12:25:31 +03:00
|
|
|
if (ignoreUnknown)
|
|
|
|
{
|
|
|
|
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
|
|
|
|
}
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
*count = 0;
|
|
|
|
detect_status = 0;
|
|
|
|
CommandLineClearArgumentsA(args);
|
2018-06-06 17:43:09 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, args, flags,
|
2016-08-04 17:13:37 +03:00
|
|
|
NULL, freerdp_detect_command_line_pre_filter, NULL);
|
2013-09-18 01:03:35 +04:00
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
arg = args;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(*count)++;
|
|
|
|
}
|
|
|
|
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
|
|
|
|
2013-07-03 18:44:06 +04:00
|
|
|
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
|
|
|
|
detect_status = -1;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2013-07-03 18:44:06 +04:00
|
|
|
return detect_status;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-16 12:25:31 +03:00
|
|
|
int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t* count, BOOL ignoreUnknown)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
DWORD flags;
|
|
|
|
int detect_status;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
|
|
|
flags = COMMAND_LINE_SEPARATOR_SPACE;
|
|
|
|
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
|
|
|
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2015-03-16 12:25:31 +03:00
|
|
|
if (ignoreUnknown)
|
|
|
|
{
|
|
|
|
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
|
|
|
|
}
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
*count = 0;
|
|
|
|
detect_status = 0;
|
|
|
|
CommandLineClearArgumentsA(args);
|
2018-06-06 17:43:09 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, args, flags,
|
2016-08-04 17:13:37 +03:00
|
|
|
NULL, freerdp_detect_command_line_pre_filter, NULL);
|
2013-09-18 01:03:35 +04:00
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
arg = args;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(*count)++;
|
|
|
|
}
|
|
|
|
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
|
|
|
|
2013-07-03 18:44:06 +04:00
|
|
|
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
|
|
|
|
detect_status = -1;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
2013-07-03 18:44:06 +04:00
|
|
|
return detect_status;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-16 12:25:31 +03:00
|
|
|
static BOOL freerdp_client_detect_command_line(int argc, char** argv,
|
2016-08-04 17:13:37 +03:00
|
|
|
DWORD* flags, BOOL ignoreUnknown)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
int old_cli_status;
|
|
|
|
int old_cli_count;
|
|
|
|
int posix_cli_status;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t posix_cli_count;
|
2012-12-05 21:12:18 +04:00
|
|
|
int windows_cli_status;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t windows_cli_count;
|
2012-12-05 21:12:18 +04:00
|
|
|
BOOL compatibility = FALSE;
|
2016-08-04 17:13:37 +03:00
|
|
|
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);
|
2012-12-05 21:12:18 +04:00
|
|
|
/* 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;
|
|
|
|
|
2014-09-17 00:51:01 +04:00
|
|
|
if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
|
|
|
|
return compatibility;
|
|
|
|
|
2015-01-15 15:57:28 +03:00
|
|
|
/* Check, if this may be windows style syntax... */
|
2016-08-04 17:13:37 +03:00
|
|
|
if ((windows_cli_count && (windows_cli_count >= posix_cli_count))
|
|
|
|
|| (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2015-01-15 18:01:57 +03:00
|
|
|
windows_cli_count = 1;
|
2012-12-05 21:12:18 +04:00
|
|
|
*flags = COMMAND_LINE_SEPARATOR_COLON;
|
|
|
|
*flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
|
|
|
}
|
2013-09-09 18:07:14 +04:00
|
|
|
else if (old_cli_status >= 0)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2013-09-18 01:03:35 +04:00
|
|
|
/* Ignore legacy parsing in case there is an error in the command line. */
|
2016-08-04 17:13:37 +03:00
|
|
|
if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count)
|
|
|
|
&& (old_cli_status != -1)))
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
|
|
|
*flags = COMMAND_LINE_SEPARATOR_SPACE;
|
|
|
|
*flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
|
|
|
compatibility = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
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);
|
2012-12-05 21:12:18 +04:00
|
|
|
return compatibility;
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
int freerdp_client_settings_command_line_status_print(rdpSettings* settings,
|
|
|
|
int status, int argc, char** argv)
|
2017-05-04 15:46:58 +03:00
|
|
|
{
|
|
|
|
return freerdp_client_settings_command_line_status_print_ex(
|
|
|
|
settings, status, argc, argv, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
|
|
|
|
int status, int argc, char** argv, COMMAND_LINE_ARGUMENT_A* custom)
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
|
2012-11-07 03:49:02 +04:00
|
|
|
{
|
2012-11-07 07:08:09 +04:00
|
|
|
freerdp_client_print_version();
|
2012-11-07 03:49:02 +04:00
|
|
|
return COMMAND_LINE_STATUS_PRINT_VERSION;
|
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-01-11 18:18:40 +03:00
|
|
|
if (status == COMMAND_LINE_STATUS_PRINT_BUILDCONFIG)
|
|
|
|
{
|
|
|
|
freerdp_client_print_version();
|
|
|
|
freerdp_client_print_buildconfig();
|
|
|
|
return COMMAND_LINE_STATUS_PRINT_BUILDCONFIG;
|
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
else if (status == COMMAND_LINE_STATUS_PRINT)
|
|
|
|
{
|
|
|
|
arg = CommandLineFindArgumentA(args, "kbd-list");
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2017-11-21 10:46:29 +03:00
|
|
|
DWORD i;
|
2012-11-27 01:49:12 +04:00
|
|
|
RDP_KEYBOARD_LAYOUT* layouts;
|
|
|
|
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
|
2015-06-17 23:08:02 +03:00
|
|
|
//if (!layouts) /* FIXME*/
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\nKeyboard Layouts\n");
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
for (i = 0; layouts[i].code; i++)
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
|
2014-09-12 19:13:01 +04:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
free(layouts);
|
2014-09-16 23:07:38 +04:00
|
|
|
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
|
2015-06-17 23:08:02 +03:00
|
|
|
//if (!layouts) /* FIXME*/
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\nKeyboard Layout Variants\n");
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
for (i = 0; layouts[i].code; i++)
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
|
2014-09-12 19:13:01 +04:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
free(layouts);
|
2014-09-16 23:07:38 +04:00
|
|
|
layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
|
2015-06-17 23:08:02 +03:00
|
|
|
//if (!layouts) /* FIXME*/
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\nKeyboard Input Method Editors (IMEs)\n");
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
for (i = 0; layouts[i].code; i++)
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("0x%08"PRIX32"\t%s\n", layouts[i].code, layouts[i].name);
|
2014-09-16 23:07:38 +04:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
free(layouts);
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\n");
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
|
2013-04-29 01:10:43 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "monitor-list");
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
settings->ListMonitors = TRUE;
|
|
|
|
}
|
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
return COMMAND_LINE_STATUS_PRINT;
|
|
|
|
}
|
2013-09-09 18:07:14 +04:00
|
|
|
else if (status < 0)
|
|
|
|
{
|
2017-05-04 15:46:58 +03:00
|
|
|
freerdp_client_print_command_line_help_ex(argc, argv, custom);
|
2013-09-09 18:07:14 +04:00
|
|
|
return COMMAND_LINE_STATUS_PRINT_HELP;
|
|
|
|
}
|
2012-11-07 03:49:02 +04:00
|
|
|
|
2013-06-15 23:13:38 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
|
2017-11-21 21:10:28 +03:00
|
|
|
static BOOL ends_with(const char* str, const char* ext)
|
|
|
|
{
|
|
|
|
const size_t strLen = strlen(str);
|
|
|
|
const size_t extLen = strlen(ext);
|
|
|
|
|
|
|
|
if (strLen < extLen)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return strncmp(&str[strLen - extLen], ext, extLen) == 0;
|
|
|
|
}
|
2015-03-16 12:15:37 +03:00
|
|
|
int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
2016-08-04 17:13:37 +03:00
|
|
|
int argc, char** argv, BOOL allowUnknown)
|
2013-06-15 23:13:38 +04:00
|
|
|
{
|
|
|
|
char* p;
|
2015-06-18 12:35:22 +03:00
|
|
|
char* user = NULL;
|
|
|
|
char* gwUser = NULL;
|
2013-06-15 23:13:38 +04:00
|
|
|
char* str;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t length;
|
2013-06-15 23:13:38 +04:00
|
|
|
int status;
|
2018-02-19 12:00:54 +03:00
|
|
|
BOOL ext = FALSE;
|
|
|
|
BOOL assist = FALSE;
|
|
|
|
DWORD flags = 0;
|
2017-11-10 13:52:23 +03:00
|
|
|
BOOL promptForPassword = FALSE;
|
2018-02-19 12:00:54 +03:00
|
|
|
BOOL compatibility = FALSE;
|
2013-06-15 23:13:38 +04:00
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
2018-02-19 12:00:54 +03:00
|
|
|
|
|
|
|
/* Command line detection fails if only a .rdp or .msrcIncident file
|
|
|
|
* is supplied. Check this case first, only then try to detect
|
|
|
|
* legacy command line syntax. */
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
ext = ends_with(argv[1], ".rdp");
|
|
|
|
assist = ends_with(argv[1], ".msrcIncident");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ext && !assist)
|
|
|
|
compatibility = freerdp_client_detect_command_line(argc, argv, &flags,
|
|
|
|
allowUnknown);
|
2018-03-09 16:25:45 +03:00
|
|
|
else
|
|
|
|
compatibility = freerdp_client_detect_command_line(argc - 1, &argv[1], &flags,
|
2018-06-06 17:43:09 +03:00
|
|
|
allowUnknown);
|
2013-06-15 23:13:38 +04:00
|
|
|
|
2017-08-18 20:17:17 +03:00
|
|
|
settings->ProxyHostname = NULL;
|
2018-04-29 22:25:28 +03:00
|
|
|
settings->ProxyUsername = NULL;
|
|
|
|
settings->ProxyPassword = NULL;
|
2017-08-18 20:17:17 +03:00
|
|
|
|
2013-06-15 23:13:38 +04:00
|
|
|
if (compatibility)
|
|
|
|
{
|
2015-06-15 10:47:16 +03:00
|
|
|
WLog_WARN(TAG, "Using deprecated command-line interface!");
|
2013-06-15 23:13:38 +04:00
|
|
|
return freerdp_client_parse_old_command_line_arguments(argc, argv, settings);
|
|
|
|
}
|
|
|
|
else
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
2015-03-16 12:15:37 +03:00
|
|
|
if (allowUnknown)
|
|
|
|
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2018-02-19 12:00:54 +03:00
|
|
|
if (ext)
|
2017-11-21 15:47:28 +03:00
|
|
|
{
|
2018-02-19 12:00:54 +03:00
|
|
|
if (freerdp_client_settings_parse_connection_file(settings, argv[1]))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2017-11-21 15:47:28 +03:00
|
|
|
|
2018-02-19 12:00:54 +03:00
|
|
|
if (assist)
|
|
|
|
{
|
|
|
|
if (freerdp_client_settings_parse_assistance_file(settings,
|
|
|
|
argv[1]) < 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-21 15:47:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CommandLineClearArgumentsA(args);
|
2018-06-06 17:43:09 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, args, flags,
|
2016-08-04 17:13:37 +03:00
|
|
|
settings,
|
|
|
|
freerdp_client_command_line_pre_filter,
|
|
|
|
freerdp_client_command_line_post_filter);
|
2013-09-18 01:03:35 +04:00
|
|
|
|
2013-09-09 18:07:14 +04:00
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:57:28 +03:00
|
|
|
CommandLineFindArgumentA(args, "v");
|
2012-11-06 07:11:13 +04:00
|
|
|
arg = args;
|
2017-11-14 18:10:52 +03:00
|
|
|
errno = 0;
|
2012-11-06 07:11:13 +04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2012-11-27 11:49:44 +04:00
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
2012-11-06 07:11:13 +04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
CommandLineSwitchStart(arg)
|
2016-08-04 17:13:37 +03:00
|
|
|
CommandLineSwitchCase(arg, "v")
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->ServerHostname);
|
2016-03-07 15:12:38 +03:00
|
|
|
settings->ServerHostname = NULL;
|
2014-10-17 14:08:39 +04:00
|
|
|
p = strchr(arg->Value, '[');
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2014-10-17 14:08:39 +04:00
|
|
|
/* ipv4 */
|
|
|
|
if (!p)
|
2012-11-07 03:49:02 +04:00
|
|
|
{
|
2014-10-17 14:08:39 +04:00
|
|
|
p = strchr(arg->Value, ':');
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2014-10-17 14:08:39 +04:00
|
|
|
if (p)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(&p[1], NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
length = (int)(p - arg->Value);
|
2017-11-14 18:10:52 +03:00
|
|
|
settings->ServerPort = val;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ServerHostname = (char*) calloc(length + 1UL, sizeof(char))))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
2014-10-17 14:08:39 +04:00
|
|
|
strncpy(settings->ServerHostname, arg->Value, length);
|
|
|
|
settings->ServerHostname[length] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ServerHostname = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2014-10-17 14:08:39 +04:00
|
|
|
}
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
2014-10-17 14:08:39 +04:00
|
|
|
else /* ipv6 */
|
2012-11-07 03:49:02 +04:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
char* p2 = strchr(arg->Value, ']');
|
|
|
|
|
2014-10-17 14:08:39 +04:00
|
|
|
/* not a valid [] ipv6 addr found */
|
|
|
|
if (!p2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
length = p2 - p;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ServerHostname = (char*) calloc(length, sizeof(char))))
|
2016-02-01 17:09:51 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
strncpy(settings->ServerHostname, p + 1, length - 1);
|
|
|
|
|
2014-10-17 14:08:39 +04:00
|
|
|
if (*(p2 + 1) == ':')
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(&p2[2], NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->ServerPort = val;
|
2014-10-17 14:08:39 +04:00
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("hostname %s port %"PRIu32"\n", settings->ServerHostname, settings->ServerPort);
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
|
|
|
}
|
2014-02-12 09:43:02 +04:00
|
|
|
CommandLineSwitchCase(arg, "spn-class")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->AuthenticationServiceClass);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AuthenticationServiceClass = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2014-02-12 09:43:02 +04:00
|
|
|
}
|
2014-02-14 09:43:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "credentials-delegation")
|
|
|
|
{
|
|
|
|
settings->DisableCredentialsDelegation = arg->Value ? FALSE : TRUE;
|
|
|
|
}
|
2013-01-09 02:18:34 +04:00
|
|
|
CommandLineSwitchCase(arg, "vmconnect")
|
|
|
|
{
|
2016-05-11 22:52:36 +03:00
|
|
|
settings->VmConnectMode = TRUE;
|
2013-01-09 02:18:34 +04:00
|
|
|
settings->ServerPort = 2179;
|
|
|
|
settings->NegotiateSecurityLayer = FALSE;
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
settings->SendPreconnectionPdu = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->PreconnectionBlob);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->PreconnectionBlob = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2013-01-09 02:18:34 +04:00
|
|
|
}
|
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "w")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
long val = strtol(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->DesktopWidth = val;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "h")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
long val = strtol(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->DesktopHeight = val;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "size")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(str = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
|
|
|
|
p = strchr(str, 'x');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
*p = '\0';
|
2017-11-14 18:10:52 +03:00
|
|
|
{
|
|
|
|
long val = strtol(str, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
|
|
|
|
{
|
|
|
|
free(str);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->DesktopWidth = val;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
long val = strtol(&p[1], NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
|
|
|
|
{
|
|
|
|
free(str);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->DesktopHeight = val;
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2014-08-06 14:19:50 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
p = strchr(str, '%');
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
if (p)
|
2014-08-06 14:19:50 +04:00
|
|
|
{
|
2017-09-25 10:35:49 +03:00
|
|
|
BOOL partial = FALSE;
|
|
|
|
|
|
|
|
if (strchr(p, 'w'))
|
|
|
|
{
|
|
|
|
settings->PercentScreenUseWidth = 1;
|
|
|
|
partial = TRUE;
|
|
|
|
}
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-09-25 10:35:49 +03:00
|
|
|
if (strchr(p, 'h'))
|
|
|
|
{
|
|
|
|
settings->PercentScreenUseHeight = 1;
|
|
|
|
partial = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!partial)
|
|
|
|
{
|
|
|
|
settings->PercentScreenUseWidth = 1;
|
|
|
|
settings->PercentScreenUseHeight = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = '\0';
|
2017-11-14 18:10:52 +03:00
|
|
|
{
|
|
|
|
long val = strtol(str, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val < 0) || (val > 100))
|
|
|
|
{
|
|
|
|
free(str);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->PercentScreen = val;
|
|
|
|
}
|
2014-08-06 14:19:50 +04:00
|
|
|
}
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
|
|
|
|
free(str);
|
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "f")
|
|
|
|
{
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->Fullscreen = TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-12-13 23:38:02 +04:00
|
|
|
CommandLineSwitchCase(arg, "multimon")
|
|
|
|
{
|
|
|
|
settings->UseMultimon = TRUE;
|
2013-04-25 23:42:40 +04:00
|
|
|
|
2012-12-13 23:38:02 +04:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
if (_stricmp(arg->Value, "force") == 0)
|
|
|
|
{
|
|
|
|
settings->ForceMultimon = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-25 22:39:21 +04:00
|
|
|
CommandLineSwitchCase(arg, "span")
|
|
|
|
{
|
|
|
|
settings->SpanMonitors = TRUE;
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "workarea")
|
|
|
|
{
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->Workarea = TRUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2013-04-29 02:48:27 +04:00
|
|
|
CommandLineSwitchCase(arg, "monitors")
|
|
|
|
{
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2014-02-11 07:23:59 +04:00
|
|
|
UINT32 i;
|
2013-04-29 02:48:27 +04:00
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count = 0;
|
2013-04-29 02:48:27 +04:00
|
|
|
p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!p)
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2013-04-29 02:48:27 +04:00
|
|
|
|
2015-02-10 23:15:30 +03:00
|
|
|
if (count > 16)
|
|
|
|
count = 16;
|
|
|
|
|
2014-02-11 07:23:59 +04:00
|
|
|
settings->NumMonitorIds = (UINT32) count;
|
2013-04-29 02:48:27 +04:00
|
|
|
|
|
|
|
for (i = 0; i < settings->NumMonitorIds; i++)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(p[i], NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->MonitorIds[i] = val;
|
2013-04-29 02:48:27 +04:00
|
|
|
}
|
2013-08-28 18:05:02 +04:00
|
|
|
|
|
|
|
free(p);
|
2013-04-29 02:48:27 +04:00
|
|
|
}
|
|
|
|
}
|
2013-04-29 01:10:43 +04:00
|
|
|
CommandLineSwitchCase(arg, "monitor-list")
|
|
|
|
{
|
|
|
|
settings->ListMonitors = TRUE;
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "t")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->WindowTitle);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->WindowTitle = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "decorations")
|
|
|
|
{
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->Decorations = arg->Value ? TRUE : FALSE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2017-11-29 12:26:04 +03:00
|
|
|
CommandLineSwitchCase(arg, "dynamic-resolution")
|
|
|
|
{
|
|
|
|
if (settings->SmartSizing)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Smart sizing and dynamic resolution are mutually exclusive options");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2017-12-28 16:05:11 +03:00
|
|
|
|
2017-11-29 12:26:04 +03:00
|
|
|
settings->SupportDisplayControl = TRUE;
|
|
|
|
settings->DynamicResolutionUpdate = TRUE;
|
|
|
|
}
|
2013-04-11 00:58:14 +04:00
|
|
|
CommandLineSwitchCase(arg, "smart-sizing")
|
|
|
|
{
|
2017-11-29 12:26:04 +03:00
|
|
|
if (settings->DynamicResolutionUpdate)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Smart sizing and dynamic resolution are mutually exclusive options");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
2014-12-01 13:56:44 +03:00
|
|
|
settings->SmartSizing = TRUE;
|
|
|
|
|
|
|
|
if (arg->Value)
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(str = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2014-12-01 13:56:44 +03:00
|
|
|
if ((p = strchr(str, 'x')))
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long w, h;
|
2014-12-01 13:56:44 +03:00
|
|
|
*p = '\0';
|
2017-11-14 18:10:52 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->SmartSizingWidth = w;
|
|
|
|
settings->SmartSizingHeight = h;
|
2014-12-01 13:56:44 +03:00
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2014-12-01 13:56:44 +03:00
|
|
|
free(str);
|
|
|
|
}
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "bpp")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->ColorDepth = val;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
switch (settings->ColorDepth)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
case 24:
|
|
|
|
case 16:
|
|
|
|
case 15:
|
|
|
|
case 8:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-12-13 16:39:49 +04:00
|
|
|
CommandLineSwitchCase(arg, "admin")
|
|
|
|
{
|
|
|
|
settings->ConsoleSession = TRUE;
|
|
|
|
}
|
2013-11-06 10:51:55 +04:00
|
|
|
CommandLineSwitchCase(arg, "restricted-admin")
|
|
|
|
{
|
|
|
|
settings->ConsoleSession = TRUE;
|
|
|
|
settings->RestrictedAdminModeRequired = TRUE;
|
|
|
|
}
|
2013-11-06 19:02:58 +04:00
|
|
|
CommandLineSwitchCase(arg, "pth")
|
|
|
|
{
|
|
|
|
settings->ConsoleSession = TRUE;
|
|
|
|
settings->RestrictedAdminModeRequired = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->PasswordHash);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->PasswordHash = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2013-11-06 19:02:58 +04:00
|
|
|
}
|
2013-11-12 04:57:44 +04:00
|
|
|
CommandLineSwitchCase(arg, "client-hostname")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->ClientHostname);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ClientHostname = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2013-11-12 04:57:44 +04:00
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "kbd")
|
|
|
|
{
|
2017-11-21 10:46:29 +03:00
|
|
|
unsigned long id = strtoul(arg->Value, NULL, 0);
|
2012-11-27 01:49:12 +04:00
|
|
|
|
2017-11-21 10:46:29 +03:00
|
|
|
if ((errno != 0) || (id > UINT32_MAX) || (id == 0))
|
2012-11-27 01:49:12 +04:00
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
const int rc = freerdp_map_keyboard_layout_name_to_id(arg->Value);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2017-11-21 10:46:29 +03:00
|
|
|
if (rc <= 0)
|
2012-11-27 01:49:12 +04:00
|
|
|
{
|
2015-06-15 10:47:16 +03:00
|
|
|
WLog_ERR(TAG, "Could not identify keyboard layout: %s", arg->Value);
|
2015-06-17 23:08:02 +03:00
|
|
|
WLog_ERR(TAG, "Use /kbd-list to list available layouts");
|
2017-11-21 10:46:29 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2017-11-21 10:46:29 +03:00
|
|
|
/* Found a valid mapping, reset errno */
|
|
|
|
id = (unsigned long)rc;
|
|
|
|
errno = 0;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
|
2014-04-05 00:09:48 +04:00
|
|
|
settings->KeyboardLayout = (UINT32) id;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "kbd-type")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->KeyboardType = val;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "kbd-subtype")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->KeyboardSubType = val;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "kbd-fn-key")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->KeyboardFunctionKey = val;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "u")
|
|
|
|
{
|
2015-06-18 12:35:22 +03:00
|
|
|
user = _strdup(arg->Value);
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "d")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->Domain);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->Domain = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "p")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->Password);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->Password = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "g")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->GatewayHostname);
|
|
|
|
|
2012-11-27 11:49:44 +04:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
2012-11-27 11:49:44 +04:00
|
|
|
p = strchr(arg->Value, ':');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(&p[1], NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
length = (int)(p - arg->Value);
|
2017-11-14 18:10:52 +03:00
|
|
|
settings->GatewayPort = val;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->GatewayHostname = (char*) calloc(length + 1UL, sizeof(char))))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2012-11-27 11:49:44 +04:00
|
|
|
strncpy(settings->GatewayHostname, arg->Value, length);
|
|
|
|
settings->GatewayHostname[length] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->GatewayHostname = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-27 11:49:44 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->GatewayHostname = _strdup(settings->ServerHostname)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
|
2014-05-30 20:31:26 +04:00
|
|
|
settings->GatewayEnabled = TRUE;
|
2012-11-09 04:56:37 +04:00
|
|
|
settings->GatewayUseSameCredentials = TRUE;
|
2015-01-28 23:16:31 +03:00
|
|
|
freerdp_set_gateway_usage_method(settings, TSC_PROXY_MODE_DIRECT);
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2016-12-11 01:13:35 +03:00
|
|
|
CommandLineSwitchCase(arg, "proxy")
|
2014-03-21 21:58:28 +04:00
|
|
|
{
|
2018-04-29 22:25:28 +03:00
|
|
|
/* initial value */
|
|
|
|
settings->ProxyType = PROXY_TYPE_HTTP;
|
2017-08-18 20:17:17 +03:00
|
|
|
|
2014-03-21 21:58:28 +04:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2018-06-06 17:43:09 +03:00
|
|
|
char* atPtr;
|
2018-04-29 22:25:28 +03:00
|
|
|
/* value is [scheme://][user:password@]hostname:port */
|
2016-12-11 01:13:35 +03:00
|
|
|
p = strstr(arg->Value, "://");
|
2017-05-15 14:43:51 +03:00
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2016-12-11 01:13:35 +03:00
|
|
|
*p = '\0';
|
2017-05-15 14:43:51 +03:00
|
|
|
|
|
|
|
if (!strcmp("http", arg->Value))
|
|
|
|
{
|
2016-12-11 01:13:35 +03:00
|
|
|
settings->ProxyType = PROXY_TYPE_HTTP;
|
2017-05-15 14:43:51 +03:00
|
|
|
}
|
2018-04-23 21:30:08 +03:00
|
|
|
else if (!strcmp("socks5", arg->Value))
|
2017-08-18 20:17:17 +03:00
|
|
|
{
|
|
|
|
settings->ProxyType = PROXY_TYPE_SOCKS;
|
|
|
|
}
|
2017-05-15 14:43:51 +03:00
|
|
|
else
|
|
|
|
{
|
2018-04-23 21:30:08 +03:00
|
|
|
WLog_ERR(TAG, "Only HTTP and SOCKS5 proxies supported by now");
|
2016-12-11 01:13:35 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2017-05-15 14:43:51 +03:00
|
|
|
|
2016-12-11 01:13:35 +03:00
|
|
|
arg->Value = p + 3;
|
|
|
|
}
|
|
|
|
|
2018-04-29 22:25:28 +03:00
|
|
|
/* arg->Value is now [user:password@]hostname:port */
|
|
|
|
atPtr = strrchr(arg->Value, '@');
|
2018-06-06 17:43:09 +03:00
|
|
|
|
2018-04-29 22:25:28 +03:00
|
|
|
if (atPtr)
|
|
|
|
{
|
|
|
|
/* got a login / password,
|
|
|
|
* atPtr
|
|
|
|
* v
|
|
|
|
* [user:password@]hostname:port
|
|
|
|
* ^
|
|
|
|
* colonPtr
|
|
|
|
*/
|
2018-06-06 17:43:09 +03:00
|
|
|
char* colonPtr = strchr(arg->Value, ':');
|
|
|
|
|
2018-04-29 22:25:28 +03:00
|
|
|
if (!colonPtr || (colonPtr > atPtr))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "invalid syntax for proxy, expected syntax is user:password@host:port");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*colonPtr = '\0';
|
|
|
|
settings->ProxyUsername = _strdup(arg->Value);
|
2018-06-06 17:43:09 +03:00
|
|
|
|
2018-04-29 22:25:28 +03:00
|
|
|
if (!settings->ProxyUsername)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "unable to allocate proxy username");
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
*atPtr = '\0';
|
|
|
|
settings->ProxyPassword = _strdup(colonPtr + 1);
|
2018-06-06 17:43:09 +03:00
|
|
|
|
2018-04-29 22:25:28 +03:00
|
|
|
if (!settings->ProxyPassword)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "unable to allocate proxy password");
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg->Value = atPtr + 1;
|
|
|
|
}
|
|
|
|
|
2014-03-21 21:58:28 +04:00
|
|
|
p = strchr(arg->Value, ':');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(&p[1], NULL, 0);
|
2017-05-15 14:43:51 +03:00
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
2016-12-11 01:13:35 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-05-15 14:43:51 +03:00
|
|
|
|
2017-11-14 18:10:52 +03:00
|
|
|
length = (p - arg->Value);
|
|
|
|
settings->ProxyPort = val;
|
2016-12-11 01:13:35 +03:00
|
|
|
settings->ProxyHostname = (char*) malloc(length + 1);
|
|
|
|
strncpy(settings->ProxyHostname, arg->Value, length);
|
|
|
|
settings->ProxyHostname[length] = '\0';
|
2014-03-21 21:58:28 +04:00
|
|
|
}
|
|
|
|
}
|
2016-12-11 01:13:35 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Option http-proxy needs argument.");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2014-03-21 21:58:28 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "gu")
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(gwUser = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->GatewayUseSameCredentials = FALSE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gd")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->GatewayDomain);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->GatewayDomain = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->GatewayUseSameCredentials = FALSE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gp")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->GatewayPassword);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->GatewayPassword = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->GatewayUseSameCredentials = FALSE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2015-03-19 18:44:47 +03:00
|
|
|
CommandLineSwitchCase(arg, "gt")
|
|
|
|
{
|
|
|
|
if (_stricmp(arg->Value, "rpc") == 0)
|
|
|
|
{
|
|
|
|
settings->GatewayRpcTransport = TRUE;
|
|
|
|
settings->GatewayHttpTransport = FALSE;
|
|
|
|
}
|
|
|
|
else if (_stricmp(arg->Value, "http") == 0)
|
|
|
|
{
|
|
|
|
settings->GatewayRpcTransport = FALSE;
|
|
|
|
settings->GatewayHttpTransport = TRUE;
|
|
|
|
}
|
|
|
|
else if (_stricmp(arg->Value, "auto") == 0)
|
|
|
|
{
|
|
|
|
settings->GatewayRpcTransport = TRUE;
|
|
|
|
settings->GatewayHttpTransport = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2018-02-13 16:59:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "gat")
|
|
|
|
{
|
|
|
|
free(settings->GatewayAccessToken);
|
|
|
|
|
|
|
|
if (!(settings->GatewayAccessToken = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2014-05-30 20:31:26 +04:00
|
|
|
CommandLineSwitchCase(arg, "gateway-usage-method")
|
|
|
|
{
|
2018-05-02 13:57:34 +03:00
|
|
|
long type = 0;
|
2014-05-30 20:31:26 +04:00
|
|
|
char* pEnd;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2018-05-02 13:57:34 +03:00
|
|
|
if (_stricmp(arg->Value, "none") == 0)
|
|
|
|
type = TSC_PROXY_MODE_NONE_DIRECT;
|
|
|
|
else if (_stricmp(arg->Value, "direct") == 0)
|
|
|
|
type = TSC_PROXY_MODE_DIRECT;
|
|
|
|
else if (_stricmp(arg->Value, "detect") == 0)
|
|
|
|
type = TSC_PROXY_MODE_DETECT;
|
|
|
|
else if (_stricmp(arg->Value, "default") == 0)
|
|
|
|
type = TSC_PROXY_MODE_DEFAULT;
|
|
|
|
else
|
2014-05-30 20:31:26 +04:00
|
|
|
{
|
2018-05-02 13:57:34 +03:00
|
|
|
type = strtol(arg->Value, &pEnd, 10);
|
2018-06-06 17:43:09 +03:00
|
|
|
|
2018-05-02 13:57:34 +03:00
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2014-05-30 20:31:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
freerdp_set_gateway_usage_method(settings, (UINT32) type);
|
|
|
|
}
|
2012-11-19 22:26:56 +04:00
|
|
|
CommandLineSwitchCase(arg, "app")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteApplicationProgram);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationProgram = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
|
|
|
|
settings->RemoteApplicationMode = TRUE;
|
|
|
|
settings->RemoteAppLanguageBarSupported = TRUE;
|
|
|
|
settings->Workarea = TRUE;
|
|
|
|
settings->DisableWallpaper = TRUE;
|
|
|
|
settings->DisableFullWindowDrag = TRUE;
|
|
|
|
}
|
2013-04-11 19:51:10 +04:00
|
|
|
CommandLineSwitchCase(arg, "load-balance-info")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->LoadBalanceInfo);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->LoadBalanceInfo = (BYTE*) _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
settings->LoadBalanceInfoLength = (UINT32) strlen((char*)
|
|
|
|
settings->LoadBalanceInfo);
|
2013-04-11 19:51:10 +04:00
|
|
|
}
|
2012-11-19 22:26:56 +04:00
|
|
|
CommandLineSwitchCase(arg, "app-name")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteApplicationName);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationName = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-icon")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteApplicationIcon);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationIcon = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-cmd")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteApplicationCmdLine);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationCmdLine = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-file")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteApplicationFile);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationFile = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-guid")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteApplicationGuid);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteApplicationGuid = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "compression")
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->CompressionEnabled = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2014-03-10 19:16:36 +04:00
|
|
|
CommandLineSwitchCase(arg, "compression-level")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtol(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->CompressionLevel = val;
|
2014-03-10 19:16:36 +04:00
|
|
|
}
|
2013-02-15 04:38:45 +04:00
|
|
|
CommandLineSwitchCase(arg, "drives")
|
|
|
|
{
|
|
|
|
settings->RedirectDrives = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "home-drive")
|
|
|
|
{
|
|
|
|
settings->RedirectHomeDrive = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2017-11-27 12:54:49 +03:00
|
|
|
CommandLineSwitchCase(arg, "ipv6")
|
|
|
|
{
|
|
|
|
settings->PreferIPv6OverIPv4 = TRUE;
|
|
|
|
}
|
2012-11-21 04:34:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "clipboard")
|
|
|
|
{
|
|
|
|
settings->RedirectClipboard = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "shell")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->AlternateShell);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AlternateShell = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "shell-dir")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->ShellWorkingDirectory);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->ShellWorkingDirectory = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "audio-mode")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
long mode = strtol(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
|
|
|
if (mode == AUDIO_MODE_REDIRECT)
|
|
|
|
{
|
|
|
|
settings->AudioPlayback = TRUE;
|
|
|
|
}
|
|
|
|
else if (mode == AUDIO_MODE_PLAY_ON_SERVER)
|
|
|
|
{
|
|
|
|
settings->RemoteConsoleAudio = TRUE;
|
|
|
|
}
|
|
|
|
else if (mode == AUDIO_MODE_NONE)
|
|
|
|
{
|
|
|
|
settings->AudioPlayback = FALSE;
|
|
|
|
settings->RemoteConsoleAudio = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "network")
|
|
|
|
{
|
2018-05-02 13:57:34 +03:00
|
|
|
long type = 0;
|
2012-11-26 23:31:31 +04:00
|
|
|
char* pEnd;
|
|
|
|
|
2018-05-02 13:57:34 +03:00
|
|
|
if (_stricmp(arg->Value, "modem") == 0)
|
|
|
|
type = CONNECTION_TYPE_MODEM;
|
|
|
|
else if (_stricmp(arg->Value, "broadband") == 0)
|
|
|
|
type = CONNECTION_TYPE_BROADBAND_HIGH;
|
|
|
|
else if (_stricmp(arg->Value, "broadband-low") == 0)
|
|
|
|
type = CONNECTION_TYPE_BROADBAND_LOW;
|
|
|
|
else if (_stricmp(arg->Value, "broadband-high") == 0)
|
|
|
|
type = CONNECTION_TYPE_BROADBAND_HIGH;
|
|
|
|
else if (_stricmp(arg->Value, "wan") == 0)
|
|
|
|
type = CONNECTION_TYPE_WAN;
|
|
|
|
else if (_stricmp(arg->Value, "lan") == 0)
|
|
|
|
type = CONNECTION_TYPE_LAN;
|
|
|
|
else if ((_stricmp(arg->Value, "autodetect") == 0) ||
|
2018-06-06 17:43:09 +03:00
|
|
|
(_stricmp(arg->Value, "auto") == 0) ||
|
|
|
|
(_stricmp(arg->Value, "detect") == 0))
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
2018-05-02 13:57:34 +03:00
|
|
|
type = CONNECTION_TYPE_AUTODETECT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
type = strtol(arg->Value, &pEnd, 10);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_set_connection_type(settings, type))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "fonts")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->AllowFontSmoothing = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "wallpaper")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->DisableWallpaper = arg->Value ? FALSE : TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "window-drag")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->DisableFullWindowDrag = arg->Value ? FALSE : TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "menu-anims")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->DisableMenuAnims = arg->Value ? FALSE : TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "themes")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->DisableThemes = arg->Value ? FALSE : TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "aero")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->AllowDesktopComposition = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "gdi")
|
|
|
|
{
|
2013-12-10 21:30:25 +04:00
|
|
|
if (_stricmp(arg->Value, "sw") == 0)
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->SoftwareGdi = TRUE;
|
2013-12-10 21:30:25 +04:00
|
|
|
else if (_stricmp(arg->Value, "hw") == 0)
|
2012-11-08 03:23:25 +04:00
|
|
|
settings->SoftwareGdi = FALSE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2013-10-22 07:33:25 +04:00
|
|
|
CommandLineSwitchCase(arg, "gfx")
|
|
|
|
{
|
|
|
|
settings->SupportGraphicsPipeline = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-03-24 18:25:22 +03:00
|
|
|
if (arg->Value)
|
|
|
|
{
|
2017-07-17 10:00:57 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2016-03-24 18:25:22 +03:00
|
|
|
if (_strnicmp("AVC444", arg->Value, 6) == 0)
|
|
|
|
{
|
|
|
|
settings->GfxH264 = TRUE;
|
|
|
|
settings->GfxAVC444 = TRUE;
|
|
|
|
}
|
|
|
|
else if (_strnicmp("AVC420", arg->Value, 6) == 0)
|
|
|
|
{
|
|
|
|
settings->GfxH264 = TRUE;
|
|
|
|
}
|
2017-07-17 10:00:57 +03:00
|
|
|
else
|
|
|
|
#endif
|
2017-05-04 15:46:58 +03:00
|
|
|
if (_strnicmp("RFX", arg->Value, 3) != 0)
|
|
|
|
return COMMAND_LINE_ERROR;
|
2016-03-24 18:25:22 +03:00
|
|
|
}
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gfx-thin-client")
|
|
|
|
{
|
|
|
|
settings->GfxThinClient = arg->Value ? TRUE : FALSE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-10-10 18:12:16 +03:00
|
|
|
if (settings->GfxThinClient)
|
|
|
|
settings->GfxSmallCache = TRUE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2014-07-03 22:35:03 +04:00
|
|
|
settings->SupportGraphicsPipeline = TRUE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gfx-small-cache")
|
|
|
|
{
|
|
|
|
settings->GfxSmallCache = arg->Value ? TRUE : FALSE;
|
|
|
|
settings->SupportGraphicsPipeline = TRUE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gfx-progressive")
|
|
|
|
{
|
|
|
|
settings->GfxProgressive = arg->Value ? TRUE : FALSE;
|
2014-07-30 01:37:46 +04:00
|
|
|
settings->GfxThinClient = settings->GfxProgressive ? FALSE : TRUE;
|
2014-07-03 22:35:03 +04:00
|
|
|
settings->SupportGraphicsPipeline = TRUE;
|
|
|
|
}
|
2017-07-17 10:00:57 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2014-07-03 22:35:03 +04:00
|
|
|
CommandLineSwitchCase(arg, "gfx-h264")
|
|
|
|
{
|
|
|
|
settings->SupportGraphicsPipeline = TRUE;
|
2016-03-24 18:25:22 +03:00
|
|
|
settings->GfxH264 = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-03-24 18:25:22 +03:00
|
|
|
if (arg->Value)
|
|
|
|
{
|
|
|
|
if (_strnicmp("AVC444", arg->Value, 6) == 0)
|
|
|
|
{
|
|
|
|
settings->GfxAVC444 = TRUE;
|
|
|
|
}
|
2016-03-31 12:01:45 +03:00
|
|
|
else if (_strnicmp("AVC420", arg->Value, 6) != 0)
|
2016-03-24 18:25:22 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2013-10-22 07:33:25 +04:00
|
|
|
}
|
2017-07-17 10:00:57 +03:00
|
|
|
#endif
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "rfx")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->RemoteFxCodec = TRUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "rfx-mode")
|
|
|
|
{
|
|
|
|
if (strcmp(arg->Value, "video") == 0)
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->RemoteFxCodecMode = 0x00;
|
2012-11-07 07:08:09 +04:00
|
|
|
else if (strcmp(arg->Value, "image") == 0)
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->RemoteFxCodecMode = 0x02;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "frame-ack")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->FrameAcknowledge = val;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "nsc")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->NSCodec = TRUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2017-07-24 16:23:36 +03:00
|
|
|
#if defined(WITH_JPEG)
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "jpeg")
|
|
|
|
{
|
|
|
|
settings->JpegCodec = TRUE;
|
|
|
|
settings->JpegQuality = 75;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "jpeg-quality")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > 100))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->JpegQuality = val;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2017-07-24 16:23:36 +03:00
|
|
|
#endif
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "nego")
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->NegotiateSecurityLayer = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2013-01-09 02:18:34 +04:00
|
|
|
CommandLineSwitchCase(arg, "pcb")
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->SendPreconnectionPdu = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->PreconnectionBlob);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->PreconnectionBlob = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2013-01-09 02:18:34 +04:00
|
|
|
CommandLineSwitchCase(arg, "pcid")
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->SendPreconnectionPdu = TRUE;
|
2017-11-14 18:10:52 +03:00
|
|
|
settings->PreconnectionId = val;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec")
|
|
|
|
{
|
|
|
|
if (strcmp("rdp", arg->Value) == 0) /* Standard RDP */
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->RdpSecurity = TRUE;
|
|
|
|
settings->TlsSecurity = FALSE;
|
|
|
|
settings->NlaSecurity = FALSE;
|
|
|
|
settings->ExtSecurity = 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 = TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
else if (strcmp("tls", arg->Value) == 0) /* TLS */
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->RdpSecurity = FALSE;
|
|
|
|
settings->TlsSecurity = TRUE;
|
|
|
|
settings->NlaSecurity = FALSE;
|
|
|
|
settings->ExtSecurity = FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
else if (strcmp("nla", arg->Value) == 0) /* NLA */
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->RdpSecurity = FALSE;
|
|
|
|
settings->TlsSecurity = FALSE;
|
|
|
|
settings->NlaSecurity = TRUE;
|
|
|
|
settings->ExtSecurity = FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
else if (strcmp("ext", arg->Value) == 0) /* NLA Extended */
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->RdpSecurity = FALSE;
|
|
|
|
settings->TlsSecurity = FALSE;
|
|
|
|
settings->NlaSecurity = FALSE;
|
|
|
|
settings->ExtSecurity = TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-15 10:47:16 +03:00
|
|
|
WLog_ERR(TAG, "unknown protocol security: %s", arg->Value);
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
CommandLineSwitchCase(arg, "encryption-methods")
|
|
|
|
{
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
UINT32 i;
|
|
|
|
char** p;
|
2017-11-30 18:56:45 +03:00
|
|
|
size_t count = 0;
|
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
|
|
|
p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(p[i], "40"))
|
|
|
|
settings->EncryptionMethods |= ENCRYPTION_METHOD_40BIT;
|
|
|
|
else if (!strcmp(p[i], "56"))
|
|
|
|
settings->EncryptionMethods |= ENCRYPTION_METHOD_56BIT;
|
|
|
|
else if (!strcmp(p[i], "128"))
|
|
|
|
settings->EncryptionMethods |= ENCRYPTION_METHOD_128BIT;
|
|
|
|
else if (!strcmp(p[i], "FIPS"))
|
|
|
|
settings->EncryptionMethods |= ENCRYPTION_METHOD_FIPS;
|
|
|
|
else
|
2015-06-15 10:47:16 +03:00
|
|
|
WLog_ERR(TAG, "unknown encryption method '%s'", p[i]);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
}
|
2015-06-23 15:59:54 +03:00
|
|
|
CommandLineSwitchCase(arg, "from-stdin")
|
|
|
|
{
|
|
|
|
settings->CredentialsFromStdin = TRUE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-11-10 13:52:23 +03:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
promptForPassword = (strncmp(arg->Value, "force", 6) == 0);
|
|
|
|
|
|
|
|
if (!promptForPassword)
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2015-06-23 15:59:54 +03:00
|
|
|
}
|
2016-01-23 17:16:13 +03:00
|
|
|
CommandLineSwitchCase(arg, "log-level")
|
|
|
|
{
|
|
|
|
wLog* root = WLog_GetRoot();
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-01-23 17:16:13 +03:00
|
|
|
if (!WLog_SetStringLogLevel(root, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "log-filters")
|
|
|
|
{
|
|
|
|
if (!WLog_AddStringLogFilters(arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "sec-rdp")
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->RdpSecurity = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec-tls")
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->TlsSecurity = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec-nla")
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->NlaSecurity = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec-ext")
|
|
|
|
{
|
2012-11-07 20:02:46 +04:00
|
|
|
settings->ExtSecurity = arg->Value ? TRUE : FALSE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2014-07-17 16:59:06 +04:00
|
|
|
CommandLineSwitchCase(arg, "tls-ciphers")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->AllowedTlsCiphers);
|
|
|
|
|
2015-02-06 22:21:26 +03:00
|
|
|
if (strcmp(arg->Value, "netmon") == 0)
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AllowedTlsCiphers = _strdup("ALL:!ECDH")))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2015-02-06 22:21:26 +03:00
|
|
|
}
|
|
|
|
else if (strcmp(arg->Value, "ma") == 0)
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AllowedTlsCiphers = _strdup("AES128-SHA")))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2015-02-06 22:21:26 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->AllowedTlsCiphers = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2015-02-06 22:21:26 +03:00
|
|
|
}
|
2014-07-17 16:59:06 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "cert-name")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->CertificateName);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->CertificateName = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "cert-ignore")
|
|
|
|
{
|
2012-11-08 00:13:14 +04:00
|
|
|
settings->IgnoreCertificate = TRUE;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2016-03-31 13:16:55 +03:00
|
|
|
CommandLineSwitchCase(arg, "cert-tofu")
|
|
|
|
{
|
|
|
|
settings->AutoAcceptCertificate = TRUE;
|
|
|
|
}
|
2012-11-15 08:06:56 +04:00
|
|
|
CommandLineSwitchCase(arg, "authentication")
|
|
|
|
{
|
|
|
|
settings->Authentication = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "encryption")
|
|
|
|
{
|
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 = arg->Value ? FALSE : TRUE;
|
2012-11-15 08:06:56 +04:00
|
|
|
}
|
2012-11-15 19:00:07 +04:00
|
|
|
CommandLineSwitchCase(arg, "grab-keyboard")
|
|
|
|
{
|
|
|
|
settings->GrabKeyboard = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2015-07-14 02:03:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "unmap-buttons")
|
|
|
|
{
|
|
|
|
settings->UnmapButtons = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2013-02-28 20:32:46 +04:00
|
|
|
CommandLineSwitchCase(arg, "toggle-fullscreen")
|
|
|
|
{
|
|
|
|
settings->ToggleFullscreen = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "mouse-motion")
|
|
|
|
{
|
|
|
|
settings->MouseMotion = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "parent-window")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
UINT64 val = _strtoui64(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->ParentWindowId = val;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "bitmap-cache")
|
|
|
|
{
|
|
|
|
settings->BitmapCacheEnabled = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "offscreen-cache")
|
|
|
|
{
|
2012-11-27 01:49:12 +04:00
|
|
|
settings->OffscreenSupportLevel = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "glyph-cache")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
settings->GlyphSupportLevel = arg->Value ? GLYPH_SUPPORT_FULL :
|
|
|
|
GLYPH_SUPPORT_NONE;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "codec-cache")
|
|
|
|
{
|
|
|
|
settings->BitmapCacheV3Enabled = TRUE;
|
|
|
|
|
|
|
|
if (strcmp(arg->Value, "rfx") == 0)
|
|
|
|
{
|
|
|
|
settings->RemoteFxCodec = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(arg->Value, "nsc") == 0)
|
|
|
|
{
|
|
|
|
settings->NSCodec = TRUE;
|
|
|
|
}
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-07-24 16:23:36 +03:00
|
|
|
#if defined(WITH_JPEG)
|
2012-11-27 01:49:12 +04:00
|
|
|
else if (strcmp(arg->Value, "jpeg") == 0)
|
|
|
|
{
|
|
|
|
settings->JpegCodec = TRUE;
|
|
|
|
|
|
|
|
if (settings->JpegQuality == 0)
|
|
|
|
settings->JpegQuality = 75;
|
|
|
|
}
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-07-24 16:23:36 +03:00
|
|
|
#endif
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "fast-path")
|
|
|
|
{
|
|
|
|
settings->FastPathInput = arg->Value ? TRUE : FALSE;
|
|
|
|
settings->FastPathOutput = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2013-05-14 12:24:05 +04:00
|
|
|
CommandLineSwitchCase(arg, "max-fast-path-size")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->MultifragMaxRequestSize = val;
|
2013-05-14 12:24:05 +04:00
|
|
|
}
|
2016-10-17 19:56:52 +03:00
|
|
|
CommandLineSwitchCase(arg, "max-loop-time")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->MaxTimeInCheckLoop = val;
|
2016-12-16 14:56:17 +03:00
|
|
|
|
2016-11-25 14:40:11 +03:00
|
|
|
if ((long) settings->MaxTimeInCheckLoop < 0)
|
2016-10-17 19:56:52 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "invalid max loop time: %s", arg->Value);
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
|
2016-11-25 14:40:11 +03:00
|
|
|
if ((long) settings->MaxTimeInCheckLoop <= 0)
|
2016-10-17 19:56:52 +03:00
|
|
|
{
|
|
|
|
settings->MaxTimeInCheckLoop = 10 * 60 * 60 * 1000; /* 10 hours can be considered as infinite */
|
|
|
|
}
|
|
|
|
}
|
2013-01-28 03:22:46 +04:00
|
|
|
CommandLineSwitchCase(arg, "async-input")
|
|
|
|
{
|
|
|
|
settings->AsyncInput = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "async-update")
|
|
|
|
{
|
|
|
|
settings->AsyncUpdate = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2013-02-19 21:29:15 +04:00
|
|
|
CommandLineSwitchCase(arg, "async-channels")
|
|
|
|
{
|
|
|
|
settings->AsyncChannels = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2013-03-27 21:03:41 +04:00
|
|
|
CommandLineSwitchCase(arg, "async-transport")
|
|
|
|
{
|
|
|
|
settings->AsyncTransport = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2013-03-26 18:47:39 +04:00
|
|
|
CommandLineSwitchCase(arg, "wm-class")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->WmClass);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->WmClass = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2013-03-26 18:47:39 +04:00
|
|
|
}
|
2013-05-27 17:28:08 +04:00
|
|
|
CommandLineSwitchCase(arg, "play-rfx")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->PlayRemoteFxFile);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->PlayRemoteFxFile = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2013-05-27 17:28:08 +04:00
|
|
|
settings->PlayRemoteFx = TRUE;
|
|
|
|
}
|
2013-05-27 17:35:25 +04:00
|
|
|
CommandLineSwitchCase(arg, "auth-only")
|
|
|
|
{
|
|
|
|
settings->AuthenticationOnly = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2014-02-28 01:55:07 +04:00
|
|
|
CommandLineSwitchCase(arg, "auto-reconnect")
|
|
|
|
{
|
|
|
|
settings->AutoReconnectionEnabled = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2016-12-16 14:56:17 +03:00
|
|
|
CommandLineSwitchCase(arg, "auto-reconnect-max-retries")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->AutoReconnectMaxRetries = val;
|
2016-12-16 14:56:17 +03:00
|
|
|
|
2017-07-10 16:29:09 +03:00
|
|
|
if (settings->AutoReconnectMaxRetries > 1000)
|
2016-12-16 14:56:17 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2013-10-22 19:14:29 +04:00
|
|
|
CommandLineSwitchCase(arg, "reconnect-cookie")
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
BYTE* base64;
|
2013-10-22 19:14:29 +04:00
|
|
|
int length;
|
2016-08-04 17:13:37 +03:00
|
|
|
crypto_base64_decode((const char*)(arg->Value), (int) strlen(arg->Value),
|
|
|
|
&base64, &length);
|
|
|
|
|
2013-10-22 19:14:29 +04:00
|
|
|
if ((base64 != NULL) && (length == sizeof(ARC_SC_PRIVATE_PACKET)))
|
|
|
|
{
|
|
|
|
memcpy(settings->ServerAutoReconnectCookie, base64, length);
|
|
|
|
free(base64);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-15 10:47:16 +03:00
|
|
|
WLog_ERR(TAG, "reconnect-cookie: invalid base64 '%s'", arg->Value);
|
2013-10-22 19:14:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "print-reconnect-cookie")
|
|
|
|
{
|
|
|
|
settings->PrintReconnectCookie = arg->Value ? TRUE : FALSE;
|
|
|
|
}
|
2014-06-29 02:33:46 +04:00
|
|
|
CommandLineSwitchCase(arg, "assistance")
|
|
|
|
{
|
2014-06-30 20:51:27 +04:00
|
|
|
settings->RemoteAssistanceMode = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
free(settings->RemoteAssistancePassword);
|
|
|
|
|
2015-06-18 14:00:10 +03:00
|
|
|
if (!(settings->RemoteAssistancePassword = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2014-06-29 02:33:46 +04:00
|
|
|
}
|
2015-03-04 17:37:25 +03:00
|
|
|
CommandLineSwitchCase(arg, "pwidth")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->DesktopPhysicalWidth = val;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "pheight")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->DesktopPhysicalHeight = val;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "orientation")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > INT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->DesktopOrientation = val;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "scale")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long scaleFactor = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
if (scaleFactor == 100 || scaleFactor == 140 || scaleFactor == 180)
|
|
|
|
{
|
2015-03-04 17:37:25 +03:00
|
|
|
settings->DesktopScaleFactor = scaleFactor;
|
|
|
|
settings->DeviceScaleFactor = scaleFactor;
|
2016-08-04 17:13:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-04 17:37:25 +03:00
|
|
|
WLog_ERR(TAG, "scale: invalid scale factor (%d)", scaleFactor);
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "scale-desktop")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long desktopScaleFactor = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2015-03-04 17:37:25 +03:00
|
|
|
if (desktopScaleFactor >= 100 && desktopScaleFactor <= 500)
|
|
|
|
{
|
|
|
|
settings->DesktopScaleFactor = desktopScaleFactor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "scale: invalid desktop scale factor (%d)", desktopScaleFactor);
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "scale-device")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long deviceScaleFactor = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
if (deviceScaleFactor == 100 || deviceScaleFactor == 140
|
|
|
|
|| deviceScaleFactor == 180)
|
2015-03-04 17:37:25 +03:00
|
|
|
{
|
|
|
|
settings->DeviceScaleFactor = deviceScaleFactor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "scale: invalid device scale factor (%d)", deviceScaleFactor);
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2017-02-06 07:54:54 +03:00
|
|
|
CommandLineSwitchCase(arg, "action-script")
|
|
|
|
{
|
2017-05-15 14:43:51 +03:00
|
|
|
free(settings->ActionScript);
|
|
|
|
|
2017-02-06 07:54:54 +03:00
|
|
|
if (!(settings->ActionScript = _strdup(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2017-04-08 00:54:08 +03:00
|
|
|
CommandLineSwitchCase(arg, "fipsmode")
|
|
|
|
{
|
|
|
|
settings->FIPSMode = TRUE;
|
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CommandLineSwitchEnd(arg)
|
|
|
|
}
|
|
|
|
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
|
|
|
|
2017-02-16 22:16:56 +03:00
|
|
|
if (user)
|
2015-06-18 12:35:22 +03:00
|
|
|
{
|
2017-02-10 23:38:52 +03:00
|
|
|
free(settings->Username);
|
2017-05-15 14:43:51 +03:00
|
|
|
|
2017-02-10 23:38:52 +03:00
|
|
|
if (!settings->Domain && user)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
free(settings->Domain);
|
|
|
|
ret = freerdp_parse_username(user, &settings->Username, &settings->Domain);
|
|
|
|
free(user);
|
2017-05-15 14:43:51 +03:00
|
|
|
|
2017-02-10 23:38:52 +03:00
|
|
|
if (!ret)
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
settings->Username = user;
|
2015-06-18 12:35:22 +03:00
|
|
|
}
|
|
|
|
|
2017-02-17 13:53:57 +03:00
|
|
|
if (gwUser)
|
2015-06-18 12:35:22 +03:00
|
|
|
{
|
2017-02-17 13:53:57 +03:00
|
|
|
free(settings->GatewayUsername);
|
|
|
|
|
|
|
|
if (!settings->GatewayDomain && gwUser)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
free(settings->GatewayDomain);
|
|
|
|
ret = freerdp_parse_username(gwUser, &settings->GatewayUsername,
|
2017-05-15 14:43:51 +03:00
|
|
|
&settings->GatewayDomain);
|
2017-02-17 13:53:57 +03:00
|
|
|
free(gwUser);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
settings->GatewayUsername = gwUser;
|
2015-06-18 12:35:22 +03:00
|
|
|
}
|
|
|
|
|
2017-11-10 13:52:23 +03:00
|
|
|
if (promptForPassword)
|
|
|
|
{
|
|
|
|
const size_t size = 512;
|
|
|
|
|
|
|
|
if (!settings->Password)
|
|
|
|
{
|
|
|
|
settings->Password = calloc(size, sizeof(char));
|
|
|
|
|
|
|
|
if (!settings->Password)
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (!freerdp_passphrase_read("Password: ", settings->Password, size, 1))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->GatewayEnabled && !settings->GatewayUseSameCredentials)
|
|
|
|
{
|
|
|
|
if (!settings->GatewayPassword)
|
|
|
|
{
|
|
|
|
settings->GatewayPassword = calloc(size, sizeof(char));
|
|
|
|
|
|
|
|
if (!settings->GatewayPassword)
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (!freerdp_passphrase_read("Gateway Password: ", settings->GatewayPassword, size, 1))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-17 22:56:23 +04:00
|
|
|
freerdp_performance_flags_make(settings);
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
if (settings->RemoteFxCodec || settings->NSCodec
|
|
|
|
|| settings->SupportGraphicsPipeline)
|
2014-07-03 22:35:03 +04:00
|
|
|
{
|
|
|
|
settings->FastPathOutput = TRUE;
|
|
|
|
settings->LargePointerFlag = TRUE;
|
|
|
|
settings->FrameMarkerCommandEnabled = TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
settings->ColorDepth = 32;
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 20:54:42 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "port");
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
settings->ServerPort = val;
|
2014-02-05 20:54:42 +04:00
|
|
|
}
|
|
|
|
|
2012-12-06 01:04:01 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "p");
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
|
|
|
FillMemory(arg->Value, strlen(arg->Value), '*');
|
|
|
|
}
|
|
|
|
|
|
|
|
arg = CommandLineFindArgumentA(args, "gp");
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
|
|
|
FillMemory(arg->Value, strlen(arg->Value), '*');
|
|
|
|
}
|
|
|
|
|
2013-07-03 18:41:26 +04:00
|
|
|
return status;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels,
|
|
|
|
rdpSettings* settings, char* name, void* data)
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2016-11-15 18:58:38 +03:00
|
|
|
PVIRTUALCHANNELENTRY entry = NULL;
|
|
|
|
PVIRTUALCHANNELENTRYEX entryEx = NULL;
|
2016-11-16 17:52:24 +03:00
|
|
|
entryEx = (PVIRTUALCHANNELENTRYEX) freerdp_load_channel_addin_entry(name, NULL, NULL,
|
2016-12-16 14:56:17 +03:00
|
|
|
FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
|
2012-11-19 22:26:56 +04:00
|
|
|
|
2016-11-16 17:52:24 +03:00
|
|
|
if (!entryEx)
|
|
|
|
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
|
2016-11-15 18:58:38 +03:00
|
|
|
|
|
|
|
if (entryEx)
|
|
|
|
{
|
|
|
|
if (freerdp_channels_client_load_ex(channels, settings, entryEx, data) == 0)
|
|
|
|
{
|
|
|
|
WLog_INFO(TAG, "loading channelEx %s", name);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (entry)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
|
|
|
if (freerdp_channels_client_load(channels, settings, entry, data) == 0)
|
2012-11-19 22:26:56 +04:00
|
|
|
{
|
2015-06-15 10:47:16 +03:00
|
|
|
WLog_INFO(TAG, "loading channel %s", name);
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-21 18:30:06 +04:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
2014-02-10 10:06:11 +04:00
|
|
|
UINT32 index;
|
2012-11-21 18:30:06 +04:00
|
|
|
ADDIN_ARGV* args;
|
|
|
|
|
2012-11-26 10:34:40 +04:00
|
|
|
if ((freerdp_static_channel_collection_find(settings, "rdpsnd")) ||
|
2016-02-01 17:09:51 +03:00
|
|
|
(freerdp_dynamic_channel_collection_find(settings, "tsmf")))
|
2012-11-26 10:34:40 +04:00
|
|
|
{
|
2013-05-11 00:39:16 +04:00
|
|
|
settings->DeviceRedirection = TRUE; /* rdpsnd requires rdpdr to be registered */
|
2016-08-04 17:13:37 +03:00
|
|
|
settings->AudioPlayback =
|
|
|
|
TRUE; /* Both rdpsnd and tsmf require this flag to be set */
|
2012-11-26 10:34:40 +04:00
|
|
|
}
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2013-05-17 17:29:53 +04:00
|
|
|
if (freerdp_dynamic_channel_collection_find(settings, "audin"))
|
|
|
|
{
|
|
|
|
settings->AudioCapture = TRUE;
|
|
|
|
}
|
|
|
|
|
2014-01-30 07:53:32 +04:00
|
|
|
if (settings->NetworkAutoDetect ||
|
2016-02-01 17:09:51 +03:00
|
|
|
settings->SupportHeartbeatPdu ||
|
|
|
|
settings->SupportMultitransport)
|
2014-01-30 07:53:32 +04:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
settings->DeviceRedirection =
|
|
|
|
TRUE; /* these RDP8 features require rdpdr to be registered */
|
2014-01-30 07:53:32 +04:00
|
|
|
}
|
|
|
|
|
2016-08-04 17:13:37 +03:00
|
|
|
if (settings->RedirectDrives || settings->RedirectHomeDrive
|
|
|
|
|| settings->RedirectSerialPorts
|
2016-02-01 17:09:51 +03:00
|
|
|
|| settings->RedirectSmartCards || settings->RedirectPrinters)
|
2013-02-15 04:38:45 +04:00
|
|
|
{
|
2014-04-28 05:29:44 +04:00
|
|
|
settings->DeviceRedirection = TRUE; /* All of these features require rdpdr */
|
|
|
|
}
|
2013-02-15 04:38:45 +04:00
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
if (settings->RedirectDrives)
|
|
|
|
{
|
2013-02-15 04:38:45 +04:00
|
|
|
if (!freerdp_device_collection_find(settings, "drive"))
|
|
|
|
{
|
|
|
|
char* params[3];
|
|
|
|
params[0] = "drive";
|
|
|
|
params[1] = "media";
|
|
|
|
params[2] = "*";
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_device_channel(settings, 3, (char**) params))
|
|
|
|
return FALSE;
|
2013-02-15 04:38:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->RedirectHomeDrive)
|
|
|
|
{
|
|
|
|
if (!freerdp_device_collection_find(settings, "drive"))
|
|
|
|
{
|
|
|
|
char* params[3];
|
|
|
|
params[0] = "drive";
|
|
|
|
params[1] = "home";
|
|
|
|
params[2] = "%";
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_device_channel(settings, 3, (char**) params))
|
|
|
|
return FALSE;
|
2013-02-15 04:38:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-09 04:01:52 +04:00
|
|
|
if (settings->DeviceRedirection)
|
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, "rdpdr",
|
2017-05-15 14:43:51 +03:00
|
|
|
settings))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2012-11-21 18:30:06 +04:00
|
|
|
if (!freerdp_static_channel_collection_find(settings, "rdpsnd"))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2012-11-21 18:30:06 +04:00
|
|
|
char* params[2];
|
|
|
|
params[0] = "rdpsnd";
|
|
|
|
params[1] = "sys:fake";
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_static_channel(settings, 2, (char**) params))
|
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-28 05:29:44 +04:00
|
|
|
if (settings->RedirectSmartCards)
|
|
|
|
{
|
|
|
|
RDPDR_SMARTCARD* smartcard;
|
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_SMARTCARD))
|
|
|
|
{
|
|
|
|
smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
|
2014-04-28 05:29:44 +04:00
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!smartcard)
|
|
|
|
return FALSE;
|
2014-04-28 05:29:44 +04:00
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
smartcard->Type = RDPDR_DTYP_SMARTCARD;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-04-28 05:29:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->RedirectPrinters)
|
|
|
|
{
|
|
|
|
RDPDR_PRINTER* printer;
|
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_PRINT))
|
|
|
|
{
|
|
|
|
printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
|
2014-04-28 05:29:44 +04:00
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!printer)
|
|
|
|
return FALSE;
|
2014-04-28 05:29:44 +04:00
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
printer->Type = RDPDR_DTYP_PRINT;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-04-28 05:29:44 +04:00
|
|
|
}
|
|
|
|
|
2012-11-21 20:56:40 +04:00
|
|
|
if (settings->RedirectClipboard)
|
2012-11-21 04:34:52 +04:00
|
|
|
{
|
2017-02-22 15:46:47 +03:00
|
|
|
char* params[1];
|
|
|
|
params[0] = "cliprdr";
|
2012-11-21 20:56:40 +04:00
|
|
|
|
2017-02-22 15:46:47 +03:00
|
|
|
if (!freerdp_client_add_static_channel(settings, 1, (char**) params))
|
|
|
|
return FALSE;
|
2012-11-21 18:30:06 +04:00
|
|
|
}
|
2012-11-21 04:34:52 +04:00
|
|
|
|
2014-11-21 23:10:39 +03:00
|
|
|
if (settings->LyncRdpMode)
|
|
|
|
{
|
|
|
|
settings->EncomspVirtualChannel = TRUE;
|
|
|
|
settings->RemdeskVirtualChannel = TRUE;
|
|
|
|
settings->CompressionEnabled = FALSE;
|
|
|
|
}
|
|
|
|
|
2014-06-29 02:33:46 +04:00
|
|
|
if (settings->RemoteAssistanceMode)
|
|
|
|
{
|
2014-11-21 23:10:39 +03:00
|
|
|
settings->EncomspVirtualChannel = TRUE;
|
|
|
|
settings->RemdeskVirtualChannel = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings->EncomspVirtualChannel)
|
2016-02-01 17:09:51 +03:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, "encomsp",
|
2017-05-15 14:43:51 +03:00
|
|
|
settings))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-21 23:10:39 +03:00
|
|
|
|
|
|
|
if (settings->RemdeskVirtualChannel)
|
2016-02-01 17:09:51 +03:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, "remdesk",
|
2017-05-15 14:43:51 +03:00
|
|
|
settings))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-06-29 02:33:46 +04:00
|
|
|
|
2012-11-21 20:56:40 +04:00
|
|
|
for (index = 0; index < settings->StaticChannelCount; index++)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
2012-11-21 20:56:40 +04:00
|
|
|
args = settings->StaticChannelArray[index];
|
2016-08-04 17:13:37 +03:00
|
|
|
|
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, args->argv[0],
|
|
|
|
args))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-21 04:34:52 +04:00
|
|
|
}
|
|
|
|
|
2012-11-19 22:26:56 +04:00
|
|
|
if (settings->RemoteApplicationMode)
|
2012-11-19 02:32:18 +04:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, "rail",
|
|
|
|
settings))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-19 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-26 01:31:05 +04:00
|
|
|
if (settings->MultiTouchInput)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "rdpei";
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
2014-09-26 01:31:05 +04:00
|
|
|
}
|
|
|
|
|
2013-10-22 07:33:25 +04:00
|
|
|
if (settings->SupportGraphicsPipeline)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "rdpgfx";
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
2013-10-22 07:33:25 +04:00
|
|
|
}
|
|
|
|
|
2014-09-26 01:31:05 +04:00
|
|
|
if (settings->SupportEchoChannel)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "echo";
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
2014-09-26 01:31:05 +04:00
|
|
|
}
|
|
|
|
|
2017-06-26 23:16:22 +03:00
|
|
|
if (settings->SupportSSHAgentChannel)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "sshagent";
|
|
|
|
|
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-09-26 01:31:05 +04:00
|
|
|
if (settings->SupportDisplayControl)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "disp";
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
2014-09-26 01:31:05 +04:00
|
|
|
}
|
|
|
|
|
2017-12-06 15:51:45 +03:00
|
|
|
if (settings->SupportGeometryTracking)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "geometry";
|
|
|
|
|
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-12-08 00:50:29 +03:00
|
|
|
if (settings->SupportVideoOptimized)
|
|
|
|
{
|
|
|
|
char* p[1];
|
|
|
|
int count;
|
|
|
|
count = 1;
|
|
|
|
p[0] = "video";
|
|
|
|
|
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, count, p))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-11-19 02:32:18 +04:00
|
|
|
if (settings->DynamicChannelCount)
|
2014-08-15 03:23:48 +04:00
|
|
|
settings->SupportDynamicChannels = TRUE;
|
|
|
|
|
|
|
|
if (settings->SupportDynamicChannels)
|
2012-11-19 02:32:18 +04:00
|
|
|
{
|
2016-08-04 17:13:37 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, "drdynvc",
|
|
|
|
settings))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-19 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|