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.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2016-12-11 01:13:35 +03:00
|
|
|
#include <ctype.h>
|
2017-11-14 18:10:52 +03:00
|
|
|
#include <errno.h>
|
2013-10-02 11:48:25 +04:00
|
|
|
|
2022-02-02 01:23:34 +03:00
|
|
|
#include <winpr/assert.h>
|
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>
|
2022-02-02 01:23:34 +03:00
|
|
|
#include <winpr/ncrypt.h>
|
2023-06-05 11:53:30 +03:00
|
|
|
#include <winpr/environment.h>
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2023-03-14 12:39:18 +03:00
|
|
|
#include <freerdp/freerdp.h>
|
2012-11-18 07:03:04 +04:00
|
|
|
#include <freerdp/addin.h>
|
2012-11-09 23:35:21 +04:00
|
|
|
#include <freerdp/settings.h>
|
2023-03-14 12:39:18 +03:00
|
|
|
#include <freerdp/client.h>
|
2012-11-09 04:01:52 +04:00
|
|
|
#include <freerdp/client/channels.h>
|
2021-08-25 11:02:46 +03:00
|
|
|
#include <freerdp/channels/drdynvc.h>
|
|
|
|
#include <freerdp/channels/cliprdr.h>
|
|
|
|
#include <freerdp/channels/encomsp.h>
|
|
|
|
#include <freerdp/channels/rdp2tcp.h>
|
|
|
|
#include <freerdp/channels/remdesk.h>
|
|
|
|
#include <freerdp/channels/rdpsnd.h>
|
2022-02-22 12:54:42 +03:00
|
|
|
#include <freerdp/channels/disp.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>
|
2017-11-10 13:52:23 +03:00
|
|
|
#include <freerdp/utils/passphrase.h>
|
2022-04-04 13:59:37 +03:00
|
|
|
#include <freerdp/utils/proxy_utils.h>
|
2019-11-22 12:43:29 +03:00
|
|
|
#include <freerdp/channels/urbdrc.h>
|
2021-09-22 15:27:21 +03:00
|
|
|
#include <freerdp/channels/rdpdr.h>
|
2014-09-12 19:13:01 +04:00
|
|
|
|
2022-01-17 16:21:17 +03:00
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
|
|
|
#include <freerdp/channels/ainput.h>
|
|
|
|
#endif
|
|
|
|
|
2023-11-01 09:07:44 +03:00
|
|
|
#include <freerdp/channels/audin.h>
|
|
|
|
#include <freerdp/channels/echo.h>
|
|
|
|
|
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>
|
2022-02-23 18:26:14 +03:00
|
|
|
#include <freerdp/client/utils/smartcard_cli.h>
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2023-02-03 14:11:46 +03:00
|
|
|
#include <openssl/tls1.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")
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
static const char* option_starts_with(const char* what, const char* val);
|
2022-10-27 11:29:01 +03:00
|
|
|
static BOOL option_ends_with(const char* str, const char* ext);
|
|
|
|
static BOOL option_equals(const char* what, const char* val);
|
|
|
|
|
2019-11-08 17:42:05 +03:00
|
|
|
static BOOL freerdp_client_print_codepages(const char* arg)
|
|
|
|
{
|
2022-10-19 17:03:20 +03:00
|
|
|
size_t count = 0;
|
2019-11-08 17:42:05 +03:00
|
|
|
DWORD column = 2;
|
|
|
|
const char* filter = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
RDP_CODEPAGE* pages = NULL;
|
2019-11-08 17:42:05 +03:00
|
|
|
|
|
|
|
if (arg)
|
2022-10-19 17:03:20 +03:00
|
|
|
{
|
|
|
|
filter = strchr(arg, ',');
|
|
|
|
if (!filter)
|
|
|
|
filter = arg;
|
|
|
|
else
|
|
|
|
filter++;
|
|
|
|
}
|
2019-11-08 17:42:05 +03:00
|
|
|
pages = freerdp_keyboard_get_matching_codepages(column, filter, &count);
|
|
|
|
if (!pages)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
printf("%-10s %-8s %-60s %-36s %-48s\n", "<id>", "<locale>", "<win langid>", "<language>",
|
|
|
|
"<country>");
|
2022-10-19 17:03:20 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
2019-11-08 17:42:05 +03:00
|
|
|
{
|
|
|
|
const RDP_CODEPAGE* page = &pages[x];
|
2023-06-26 12:08:21 +03:00
|
|
|
char buffer[520] = { 0 };
|
2022-10-19 17:03:20 +03:00
|
|
|
|
2019-11-08 17:42:05 +03:00
|
|
|
if (strnlen(page->subLanguageSymbol, ARRAYSIZE(page->subLanguageSymbol)) > 0)
|
|
|
|
_snprintf(buffer, sizeof(buffer), "[%s|%s]", page->primaryLanguageSymbol,
|
|
|
|
page->subLanguageSymbol);
|
|
|
|
else
|
|
|
|
_snprintf(buffer, sizeof(buffer), "[%s]", page->primaryLanguageSymbol);
|
|
|
|
printf("id=0x%04" PRIx16 ": [%-6s] %-60s %-36s %-48s\n", page->id, page->locale, buffer,
|
|
|
|
page->primaryLanguage, page->subLanguage);
|
|
|
|
}
|
|
|
|
freerdp_codepages_free(pages);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:47:31 +03:00
|
|
|
static BOOL freerdp_path_valid(const char* path, BOOL* special)
|
|
|
|
{
|
|
|
|
const char DynamicDrives[] = "DynamicDrives";
|
|
|
|
BOOL isPath = FALSE;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL isSpecial = 0;
|
2019-08-23 12:47:31 +03:00
|
|
|
if (!path)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-10-27 11:29:01 +03:00
|
|
|
isSpecial =
|
|
|
|
(option_equals("*", path) || option_equals(DynamicDrives, path) || option_equals("%", path))
|
|
|
|
? TRUE
|
|
|
|
: FALSE;
|
2019-08-23 12:47:31 +03:00
|
|
|
if (!isSpecial)
|
2021-05-31 12:42:03 +03:00
|
|
|
isPath = winpr_PathFileExists(path);
|
2019-08-23 12:47:31 +03:00
|
|
|
|
|
|
|
if (special)
|
|
|
|
*special = isSpecial;
|
|
|
|
|
|
|
|
return isSpecial || isPath;
|
|
|
|
}
|
|
|
|
|
2019-08-23 13:44:44 +03:00
|
|
|
static BOOL freerdp_sanitize_drive_name(char* name, const char* invalid, const char* replacement)
|
|
|
|
{
|
|
|
|
if (!name || !invalid || !replacement)
|
|
|
|
return FALSE;
|
|
|
|
if (strlen(invalid) != strlen(replacement))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
while (*invalid != '\0')
|
2019-08-23 13:44:44 +03:00
|
|
|
{
|
|
|
|
const char what = *invalid++;
|
|
|
|
const char with = *replacement++;
|
|
|
|
|
|
|
|
char* cur = name;
|
2019-11-06 17:24:51 +03:00
|
|
|
while ((cur = strchr(cur, what)) != NULL)
|
2019-08-23 13:44:44 +03:00
|
|
|
*cur = with;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-03-09 14:09:58 +03:00
|
|
|
static char* name_from_path(const char* path)
|
|
|
|
{
|
|
|
|
const char* name = "NULL";
|
|
|
|
if (path)
|
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals("%", path))
|
2021-03-09 14:09:58 +03:00
|
|
|
name = "home";
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals("*", path))
|
2021-03-09 14:09:58 +03:00
|
|
|
name = "hotplug-all";
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals("DynamicDrives", path))
|
2021-03-09 14:09:58 +03:00
|
|
|
name = "hotplug";
|
|
|
|
else
|
|
|
|
name = path;
|
|
|
|
}
|
|
|
|
return _strdup(name);
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:47:31 +03:00
|
|
|
static BOOL freerdp_client_add_drive(rdpSettings* settings, const char* path, const char* name)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
char* dname = NULL;
|
2021-10-07 11:43:16 +03:00
|
|
|
RDPDR_DEVICE* device = NULL;
|
2019-08-23 12:47:31 +03:00
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
2023-07-31 10:42:44 +03:00
|
|
|
BOOL skip = FALSE;
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
switch (path[0])
|
|
|
|
{
|
|
|
|
case '*':
|
|
|
|
case '%':
|
|
|
|
skip = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-08-23 12:47:31 +03:00
|
|
|
/* Path was entered as secondary argument, swap */
|
2023-07-31 10:42:44 +03:00
|
|
|
if (!skip && winpr_PathFileExists(name))
|
2019-08-23 12:47:31 +03:00
|
|
|
{
|
2021-05-31 12:42:03 +03:00
|
|
|
if (!winpr_PathFileExists(path) || (!PathIsRelativeA(name) && PathIsRelativeA(path)))
|
2019-09-24 16:44:34 +03:00
|
|
|
{
|
|
|
|
const char* tmp = path;
|
|
|
|
path = name;
|
|
|
|
name = tmp;
|
|
|
|
}
|
2019-08-23 12:47:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name)
|
2021-10-07 11:43:16 +03:00
|
|
|
dname = _strdup(name);
|
2019-08-23 12:47:31 +03:00
|
|
|
else /* We need a name to send to the server. */
|
2021-10-07 11:43:16 +03:00
|
|
|
dname = name_from_path(path);
|
|
|
|
|
|
|
|
if (freerdp_sanitize_drive_name(dname, "\\/", "__"))
|
2021-03-09 14:09:58 +03:00
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
const char* args[] = { dname, path };
|
|
|
|
device = freerdp_device_new(RDPDR_DTYP_FILESYSTEM, ARRAYSIZE(args), args);
|
2021-03-09 14:09:58 +03:00
|
|
|
}
|
2021-10-07 11:43:16 +03:00
|
|
|
free(dname);
|
|
|
|
if (!device)
|
2022-05-01 11:57:11 +03:00
|
|
|
goto fail;
|
2019-08-23 12:47:31 +03:00
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!path)
|
2019-08-23 12:47:31 +03:00
|
|
|
goto fail;
|
2024-03-18 11:30:42 +03:00
|
|
|
|
2019-08-23 12:47:31 +03:00
|
|
|
{
|
|
|
|
BOOL isSpecial = FALSE;
|
|
|
|
BOOL isPath = freerdp_path_valid(path, &isSpecial);
|
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!isPath && !isSpecial)
|
2024-03-18 11:30:42 +03:00
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "Invalid drive to redirect: '%s' does not exist, skipping.", path);
|
|
|
|
freerdp_device_free(device);
|
|
|
|
}
|
|
|
|
else if (!freerdp_device_collection_add(settings, device))
|
2019-08-23 12:47:31 +03:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
fail:
|
2021-10-07 11:43:16 +03:00
|
|
|
freerdp_device_free(device);
|
2019-08-23 12:47:31 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
static BOOL value_to_int(const char* value, LONGLONG* result, LONGLONG min, LONGLONG max)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
long long rc = 0;
|
2018-11-22 18:28:30 +03:00
|
|
|
|
|
|
|
if (!value || !result)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
rc = _strtoi64(value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((rc < min) || (rc > max))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*result = rc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL value_to_uint(const char* value, ULONGLONG* result, ULONGLONG min, ULONGLONG max)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
unsigned long long rc = 0;
|
2018-11-22 18:28:30 +03:00
|
|
|
|
|
|
|
if (!value || !result)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
rc = _strtoui64(value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((rc < min) || (rc > max))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*result = rc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-05-04 15:46:58 +03:00
|
|
|
BOOL freerdp_client_print_version(void)
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
2021-05-18 13:31:59 +03:00
|
|
|
printf("This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL, FREERDP_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
|
|
|
}
|
|
|
|
|
2021-09-10 14:03:09 +03:00
|
|
|
static void freerdp_client_print_scancodes(void)
|
|
|
|
{
|
2022-10-20 11:44:18 +03:00
|
|
|
printf("RDP scancodes and their name for use with /kbd:remap\n");
|
2021-09-10 14:03:09 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 x = 0; x < UINT16_MAX; x++)
|
2021-09-10 14:03:09 +03:00
|
|
|
{
|
|
|
|
const char* name = freerdp_keyboard_scancode_name(x);
|
|
|
|
if (name)
|
2022-02-01 18:46:03 +03:00
|
|
|
printf("0x%04" PRIx32 " --> %s\n", x, name);
|
2021-09-10 14:03:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
static BOOL is_delimiter(char c, const char* delimiters)
|
2022-02-24 15:56:58 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
char d = 0;
|
2022-02-24 15:56:58 +03:00
|
|
|
while ((d = *delimiters++) != '\0')
|
|
|
|
{
|
2023-12-20 19:06:17 +03:00
|
|
|
if (c == d)
|
2022-02-24 15:56:58 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
static const char* get_last(const char* start, size_t len, const char* delimiters)
|
2018-11-20 16:11:10 +03:00
|
|
|
{
|
2023-12-20 19:06:17 +03:00
|
|
|
const char* last = NULL;
|
|
|
|
for (size_t x = 0; x < len; x++)
|
|
|
|
{
|
|
|
|
char c = start[x];
|
|
|
|
if (is_delimiter(c, delimiters))
|
|
|
|
last = &start[x];
|
|
|
|
}
|
|
|
|
return last;
|
|
|
|
}
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
static SSIZE_T next_delimiter(const char* text, size_t len, size_t max, const char* delimiters)
|
|
|
|
{
|
|
|
|
if (len < max)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
const char* last = get_last(text, max, delimiters);
|
|
|
|
if (!last)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return (SSIZE_T)(last - text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SSIZE_T forced_newline_at(const char* text, size_t len, size_t limit,
|
|
|
|
const char* force_newline)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
char d = 0;
|
2023-12-20 19:06:17 +03:00
|
|
|
while ((d = *force_newline++) != '\0')
|
|
|
|
{
|
|
|
|
const char* tok = strchr(text, d);
|
|
|
|
if (tok)
|
|
|
|
{
|
|
|
|
const size_t offset = tok - text;
|
|
|
|
if ((offset > len) || (offset > limit))
|
|
|
|
continue;
|
|
|
|
return (SSIZE_T)(offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL print_align(size_t start_offset, size_t* current)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(current);
|
2018-11-20 16:11:10 +03:00
|
|
|
if (*current < start_offset)
|
2019-10-29 13:12:15 +03:00
|
|
|
{
|
2023-12-20 19:06:17 +03:00
|
|
|
const int rc = printf("%*c", (int)(start_offset - *current), ' ');
|
2019-10-29 13:12:15 +03:00
|
|
|
if (rc < 0)
|
2023-12-20 19:06:17 +03:00
|
|
|
return FALSE;
|
2019-10-29 13:12:15 +03:00
|
|
|
*current += (size_t)rc;
|
|
|
|
}
|
2023-12-20 19:06:17 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
static char* print_token(char* text, size_t start_offset, size_t* current, size_t limit,
|
|
|
|
const char* delimiters, const char* force_newline)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int rc = 0;
|
2023-12-20 19:06:17 +03:00
|
|
|
const size_t tlen = strnlen(text, limit);
|
|
|
|
size_t len = tlen;
|
|
|
|
const SSIZE_T force_at = forced_newline_at(text, len, limit - *current, force_newline);
|
2024-02-26 11:30:03 +03:00
|
|
|
BOOL isForce = (force_at >= 0);
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
if (isForce)
|
|
|
|
len = MIN(len, (size_t)force_at);
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
if (!print_align(start_offset, current))
|
2018-11-20 16:11:10 +03:00
|
|
|
return NULL;
|
2023-12-20 19:06:17 +03:00
|
|
|
|
|
|
|
const SSIZE_T delim = next_delimiter(text, len, limit - *current, delimiters);
|
|
|
|
const BOOL isDelim = delim > 0;
|
|
|
|
if (isDelim)
|
|
|
|
{
|
|
|
|
len = MIN(len, (size_t)delim + 1);
|
2018-11-20 16:11:10 +03:00
|
|
|
}
|
|
|
|
|
2023-12-20 19:06:17 +03:00
|
|
|
rc = printf("%.*s", (int)len, text);
|
2019-10-29 13:12:15 +03:00
|
|
|
if (rc < 0)
|
|
|
|
return NULL;
|
2023-12-20 19:06:17 +03:00
|
|
|
|
|
|
|
if (isForce || isDelim)
|
|
|
|
{
|
|
|
|
printf("\n");
|
|
|
|
*current = 0;
|
|
|
|
|
2024-02-26 11:30:03 +03:00
|
|
|
const size_t offset = len + ((isForce && (force_at == 0)) ? 1 : 0);
|
2023-12-20 19:06:17 +03:00
|
|
|
return &text[offset];
|
|
|
|
}
|
|
|
|
|
2019-10-29 13:12:15 +03:00
|
|
|
*current += (size_t)rc;
|
2023-12-20 19:06:17 +03:00
|
|
|
|
|
|
|
if (tlen == (size_t)rc)
|
|
|
|
return NULL;
|
|
|
|
return &text[(size_t)rc];
|
2018-11-20 16:11:10 +03:00
|
|
|
}
|
|
|
|
|
2019-10-29 13:12:15 +03:00
|
|
|
static size_t print_optionals(const char* text, size_t start_offset, size_t current)
|
2018-11-20 16:11:10 +03:00
|
|
|
{
|
|
|
|
const size_t limit = 80;
|
|
|
|
char* str = _strdup(text);
|
2023-12-20 19:06:17 +03:00
|
|
|
char* cur = str;
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2024-02-26 11:30:03 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
cur = print_token(cur, start_offset + 1, ¤t, limit, "[], ", "\r\n");
|
|
|
|
} while (cur != NULL);
|
2018-11-20 16:11:10 +03:00
|
|
|
|
|
|
|
free(str);
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2019-10-29 13:12:15 +03:00
|
|
|
static size_t print_description(const char* text, size_t start_offset, size_t current)
|
2018-11-20 16:11:10 +03:00
|
|
|
{
|
|
|
|
const size_t limit = 80;
|
|
|
|
char* str = _strdup(text);
|
2023-12-20 19:06:17 +03:00
|
|
|
char* cur = str;
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2024-02-26 11:30:03 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
cur = print_token(cur, start_offset, ¤t, limit, " ", "\r\n");
|
|
|
|
} while (cur != NULL);
|
2018-11-20 16:11:10 +03:00
|
|
|
|
|
|
|
free(str);
|
2019-11-06 17:24:51 +03:00
|
|
|
current += (size_t)printf("\n");
|
2018-11-20 16:11:10 +03:00
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2023-10-21 12:33:54 +03:00
|
|
|
static int cmp_cmdline_args(const void* pva, const void* pvb)
|
2012-11-07 03:49:02 +04:00
|
|
|
{
|
2023-10-21 12:33:54 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* a = (const COMMAND_LINE_ARGUMENT_A*)pva;
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* b = (const COMMAND_LINE_ARGUMENT_A*)pvb;
|
|
|
|
|
|
|
|
if (!a->Name && !b->Name)
|
|
|
|
return 0;
|
|
|
|
if (!a->Name)
|
|
|
|
return 1;
|
|
|
|
if (!b->Name)
|
|
|
|
return -1;
|
|
|
|
return strcmp(a->Name, b->Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* parg, size_t count)
|
|
|
|
{
|
|
|
|
if (!parg)
|
2017-05-04 15:46:58 +03:00
|
|
|
return;
|
2012-11-07 03:49:02 +04:00
|
|
|
|
2023-10-21 12:33:54 +03:00
|
|
|
qsort(parg, count, sizeof(COMMAND_LINE_ARGUMENT_A), cmp_cmdline_args);
|
|
|
|
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = parg;
|
2012-11-07 03:49:02 +04:00
|
|
|
do
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int rc = 0;
|
2019-10-29 13:12:15 +03:00
|
|
|
size_t pos = 0;
|
|
|
|
const size_t description_offset = 30 + 8;
|
2012-11-07 03:49:02 +04:00
|
|
|
|
2024-01-23 10:36:20 +03:00
|
|
|
if (arg->Flags & (COMMAND_LINE_VALUE_BOOL | COMMAND_LINE_VALUE_FLAG))
|
|
|
|
{
|
|
|
|
if ((arg->Flags & ~COMMAND_LINE_VALUE_BOOL) == 0)
|
|
|
|
rc = printf(" %s%s", arg->Default ? "-" : "+", arg->Name);
|
|
|
|
else if ((arg->Flags & COMMAND_LINE_VALUE_OPTIONAL) != 0)
|
|
|
|
rc = printf(" [%s|/]%s", arg->Default ? "-" : "+", arg->Name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = printf(" %s%s", arg->Default ? "-" : "+", arg->Name);
|
|
|
|
}
|
|
|
|
}
|
2018-11-20 16:11:10 +03:00
|
|
|
else
|
2019-10-29 13:12:15 +03:00
|
|
|
rc = printf(" /%s", arg->Name);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
return;
|
|
|
|
pos += (size_t)rc;
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED) ||
|
|
|
|
(arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
2018-11-20 16:11:10 +03:00
|
|
|
{
|
2012-11-07 03:49:02 +04:00
|
|
|
if (arg->Format)
|
|
|
|
{
|
2017-09-25 12:44:07 +03:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
|
2018-11-20 16:11:10 +03:00
|
|
|
{
|
2019-10-29 13:12:15 +03:00
|
|
|
rc = printf("[:");
|
|
|
|
if (rc < 0)
|
|
|
|
return;
|
|
|
|
pos += (size_t)rc;
|
2018-11-20 16:11:10 +03:00
|
|
|
pos = print_optionals(arg->Format, pos, pos);
|
2019-10-29 13:12:15 +03:00
|
|
|
rc = printf("]");
|
|
|
|
if (rc < 0)
|
|
|
|
return;
|
|
|
|
pos += (size_t)rc;
|
2018-11-20 16:11:10 +03:00
|
|
|
}
|
2017-09-25 12:44:07 +03:00
|
|
|
else
|
2018-11-20 16:11:10 +03:00
|
|
|
{
|
2019-10-29 13:12:15 +03:00
|
|
|
rc = printf(":");
|
|
|
|
if (rc < 0)
|
|
|
|
return;
|
|
|
|
pos += (size_t)rc;
|
2018-11-20 16:11:10 +03:00
|
|
|
pos = print_optionals(arg->Format, pos, pos);
|
|
|
|
}
|
2012-11-07 03:49:02 +04:00
|
|
|
|
2018-11-20 16:11:10 +03:00
|
|
|
if (pos > description_offset)
|
|
|
|
{
|
|
|
|
printf("\n");
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2019-10-29 13:12:15 +03:00
|
|
|
rc = printf("%*c", (int)(description_offset - pos), ' ');
|
|
|
|
if (rc < 0)
|
|
|
|
return;
|
|
|
|
pos += (size_t)rc;
|
2018-11-20 16:11:10 +03:00
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_BOOL)
|
2019-10-29 13:12:15 +03:00
|
|
|
{
|
|
|
|
rc = printf("%s ", arg->Default ? "Disable" : "Enable");
|
|
|
|
if (rc < 0)
|
|
|
|
return;
|
|
|
|
pos += (size_t)rc;
|
|
|
|
}
|
2018-11-20 16:11:10 +03:00
|
|
|
|
|
|
|
print_description(arg->Text, description_offset, pos);
|
2019-11-06 17:24:51 +03: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
|
|
|
|
2023-10-21 15:39:43 +03:00
|
|
|
static COMMAND_LINE_ARGUMENT_A* create_merged_args(const COMMAND_LINE_ARGUMENT_A* custom,
|
|
|
|
SSIZE_T count, size_t* pcount)
|
2017-05-04 15:46:58 +03:00
|
|
|
{
|
2023-10-21 15:39:43 +03:00
|
|
|
WINPR_ASSERT(pcount);
|
|
|
|
if (count < 0)
|
2023-10-21 12:33:54 +03:00
|
|
|
{
|
2023-10-21 15:39:43 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* cur = custom;
|
|
|
|
count = 0;
|
|
|
|
while (cur && cur->Name)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
cur++;
|
|
|
|
}
|
2023-10-21 12:33:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
COMMAND_LINE_ARGUMENT_A* largs =
|
|
|
|
calloc(count + ARRAYSIZE(global_cmd_args), sizeof(COMMAND_LINE_ARGUMENT_A));
|
2023-10-21 15:39:43 +03:00
|
|
|
*pcount = 0;
|
2023-10-21 12:33:54 +03:00
|
|
|
if (!largs)
|
2023-11-25 17:09:12 +03:00
|
|
|
return NULL;
|
2023-10-21 12:33:54 +03:00
|
|
|
|
2023-10-21 15:39:43 +03:00
|
|
|
size_t lcount = 0;
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* cur = custom;
|
2023-10-21 12:33:54 +03:00
|
|
|
while (cur && cur->Name)
|
|
|
|
{
|
2023-10-21 15:39:43 +03:00
|
|
|
largs[lcount++] = *cur++;
|
2023-10-21 12:33:54 +03:00
|
|
|
}
|
2023-10-21 15:39:43 +03:00
|
|
|
|
2023-10-21 12:33:54 +03:00
|
|
|
cur = global_cmd_args;
|
|
|
|
while (cur && cur->Name)
|
|
|
|
{
|
2023-10-21 15:39:43 +03:00
|
|
|
largs[lcount++] = *cur++;
|
2023-10-21 12:33:54 +03:00
|
|
|
}
|
2023-10-21 15:39:43 +03:00
|
|
|
*pcount = lcount;
|
|
|
|
return largs;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* custom)
|
|
|
|
{
|
|
|
|
const char* name = "FreeRDP";
|
|
|
|
|
|
|
|
/* allocate a merged copy of implementation defined and default arguments */
|
|
|
|
size_t lcount = 0;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* largs = create_merged_args(custom, -1, &lcount);
|
|
|
|
if (!largs)
|
|
|
|
return FALSE;
|
2019-02-12 12:53:42 +03:00
|
|
|
|
|
|
|
if (argc > 0)
|
|
|
|
name = argv[0];
|
2019-01-29 18:22:46 +03:00
|
|
|
|
2017-05-04 15:46:58 +03:00
|
|
|
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");
|
2023-10-21 12:33:54 +03:00
|
|
|
|
2023-10-21 15:39:43 +03:00
|
|
|
freerdp_client_print_command_line_args(largs, lcount);
|
|
|
|
free(largs);
|
2023-10-21 12:33:54 +03:00
|
|
|
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\n");
|
|
|
|
printf("Examples:\n");
|
2019-02-12 12:53:42 +03:00
|
|
|
printf(" %s connection.rdp /p:Pwd123! /f\n", name);
|
|
|
|
printf(" %s /u:CONTOSO\\JohnDoe /p:Pwd123! /v:rdp.contoso.com\n", name);
|
|
|
|
printf(" %s /u:JohnDoe /p:Pwd123! /w:1366 /h:768 /v:192.168.1.100:4489\n", name);
|
2019-11-06 17:24:51 +03:00
|
|
|
printf(" %s /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 "
|
|
|
|
"/v:192.168.1.100\n",
|
2019-05-08 15:35:25 +03:00
|
|
|
name);
|
2024-01-18 11:52:17 +03:00
|
|
|
printf(" %s /u:\\AzureAD\\user@corp.example /p:pwd /v:host\n", name);
|
2014-09-16 23:07:38 +04:00
|
|
|
printf("\n");
|
|
|
|
printf("Clipboard Redirection: +clipboard\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("Drive Redirection: /drive:home,/home/user\n");
|
|
|
|
printf("Smartcard Redirection: /smartcard:<device>\n");
|
2022-02-02 01:23:34 +03:00
|
|
|
printf("Smartcard logon with Kerberos authentication: /smartcard-logon /sec:nla\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");
|
2022-09-20 11:36:45 +03:00
|
|
|
printf("Printer Redirection: /printer:<device>,<driver>,[default]\n");
|
2019-05-14 21:02:31 +03:00
|
|
|
printf("TCP redirection: /rdp2tcp:/usr/bin/rdp2tcp\n");
|
2014-09-16 23:07:38 +04:00
|
|
|
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");
|
2020-02-25 17:21:16 +03:00
|
|
|
printf("Multimedia Redirection: /video\n");
|
2020-02-26 13:12:46 +03:00
|
|
|
#ifdef CHANNEL_URBDRC_CLIENT
|
2020-04-24 02:16:10 +03:00
|
|
|
printf("USB Device Redirection: /usb:id:054c:0268#4669:6e6b,addr:04:0c\n");
|
2020-02-26 13:12:46 +03:00
|
|
|
#endif
|
2014-09-16 23:07:38 +04:00
|
|
|
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
|
2019-02-12 12:53:42 +03:00
|
|
|
printf(" %s /g:rdp.contoso.com ...\n", name);
|
2014-03-22 04:24:43 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-12-15 16:56:58 +03:00
|
|
|
static BOOL option_is_rdp_file(const char* option)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(option);
|
|
|
|
|
|
|
|
if (option_ends_with(option, ".rdp"))
|
|
|
|
return TRUE;
|
|
|
|
if (option_ends_with(option, ".rdpw"))
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL option_is_incident_file(const char* option)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(option);
|
|
|
|
|
|
|
|
if (option_ends_with(option, ".msrcIncident"))
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static int freerdp_client_command_line_pre_filter(void* context, int index, int argc, LPSTR* argv)
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
|
|
|
if (index == 1)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
|
|
|
rdpSettings* settings = NULL;
|
2019-01-29 18:22:46 +03:00
|
|
|
|
|
|
|
if (argc <= index)
|
|
|
|
return -1;
|
|
|
|
|
2018-10-15 12:51:16 +03:00
|
|
|
length = strlen(argv[index]);
|
2012-11-07 07:08:09 +04:00
|
|
|
|
|
|
|
if (length > 4)
|
|
|
|
{
|
2022-12-15 16:56:58 +03:00
|
|
|
if (option_is_rdp_file(argv[index]))
|
2012-11-07 07:08:09 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
settings = (rdpSettings*)context;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ConnectionFile, argv[index]))
|
2015-06-18 14:00:10 +03:00
|
|
|
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)
|
|
|
|
{
|
2022-12-15 16:56:58 +03:00
|
|
|
if (option_is_incident_file(argv[index]))
|
2014-06-29 02:33:46 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
settings = (rdpSettings*)context;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AssistanceFile, argv[index]))
|
2015-06-18 14:00:10 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
BOOL freerdp_client_add_device_channel(rdpSettings* settings, size_t count, const char** params)
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(params);
|
|
|
|
WINPR_ASSERT(count > 0);
|
|
|
|
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(params[0], "drive"))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL rc = 0;
|
2019-08-23 12:47:31 +03:00
|
|
|
if (count < 2)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return FALSE;
|
2019-08-23 12:47:31 +03:00
|
|
|
if (count < 3)
|
|
|
|
rc = freerdp_client_add_drive(settings, params[1], NULL);
|
|
|
|
else
|
|
|
|
rc = freerdp_client_add_drive(settings, params[2], params[1]);
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2019-08-23 12:47:31 +03:00
|
|
|
return rc;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(params[0], "printer"))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
RDPDR_DEVICE* printer = NULL;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
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
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return FALSE;
|
2014-03-26 19:05:12 +04:00
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
printer = freerdp_device_new(RDPDR_DTYP_PRINT, count - 1, ¶ms[1]);
|
|
|
|
if (!printer)
|
|
|
|
return FALSE;
|
2015-06-18 14:00:10 +03:00
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, printer))
|
|
|
|
{
|
|
|
|
freerdp_device_free(printer);
|
|
|
|
return FALSE;
|
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
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(params[0], "smartcard"))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
RDPDR_DEVICE* smartcard = NULL;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
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
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return FALSE;
|
2021-10-07 11:43:16 +03:00
|
|
|
|
|
|
|
smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, count - 1, ¶ms[1]);
|
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
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, smartcard))
|
2017-12-11 16:00:09 +03:00
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
freerdp_device_free(smartcard);
|
2017-12-11 16:00:09 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(params[0], "serial"))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
RDPDR_DEVICE* serial = NULL;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
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
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return FALSE;
|
2021-10-07 11:43:16 +03:00
|
|
|
|
|
|
|
serial = freerdp_device_new(RDPDR_DTYP_SERIAL, count - 1, ¶ms[1]);
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (!serial)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, serial))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
freerdp_device_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
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(params[0], "parallel"))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
RDPDR_DEVICE* parallel = NULL;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
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
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return FALSE;
|
2021-10-07 11:43:16 +03:00
|
|
|
|
|
|
|
parallel = freerdp_device_new(RDPDR_DTYP_PARALLEL, count - 1, ¶ms[1]);
|
2014-03-26 19:05:12 +04:00
|
|
|
|
|
|
|
if (!parallel)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, parallel))
|
2015-06-18 14:00:10 +03:00
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
freerdp_device_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
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL freerdp_client_del_static_channel(rdpSettings* settings, const char* name)
|
|
|
|
{
|
|
|
|
return freerdp_static_channel_collection_del(settings, name);
|
|
|
|
}
|
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
BOOL freerdp_client_add_static_channel(rdpSettings* settings, size_t count, const char** params)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
ADDIN_ARGV* _args = NULL;
|
2017-02-22 15:46:47 +03:00
|
|
|
|
2019-10-29 13:12:15 +03:00
|
|
|
if (!settings || !params || !params[0] || (count > INT_MAX))
|
2017-02-22 15:46:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (freerdp_static_channel_collection_find(settings, params[0]))
|
|
|
|
return TRUE;
|
|
|
|
|
2021-07-28 17:27:59 +03:00
|
|
|
_args = freerdp_addin_argv_new(count, (const char**)params);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2021-07-28 17:27:59 +03:00
|
|
|
if (!_args)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2021-07-28 17:27:59 +03:00
|
|
|
if (!freerdp_static_channel_collection_add(settings, _args))
|
2021-04-12 11:38:40 +03:00
|
|
|
goto fail;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2021-04-12 11:38:40 +03:00
|
|
|
fail:
|
2021-07-28 17:27:59 +03:00
|
|
|
freerdp_addin_argv_free(_args);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
BOOL freerdp_client_del_dynamic_channel(rdpSettings* settings, const char* name)
|
|
|
|
{
|
|
|
|
return freerdp_dynamic_channel_collection_del(settings, name);
|
|
|
|
}
|
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, size_t count, const char** params)
|
2012-11-18 09:08:03 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
ADDIN_ARGV* _args = NULL;
|
2017-02-22 15:46:47 +03:00
|
|
|
|
2019-10-29 13:12:15 +03:00
|
|
|
if (!settings || !params || !params[0] || (count > INT_MAX))
|
2017-02-22 15:46:47 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (freerdp_dynamic_channel_collection_find(settings, params[0]))
|
|
|
|
return TRUE;
|
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
_args = freerdp_addin_argv_new(count, params);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2021-07-28 17:27:59 +03:00
|
|
|
if (!_args)
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2021-07-28 17:27:59 +03:00
|
|
|
if (!freerdp_dynamic_channel_collection_add(settings, _args))
|
2021-04-12 11:38:40 +03:00
|
|
|
goto fail;
|
2012-11-18 09:08:03 +04:00
|
|
|
|
2016-02-01 17:09:51 +03:00
|
|
|
return TRUE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2021-04-12 11:38:40 +03:00
|
|
|
fail:
|
2021-07-28 17:27:59 +03:00
|
|
|
freerdp_addin_argv_free(_args);
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
|
2023-10-16 20:37:36 +03:00
|
|
|
static BOOL read_pem_file(rdpSettings* settings, FreeRDP_Settings_Keys_String id, const char* file)
|
2022-05-06 09:21:29 +03:00
|
|
|
{
|
2023-02-03 16:14:55 +03:00
|
|
|
size_t length = 0;
|
|
|
|
char* pem = crypto_read_pem(file, &length);
|
|
|
|
if (!pem || (length == 0))
|
2024-04-11 11:51:26 +03:00
|
|
|
{
|
|
|
|
free(pem);
|
2023-02-03 16:14:55 +03:00
|
|
|
return FALSE;
|
2024-04-11 11:51:26 +03:00
|
|
|
}
|
2022-05-06 09:21:29 +03:00
|
|
|
|
2023-02-03 16:14:55 +03:00
|
|
|
BOOL rc = freerdp_settings_set_string_len(settings, id, pem, length);
|
|
|
|
free(pem);
|
2022-05-06 09:21:29 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief suboption type */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
CMDLINE_SUBOPTION_STRING,
|
|
|
|
CMDLINE_SUBOPTION_FILE,
|
|
|
|
} CmdLineSubOptionType;
|
|
|
|
|
|
|
|
typedef BOOL (*CmdLineSubOptionCb)(const char* value, rdpSettings* settings);
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char* optname;
|
2023-10-16 20:37:36 +03:00
|
|
|
FreeRDP_Settings_Keys_String id;
|
2022-05-06 09:21:29 +03:00
|
|
|
CmdLineSubOptionType opttype;
|
|
|
|
CmdLineSubOptionCb cb;
|
|
|
|
} CmdLineSubOptions;
|
|
|
|
|
|
|
|
static BOOL parseSubOptions(rdpSettings* settings, const CmdLineSubOptions* opts, size_t count,
|
|
|
|
const char* arg)
|
|
|
|
{
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t xx = 0; xx < count; xx++)
|
2022-05-06 09:21:29 +03:00
|
|
|
{
|
|
|
|
const CmdLineSubOptions* opt = &opts[xx];
|
|
|
|
|
2022-10-27 12:41:22 +03:00
|
|
|
if (option_starts_with(opt->optname, arg))
|
2022-05-06 09:21:29 +03:00
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
const size_t optlen = strlen(opt->optname);
|
2022-05-06 09:21:29 +03:00
|
|
|
const char* val = &arg[optlen];
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL status = 0;
|
2022-05-06 09:21:29 +03:00
|
|
|
|
|
|
|
switch (opt->opttype)
|
|
|
|
{
|
|
|
|
case CMDLINE_SUBOPTION_STRING:
|
|
|
|
status = freerdp_settings_set_string(settings, opt->id, val);
|
|
|
|
break;
|
|
|
|
case CMDLINE_SUBOPTION_FILE:
|
|
|
|
status = read_pem_file(settings, opt->id, val);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_ERR(TAG, "invalid subOption type");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!status)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (opt->cb && !opt->cb(val, settings))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
WLog_ERR(TAG, "option %s not handled", arg);
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +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
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
rdpSettings* settings = (rdpSettings*)context;
|
2017-11-30 18:56:45 +03:00
|
|
|
BOOL status = TRUE;
|
2018-10-15 12:51:16 +03:00
|
|
|
BOOL enable = arg->Value ? TRUE : FALSE;
|
2021-10-06 10:44:26 +03:00
|
|
|
union
|
2012-11-07 08:07:03 +04:00
|
|
|
{
|
2012-11-18 09:08:03 +04:00
|
|
|
char** p;
|
2021-10-06 10:44:26 +03:00
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
|
|
|
|
|
|
|
CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "a")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
if ((status = freerdp_client_add_device_channel(settings, count, ptr.pc)))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE);
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
free(ptr.p);
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
2022-05-06 09:21:29 +03:00
|
|
|
CommandLineSwitchCase(arg, "kerberos")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2022-05-06 09:21:29 +03:00
|
|
|
|
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx("kerberos", arg->Value, &count);
|
|
|
|
if (ptr.pc)
|
|
|
|
{
|
|
|
|
const CmdLineSubOptions opts[] = {
|
2022-09-30 17:14:41 +03:00
|
|
|
{ "kdc-url:", FreeRDP_KerberosKdcUrl, CMDLINE_SUBOPTION_STRING, NULL },
|
2022-05-06 09:21:29 +03:00
|
|
|
{ "start-time:", FreeRDP_KerberosStartTime, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "lifetime:", FreeRDP_KerberosLifeTime, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "renewable-lifetime:", FreeRDP_KerberosRenewableLifeTime,
|
|
|
|
CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "cache:", FreeRDP_KerberosCache, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "armor:", FreeRDP_KerberosArmor, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "pkinit-anchors:", FreeRDP_PkinitAnchors, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL }
|
|
|
|
};
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 1; x < count; x++)
|
2022-05-06 09:21:29 +03:00
|
|
|
{
|
|
|
|
const char* cur = ptr.pc[x];
|
|
|
|
if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur))
|
|
|
|
{
|
|
|
|
free(ptr.p);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr.p);
|
|
|
|
}
|
|
|
|
|
2012-11-18 09:08:03 +04:00
|
|
|
CommandLineSwitchCase(arg, "vc")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
status = freerdp_client_add_static_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2012-11-18 09:08:03 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "dvc")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2012-11-07 08:07:03 +04:00
|
|
|
}
|
2013-02-18 16:49:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "drive")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "serial")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "parallel")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "smartcard")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "printer")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_device_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "usb")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(URBDRC_CHANNEL_NAME, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
2013-05-09 06:14:16 +04:00
|
|
|
CommandLineSwitchCase(arg, "multitouch")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_MultiTouchInput, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-05-09 06:14:16 +04:00
|
|
|
}
|
2013-06-20 02:43:24 +04:00
|
|
|
CommandLineSwitchCase(arg, "gestures")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_MultiTouchGestures, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-06-20 02:43:24 +04:00
|
|
|
}
|
2013-03-13 03:23:59 +04:00
|
|
|
CommandLineSwitchCase(arg, "echo")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportEchoChannel, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-03-13 03:23:59 +04:00
|
|
|
}
|
2017-06-26 23:16:22 +03:00
|
|
|
CommandLineSwitchCase(arg, "ssh-agent")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportSSHAgentChannel, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-06-26 23:16:22 +03:00
|
|
|
}
|
2013-07-10 00:10:59 +04:00
|
|
|
CommandLineSwitchCase(arg, "disp")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDisplayControl, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-07-10 00:10:59 +04:00
|
|
|
}
|
2017-12-06 15:51:45 +03:00
|
|
|
CommandLineSwitchCase(arg, "geometry")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGeometryTracking, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-12-06 15:51:45 +03:00
|
|
|
}
|
2017-12-08 00:50:29 +03:00
|
|
|
CommandLineSwitchCase(arg, "video")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGeometryTracking,
|
|
|
|
enable)) /* this requires geometry tracking */
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportVideoOptimized, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-12-08 00:50:29 +03:00
|
|
|
}
|
2013-02-18 16:49:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "sound")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(RDPSND_CHANNEL_NAME, arg->Value, &count);
|
|
|
|
status = freerdp_client_add_static_channel(settings, count, ptr.pc);
|
2020-02-27 14:12:20 +03:00
|
|
|
if (status)
|
|
|
|
{
|
2021-10-06 10:44:26 +03:00
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, ptr.pc);
|
2020-02-27 14:12:20 +03:00
|
|
|
}
|
2021-10-06 10:44:26 +03:00
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "microphone")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-01 09:07:44 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx(AUDIN_CHANNEL_NAME, arg->Value, &count);
|
2021-10-06 10:44:26 +03:00
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
2020-02-25 17:21:16 +03:00
|
|
|
#if defined(CHANNEL_TSMF_CLIENT)
|
2013-02-18 16:49:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "multimedia")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2021-10-06 10:44:26 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx("tsmf", arg->Value, &count);
|
|
|
|
status = freerdp_client_add_dynamic_channel(settings, count, ptr.pc);
|
|
|
|
free(ptr.p);
|
2013-02-18 16:49:52 +04:00
|
|
|
}
|
2020-02-25 17:21:16 +03:00
|
|
|
#endif
|
2014-01-30 07:53:32 +04:00
|
|
|
CommandLineSwitchCase(arg, "heartbeat")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportHeartbeatPdu, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-01-30 07:53:32 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "multitransport")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMultitransport, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-10-15 12:51:16 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
UINT32 flags = 0;
|
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_SupportMultitransport))
|
|
|
|
flags =
|
2019-11-06 17:24:51 +03:00
|
|
|
(TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
|
2023-10-13 10:48:44 +03:00
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_MultitransportFlags, flags))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-01-30 07:53:32 +04:00
|
|
|
}
|
2021-10-07 11:43:16 +03:00
|
|
|
CommandLineSwitchEnd(arg)
|
|
|
|
|
|
|
|
return status
|
|
|
|
? 1
|
|
|
|
: -1;
|
2012-11-07 08:07:03 +04:00
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
static BOOL freerdp_parse_username_ptr(const char* username, const char** user, size_t* userlen,
|
|
|
|
const char** domain, size_t* domainlen)
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
2024-04-12 11:33:39 +03:00
|
|
|
WINPR_ASSERT(user);
|
|
|
|
WINPR_ASSERT(userlen);
|
|
|
|
WINPR_ASSERT(domain);
|
|
|
|
WINPR_ASSERT(domainlen);
|
|
|
|
|
|
|
|
if (!username)
|
|
|
|
return FALSE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
const char* p = strchr(username, '\\');
|
|
|
|
|
2015-06-18 13:24:22 +03:00
|
|
|
*user = NULL;
|
2023-10-13 10:48:44 +03:00
|
|
|
*userlen = 0;
|
|
|
|
|
2015-06-18 13:24:22 +03:00
|
|
|
*domain = NULL;
|
2023-10-13 10:48:44 +03:00
|
|
|
*domainlen = 0;
|
2012-11-26 23:31:31 +04:00
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
const size_t length = (size_t)(p - username);
|
|
|
|
*user = &p[1];
|
|
|
|
*userlen = strlen(*user);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
*domain = username;
|
|
|
|
*domainlen = length;
|
2015-06-15 10:47:16 +03:00
|
|
|
}
|
2024-04-12 11:33:39 +03:00
|
|
|
else
|
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
|
|
|
*/
|
2023-10-13 10:48:44 +03:00
|
|
|
*user = username;
|
|
|
|
*userlen = strlen(username);
|
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL freerdp_parse_username_settings(const char* username, rdpSettings* settings,
|
2023-10-16 20:37:36 +03:00
|
|
|
FreeRDP_Settings_Keys_String userID,
|
|
|
|
FreeRDP_Settings_Keys_String domainID)
|
2023-10-13 10:48:44 +03:00
|
|
|
{
|
|
|
|
const char* user = NULL;
|
|
|
|
const char* domain = NULL;
|
|
|
|
size_t userlen = 0;
|
|
|
|
size_t domainlen = 0;
|
|
|
|
|
|
|
|
const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_string_len(settings, userID, user, userlen))
|
|
|
|
return FALSE;
|
|
|
|
return freerdp_settings_set_string_len(settings, domainID, domain, domainlen);
|
|
|
|
}
|
2015-06-15 10:47:16 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
BOOL freerdp_parse_username(const char* username, char** puser, char** pdomain)
|
|
|
|
{
|
|
|
|
const char* user = NULL;
|
|
|
|
const char* domain = NULL;
|
|
|
|
size_t userlen = 0;
|
|
|
|
size_t domainlen = 0;
|
|
|
|
|
|
|
|
*puser = NULL;
|
|
|
|
*pdomain = NULL;
|
|
|
|
|
|
|
|
const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (userlen > 0)
|
|
|
|
{
|
|
|
|
*puser = strndup(user, userlen);
|
|
|
|
if (!*puser)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-06-18 13:24:22 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (domainlen > 0)
|
|
|
|
{
|
|
|
|
*pdomain = strndup(domain, domainlen);
|
|
|
|
if (!*pdomain)
|
2015-06-18 13:24:22 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
free(*puser);
|
|
|
|
*puser = 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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
char* p = NULL;
|
2014-06-12 18:49:29 +04:00
|
|
|
p = strrchr(hostname, ':');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2019-01-29 18:22:46 +03:00
|
|
|
size_t length = (size_t)(p - hostname);
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(p + 1, &val, 1, UINT16_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return FALSE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2019-11-06 17:24:51 +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';
|
2018-11-22 18:28:30 +03:00
|
|
|
*port = (UINT16)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
|
|
|
}
|
|
|
|
|
2022-10-10 13:02:32 +03:00
|
|
|
static BOOL freerdp_apply_connection_type(rdpSettings* settings, UINT32 type)
|
2012-11-26 23:31:31 +04:00
|
|
|
{
|
2022-10-10 13:02:32 +03:00
|
|
|
struct network_settings
|
|
|
|
{
|
2023-10-16 20:37:36 +03:00
|
|
|
FreeRDP_Settings_Keys_Bool id;
|
2022-10-10 13:02:32 +03:00
|
|
|
BOOL value[7];
|
|
|
|
};
|
|
|
|
const struct network_settings config[] = {
|
|
|
|
{ FreeRDP_DisableWallpaper, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
|
|
|
|
{ FreeRDP_AllowFontSmoothing, { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
|
|
|
|
{ FreeRDP_AllowDesktopComposition, { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
|
|
|
|
{ FreeRDP_DisableFullWindowDrag, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
|
|
|
|
{ FreeRDP_DisableMenuAnims, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
|
|
|
|
{ FreeRDP_DisableThemes, { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE } },
|
|
|
|
{ FreeRDP_NetworkAutoDetect, { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE } }
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CONNECTION_TYPE_MODEM:
|
|
|
|
case CONNECTION_TYPE_BROADBAND_LOW:
|
|
|
|
case CONNECTION_TYPE_BROADBAND_HIGH:
|
|
|
|
case CONNECTION_TYPE_SATELLITE:
|
|
|
|
case CONNECTION_TYPE_WAN:
|
|
|
|
case CONNECTION_TYPE_LAN:
|
|
|
|
case CONNECTION_TYPE_AUTODETECT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WLog_WARN(TAG, "Invalid ConnectionType %" PRIu32 ", aborting", type);
|
|
|
|
return FALSE;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
2022-10-10 13:02:32 +03:00
|
|
|
|
|
|
|
for (size_t x = 0; x < ARRAYSIZE(config); x++)
|
2018-09-11 18:17:52 +03:00
|
|
|
{
|
2022-10-10 13:02:32 +03:00
|
|
|
const struct network_settings* cur = &config[x];
|
|
|
|
if (!freerdp_settings_set_bool(settings, cur->id, cur->value[type - 1]))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, type))
|
2018-09-11 18:17:52 +03:00
|
|
|
return FALSE;
|
2022-10-10 13:02:32 +03:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CONNECTION_TYPE_MODEM:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_BROADBAND_LOW:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_SATELLITE:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_BROADBAND_HIGH:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_WAN:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_LAN:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CONNECTION_TYPE_AUTODETECT:
|
|
|
|
if (!freerdp_apply_connection_type(settings, type))
|
|
|
|
return FALSE;
|
|
|
|
/* Automatically activate GFX and RFX codec support */
|
|
|
|
#ifdef WITH_GFX_H264
|
2023-12-20 15:53:19 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444v2, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, TRUE) ||
|
2022-10-10 13:02:32 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2018-09-11 18:17:52 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2022-10-19 17:03:20 +03:00
|
|
|
static UINT32 freerdp_get_keyboard_layout_for_type(const char* name, DWORD type)
|
2012-11-27 01:49:12 +04:00
|
|
|
{
|
2024-04-11 14:16:36 +03:00
|
|
|
UINT32 res = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2022-10-19 17:03:20 +03:00
|
|
|
RDP_KEYBOARD_LAYOUT* layouts =
|
|
|
|
freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, &count);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2022-10-19 17:03:20 +03:00
|
|
|
if (!layouts || (count == 0))
|
2024-04-11 14:16:36 +03:00
|
|
|
goto fail;
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
2012-11-27 01:49:12 +04:00
|
|
|
{
|
2022-10-19 17:03:20 +03:00
|
|
|
const RDP_KEYBOARD_LAYOUT* layout = &layouts[x];
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(layout->name, name))
|
2022-10-19 17:03:20 +03:00
|
|
|
{
|
2024-04-11 14:16:36 +03:00
|
|
|
res = layout->code;
|
|
|
|
break;
|
2022-10-19 17:03:20 +03:00
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2024-04-11 14:16:36 +03:00
|
|
|
fail:
|
2022-10-19 17:03:20 +03:00
|
|
|
freerdp_keyboard_layouts_free(layouts, count);
|
2024-04-11 14:16:36 +03:00
|
|
|
return res;
|
2022-10-19 17:03:20 +03:00
|
|
|
}
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2022-10-19 17:03:20 +03:00
|
|
|
static UINT32 freerdp_map_keyboard_layout_name_to_id(const char* name)
|
|
|
|
{
|
|
|
|
const UINT32 variants[] = { RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, RDP_KEYBOARD_LAYOUT_TYPE_VARIANT,
|
|
|
|
RDP_KEYBOARD_LAYOUT_TYPE_IME };
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < ARRAYSIZE(variants); x++)
|
2012-11-27 01:49:12 +04:00
|
|
|
{
|
2022-10-19 17:03:20 +03:00
|
|
|
UINT32 rc = freerdp_get_keyboard_layout_for_type(name, variants[x]);
|
|
|
|
if (rc > 0)
|
|
|
|
return rc;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
2012-11-27 01:49:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static int freerdp_detect_command_line_pre_filter(void* context, int index, int argc, LPSTR* argv)
|
2013-09-18 01:03:35 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
2019-01-29 18:22:46 +03:00
|
|
|
WINPR_UNUSED(context);
|
2013-09-18 01:03:35 +04:00
|
|
|
|
|
|
|
if (index == 1)
|
|
|
|
{
|
2019-01-29 18:22:46 +03:00
|
|
|
if (argc < index)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
length = strlen(argv[index]);
|
2013-09-18 01:03:35 +04:00
|
|
|
|
|
|
|
if (length > 4)
|
|
|
|
{
|
2022-12-15 16:56:58 +03:00
|
|
|
if (option_is_rdp_file(argv[index]))
|
2013-09-18 01:03:35 +04:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2015-05-06 23:32:45 +03:00
|
|
|
|
|
|
|
if (length > 13)
|
|
|
|
{
|
2022-12-15 16:56:58 +03:00
|
|
|
if (option_is_incident_file(argv[index]))
|
2015-05-06 23:32:45 +03:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2013-09-18 01:03:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int status = 0;
|
|
|
|
DWORD flags = 0;
|
|
|
|
int detect_status = 0;
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = NULL;
|
2021-10-06 10:47:30 +03:00
|
|
|
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(global_cmd_args)];
|
|
|
|
memcpy(largs, global_cmd_args, sizeof(global_cmd_args));
|
2019-10-28 12:10:14 +03:00
|
|
|
|
2018-12-11 12:25:44 +03:00
|
|
|
flags = COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SILENCE_PARSER;
|
2012-12-05 21:12:18 +04:00
|
|
|
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;
|
2019-10-28 12:10:14 +03:00
|
|
|
CommandLineClearArgumentsA(largs);
|
2019-11-06 17:24:51 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, largs, flags, 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
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = largs;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(*count)++;
|
2019-11-06 17:24:51 +03:00
|
|
|
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv, size_t* count,
|
|
|
|
BOOL ignoreUnknown)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int status = 0;
|
|
|
|
DWORD flags = 0;
|
|
|
|
int detect_status = 0;
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = NULL;
|
2021-10-06 10:47:30 +03:00
|
|
|
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(global_cmd_args)];
|
|
|
|
memcpy(largs, global_cmd_args, sizeof(global_cmd_args));
|
2019-10-28 12:10:14 +03:00
|
|
|
|
2018-12-11 12:25:44 +03:00
|
|
|
flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER;
|
2012-12-05 21:12:18 +04:00
|
|
|
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
|
|
|
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;
|
2019-10-28 12:10:14 +03:00
|
|
|
CommandLineClearArgumentsA(largs);
|
2019-11-06 17:24:51 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, largs, flags, 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
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = largs;
|
2012-12-05 21:12:18 +04:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(*count)++;
|
2019-11-06 17:24:51 +03:00
|
|
|
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2012-12-05 21:12:18 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
|
2012-12-05 21:12:18 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int posix_cli_status = 0;
|
|
|
|
size_t posix_cli_count = 0;
|
|
|
|
int windows_cli_status = 0;
|
|
|
|
size_t windows_cli_count = 0;
|
2018-12-11 13:42:25 +03:00
|
|
|
const BOOL ignoreUnknown = TRUE;
|
2019-11-06 17:24:51 +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);
|
2021-10-14 09:25:46 +03:00
|
|
|
|
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)
|
2021-10-14 09:25:46 +03:00
|
|
|
return FALSE;
|
2014-09-17 00:51:01 +04:00
|
|
|
|
2015-01-15 15:57:28 +03:00
|
|
|
/* Check, if this may be windows style syntax... */
|
2019-11-06 17:24:51 +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;
|
|
|
|
}
|
|
|
|
|
2022-09-29 15:55:27 +03:00
|
|
|
WLog_DBG(TAG, "windows: %d/%" PRIuz " posix: %d/%" PRIuz "", windows_cli_status,
|
|
|
|
windows_cli_count, posix_cli_status, posix_cli_count);
|
2021-10-14 10:01:00 +03:00
|
|
|
if ((posix_cli_count == 0) && (windows_cli_count == 0))
|
|
|
|
{
|
|
|
|
if ((posix_cli_status == COMMAND_LINE_ERROR) && (windows_cli_status == COMMAND_LINE_ERROR))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2021-10-14 09:25:46 +03:00
|
|
|
return FALSE;
|
2012-12-05 21:12:18 +04:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +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
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
return freerdp_client_settings_command_line_status_print_ex(settings, status, argc, argv, NULL);
|
2017-05-04 15:46:58 +03:00
|
|
|
}
|
|
|
|
|
2022-10-19 17:03:20 +03:00
|
|
|
static void freerdp_client_print_keyboard_type_list(const char* msg, DWORD type)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
RDP_KEYBOARD_LAYOUT* layouts = NULL;
|
2022-10-19 17:03:20 +03:00
|
|
|
layouts = freerdp_keyboard_get_layouts(type, &count);
|
|
|
|
|
|
|
|
printf("\n%s\n", msg);
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
2022-10-19 17:03:20 +03:00
|
|
|
{
|
|
|
|
const RDP_KEYBOARD_LAYOUT* layout = &layouts[x];
|
|
|
|
printf("0x%08" PRIX32 "\t%s\n", layout->code, layout->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
freerdp_keyboard_layouts_free(layouts, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void freerdp_client_print_keyboard_list(void)
|
|
|
|
{
|
|
|
|
freerdp_client_print_keyboard_type_list("Keyboard Layouts", RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
|
|
|
|
freerdp_client_print_keyboard_type_list("Keyboard Layout Variants",
|
|
|
|
RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
|
|
|
|
freerdp_client_print_keyboard_type_list("Keyboard Layout Variants",
|
|
|
|
RDP_KEYBOARD_LAYOUT_TYPE_IME);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void freerdp_client_print_tune_list(const rdpSettings* settings)
|
|
|
|
{
|
|
|
|
SSIZE_T type = 0;
|
|
|
|
|
|
|
|
printf("%s\t%50s\t%s\t%s", "<index>", "<key>", "<type>", "<default value>\n");
|
2023-10-16 18:31:31 +03:00
|
|
|
for (size_t x = 0; x < FreeRDP_Settings_StableAPI_MAX; x++)
|
2022-10-19 17:03:20 +03:00
|
|
|
{
|
|
|
|
const char* name = freerdp_settings_get_name_for_key(x);
|
|
|
|
type = freerdp_settings_get_type_for_key(x);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RDP_SETTINGS_TYPE_BOOL:
|
|
|
|
printf("%" PRIuz "\t%50s\tBOOL\t%s\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_bool(settings, (FreeRDP_Settings_Keys_Bool)x)
|
|
|
|
? "TRUE"
|
|
|
|
: "FALSE");
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_UINT16:
|
|
|
|
printf("%" PRIuz "\t%50s\tUINT16\t%" PRIu16 "\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_uint16(settings, (FreeRDP_Settings_Keys_UInt16)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_INT16:
|
|
|
|
printf("%" PRIuz "\t%50s\tINT16\t%" PRId16 "\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_int16(settings, (FreeRDP_Settings_Keys_Int16)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_UINT32:
|
|
|
|
printf("%" PRIuz "\t%50s\tUINT32\t%" PRIu32 "\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_uint32(settings, (FreeRDP_Settings_Keys_UInt32)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_INT32:
|
|
|
|
printf("%" PRIuz "\t%50s\tINT32\t%" PRId32 "\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_int32(settings, (FreeRDP_Settings_Keys_Int32)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_UINT64:
|
|
|
|
printf("%" PRIuz "\t%50s\tUINT64\t%" PRIu64 "\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_uint64(settings, (FreeRDP_Settings_Keys_UInt64)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_INT64:
|
|
|
|
printf("%" PRIuz "\t%50s\tINT64\t%" PRId64 "\n", x, name,
|
2023-10-16 20:37:36 +03:00
|
|
|
freerdp_settings_get_int64(settings, (FreeRDP_Settings_Keys_Int64)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_STRING:
|
|
|
|
printf("%" PRIuz "\t%50s\tSTRING\t%s"
|
|
|
|
"\n",
|
2023-10-16 20:37:36 +03:00
|
|
|
x, name,
|
|
|
|
freerdp_settings_get_string(settings, (FreeRDP_Settings_Keys_String)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
case RDP_SETTINGS_TYPE_POINTER:
|
|
|
|
printf("%" PRIuz "\t%50s\tPOINTER\t%p"
|
|
|
|
"\n",
|
2023-10-16 20:37:36 +03:00
|
|
|
x, name,
|
|
|
|
freerdp_settings_get_pointer(settings, (FreeRDP_Settings_Keys_Pointer)x));
|
2022-10-19 17:03:20 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, int status,
|
|
|
|
int argc, char** argv,
|
2022-02-24 15:56:58 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* custom)
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = NULL;
|
2021-10-06 10:47:30 +03:00
|
|
|
COMMAND_LINE_ARGUMENT_A largs[ARRAYSIZE(global_cmd_args)];
|
|
|
|
memcpy(largs, global_cmd_args, sizeof(global_cmd_args));
|
2012-11-06 07:11:13 +04:00
|
|
|
|
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();
|
2021-01-22 11:44:55 +03:00
|
|
|
goto out;
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
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();
|
2021-01-22 11:44:55 +03:00
|
|
|
goto out;
|
2016-01-11 18:18:40 +03:00
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
else if (status == COMMAND_LINE_STATUS_PRINT)
|
|
|
|
{
|
2019-11-08 17:42:05 +03:00
|
|
|
CommandLineParseArgumentsA(argc, argv, largs, 0x112, NULL, NULL, NULL);
|
|
|
|
|
2022-10-19 16:18:14 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "list");
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals("tune", arg->Value))
|
2022-10-19 16:18:14 +03:00
|
|
|
freerdp_client_print_tune_list(settings);
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals("kbd", arg->Value))
|
2022-10-19 16:18:14 +03:00
|
|
|
freerdp_client_print_keyboard_list();
|
2023-06-08 10:39:01 +03:00
|
|
|
else if (option_starts_with("kbd-lang", arg->Value))
|
2022-10-19 16:18:14 +03:00
|
|
|
{
|
|
|
|
const char* val = NULL;
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_starts_with("kbd-lang:", arg->Value))
|
2022-10-19 16:18:14 +03:00
|
|
|
val = &arg->Value[9];
|
2023-06-08 10:39:01 +03:00
|
|
|
else if (!option_equals("kbd-lang", arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2023-09-04 17:37:52 +03:00
|
|
|
|
|
|
|
if (val && strchr(val, ','))
|
2023-06-08 10:39:01 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-10-19 16:18:14 +03:00
|
|
|
freerdp_client_print_codepages(val);
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals("kbd-scancode", arg->Value))
|
2022-10-19 16:18:14 +03:00
|
|
|
freerdp_client_print_scancodes();
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals("monitor", arg->Value))
|
2023-10-13 10:48:44 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ListMonitors, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2023-06-08 10:39:01 +03:00
|
|
|
else if (option_starts_with("smartcard", arg->Value))
|
|
|
|
{
|
|
|
|
BOOL opts = FALSE;
|
|
|
|
if (option_starts_with("smartcard:", arg->Value))
|
|
|
|
opts = TRUE;
|
|
|
|
else if (!option_equals("smartcard", arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (opts)
|
|
|
|
{
|
|
|
|
const char* sub = strchr(arg->Value, ':') + 1;
|
|
|
|
const CmdLineSubOptions options[] = {
|
|
|
|
{ "pkinit-anchors:", FreeRDP_PkinitAnchors, CMDLINE_SUBOPTION_STRING,
|
|
|
|
NULL },
|
|
|
|
{ "pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t count = 0;
|
|
|
|
|
|
|
|
char** ptr = CommandLineParseCommaSeparatedValuesEx("smartcard", sub, &count);
|
|
|
|
if (!ptr)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
if (count < 2)
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t x = 1; x < count; x++)
|
|
|
|
{
|
|
|
|
const char* cur = ptr[x];
|
|
|
|
if (!parseSubOptions(settings, options, ARRAYSIZE(options), cur))
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
2022-10-19 16:18:14 +03:00
|
|
|
freerdp_smartcard_list(settings);
|
2023-06-08 10:39:01 +03:00
|
|
|
}
|
2022-10-19 16:18:14 +03:00
|
|
|
else
|
2023-01-25 14:42:54 +03:00
|
|
|
{
|
|
|
|
freerdp_client_print_command_line_help_ex(argc, argv, custom);
|
2022-10-19 16:18:14 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
2023-01-25 14:42:54 +03:00
|
|
|
}
|
2022-10-19 16:18:14 +03:00
|
|
|
}
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2022-10-19 16:18:14 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "tune-list");
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "Option /tune-list is deprecated, use /list:tune instead");
|
2022-10-19 16:18:14 +03:00
|
|
|
freerdp_client_print_tune_list(settings);
|
|
|
|
}
|
|
|
|
|
2019-11-08 17:42:05 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "kbd-lang-list");
|
2022-10-19 17:03:20 +03:00
|
|
|
WINPR_ASSERT(arg);
|
2019-11-08 17:42:05 +03:00
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "Option /kbd-lang-list is deprecated, use /list:kbd-lang instead");
|
2019-11-08 17:42:05 +03:00
|
|
|
freerdp_client_print_codepages(arg->Value);
|
|
|
|
}
|
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "kbd-list");
|
2022-10-19 17:03:20 +03:00
|
|
|
WINPR_ASSERT(arg);
|
2012-11-27 01:49:12 +04:00
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "Option /kbd-list is deprecated, use /list:kbd instead");
|
2022-10-19 17:03:20 +03:00
|
|
|
freerdp_client_print_keyboard_list();
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "monitor-list");
|
2022-10-19 17:03:20 +03:00
|
|
|
WINPR_ASSERT(arg);
|
2013-04-29 01:10:43 +04:00
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "Option /monitor-list is deprecated, use /list:monitor instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ListMonitors, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-04-29 01:10:43 +04:00
|
|
|
}
|
|
|
|
|
2022-02-02 01:23:34 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "smartcard-list");
|
2022-10-19 17:03:20 +03:00
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2022-02-02 01:23:34 +03:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "Option /smartcard-list is deprecated, use /list:smartcard instead");
|
2022-02-02 15:15:58 +03:00
|
|
|
freerdp_smartcard_list(settings);
|
2022-02-02 01:23:34 +03:00
|
|
|
}
|
|
|
|
|
2021-09-10 14:03:09 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "kbd-scancode-list");
|
2022-10-19 17:03:20 +03:00
|
|
|
WINPR_ASSERT(arg);
|
2021-09-10 14:03:09 +03:00
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG,
|
|
|
|
"Option /kbd-scancode-list is deprecated, use /list:kbd-scancode instead");
|
2021-09-10 14:03:09 +03:00
|
|
|
freerdp_client_print_scancodes();
|
|
|
|
goto out;
|
|
|
|
}
|
2022-10-19 16:18:14 +03:00
|
|
|
#endif
|
2021-01-22 11:44:55 +03:00
|
|
|
goto out;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
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);
|
2021-01-22 11:44:55 +03:00
|
|
|
goto out;
|
2013-09-09 18:07:14 +04:00
|
|
|
}
|
2012-11-07 03:49:02 +04:00
|
|
|
|
2021-01-22 11:44:55 +03:00
|
|
|
out:
|
|
|
|
if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
|
|
|
|
return 0;
|
|
|
|
return status;
|
2013-06-15 23:13:38 +04:00
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
|
2018-11-15 16:40:03 +03:00
|
|
|
/**
|
|
|
|
* parses a string value with the format <v1>x<v2>
|
2022-04-28 00:10:49 +03:00
|
|
|
*
|
|
|
|
* @param input input string
|
|
|
|
* @param v1 pointer to output v1
|
|
|
|
* @param v2 pointer to output v2
|
2018-11-15 16:40:03 +03:00
|
|
|
* @return if the parsing was successful
|
|
|
|
*/
|
2018-11-20 16:11:10 +03:00
|
|
|
static BOOL parseSizeValue(const char* input, unsigned long* v1, unsigned long* v2)
|
2018-11-15 16:40:03 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
const char* xcharpos = NULL;
|
|
|
|
char* endPtr = NULL;
|
|
|
|
unsigned long v = 0;
|
2018-11-15 16:40:03 +03:00
|
|
|
errno = 0;
|
|
|
|
v = strtoul(input, &endPtr, 10);
|
|
|
|
|
|
|
|
if ((v == 0 || v == ULONG_MAX) && (errno != 0))
|
|
|
|
return FALSE;
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2018-11-15 16:40:03 +03:00
|
|
|
if (v1)
|
|
|
|
*v1 = v;
|
|
|
|
|
|
|
|
xcharpos = strchr(input, 'x');
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2018-11-15 16:40:03 +03:00
|
|
|
if (!xcharpos || xcharpos != endPtr)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
v = strtoul(xcharpos + 1, &endPtr, 10);
|
|
|
|
|
|
|
|
if ((v == 0 || v == ULONG_MAX) && (errno != 0))
|
|
|
|
return FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (*endPtr != '\0')
|
2018-11-15 16:40:03 +03:00
|
|
|
return FALSE;
|
2018-11-20 16:11:10 +03:00
|
|
|
|
2018-11-15 16:40:03 +03:00
|
|
|
if (v2)
|
|
|
|
*v2 = v;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-09-06 16:12:12 +03:00
|
|
|
static BOOL prepare_default_settings(rdpSettings* settings, COMMAND_LINE_ARGUMENT_A* args,
|
2021-07-29 14:26:05 +03:00
|
|
|
BOOL rdp_file)
|
|
|
|
{
|
|
|
|
const char* arguments[] = { "network", "gfx", "rfx", "bpp" };
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(args);
|
|
|
|
|
|
|
|
if (rdp_file)
|
|
|
|
return FALSE;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < ARRAYSIZE(arguments); x++)
|
2021-07-29 14:26:05 +03:00
|
|
|
{
|
|
|
|
const char* arg = arguments[x];
|
2021-09-07 09:31:07 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* p = CommandLineFindArgumentA(args, arg);
|
2021-07-29 14:26:05 +03:00
|
|
|
if (p && (p->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT);
|
|
|
|
}
|
|
|
|
|
2022-02-05 01:59:16 +03:00
|
|
|
static BOOL setSmartcardEmulation(const char* value, rdpSettings* settings)
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
return freerdp_settings_set_bool(settings, FreeRDP_SmartcardEmulation, TRUE);
|
2022-02-05 01:59:16 +03:00
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* option_starts_with(const char* what, const char* val)
|
2022-10-27 11:29:01 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(what);
|
|
|
|
WINPR_ASSERT(val);
|
|
|
|
const size_t wlen = strlen(what);
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
if (_strnicmp(what, val, wlen) != 0)
|
|
|
|
return NULL;
|
|
|
|
return &val[wlen];
|
2022-10-27 11:29:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL option_ends_with(const char* str, const char* ext)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(str);
|
|
|
|
WINPR_ASSERT(ext);
|
|
|
|
const size_t strLen = strlen(str);
|
|
|
|
const size_t extLen = strlen(ext);
|
|
|
|
|
|
|
|
if (strLen < extLen)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return _strnicmp(&str[strLen - extLen], ext, extLen) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL option_equals(const char* what, const char* val)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(what);
|
|
|
|
WINPR_ASSERT(val);
|
|
|
|
return _stricmp(what, val) == 0;
|
|
|
|
}
|
|
|
|
|
2023-03-10 12:36:00 +03:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PARSE_ON,
|
|
|
|
PARSE_OFF,
|
|
|
|
PARSE_NONE,
|
|
|
|
PARSE_FAIL
|
|
|
|
} PARSE_ON_OFF_RESULT;
|
|
|
|
|
|
|
|
static PARSE_ON_OFF_RESULT parse_on_off_option(const char* value)
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
const char* sep = strchr(value, ':');
|
|
|
|
if (!sep)
|
2023-03-10 12:36:00 +03:00
|
|
|
return PARSE_NONE;
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals("on", &sep[1]))
|
2023-03-10 12:36:00 +03:00
|
|
|
return PARSE_ON;
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals("off", &sep[1]))
|
2023-03-10 12:36:00 +03:00
|
|
|
return PARSE_OFF;
|
|
|
|
return PARSE_FAIL;
|
2022-10-20 10:16:18 +03:00
|
|
|
}
|
|
|
|
|
2023-05-09 12:47:28 +03:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
CLIP_DIR_PARSE_ALL,
|
|
|
|
CLIP_DIR_PARSE_OFF,
|
|
|
|
CLIP_DIR_PARSE_LOCAL,
|
|
|
|
CLIP_DIR_PARSE_REMOTE,
|
|
|
|
CLIP_DIR_PARSE_FAIL
|
|
|
|
} PARSE_CLIP_DIR_RESULT;
|
|
|
|
|
|
|
|
static PARSE_CLIP_DIR_RESULT parse_clip_direciton_to_option(const char* value)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
const char* sep = strchr(value, ':');
|
|
|
|
if (!sep)
|
|
|
|
return CLIP_DIR_PARSE_FAIL;
|
|
|
|
if (option_equals("all", &sep[1]))
|
|
|
|
return CLIP_DIR_PARSE_ALL;
|
|
|
|
if (option_equals("off", &sep[1]))
|
|
|
|
return CLIP_DIR_PARSE_OFF;
|
|
|
|
if (option_equals("local", &sep[1]))
|
|
|
|
return CLIP_DIR_PARSE_LOCAL;
|
|
|
|
if (option_equals("remote", &sep[1]))
|
|
|
|
return CLIP_DIR_PARSE_REMOTE;
|
|
|
|
return CLIP_DIR_PARSE_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-10-19 14:50:33 +03:00
|
|
|
static int parse_tls_ciphers(rdpSettings* settings, const char* Value)
|
|
|
|
{
|
|
|
|
const char* ciphers = NULL;
|
|
|
|
if (!Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(Value, "netmon"))
|
2022-10-19 14:50:33 +03:00
|
|
|
{
|
|
|
|
ciphers = "ALL:!ECDH:!ADH:!DHE";
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(Value, "ma"))
|
2022-10-19 14:50:33 +03:00
|
|
|
{
|
|
|
|
ciphers = "AES128-SHA";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ciphers = Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AllowedTlsCiphers, ciphers))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_tls_seclevel(rdpSettings* settings, const char* Value)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2022-10-19 14:50:33 +03:00
|
|
|
|
|
|
|
if (!value_to_int(Value, &val, 0, 5))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_TlsSecLevel, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_tls_secrets_file(rdpSettings* settings, const char* Value)
|
|
|
|
{
|
|
|
|
if (!Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_TlsSecretsFile, Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_tls_enforce(rdpSettings* settings, const char* Value)
|
|
|
|
{
|
2022-10-19 17:59:37 +03:00
|
|
|
UINT16 version = TLS1_2_VERSION;
|
2022-10-19 14:50:33 +03:00
|
|
|
|
2022-10-19 17:59:37 +03:00
|
|
|
if (Value)
|
|
|
|
{
|
|
|
|
struct map_t
|
|
|
|
{
|
2022-11-16 16:55:52 +03:00
|
|
|
const char* name;
|
2022-10-19 17:59:37 +03:00
|
|
|
UINT16 version;
|
|
|
|
};
|
|
|
|
const struct map_t map[] = {
|
2022-10-20 09:25:41 +03:00
|
|
|
{ "1.0", TLS1_VERSION },
|
|
|
|
{ "1.1", TLS1_1_VERSION },
|
|
|
|
{ "1.2", TLS1_2_VERSION }
|
|
|
|
#if defined(TLS1_3_VERSION)
|
|
|
|
,
|
|
|
|
{ "1.3", TLS1_3_VERSION }
|
|
|
|
#endif
|
2022-10-19 17:59:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t x = 0; x < ARRAYSIZE(map); x++)
|
|
|
|
{
|
|
|
|
const struct map_t* cur = &map[x];
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(cur->name, Value))
|
2022-10-19 17:59:37 +03:00
|
|
|
{
|
|
|
|
version = cur->version;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(freerdp_settings_set_uint16(settings, FreeRDP_TLSMinVersion, version) &&
|
|
|
|
freerdp_settings_set_uint16(settings, FreeRDP_TLSMaxVersion, version)))
|
2022-10-19 14:50:33 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
static int parse_tls_cipher_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
2022-10-19 14:50:33 +03:00
|
|
|
{
|
|
|
|
int rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "tls")
|
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_starts_with("ciphers:", arg->Value))
|
2022-10-19 14:50:33 +03:00
|
|
|
rc = parse_tls_ciphers(settings, &arg->Value[8]);
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("seclevel:", arg->Value))
|
2022-10-20 09:25:41 +03:00
|
|
|
rc = parse_tls_seclevel(settings, &arg->Value[9]);
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("secrets-file:", arg->Value))
|
2022-10-19 14:50:33 +03:00
|
|
|
rc = parse_tls_secrets_file(settings, &arg->Value[13]);
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("enforce:", arg->Value))
|
2022-10-19 17:59:37 +03:00
|
|
|
rc = parse_tls_enforce(settings, &arg->Value[8]);
|
2022-10-19 14:50:33 +03:00
|
|
|
}
|
2022-10-19 15:00:48 +03:00
|
|
|
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2022-10-19 14:50:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "tls-ciphers")
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "Option /tls-ciphers is deprecated, use /tls:ciphers instead");
|
|
|
|
rc = parse_tls_ciphers(settings, arg->Value);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "tls-seclevel")
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "Option /tls-seclevel is deprecated, use /tls:seclevel instead");
|
|
|
|
rc = parse_tls_seclevel(settings, arg->Value);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "tls-secrets-file")
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "Option /tls-secrets-file is deprecated, use /tls:secrets-file instead");
|
|
|
|
rc = parse_tls_secrets_file(settings, arg->Value);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "enforce-tlsv1_2")
|
|
|
|
{
|
2022-11-16 16:55:52 +03:00
|
|
|
WLog_WARN(TAG, "Option /enforce-tlsv1_2 is deprecated, use /tls:enforce:1.2 instead");
|
|
|
|
rc = parse_tls_enforce(settings, "1.2");
|
2022-10-19 14:50:33 +03:00
|
|
|
}
|
2022-10-19 15:00:48 +03:00
|
|
|
#endif
|
2022-10-19 14:50:33 +03:00
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CommandLineSwitchEnd(arg)
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
static int parse_tls_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
|
|
|
COMMAND_LINE_ARGUMENT_A larg = *arg;
|
|
|
|
larg.Value = ptr[x];
|
|
|
|
|
|
|
|
int rc = parse_tls_cipher_options(settings, &larg);
|
|
|
|
if (rc != 0)
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-10-20 10:16:18 +03:00
|
|
|
static int parse_gfx_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2023-11-29 19:28:56 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE))
|
2022-10-20 10:16:18 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (arg->Value)
|
|
|
|
{
|
|
|
|
int rc = CHANNEL_RC_OK;
|
|
|
|
size_t count = 0;
|
|
|
|
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (!ptr || (count == 0))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL GfxH264 = FALSE;
|
|
|
|
BOOL GfxAVC444 = FALSE;
|
|
|
|
BOOL RemoteFxCodec = FALSE;
|
|
|
|
BOOL GfxProgressive = FALSE;
|
|
|
|
BOOL codecSelected = FALSE;
|
|
|
|
|
|
|
|
for (size_t x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
const char* val = ptr[x];
|
|
|
|
#ifdef WITH_GFX_H264
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_starts_with("AVC444", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else
|
2023-03-10 12:36:00 +03:00
|
|
|
GfxAVC444 = bval != PARSE_OFF;
|
2022-10-20 10:16:18 +03:00
|
|
|
codecSelected = TRUE;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("AVC420", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else
|
2023-03-10 12:36:00 +03:00
|
|
|
GfxH264 = bval != PARSE_OFF;
|
2022-10-20 10:16:18 +03:00
|
|
|
codecSelected = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_starts_with("RFX", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else
|
2023-03-10 12:36:00 +03:00
|
|
|
RemoteFxCodec = bval != PARSE_OFF;
|
2022-10-20 10:16:18 +03:00
|
|
|
codecSelected = TRUE;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("progressive", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else
|
2023-03-10 12:36:00 +03:00
|
|
|
GfxProgressive = bval != PARSE_OFF;
|
2022-10-20 10:16:18 +03:00
|
|
|
codecSelected = TRUE;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("mask:", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
ULONGLONG v = 0;
|
2022-10-20 10:16:18 +03:00
|
|
|
const char* uv = &val[5];
|
|
|
|
if (!value_to_uint(uv, &v, 0, UINT32_MAX))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
else
|
2023-10-13 10:48:44 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_GfxCapsFilter, v))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-20 10:16:18 +03:00
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("small-cache", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2023-03-10 12:36:00 +03:00
|
|
|
else if (!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache,
|
|
|
|
bval != PARSE_OFF))
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("thin-client", val))
|
2022-10-20 10:16:18 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2023-03-10 12:36:00 +03:00
|
|
|
else if (!freerdp_settings_set_bool(settings, FreeRDP_GfxThinClient,
|
|
|
|
bval != PARSE_OFF))
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
if ((rc == CHANNEL_RC_OK) && (bval > 0))
|
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache,
|
|
|
|
bval != PARSE_OFF))
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((rc == CHANNEL_RC_OK) && codecSelected)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, GfxAVC444))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
2023-12-20 15:53:19 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444v2, GfxAVC444))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
2022-12-15 12:56:57 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, GfxH264))
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
2022-12-15 12:56:57 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, RemoteFxCodec))
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
2022-12-15 12:56:57 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, GfxProgressive))
|
2022-10-20 10:16:18 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr);
|
|
|
|
if (rc != CHANNEL_RC_OK)
|
|
|
|
return rc;
|
|
|
|
}
|
2023-11-17 11:49:22 +03:00
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_kbd_layout(rdpSettings* settings, const char* value)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
|
|
|
|
int rc = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG ival = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
const BOOL isInt = value_to_int(value, &ival, 1, UINT32_MAX);
|
|
|
|
if (!isInt)
|
|
|
|
{
|
|
|
|
ival = freerdp_map_keyboard_layout_name_to_id(value);
|
|
|
|
|
|
|
|
if (ival == 0)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Could not identify keyboard layout: %s", value);
|
|
|
|
WLog_ERR(TAG, "Use /list:kbd to list available layouts");
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, (UINT32)ival))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
|
|
|
static int parse_codec_cache_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCacheV3Enabled, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (option_equals(arg->Value, "rfx"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_equals(arg->Value, "nsc"))
|
|
|
|
{
|
2024-04-12 12:40:38 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(WITH_JPEG)
|
|
|
|
else if (option_equals(arg->Value, "jpeg"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (freerdp_settings_get_uint32(settings, FreeRDP_JpegQuality) == 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, 75))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2024-04-12 12:40:38 +03:00
|
|
|
return 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static BOOL check_kbd_remap_valid(const char* token)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
DWORD key = 0;
|
|
|
|
DWORD value = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(token);
|
|
|
|
/* The remapping is only allowed for scancodes, so maximum is 999=999 */
|
|
|
|
if (strlen(token) > 10)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
int rc = sscanf(token, "%" PRIu32 "=%" PRIu32, &key, &value);
|
|
|
|
if (rc != 2)
|
|
|
|
rc = sscanf(token, "%" PRIx32 "=%" PRIx32 "", &key, &value);
|
|
|
|
if (rc != 2)
|
|
|
|
rc = sscanf(token, "%" PRIu32 "=%" PRIx32, &key, &value);
|
|
|
|
if (rc != 2)
|
|
|
|
rc = sscanf(token, "%" PRIx32 "=%" PRIu32, &key, &value);
|
|
|
|
if (rc != 2)
|
|
|
|
{
|
|
|
|
WLog_WARN(TAG, "/kbd:remap invalid entry '%s'", token);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_host_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
freerdp_settings_set_string(settings, FreeRDP_ServerHostname, NULL);
|
|
|
|
char* p = strchr(arg->Value, '[');
|
|
|
|
|
|
|
|
/* ipv4 */
|
|
|
|
if (!p)
|
|
|
|
{
|
2023-11-14 18:33:53 +03:00
|
|
|
const char scheme[] = "://";
|
|
|
|
const char* val = strstr(arg->Value, scheme);
|
|
|
|
if (val)
|
|
|
|
val += strnlen(scheme, sizeof(scheme));
|
|
|
|
else
|
|
|
|
val = arg->Value;
|
|
|
|
p = strchr(val, ':');
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
|
|
|
size_t length = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(&p[1], &val, 1, UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
length = (size_t)(p - arg->Value);
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
if (!freerdp_settings_set_string_len(settings, FreeRDP_ServerHostname, arg->Value,
|
|
|
|
length))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* ipv6 */
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
char* p2 = strchr(arg->Value, ']');
|
|
|
|
|
|
|
|
/* not a valid [] ipv6 addr found */
|
|
|
|
if (!p2)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
length = (size_t)(p2 - p);
|
|
|
|
if (!freerdp_settings_set_string_len(settings, FreeRDP_ServerHostname, p + 1, length - 1))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
|
|
|
if (*(p2 + 1) == ':')
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(&p2[2], &val, 0, UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, (UINT16)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("hostname %s port %" PRIu32 "\n",
|
|
|
|
freerdp_settings_get_string(settings, FreeRDP_ServerHostname),
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_ServerPort));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_redirect_prefer_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
size_t count = 0;
|
|
|
|
char* cur = arg->Value;
|
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_RedirectionPreferType, 0))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
UINT32 value = 0;
|
|
|
|
do
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32 mask = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
char* next = strchr(cur, ',');
|
|
|
|
|
|
|
|
if (next)
|
|
|
|
{
|
|
|
|
*next = '\0';
|
|
|
|
next++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (option_equals("fqdn", cur))
|
|
|
|
mask = 0x06U;
|
|
|
|
else if (option_equals("ip", cur))
|
|
|
|
mask = 0x05U;
|
|
|
|
else if (option_equals("netbios", cur))
|
|
|
|
mask = 0x03U;
|
|
|
|
else
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
cur = next;
|
|
|
|
mask = (mask & 0x07);
|
|
|
|
value |= mask << (count * 3);
|
|
|
|
count++;
|
|
|
|
} while (cur != NULL);
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_RedirectionPreferType, value))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (count > 3)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_prevent_session_lock_options(rdpSettings* settings,
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_FakeMouseMotionInterval, 180))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(arg->Value, &val, 1, UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_FakeMouseMotionInterval, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_vmconnect_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, 2179))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, FALSE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_size_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
2024-01-24 10:21:47 +03:00
|
|
|
int status = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
char* p = strchr(arg->Value, 'x');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
unsigned long w = 0;
|
|
|
|
unsigned long h = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, (UINT32)w))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, (UINT32)h))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char* str = _strdup(arg->Value);
|
|
|
|
if (!str)
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
|
|
|
p = strchr(str, '%');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
BOOL partial = FALSE;
|
|
|
|
|
2024-01-24 10:21:47 +03:00
|
|
|
status = COMMAND_LINE_ERROR;
|
2023-11-17 11:49:22 +03:00
|
|
|
if (strchr(p, 'w'))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseWidth, TRUE))
|
2024-01-24 10:21:47 +03:00
|
|
|
goto fail;
|
2023-11-17 11:49:22 +03:00
|
|
|
partial = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr(p, 'h'))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseHeight, TRUE))
|
2024-01-24 10:21:47 +03:00
|
|
|
goto fail;
|
2023-11-17 11:49:22 +03:00
|
|
|
partial = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!partial)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseWidth, TRUE))
|
2024-01-24 10:21:47 +03:00
|
|
|
goto fail;
|
2023-11-17 11:49:22 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PercentScreenUseHeight, TRUE))
|
2024-01-24 10:21:47 +03:00
|
|
|
goto fail;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
*p = '\0';
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(str, &val, 0, 100))
|
|
|
|
{
|
2024-01-24 10:21:47 +03:00
|
|
|
status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
goto fail;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_PercentScreen, (UINT32)val))
|
2024-01-24 10:21:47 +03:00
|
|
|
goto fail;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
2024-01-24 10:21:47 +03:00
|
|
|
|
|
|
|
status = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
2024-01-24 10:21:47 +03:00
|
|
|
fail:
|
2023-11-17 11:49:22 +03:00
|
|
|
free(str);
|
|
|
|
}
|
|
|
|
|
2024-01-24 10:21:47 +03:00
|
|
|
return status;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_monitors_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char** p;
|
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
|
|
|
size_t count = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT32* MonitorIds = NULL;
|
2023-11-17 11:49:22 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
|
|
|
|
if (!ptr.pc)
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
|
|
|
if (count > 16)
|
|
|
|
count = 16;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, NULL, count))
|
|
|
|
{
|
|
|
|
free(ptr.p);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
MonitorIds = freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0);
|
|
|
|
for (UINT32 i = 0; i < count; i++)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(ptr.pc[i], &val, 0, UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
MonitorIds[i] = (UINT32)val;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ptr.p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_dynamic_resolution_options(rdpSettings* settings,
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Smart sizing and dynamic resolution are mutually exclusive options");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDisplayControl, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DynamicResolutionUpdate, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_smart_sizing_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Smart sizing and dynamic resolution are mutually exclusive options");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SmartSizing, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
|
|
|
|
if (arg->Value)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
unsigned long w = 0;
|
|
|
|
unsigned long h = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingWidth, (UINT32)w))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_SmartSizingHeight, (UINT32)h))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_bpp_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
case 24:
|
|
|
|
case 16:
|
|
|
|
case 15:
|
|
|
|
case 8:
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_kbd_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
int rc = CHANNEL_RC_OK;
|
|
|
|
size_t count = 0;
|
|
|
|
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (!ptr || (count == 0))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
const char* val = ptr[x];
|
|
|
|
|
|
|
|
if (option_starts_with("remap:", val))
|
|
|
|
{
|
|
|
|
/* Append this new occurance to the already existing list */
|
|
|
|
char* now = _strdup(&val[6]);
|
|
|
|
const char* old =
|
|
|
|
freerdp_settings_get_string(settings, FreeRDP_KeyboardRemappingList);
|
|
|
|
|
|
|
|
/* Basic sanity test. Entries must be like <key>=<value>, e.g. 1=2 */
|
|
|
|
if (!check_kbd_remap_valid(now))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (old)
|
|
|
|
{
|
|
|
|
const size_t olen = strlen(old);
|
|
|
|
const size_t alen = strlen(now);
|
|
|
|
const size_t tlen = olen + alen + 2;
|
|
|
|
char* tmp = calloc(tlen, sizeof(char));
|
|
|
|
if (!tmp)
|
|
|
|
rc = COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
else
|
|
|
|
_snprintf(tmp, tlen, "%s,%s", old, now);
|
2024-01-24 10:21:47 +03:00
|
|
|
free(now);
|
2023-11-17 11:49:22 +03:00
|
|
|
now = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_KeyboardRemappingList, now))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
free(now);
|
|
|
|
}
|
|
|
|
else if (option_starts_with("layout:", val))
|
|
|
|
{
|
|
|
|
rc = parse_kbd_layout(settings, &val[7]);
|
|
|
|
}
|
|
|
|
else if (option_starts_with("lang:", val))
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG ival = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
const BOOL isInt = value_to_int(&val[5], &ival, 1, UINT32_MAX);
|
|
|
|
if (!isInt)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardCodePage,
|
|
|
|
(UINT32)ival))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("type:", val))
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG ival = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
const BOOL isInt = value_to_int(&val[5], &ival, 1, UINT32_MAX);
|
|
|
|
if (!isInt)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardType, (UINT32)ival))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("subtype:", val))
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG ival = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
const BOOL isInt = value_to_int(&val[8], &ival, 1, UINT32_MAX);
|
|
|
|
if (!isInt)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardSubType,
|
|
|
|
(UINT32)ival))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("fn-key:", val))
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG ival = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
const BOOL isInt = value_to_int(&val[7], &ival, 1, UINT32_MAX);
|
|
|
|
if (!isInt)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardFunctionKey,
|
|
|
|
(UINT32)ival))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("unicode", val))
|
|
|
|
{
|
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (!freerdp_settings_set_bool(settings, FreeRDP_UnicodeInput,
|
|
|
|
bval != PARSE_OFF))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("pipe:", val))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UnicodeInput, TRUE))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else if (!freerdp_settings_set_string(settings, FreeRDP_KeyboardPipeName, &val[5]))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
|
|
|
else if (count == 1)
|
|
|
|
{
|
|
|
|
/* Legacy, allow /kbd:<value> for setting keyboard layout */
|
|
|
|
rc = parse_kbd_layout(settings, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (rc != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_proxy_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
/* initial value */
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ProxyType, PROXY_TYPE_HTTP))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
const char* cur = arg->Value;
|
|
|
|
|
|
|
|
if (!cur)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
/* value is [scheme://][user:password@]hostname:port */
|
|
|
|
if (!proxy_parse_uri(settings, cur))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Option http-proxy needs argument.");
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_dump_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
BOOL failed = FALSE;
|
|
|
|
size_t count = 0;
|
|
|
|
char** args = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (!args || (count != 2))
|
|
|
|
failed = TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_TransportDumpFile, args[1]))
|
|
|
|
failed = TRUE;
|
|
|
|
else if (option_equals(args[0], "replay"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDump, FALSE))
|
|
|
|
failed = TRUE;
|
|
|
|
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplay, TRUE))
|
|
|
|
failed = TRUE;
|
|
|
|
}
|
|
|
|
else if (option_equals(args[0], "record"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDump, TRUE))
|
|
|
|
failed = TRUE;
|
|
|
|
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplay, FALSE))
|
|
|
|
failed = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
failed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(args);
|
|
|
|
if (failed)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_clipboard_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (arg->Value == BoolValueTrue || arg->Value == BoolValueFalse)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard,
|
|
|
|
(arg->Value == BoolValueTrue)))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char** p;
|
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; (x < count) && (rc == 0); x++)
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
|
|
|
const char* usesel = "use-selection:";
|
|
|
|
|
|
|
|
const char* cur = ptr.pc[x];
|
|
|
|
if (option_starts_with(usesel, cur))
|
|
|
|
{
|
|
|
|
const char* val = &cur[strlen(usesel)];
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ClipboardUseSelection, val))
|
|
|
|
rc = COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("direction-to", cur))
|
|
|
|
{
|
|
|
|
const UINT32 mask =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_ClipboardFeatureMask) &
|
|
|
|
~(CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL);
|
|
|
|
const PARSE_CLIP_DIR_RESULT bval = parse_clip_direciton_to_option(cur);
|
|
|
|
UINT32 bflags = 0;
|
|
|
|
switch (bval)
|
|
|
|
{
|
|
|
|
case CLIP_DIR_PARSE_ALL:
|
|
|
|
bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL;
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_LOCAL:
|
|
|
|
bflags |= CLIPRDR_FLAG_REMOTE_TO_LOCAL;
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_REMOTE:
|
|
|
|
bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE;
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_OFF:
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_FAIL:
|
|
|
|
default:
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ClipboardFeatureMask,
|
|
|
|
mask | bflags))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("files-to", cur))
|
|
|
|
{
|
|
|
|
const UINT32 mask =
|
|
|
|
freerdp_settings_get_uint32(settings, FreeRDP_ClipboardFeatureMask) &
|
|
|
|
~(CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES);
|
|
|
|
const PARSE_CLIP_DIR_RESULT bval = parse_clip_direciton_to_option(cur);
|
|
|
|
UINT32 bflags = 0;
|
|
|
|
switch (bval)
|
|
|
|
{
|
|
|
|
case CLIP_DIR_PARSE_ALL:
|
|
|
|
bflags |=
|
|
|
|
CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES;
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_LOCAL:
|
|
|
|
bflags |= CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES;
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_REMOTE:
|
|
|
|
bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES;
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_OFF:
|
|
|
|
break;
|
|
|
|
case CLIP_DIR_PARSE_FAIL:
|
|
|
|
default:
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ClipboardFeatureMask,
|
|
|
|
mask | bflags))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
free(ptr.p);
|
|
|
|
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_audio_mode_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case AUDIO_MODE_REDIRECT:
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_MODE_PLAY_ON_SERVER:
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_MODE_NONE:
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, FALSE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_network_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
UINT32 type = 0;
|
|
|
|
|
|
|
|
if (option_equals(arg->Value, "modem"))
|
|
|
|
type = CONNECTION_TYPE_MODEM;
|
|
|
|
else if (option_equals(arg->Value, "broadband"))
|
|
|
|
type = CONNECTION_TYPE_BROADBAND_HIGH;
|
|
|
|
else if (option_equals(arg->Value, "broadband-low"))
|
|
|
|
type = CONNECTION_TYPE_BROADBAND_LOW;
|
|
|
|
else if (option_equals(arg->Value, "broadband-high"))
|
|
|
|
type = CONNECTION_TYPE_BROADBAND_HIGH;
|
|
|
|
else if (option_equals(arg->Value, "wan"))
|
|
|
|
type = CONNECTION_TYPE_WAN;
|
|
|
|
else if (option_equals(arg->Value, "lan"))
|
|
|
|
type = CONNECTION_TYPE_LAN;
|
|
|
|
else if ((option_equals(arg->Value, "autodetect")) || (option_equals(arg->Value, "auto")) ||
|
|
|
|
(option_equals(arg->Value, "detect")))
|
|
|
|
{
|
|
|
|
type = CONNECTION_TYPE_AUTODETECT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
if (!value_to_int(arg->Value, &val, 1, 7))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
type = (UINT32)val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_set_connection_type(settings, type))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_sec_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (count == 0)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
FreeRDP_Settings_Keys_Bool singleOptionWithoutOnOff = FreeRDP_BOOL_UNUSED;
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
|
|
|
const char* cur = ptr[x];
|
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
|
|
|
|
if (bval == PARSE_FAIL)
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BOOL val = bval != PARSE_OFF;
|
2024-01-23 18:49:54 +03:00
|
|
|
FreeRDP_Settings_Keys_Bool id = FreeRDP_BOOL_UNUSED;
|
2023-11-17 11:49:22 +03:00
|
|
|
if (option_starts_with("rdp", cur)) /* Standard RDP */
|
|
|
|
{
|
|
|
|
id = FreeRDP_RdpSecurity;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UseRdpSecurityLayer, val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("tls", cur)) /* TLS */
|
|
|
|
id = FreeRDP_TlsSecurity;
|
|
|
|
else if (option_starts_with("nla", cur)) /* NLA */
|
|
|
|
id = FreeRDP_NlaSecurity;
|
|
|
|
else if (option_starts_with("ext", cur)) /* NLA Extended */
|
|
|
|
id = FreeRDP_ExtSecurity;
|
|
|
|
else if (option_equals("aad", cur)) /* RDSAAD */
|
|
|
|
id = FreeRDP_AadSecurity;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "unknown protocol security: %s", arg->Value);
|
|
|
|
free(ptr);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((bval == PARSE_NONE) && (count == 1))
|
|
|
|
singleOptionWithoutOnOff = id;
|
|
|
|
if (!freerdp_settings_set_bool(settings, id, val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (singleOptionWithoutOnOff != FreeRDP_BOOL_UNUSED)
|
|
|
|
{
|
|
|
|
const FreeRDP_Settings_Keys_Bool options[] = { FreeRDP_AadSecurity,
|
|
|
|
FreeRDP_UseRdpSecurityLayer,
|
|
|
|
FreeRDP_RdpSecurity, FreeRDP_NlaSecurity,
|
|
|
|
FreeRDP_TlsSecurity };
|
|
|
|
|
|
|
|
for (size_t i = 0; i < ARRAYSIZE(options); i++)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, options[i], FALSE))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, singleOptionWithoutOnOff, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
if (singleOptionWithoutOnOff == FreeRDP_RdpSecurity)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UseRdpSecurityLayer, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_encryption_methods_options(rdpSettings* settings,
|
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char** p;
|
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
|
|
|
size_t count = 0;
|
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
|
|
|
|
UINT32 EncryptionMethods = 0;
|
|
|
|
for (UINT32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (option_equals(ptr.pc[i], "40"))
|
|
|
|
EncryptionMethods |= ENCRYPTION_METHOD_40BIT;
|
|
|
|
else if (option_equals(ptr.pc[i], "56"))
|
|
|
|
EncryptionMethods |= ENCRYPTION_METHOD_56BIT;
|
|
|
|
else if (option_equals(ptr.pc[i], "128"))
|
|
|
|
EncryptionMethods |= ENCRYPTION_METHOD_128BIT;
|
|
|
|
else if (option_equals(ptr.pc[i], "FIPS"))
|
|
|
|
EncryptionMethods |= ENCRYPTION_METHOD_FIPS;
|
|
|
|
else
|
|
|
|
WLog_ERR(TAG, "unknown encryption method '%s'", ptr.pc[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_EncryptionMethods, EncryptionMethods))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
free(ptr.p);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_cert_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
int rc = 0;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char** p;
|
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; (x < count) && (rc == 0); x++)
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
|
|
|
const char deny[] = "deny";
|
|
|
|
const char ignore[] = "ignore";
|
|
|
|
const char tofu[] = "tofu";
|
|
|
|
const char name[] = "name:";
|
|
|
|
const char fingerprints[] = "fingerprint:";
|
|
|
|
|
|
|
|
const char* cur = ptr.pc[x];
|
|
|
|
if (option_equals(deny, cur))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoDenyCertificate, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_equals(ignore, cur))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_IgnoreCertificate, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_equals(tofu, cur))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoAcceptCertificate, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else if (option_starts_with(name, cur))
|
|
|
|
{
|
|
|
|
const char* val = &cur[strnlen(name, sizeof(name))];
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_CertificateName, val))
|
|
|
|
rc = COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
else if (option_starts_with(fingerprints, cur))
|
|
|
|
{
|
|
|
|
const char* val = &cur[strnlen(fingerprints, sizeof(fingerprints))];
|
|
|
|
if (!freerdp_settings_append_string(settings, FreeRDP_CertificateAcceptedFingerprints,
|
|
|
|
",", val))
|
|
|
|
rc = COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
free(ptr.p);
|
|
|
|
|
2023-11-27 11:09:33 +03:00
|
|
|
return rc;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_mouse_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
size_t count = 0;
|
|
|
|
char** ptr = CommandLineParseCommaSeparatedValuesEx("mouse", arg->Value, &count);
|
|
|
|
UINT rc = 0;
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
for (size_t x = 1; x < count; x++)
|
|
|
|
{
|
|
|
|
const char* cur = ptr[x];
|
|
|
|
|
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
|
|
|
|
if (bval == PARSE_FAIL)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const BOOL val = bval != PARSE_OFF;
|
|
|
|
|
|
|
|
if (option_starts_with("relative", cur))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_MouseUseRelativeMove, val))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else if (option_starts_with("grab", cur))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GrabMouse, val))
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr);
|
|
|
|
|
2023-11-27 11:09:33 +03:00
|
|
|
return rc;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_floatbar_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
/* Defaults are enabled, visible, sticky, fullscreen */
|
|
|
|
UINT32 Floatbar = 0x0017;
|
|
|
|
|
|
|
|
if (arg->Value)
|
|
|
|
{
|
|
|
|
char* start = arg->Value;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
char* cur = start;
|
|
|
|
start = strchr(start, ',');
|
|
|
|
|
|
|
|
if (start)
|
|
|
|
{
|
|
|
|
*start = '\0';
|
|
|
|
start = start + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sticky:[on|off] */
|
|
|
|
if (option_starts_with("sticky:", cur))
|
|
|
|
{
|
|
|
|
Floatbar &= ~0x02u;
|
|
|
|
|
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
|
|
|
|
switch (bval)
|
|
|
|
{
|
|
|
|
case PARSE_ON:
|
|
|
|
case PARSE_NONE:
|
|
|
|
Floatbar |= 0x02u;
|
|
|
|
break;
|
|
|
|
case PARSE_OFF:
|
|
|
|
Floatbar &= ~0x02u;
|
|
|
|
break;
|
|
|
|
case PARSE_FAIL:
|
|
|
|
default:
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* default:[visible|hidden] */
|
|
|
|
else if (option_starts_with("default:", cur))
|
|
|
|
{
|
|
|
|
const char* val = cur + 8;
|
|
|
|
Floatbar &= ~0x04u;
|
|
|
|
|
|
|
|
if (option_equals("visible", val))
|
|
|
|
Floatbar |= 0x04u;
|
|
|
|
else if (option_equals("hidden", val))
|
|
|
|
Floatbar &= ~0x04u;
|
|
|
|
else
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
/* show:[always|fullscreen|window] */
|
|
|
|
else if (option_starts_with("show:", cur))
|
|
|
|
{
|
|
|
|
const char* val = cur + 5;
|
|
|
|
Floatbar &= ~0x30u;
|
|
|
|
|
|
|
|
if (option_equals("always", val))
|
|
|
|
Floatbar |= 0x30u;
|
|
|
|
else if (option_equals("fullscreen", val))
|
|
|
|
Floatbar |= 0x10u;
|
|
|
|
else if (option_equals("window", val))
|
|
|
|
Floatbar |= 0x20u;
|
|
|
|
else
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
} while (start);
|
|
|
|
}
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_Floatbar, Floatbar))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_reconnect_cookie_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
BYTE* base64 = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
crypto_base64_decode((const char*)(arg->Value), strlen(arg->Value), &base64, &length);
|
|
|
|
|
|
|
|
if ((base64 != NULL) && (length == sizeof(ARC_SC_PRIVATE_PACKET)))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_ServerAutoReconnectCookie, base64,
|
|
|
|
1))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "reconnect-cookie: invalid base64 '%s'", arg->Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(base64);
|
|
|
|
return 0;
|
2022-10-20 10:16:18 +03:00
|
|
|
}
|
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
static int parse_scale_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 100, 180))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
switch (val)
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
case 100:
|
|
|
|
case 140:
|
|
|
|
case 180:
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopScaleFactor, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DeviceScaleFactor, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
2023-11-17 11:49:22 +03:00
|
|
|
return 0;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
static int parse_scale_device_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 100, 180))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
switch (val)
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
case 100:
|
|
|
|
case 140:
|
|
|
|
case 180:
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DeviceScaleFactor, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
2023-11-17 11:49:22 +03:00
|
|
|
return 0;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
static int parse_smartcard_logon_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
union
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
char** p;
|
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SmartcardLogon, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx("smartcard-logon", arg->Value, &count);
|
|
|
|
if (ptr.pc)
|
|
|
|
{
|
|
|
|
const CmdLineSubOptions opts[] = {
|
|
|
|
{ "cert:", FreeRDP_SmartcardCertificate, CMDLINE_SUBOPTION_FILE,
|
|
|
|
setSmartcardEmulation },
|
|
|
|
{ "key:", FreeRDP_SmartcardPrivateKey, CMDLINE_SUBOPTION_FILE, setSmartcardEmulation },
|
|
|
|
{ "pin:", FreeRDP_Password, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "csp:", FreeRDP_CspName, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "reader:", FreeRDP_ReaderName, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "card:", FreeRDP_CardName, CMDLINE_SUBOPTION_STRING, NULL },
|
|
|
|
{ "container:", FreeRDP_ContainerName, CMDLINE_SUBOPTION_STRING, NULL }
|
|
|
|
};
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 1; x < count; x++)
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
|
|
|
const char* cur = ptr.pc[x];
|
|
|
|
if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur))
|
2022-10-20 11:44:18 +03:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
free(ptr.p);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
free(ptr.p);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-10-20 11:44:18 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
static int parse_tune_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t count = 0;
|
2023-11-17 11:49:22 +03:00
|
|
|
union
|
|
|
|
{
|
|
|
|
char** p;
|
|
|
|
const char** pc;
|
|
|
|
} ptr;
|
|
|
|
ptr.p = CommandLineParseCommaSeparatedValuesEx("tune", arg->Value, &count);
|
|
|
|
if (!ptr.pc)
|
|
|
|
return COMMAND_LINE_ERROR;
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 1; x < count; x++)
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
|
|
|
const char* cur = ptr.pc[x];
|
|
|
|
char* sep = strchr(cur, ':');
|
|
|
|
if (!sep)
|
|
|
|
{
|
|
|
|
free(ptr.p);
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
*sep++ = '\0';
|
|
|
|
if (!freerdp_settings_set_value_for_name(settings, cur, sep))
|
|
|
|
{
|
|
|
|
free(ptr.p);
|
|
|
|
return COMMAND_LINE_ERROR;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
|
|
|
}
|
2023-11-17 11:49:22 +03:00
|
|
|
|
|
|
|
free(ptr.p);
|
|
|
|
return 0;
|
2022-10-20 11:44:18 +03:00
|
|
|
}
|
|
|
|
|
2022-10-20 13:43:51 +03:00
|
|
|
static int parse_app_option_program(rdpSettings* settings, const char* cmd)
|
|
|
|
{
|
2023-10-16 20:37:36 +03:00
|
|
|
const FreeRDP_Settings_Keys_Bool ids[] = { FreeRDP_RemoteApplicationMode,
|
|
|
|
FreeRDP_RemoteAppLanguageBarSupported,
|
|
|
|
FreeRDP_Workarea, FreeRDP_DisableWallpaper,
|
|
|
|
FreeRDP_DisableFullWindowDrag };
|
2022-10-20 13:43:51 +03:00
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationProgram, cmd))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
|
|
|
for (size_t y = 0; y < ARRAYSIZE(ids); y++)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, ids[y], TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_app_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
int rc = CHANNEL_RC_OK;
|
|
|
|
size_t count = 0;
|
|
|
|
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (!ptr || (count == 0))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct app_map
|
|
|
|
{
|
|
|
|
const char* name;
|
2024-03-21 11:22:29 +03:00
|
|
|
SSIZE_T id;
|
2022-10-20 13:43:51 +03:00
|
|
|
int (*fkt)(rdpSettings* settings, const char* value);
|
|
|
|
};
|
2024-03-21 11:22:29 +03:00
|
|
|
const struct app_map amap[] = { { "program:", FreeRDP_RemoteApplicationProgram,
|
|
|
|
parse_app_option_program },
|
|
|
|
{ "workdir:", FreeRDP_RemoteApplicationWorkingDir, NULL },
|
|
|
|
{ "name:", FreeRDP_RemoteApplicationName, NULL },
|
|
|
|
{ "icon:", FreeRDP_RemoteApplicationIcon, NULL },
|
|
|
|
{ "cmd:", FreeRDP_RemoteApplicationCmdLine, NULL },
|
|
|
|
{ "file:", FreeRDP_RemoteApplicationFile, NULL },
|
|
|
|
{ "guid:", FreeRDP_RemoteApplicationGuid, NULL },
|
|
|
|
{ "hidef:", FreeRDP_HiDefRemoteApp, NULL } };
|
2022-10-20 13:43:51 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
BOOL handled = FALSE;
|
|
|
|
const char* val = ptr[x];
|
|
|
|
|
|
|
|
for (size_t y = 0; y < ARRAYSIZE(amap); y++)
|
|
|
|
{
|
|
|
|
const struct app_map* cur = &amap[y];
|
2022-11-29 23:54:24 +03:00
|
|
|
if (option_starts_with(cur->name, val))
|
2022-10-20 13:43:51 +03:00
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
const char* xval = &val[strlen(cur->name)];
|
2022-10-20 13:43:51 +03:00
|
|
|
if (cur->fkt)
|
2022-10-27 11:29:01 +03:00
|
|
|
rc = cur->fkt(settings, xval);
|
2024-03-21 11:22:29 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const char* name = freerdp_settings_get_name_for_key(cur->id);
|
|
|
|
if (!freerdp_settings_set_value_for_name(settings, name, xval))
|
|
|
|
rc = COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2022-10-20 13:43:51 +03:00
|
|
|
|
|
|
|
handled = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
|
|
|
if (!handled && (count == 1))
|
|
|
|
{
|
|
|
|
/* Legacy path, allow /app:command and /app:||command syntax */
|
|
|
|
rc = parse_app_option_program(settings, val);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (!handled)
|
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
if (rc != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ptr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2022-10-20 10:59:16 +03:00
|
|
|
static int parse_cache_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
int rc = CHANNEL_RC_OK;
|
|
|
|
size_t count = 0;
|
|
|
|
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (!ptr || (count == 0))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
|
|
|
for (size_t x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
const char* val = ptr[x];
|
|
|
|
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_starts_with("codec:", val))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCacheV3Enabled, TRUE))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(arg->Value, "rfx"))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, TRUE))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(arg->Value, "nsc"))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, TRUE))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(WITH_JPEG)
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(arg->Value, "jpeg"))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, TRUE))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_uint32(settings, FreeRDP_JpegQuality) == 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, 75))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-20 10:59:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("persist-file:", val))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_BitmapCachePersistFile, &val[13]))
|
|
|
|
rc = COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
else if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, TRUE))
|
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
|
|
|
|
if (bval == PARSE_FAIL)
|
2022-10-20 10:59:16 +03:00
|
|
|
rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
else
|
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_starts_with("bitmap", val))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCacheEnabled,
|
|
|
|
bval != PARSE_OFF))
|
2022-10-20 10:59:16 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("glyph", val))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_GlyphSupportLevel,
|
2023-03-10 12:36:00 +03:00
|
|
|
bval != PARSE_OFF ? GLYPH_SUPPORT_FULL
|
|
|
|
: GLYPH_SUPPORT_NONE))
|
2022-10-20 10:59:16 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("persist", val))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled,
|
2023-03-10 12:36:00 +03:00
|
|
|
bval != PARSE_OFF))
|
2022-10-20 10:59:16 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_starts_with("offscreen", val))
|
2022-10-20 10:59:16 +03:00
|
|
|
{
|
2023-03-10 12:36:00 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_OffscreenSupportLevel,
|
|
|
|
bval != PARSE_OFF))
|
2022-10-20 10:59:16 +03:00
|
|
|
rc = COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ptr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2023-02-01 12:38:05 +03:00
|
|
|
static BOOL parse_gateway_host_option(rdpSettings* settings, const char* host)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(host);
|
|
|
|
|
|
|
|
char* name = NULL;
|
|
|
|
int port = -1;
|
|
|
|
if (!freerdp_parse_hostname(host, &name, &port))
|
|
|
|
return FALSE;
|
|
|
|
const BOOL rc = freerdp_settings_set_string(settings, FreeRDP_GatewayHostname, name);
|
|
|
|
free(name);
|
|
|
|
if (!rc)
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayUseSameCredentials, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_set_gateway_usage_method(settings, TSC_PROXY_MODE_DIRECT))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-10-16 20:37:36 +03:00
|
|
|
static BOOL parse_gateway_cred_option(rdpSettings* settings, const char* value,
|
|
|
|
FreeRDP_Settings_Keys_String what)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
|
|
|
|
switch (what)
|
|
|
|
{
|
|
|
|
case FreeRDP_GatewayUsername:
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_parse_username_settings(value, settings, FreeRDP_GatewayUsername,
|
|
|
|
FreeRDP_GatewayDomain))
|
2023-02-01 12:38:05 +03:00
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!freerdp_settings_set_string(settings, what, value))
|
2023-03-14 12:39:18 +03:00
|
|
|
return FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return freerdp_settings_set_bool(settings, FreeRDP_GatewayUseSameCredentials, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_gateway_type_option(rdpSettings* settings, const char* value)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
|
|
|
|
if (option_equals(value, "rpc"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayRpcTransport, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpTransport, FALSE) ||
|
2023-06-26 20:24:58 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpUseWebsockets, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayArmTransport, FALSE))
|
2023-02-01 12:38:05 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (option_equals(value, "http"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayRpcTransport, FALSE) ||
|
2023-06-26 20:24:58 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpTransport, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayArmTransport, FALSE))
|
2023-02-01 12:38:05 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (option_equals(value, "auto"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayRpcTransport, TRUE) ||
|
2023-06-26 20:24:58 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpTransport, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayArmTransport, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (option_equals(value, "arm"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayRpcTransport, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpTransport, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpUseWebsockets, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_GatewayArmTransport, TRUE))
|
2023-02-01 12:38:05 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_gateway_usage_option(rdpSettings* settings, const char* value)
|
|
|
|
{
|
|
|
|
UINT32 type = 0;
|
|
|
|
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
|
|
|
|
if (option_equals(value, "none"))
|
|
|
|
type = TSC_PROXY_MODE_NONE_DIRECT;
|
|
|
|
else if (option_equals(value, "direct"))
|
|
|
|
type = TSC_PROXY_MODE_DIRECT;
|
|
|
|
else if (option_equals(value, "detect"))
|
|
|
|
type = TSC_PROXY_MODE_DETECT;
|
|
|
|
else if (option_equals(value, "default"))
|
|
|
|
type = TSC_PROXY_MODE_DEFAULT;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LONGLONG val = 0;
|
|
|
|
|
|
|
|
if (!value_to_int(value, &val, TSC_PROXY_MODE_NONE_DIRECT, TSC_PROXY_MODE_NONE_DETECT))
|
2023-03-14 12:39:18 +03:00
|
|
|
return FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return freerdp_set_gateway_usage_method(settings, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_gateway_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_A* arg)
|
|
|
|
{
|
|
|
|
BOOL rc = FALSE;
|
|
|
|
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(arg);
|
|
|
|
|
|
|
|
size_t count = 0;
|
|
|
|
char** args = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
|
|
|
if (count == 0)
|
|
|
|
return TRUE;
|
|
|
|
WINPR_ASSERT(args);
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayEnabled, TRUE))
|
|
|
|
goto fail;
|
|
|
|
|
2023-03-28 18:14:40 +03:00
|
|
|
BOOL allowHttpOpts = FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
for (size_t x = 0; x < count; x++)
|
|
|
|
{
|
|
|
|
BOOL validOption = FALSE;
|
|
|
|
const char* argval = args[x];
|
|
|
|
|
|
|
|
WINPR_ASSERT(argval);
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* gw = option_starts_with("g:", argval);
|
|
|
|
if (gw)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!parse_gateway_host_option(settings, gw))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* gu = option_starts_with("u:", argval);
|
|
|
|
if (gu)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!parse_gateway_cred_option(settings, gu, FreeRDP_GatewayUsername))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* gd = option_starts_with("d:", argval);
|
|
|
|
if (gd)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!parse_gateway_cred_option(settings, gd, FreeRDP_GatewayDomain))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* gp = option_starts_with("p:", argval);
|
|
|
|
if (gp)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!parse_gateway_cred_option(settings, gp, FreeRDP_GatewayPassword))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* gt = option_starts_with("type:", argval);
|
|
|
|
if (gt)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!parse_gateway_type_option(settings, gt))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = freerdp_settings_get_bool(settings, FreeRDP_GatewayHttpTransport);
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* gat = option_starts_with("access-token:", argval);
|
|
|
|
if (gat)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayAccessToken, gat))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = FALSE;
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
2023-06-17 22:59:49 +03:00
|
|
|
|
2023-06-14 19:55:42 +03:00
|
|
|
const char* bearer = option_starts_with("bearer:", argval);
|
|
|
|
if (bearer)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayHttpExtAuthBearer, bearer))
|
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
|
|
|
allowHttpOpts = FALSE;
|
|
|
|
}
|
2023-02-01 12:38:05 +03:00
|
|
|
|
2023-06-17 22:59:49 +03:00
|
|
|
const char* gwurl = option_starts_with("url:", argval);
|
|
|
|
if (gwurl)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUrl, gwurl))
|
|
|
|
goto fail;
|
|
|
|
if (!freerdp_set_gateway_usage_method(settings, TSC_PROXY_MODE_DIRECT))
|
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
|
|
|
allowHttpOpts = FALSE;
|
|
|
|
}
|
|
|
|
|
2023-03-01 21:30:33 +03:00
|
|
|
const char* um = option_starts_with("usage-method:", argval);
|
|
|
|
if (um)
|
2023-02-01 12:38:05 +03:00
|
|
|
{
|
2023-03-01 21:30:33 +03:00
|
|
|
if (!parse_gateway_usage_option(settings, um))
|
2023-02-01 12:38:05 +03:00
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
2023-03-28 18:14:40 +03:00
|
|
|
allowHttpOpts = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (allowHttpOpts)
|
|
|
|
{
|
|
|
|
if (option_equals(argval, "no-websockets"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpUseWebsockets, FALSE))
|
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
|
|
|
}
|
|
|
|
else if (option_equals(argval, "extauth-sspi-ntlm"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GatewayHttpExtAuthSspiNtlm, TRUE))
|
|
|
|
goto fail;
|
|
|
|
validOption = TRUE;
|
|
|
|
}
|
2023-02-01 12:38:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!validOption)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = TRUE;
|
|
|
|
fail:
|
|
|
|
free(args);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2023-02-01 13:20:21 +03:00
|
|
|
static void fill_credential_string(COMMAND_LINE_ARGUMENT_A* args, const char* value)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(args);
|
|
|
|
WINPR_ASSERT(value);
|
|
|
|
|
2023-03-10 18:52:39 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = CommandLineFindArgumentA(args, value);
|
2023-02-01 13:20:21 +03:00
|
|
|
if (!arg)
|
|
|
|
return;
|
|
|
|
|
2023-04-27 10:46:17 +03:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
2023-02-01 13:20:21 +03:00
|
|
|
FillMemory(arg->Value, strlen(arg->Value), '*');
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fill_credential_strings(COMMAND_LINE_ARGUMENT_A* args)
|
|
|
|
{
|
2023-02-01 13:46:49 +03:00
|
|
|
const char* credentials[] = {
|
|
|
|
"p",
|
|
|
|
"smartcard-logon",
|
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
|
|
|
"gp",
|
|
|
|
"gat",
|
|
|
|
#endif
|
|
|
|
"pth",
|
|
|
|
"reconnect-cookie",
|
|
|
|
"assistance"
|
|
|
|
};
|
2023-02-01 13:20:21 +03:00
|
|
|
|
|
|
|
for (size_t x = 0; x < ARRAYSIZE(credentials); x++)
|
|
|
|
{
|
|
|
|
const char* cred = credentials[x];
|
|
|
|
fill_credential_string(args, cred);
|
|
|
|
}
|
|
|
|
|
2023-03-10 18:52:39 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = CommandLineFindArgumentA(args, "gateway");
|
2023-02-01 13:20:21 +03:00
|
|
|
if (arg && ((arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) != 0))
|
|
|
|
{
|
|
|
|
const char* gwcreds[] = { "p:", "access-token:" };
|
|
|
|
char* tok = strtok(arg->Value, ",");
|
|
|
|
while (tok)
|
|
|
|
{
|
|
|
|
for (size_t x = 0; x < ARRAYSIZE(gwcreds); x++)
|
|
|
|
{
|
|
|
|
const char* opt = gwcreds[x];
|
|
|
|
if (option_starts_with(opt, tok))
|
|
|
|
{
|
|
|
|
char* val = &tok[strlen(opt)];
|
|
|
|
FillMemory(val, strlen(val), '*');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tok = strtok(NULL, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-21 15:39:43 +03:00
|
|
|
static int freerdp_client_settings_parse_command_line_arguments_int(
|
|
|
|
rdpSettings* settings, int argc, char* argv[], BOOL allowUnknown,
|
|
|
|
COMMAND_LINE_ARGUMENT_A* largs, size_t count,
|
|
|
|
int (*handle_option)(const COMMAND_LINE_ARGUMENT* arg, void* custom), void* handle_userdata)
|
2013-06-15 23:13:38 +04:00
|
|
|
{
|
2015-06-18 12:35:22 +03:00
|
|
|
char* user = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
int status = 0;
|
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;
|
2024-01-23 18:49:54 +03:00
|
|
|
const COMMAND_LINE_ARGUMENT_A* arg = NULL;
|
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)
|
|
|
|
{
|
2022-12-15 16:56:58 +03:00
|
|
|
ext = option_is_rdp_file(argv[1]);
|
|
|
|
assist = option_is_incident_file(argv[1]);
|
2018-02-19 12:00:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ext && !assist)
|
2018-12-11 13:42:25 +03:00
|
|
|
compatibility = freerdp_client_detect_command_line(argc, argv, &flags);
|
2018-03-09 16:25:45 +03:00
|
|
|
else
|
2018-12-11 13:42:25 +03:00
|
|
|
compatibility = freerdp_client_detect_command_line(argc - 1, &argv[1], &flags);
|
2013-06-15 23:13:38 +04:00
|
|
|
|
2020-08-04 09:49:46 +03:00
|
|
|
freerdp_settings_set_string(settings, FreeRDP_ProxyHostname, NULL);
|
|
|
|
freerdp_settings_set_string(settings, FreeRDP_ProxyUsername, NULL);
|
|
|
|
freerdp_settings_set_string(settings, FreeRDP_ProxyPassword, NULL);
|
2017-08-18 20:17:17 +03:00
|
|
|
|
2013-06-15 23:13:38 +04:00
|
|
|
if (compatibility)
|
|
|
|
{
|
2021-10-14 09:25:46 +03:00
|
|
|
WLog_WARN(TAG, "Unsupported command line syntax!");
|
2021-10-14 10:01:00 +03:00
|
|
|
WLog_WARN(TAG, "FreeRDP 1.0 style syntax was dropped with version 3!");
|
2021-10-14 09:25:46 +03:00
|
|
|
return -1;
|
2013-06-15 23:13:38 +04:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if (freerdp_client_settings_parse_assistance_file(settings, argc, argv) < 0)
|
2018-02-19 12:00:54 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-21 15:47:28 +03:00
|
|
|
}
|
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
CommandLineClearArgumentsA(largs);
|
2019-11-06 17:24:51 +03:00
|
|
|
status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
|
2016-08-04 17:13:37 +03:00
|
|
|
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)
|
2023-11-17 11:49:22 +03:00
|
|
|
return status;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
prepare_default_settings(settings, largs, ext);
|
|
|
|
}
|
2014-10-17 14:08:39 +04:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
CommandLineFindArgumentA(largs, "v");
|
|
|
|
arg = largs;
|
|
|
|
errno = 0;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
/* Disable unicode input unless requested. */
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UnicodeInput, FALSE))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
BOOL enable = arg->Value ? TRUE : FALSE;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
|
|
|
continue;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-11-17 11:49:22 +03:00
|
|
|
CommandLineSwitchStart(arg)
|
|
|
|
|
|
|
|
CommandLineSwitchCase(arg, "v")
|
|
|
|
{
|
|
|
|
const int rc = parse_host_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-07 03:49:02 +04:00
|
|
|
}
|
2014-02-12 09:43:02 +04:00
|
|
|
CommandLineSwitchCase(arg, "spn-class")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AuthenticationServiceClass,
|
|
|
|
arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2014-02-12 09:43:02 +04:00
|
|
|
}
|
2022-05-26 18:42:28 +03:00
|
|
|
CommandLineSwitchCase(arg, "sspi-module")
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_SspiModule, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2023-08-21 21:26:53 +03:00
|
|
|
CommandLineSwitchCase(arg, "winscard-module")
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_WinSCardModule, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2018-08-08 12:16:24 +03:00
|
|
|
CommandLineSwitchCase(arg, "redirect-prefer")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_redirect_prefer_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2018-08-08 12:16:24 +03:00
|
|
|
}
|
2014-02-14 09:43:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "credentials-delegation")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableCredentialsDelegation, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-02-14 09:43:31 +04:00
|
|
|
}
|
2023-10-19 12:52:46 +03:00
|
|
|
CommandLineSwitchCase(arg, "prevent-session-lock")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_prevent_session_lock_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2023-10-19 12:52:46 +03:00
|
|
|
}
|
2013-01-09 02:18:34 +04:00
|
|
|
CommandLineSwitchCase(arg, "vmconnect")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_vmconnect_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2013-01-09 02:18:34 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "w")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "h")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "size")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_size_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "f")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_Fullscreen, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2018-11-29 21:42:32 +03:00
|
|
|
CommandLineSwitchCase(arg, "suppress-output")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SuppressOutput, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-11-29 21:42:32 +03:00
|
|
|
}
|
2012-12-13 23:38:02 +04:00
|
|
|
CommandLineSwitchCase(arg, "multimon")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UseMultimon, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-04-25 23:42:40 +04:00
|
|
|
|
2012-12-13 23:38:02 +04:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(arg->Value, "force"))
|
2012-12-13 23:38:02 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ForceMultimon, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-12-13 23:38:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-25 22:39:21 +04:00
|
|
|
CommandLineSwitchCase(arg, "span")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SpanMonitors, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-03-25 22:39:21 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "workarea")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_Workarea, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2013-04-29 02:48:27 +04:00
|
|
|
CommandLineSwitchCase(arg, "monitors")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_monitors_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2013-04-29 02:48:27 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "t")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_WindowTitle, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "decorations")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_Decorations, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2017-11-29 12:26:04 +03:00
|
|
|
CommandLineSwitchCase(arg, "dynamic-resolution")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_dynamic_resolution_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2017-11-29 12:26:04 +03:00
|
|
|
}
|
2013-04-11 00:58:14 +04:00
|
|
|
CommandLineSwitchCase(arg, "smart-sizing")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_smart_sizing_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2013-04-11 00:58:14 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "bpp")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_bpp_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-12-13 16:39:49 +04:00
|
|
|
CommandLineSwitchCase(arg, "admin")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-12-13 16:39:49 +04:00
|
|
|
}
|
2018-10-17 13:15:57 +03:00
|
|
|
CommandLineSwitchCase(arg, "relax-order-checks")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowUnanouncedOrdersFromServer,
|
|
|
|
enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-10-17 13:15:57 +03:00
|
|
|
}
|
2013-11-06 10:51:55 +04:00
|
|
|
CommandLineSwitchCase(arg, "restricted-admin")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeRequired, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-11-06 10:51:55 +04:00
|
|
|
}
|
2013-11-06 19:02:58 +04:00
|
|
|
CommandLineSwitchCase(arg, "pth")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeRequired, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_PasswordHash, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
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")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ClientHostname, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2013-11-12 04:57:44 +04:00
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "kbd")
|
|
|
|
{
|
2022-10-20 11:44:18 +03:00
|
|
|
int rc = parse_kbd_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2020-10-28 14:22:48 +03:00
|
|
|
CommandLineSwitchCase(arg, "kbd-remap")
|
|
|
|
{
|
2022-10-20 11:44:18 +03:00
|
|
|
WLog_WARN(TAG, "/kbd-remap:<key>=<value>,<key2>=<value2> is deprecated, use "
|
|
|
|
"/kbd:remap:<key>=<value>,remap:<key2>=<value2>,... instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_KeyboardRemappingList, arg->Value))
|
2020-10-28 14:22:48 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2019-11-07 21:31:26 +03:00
|
|
|
CommandLineSwitchCase(arg, "kbd-lang")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2019-11-07 21:31:26 +03:00
|
|
|
|
2022-10-20 11:44:18 +03:00
|
|
|
WLog_WARN(TAG, "/kbd-lang:<value> is deprecated, use /kbd:lang:<value> instead");
|
2019-11-07 21:31:26 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 1, UINT32_MAX))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Could not identify keyboard active language %s", arg->Value);
|
2022-10-19 16:18:14 +03:00
|
|
|
WLog_ERR(TAG, "Use /list:kbd-lang to list available layouts");
|
2019-11-07 21:31:26 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardCodePage, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2019-11-07 21:31:26 +03:00
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "kbd-type")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2022-10-20 11:44:18 +03:00
|
|
|
WLog_WARN(TAG, "/kbd-type:<value> is deprecated, use /kbd:type:<value> instead");
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardType, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2021-09-10 16:46:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "kbd-unicode")
|
|
|
|
{
|
2022-10-20 11:44:18 +03:00
|
|
|
WLog_WARN(TAG, "/kbd-unicode is deprecated, use /kbd:unicode[:on|off] instead");
|
2021-09-10 16:46:33 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UnicodeInput, enable))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "kbd-subtype")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2022-10-20 11:44:18 +03:00
|
|
|
WLog_WARN(TAG, "/kbd-subtype:<value> is deprecated, use /kbd:subtype:<value> instead");
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardSubType, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "kbd-fn-key")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2022-10-20 11:44:18 +03:00
|
|
|
WLog_WARN(TAG, "/kbd-fn-key:<value> is deprecated, use /kbd:fn-key:<value> instead");
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardFunctionKey, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2022-10-20 11:44:18 +03:00
|
|
|
#endif
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "u")
|
|
|
|
{
|
2023-12-13 15:40:25 +03:00
|
|
|
WINPR_ASSERT(arg->Value);
|
|
|
|
user = arg->Value;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "d")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "p")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Password, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2023-02-01 12:38:05 +03:00
|
|
|
CommandLineSwitchCase(arg, "gateway")
|
|
|
|
{
|
|
|
|
if (!parse_gateway_options(settings, arg))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2016-12-11 01:13:35 +03:00
|
|
|
CommandLineSwitchCase(arg, "proxy")
|
2014-03-21 21:58:28 +04:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_proxy_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2014-03-21 21:58:28 +04:00
|
|
|
}
|
2023-02-01 13:46:49 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
|
|
|
CommandLineSwitchCase(arg, "g")
|
|
|
|
{
|
|
|
|
if (!parse_gateway_host_option(settings, arg->Value))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "gu")
|
|
|
|
{
|
2023-02-01 12:38:05 +03:00
|
|
|
if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayUsername))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gd")
|
|
|
|
{
|
2023-02-01 12:38:05 +03:00
|
|
|
if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayDomain))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gp")
|
|
|
|
{
|
2023-02-01 12:38:05 +03:00
|
|
|
if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayPassword))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2015-03-19 18:44:47 +03:00
|
|
|
CommandLineSwitchCase(arg, "gt")
|
|
|
|
{
|
2023-02-01 12:38:05 +03:00
|
|
|
if (!parse_gateway_type_option(settings, arg->Value))
|
2022-04-28 09:00:39 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2015-03-19 18:44:47 +03:00
|
|
|
}
|
2018-02-13 16:59:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "gat")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayAccessToken, arg->Value))
|
2018-02-13 16:59:33 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2014-05-30 20:31:26 +04:00
|
|
|
CommandLineSwitchCase(arg, "gateway-usage-method")
|
|
|
|
{
|
2023-02-01 12:38:05 +03:00
|
|
|
if (!parse_gateway_usage_option(settings, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2014-05-30 20:31:26 +04:00
|
|
|
}
|
2023-02-01 13:46:49 +03:00
|
|
|
#endif
|
2012-11-19 22:26:56 +04:00
|
|
|
CommandLineSwitchCase(arg, "app")
|
|
|
|
{
|
2022-10-20 13:43:51 +03:00
|
|
|
int rc = parse_app_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "load-balance-info")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_LoadBalanceInfo, arg->Value,
|
|
|
|
strlen(arg->Value)))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
2022-10-20 14:29:32 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2019-05-22 17:36:40 +03:00
|
|
|
CommandLineSwitchCase(arg, "app-workdir")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(
|
|
|
|
TAG,
|
|
|
|
"/app-workdir:<directory> is deprecated, use /app:workdir:<directory> instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationWorkingDir,
|
|
|
|
arg->Value))
|
2019-05-22 17:36:40 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2012-11-19 22:26:56 +04:00
|
|
|
CommandLineSwitchCase(arg, "app-name")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/app-name:<directory> is deprecated, use /app:name:<name> instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationName, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-icon")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/app-icon:<filename> is deprecated, use /app:icon:<filename> instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationIcon, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-cmd")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/app-cmd:<command> is deprecated, use /app:cmd:<command> instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationCmdLine,
|
|
|
|
arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-file")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/app-file:<filename> is deprecated, use /app:file:<filename> instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationFile, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "app-guid")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/app-guid:<guid> is deprecated, use /app:guid:<guid> instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationGuid, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-19 22:26:56 +04:00
|
|
|
}
|
2022-10-20 13:43:51 +03:00
|
|
|
#endif
|
2012-11-26 23:31:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "compression")
|
2012-11-06 07:11:13 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2014-03-10 19:16:36 +04:00
|
|
|
CommandLineSwitchCase(arg, "compression-level")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_CompressionLevel, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-03-10 19:16:36 +04:00
|
|
|
}
|
2013-02-15 04:38:45 +04:00
|
|
|
CommandLineSwitchCase(arg, "drives")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-02-15 04:38:45 +04:00
|
|
|
}
|
2022-10-06 17:03:31 +03:00
|
|
|
CommandLineSwitchCase(arg, "dump")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_dump_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2022-10-06 17:03:31 +03:00
|
|
|
}
|
2021-09-21 10:56:56 +03:00
|
|
|
CommandLineSwitchCase(arg, "disable-output")
|
|
|
|
{
|
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_DeactivateClientDecoding, enable);
|
|
|
|
}
|
2013-02-15 04:38:45 +04:00
|
|
|
CommandLineSwitchCase(arg, "home-drive")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectHomeDrive, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-02-15 04:38:45 +04:00
|
|
|
}
|
2017-11-27 12:54:49 +03:00
|
|
|
CommandLineSwitchCase(arg, "ipv6")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PreferIPv6OverIPv4, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-11-27 12:54:49 +03:00
|
|
|
}
|
2012-11-21 04:34:52 +04:00
|
|
|
CommandLineSwitchCase(arg, "clipboard")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_clipboard_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-21 04:34:52 +04:00
|
|
|
}
|
2022-10-14 20:39:12 +03:00
|
|
|
CommandLineSwitchCase(arg, "server-name")
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_UserSpecifiedServerName, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "shell")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AlternateShell, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "shell-dir")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ShellWorkingDirectory, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2023-11-17 11:49:22 +03:00
|
|
|
CommandLineSwitchCase(arg, "audio-mode")
|
|
|
|
{
|
|
|
|
const int rc = parse_audio_mode_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "network")
|
|
|
|
{
|
|
|
|
const int rc = parse_network_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "fonts")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "wallpaper")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableWallpaper, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "window-drag")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableFullWindowDrag, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2018-11-15 16:40:03 +03:00
|
|
|
CommandLineSwitchCase(arg, "window-position")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
unsigned long x = 0;
|
|
|
|
unsigned long y = 0;
|
2018-11-15 16:40:03 +03:00
|
|
|
|
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_MISSING_ARGUMENT;
|
|
|
|
|
|
|
|
if (!parseSizeValue(arg->Value, &x, &y) || x > UINT16_MAX || y > UINT16_MAX)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "invalid window-position argument");
|
|
|
|
return COMMAND_LINE_ERROR_MISSING_ARGUMENT;
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPosX, (UINT32)x))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPosY, (UINT32)y))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-11-15 16:40:03 +03:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "menu-anims")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableMenuAnims, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "themes")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DisableThemes, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2020-03-23 10:51:35 +03:00
|
|
|
CommandLineSwitchCase(arg, "timeout")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
ULONGLONG val = 0;
|
2020-03-23 10:51:35 +03:00
|
|
|
if (!value_to_uint(arg->Value, &val, 1, 600000))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-03-24 13:07:11 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_TcpAckTimeout, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2020-03-23 10:51:35 +03:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "aero")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowDesktopComposition, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "gdi")
|
|
|
|
{
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(arg->Value, "sw"))
|
2023-11-17 11:49:22 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SoftwareGdi, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2023-11-17 11:49:22 +03:00
|
|
|
}
|
|
|
|
else if (option_equals(arg->Value, "hw"))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SoftwareGdi, FALSE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
2013-10-22 07:33:25 +04:00
|
|
|
CommandLineSwitchCase(arg, "gfx")
|
|
|
|
{
|
2022-10-20 10:16:18 +03:00
|
|
|
int rc = parse_gfx_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2014-07-03 22:35:03 +04:00
|
|
|
CommandLineSwitchCase(arg, "gfx-thin-client")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/gfx-thin-client is deprecated, use /gfx:thin-client[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxThinClient, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_GfxThinClient))
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gfx-small-cache")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/gfx-small-cache is deprecated, use /gfx:small-cache[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxSmallCache, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-10-15 12:51:16 +03:00
|
|
|
|
|
|
|
if (enable)
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "gfx-progressive")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/gfx-progressive is deprecated, use /gfx:progressive[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxThinClient, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-10-15 12:51:16 +03:00
|
|
|
|
|
|
|
if (enable)
|
2023-10-13 10:48:44 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
2017-07-17 10:00:57 +03:00
|
|
|
#ifdef WITH_GFX_H264
|
2014-07-03 22:35:03 +04:00
|
|
|
CommandLineSwitchCase(arg, "gfx-h264")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/gfx-h264 is deprecated, use /gfx:avc420 instead");
|
2022-12-15 12:56:57 +03:00
|
|
|
int rc = parse_gfx_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2013-10-22 07:33:25 +04:00
|
|
|
}
|
2022-10-20 10:16:18 +03:00
|
|
|
#endif
|
2017-07-17 10:00:57 +03:00
|
|
|
#endif
|
2012-11-07 07:08:09 +04:00
|
|
|
CommandLineSwitchCase(arg, "rfx")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "rfx-mode")
|
|
|
|
{
|
2020-01-23 11:09:35 +03:00
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2019-01-29 19:24:29 +03:00
|
|
|
|
2022-10-27 11:29:01 +03:00
|
|
|
if (option_equals(arg->Value, "video"))
|
2023-10-13 10:48:44 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_RemoteFxCodecMode, 0x00))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2022-10-27 11:29:01 +03:00
|
|
|
else if (option_equals(arg->Value, "image"))
|
2023-09-23 19:47:36 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxImageCodec, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_RemoteFxCodecMode, 0x02))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2023-09-23 19:47:36 +03:00
|
|
|
}
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "frame-ack")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_FrameAcknowledge, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-07 07:08:09 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "nsc")
|
|
|
|
{
|
2021-07-01 12:40:41 +03:00
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_NSCodec, enable);
|
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")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_JpegCodec, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, 75))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "jpeg-quality")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, 100))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_JpegQuality, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
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")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
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
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
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
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_PreconnectionId, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2023-09-22 23:13:54 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
CommandLineSwitchCase(arg, "connect-child-session")
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AuthenticationServiceClass,
|
|
|
|
"vs-debug") ||
|
|
|
|
!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, "localhost") ||
|
|
|
|
!freerdp_settings_set_string(settings, FreeRDP_AuthenticationPackageList, "ntlm") ||
|
2024-02-21 01:59:33 +03:00
|
|
|
!freerdp_settings_set_string(settings, FreeRDP_ClientAddress, "0.0.0.0") ||
|
2023-09-22 23:13:54 +03:00
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, FALSE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_ConnectChildSession, TRUE) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, TRUE) ||
|
2024-02-21 01:59:33 +03:00
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 0) ||
|
|
|
|
!freerdp_settings_set_bool(settings, FreeRDP_NetworkAutoDetect, TRUE) ||
|
|
|
|
!freerdp_settings_set_uint32(settings, FreeRDP_ConnectionType, CONNECTION_TYPE_LAN))
|
2023-09-22 23:13:54 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "sec")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_sec_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
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")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_encryption_methods_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
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
|
|
|
}
|
2023-05-16 10:39:31 +03:00
|
|
|
CommandLineSwitchCase(arg, "args-from")
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "/args-from:%s can not be used in combination with other arguments!",
|
|
|
|
arg->Value);
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2015-06-23 15:59:54 +03:00
|
|
|
CommandLineSwitchCase(arg, "from-stdin")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_CredentialsFromStdin, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-11-27 12:54:49 +03:00
|
|
|
|
2017-11-10 13:52:23 +03:00
|
|
|
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
|
|
|
{
|
2020-01-23 11:09:35 +03:00
|
|
|
if (!arg->Value)
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-10-27 11:29:01 +03:00
|
|
|
promptForPassword = (option_equals(arg->Value, "force"));
|
2017-11-10 13:52:23 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "sec-rdp")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/sec-rdp is deprecated, use /sec:rdp[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec-tls")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/sec-tls is deprecated, use /sec:tls[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec-nla")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/sec-nla is deprecated, use /sec:nla[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "sec-ext")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/sec-ext is deprecated, use /sec:ext[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2022-10-19 15:09:03 +03:00
|
|
|
#endif
|
2022-10-19 14:50:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "tls")
|
2014-07-17 16:59:06 +04:00
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
int rc = parse_tls_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2022-10-19 14:50:33 +03:00
|
|
|
}
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2022-10-19 14:50:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "tls-ciphers")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/tls-ciphers:<cipher list> is deprecated, use "
|
2022-10-20 11:11:26 +03:00
|
|
|
"/tls:ciphers:<cipher list> instead");
|
2023-11-17 11:49:22 +03:00
|
|
|
int rc = parse_tls_cipher_options(settings, arg);
|
2022-10-19 14:50:33 +03:00
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2014-07-17 16:59:06 +04:00
|
|
|
}
|
2018-11-08 13:01:56 +03:00
|
|
|
CommandLineSwitchCase(arg, "tls-seclevel")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG,
|
|
|
|
"/tls-seclevel:<level> is deprecated, use /tls:sec-level:<level> instead");
|
2023-11-17 11:49:22 +03:00
|
|
|
int rc = parse_tls_cipher_options(settings, arg);
|
2022-10-19 14:50:33 +03:00
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2018-11-08 13:01:56 +03:00
|
|
|
}
|
2022-08-16 11:40:32 +03:00
|
|
|
CommandLineSwitchCase(arg, "tls-secrets-file")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/tls-secrets-file:<filename> is deprecated, use "
|
2022-10-20 11:11:26 +03:00
|
|
|
"/tls:secrets-file:<filename> instead");
|
2023-11-17 11:49:22 +03:00
|
|
|
int rc = parse_tls_cipher_options(settings, arg);
|
2022-10-19 14:50:33 +03:00
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2022-08-16 11:40:32 +03:00
|
|
|
}
|
2022-06-23 03:17:43 +03:00
|
|
|
CommandLineSwitchCase(arg, "enforce-tlsv1_2")
|
|
|
|
{
|
2022-10-20 14:29:32 +03:00
|
|
|
WLog_WARN(TAG, "/enforce-tlsv1_2 is deprecated, use /tls:enforce:1.2 instead");
|
2023-11-17 11:49:22 +03:00
|
|
|
int rc = parse_tls_cipher_options(settings, arg);
|
2022-10-19 14:50:33 +03:00
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2022-06-23 03:17:43 +03:00
|
|
|
}
|
2022-10-19 15:00:48 +03:00
|
|
|
#endif
|
2020-02-12 14:03:43 +03:00
|
|
|
CommandLineSwitchCase(arg, "cert")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_cert_options(settings, arg);
|
|
|
|
if (rc != 0)
|
2020-02-12 14:03:43 +03:00
|
|
|
return rc;
|
|
|
|
}
|
2022-10-19 15:00:48 +03:00
|
|
|
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchCase(arg, "cert-name")
|
|
|
|
{
|
2022-10-19 14:56:01 +03:00
|
|
|
WLog_WARN(TAG, "/cert-name is deprecated, use /cert:name instead");
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_CertificateName, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "cert-ignore")
|
|
|
|
{
|
2022-10-19 14:56:01 +03:00
|
|
|
WLog_WARN(TAG, "/cert-ignore is deprecated, use /cert:ignore instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_IgnoreCertificate, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
2016-03-31 13:16:55 +03:00
|
|
|
CommandLineSwitchCase(arg, "cert-tofu")
|
|
|
|
{
|
2022-10-19 14:56:01 +03:00
|
|
|
WLog_WARN(TAG, "/cert-tofu is deprecated, use /cert:tofu instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoAcceptCertificate, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-12-14 12:17:52 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "cert-deny")
|
|
|
|
{
|
2022-10-19 14:56:01 +03:00
|
|
|
WLog_WARN(TAG, "/cert-deny is deprecated, use /cert:deny instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoDenyCertificate, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2016-03-31 13:16:55 +03:00
|
|
|
}
|
2022-10-19 15:00:48 +03:00
|
|
|
#endif
|
2012-11-15 08:06:56 +04:00
|
|
|
CommandLineSwitchCase(arg, "authentication")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_Authentication, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-15 08:06:56 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "encryption")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_UseRdpSecurityLayer, !enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-15 08:06:56 +04:00
|
|
|
}
|
2012-11-15 19:00:07 +04:00
|
|
|
CommandLineSwitchCase(arg, "grab-keyboard")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GrabKeyboard, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-15 19:00:07 +04:00
|
|
|
}
|
2020-06-29 22:05:12 +03:00
|
|
|
CommandLineSwitchCase(arg, "grab-mouse")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_GrabMouse, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2020-06-29 22:05:12 +03:00
|
|
|
}
|
2022-01-18 18:06:25 +03:00
|
|
|
CommandLineSwitchCase(arg, "mouse-relative")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_MouseUseRelativeMove, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2022-01-18 18:06:25 +03:00
|
|
|
}
|
2023-06-26 16:39:27 +03:00
|
|
|
CommandLineSwitchCase(arg, "mouse")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_mouse_options(settings, arg);
|
2023-06-26 16:39:27 +03:00
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
|
|
|
}
|
2015-07-14 02:03:33 +03:00
|
|
|
CommandLineSwitchCase(arg, "unmap-buttons")
|
|
|
|
{
|
2023-07-19 09:41:19 +03:00
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_UnmapButtons, enable);
|
2015-07-14 02:03:33 +03:00
|
|
|
}
|
2013-02-28 20:32:46 +04:00
|
|
|
CommandLineSwitchCase(arg, "toggle-fullscreen")
|
|
|
|
{
|
2023-07-19 09:41:19 +03:00
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_ToggleFullscreen, enable);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "force-console-callbacks")
|
|
|
|
{
|
|
|
|
freerdp_settings_set_bool(settings, FreeRDP_UseCommonStdioCallbacks, enable);
|
2013-02-28 20:32:46 +04:00
|
|
|
}
|
2018-09-18 22:25:51 +03:00
|
|
|
CommandLineSwitchCase(arg, "floatbar")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_floatbar_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2018-09-18 22:25:51 +03:00
|
|
|
}
|
2012-11-27 01:49:12 +04:00
|
|
|
CommandLineSwitchCase(arg, "mouse-motion")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_MouseMotion, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "parent-window")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
ULONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_uint(arg->Value, &val, 0, UINT64_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint64(settings, FreeRDP_ParentWindowId, (UINT64)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
2020-01-13 12:50:14 +03:00
|
|
|
CommandLineSwitchCase(arg, "client-build-number")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
ULONGLONG val = 0;
|
2020-01-13 12:50:14 +03:00
|
|
|
|
|
|
|
if (!value_to_uint(arg->Value, &val, 0, UINT32_MAX))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ClientBuild, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
}
|
2022-10-20 10:59:16 +03:00
|
|
|
CommandLineSwitchCase(arg, "cache")
|
|
|
|
{
|
|
|
|
int rc = parse_cache_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
|
|
|
}
|
2022-10-20 13:57:02 +03:00
|
|
|
#if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
2012-11-26 23:31:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "bitmap-cache")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCacheEnabled, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
2022-05-30 23:32:23 +03:00
|
|
|
CommandLineSwitchCase(arg, "persist-cache")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/persist-cache is deprecated, use /cache:persist[:on|off] instead");
|
2023-01-09 17:56:20 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, enable))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-05-30 23:32:23 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "persist-cache-file")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/persist-cache-file:<filename> is deprecated, use "
|
|
|
|
"/cache:persist-file:<filename> instead");
|
2022-05-30 23:32:23 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_BitmapCachePersistFile, arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
|
2023-01-09 17:56:20 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_BitmapCachePersistEnabled, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
2022-05-30 23:32:23 +03:00
|
|
|
}
|
2012-11-26 23:31:31 +04:00
|
|
|
CommandLineSwitchCase(arg, "offscreen-cache")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_OffscreenSupportLevel,
|
|
|
|
(UINT32)enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "glyph-cache")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG, "/glyph-cache is deprecated, use /cache:glyph[:on|off] instead");
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_GlyphSupportLevel,
|
|
|
|
arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2012-11-27 01:49:12 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "codec-cache")
|
|
|
|
{
|
2022-10-20 11:11:26 +03:00
|
|
|
WLog_WARN(TAG,
|
|
|
|
"/codec-cache:<option> is deprecated, use /cache:codec:<option> instead");
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_codec_cache_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2012-11-26 23:31:31 +04:00
|
|
|
}
|
2022-10-20 10:59:16 +03:00
|
|
|
#endif
|
2013-05-14 12:24:05 +04:00
|
|
|
CommandLineSwitchCase(arg, "max-fast-path-size")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_MultifragMaxRequestSize,
|
|
|
|
(UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-05-14 12:24:05 +04:00
|
|
|
}
|
2019-11-25 11:54:56 +03:00
|
|
|
CommandLineSwitchCase(arg, "auto-request-control")
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl,
|
|
|
|
enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2013-01-28 03:22:46 +04:00
|
|
|
CommandLineSwitchCase(arg, "async-update")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AsyncUpdate, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-01-28 03:22:46 +04:00
|
|
|
}
|
2013-02-19 21:29:15 +04:00
|
|
|
CommandLineSwitchCase(arg, "async-channels")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AsyncChannels, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-02-19 21:29:15 +04:00
|
|
|
}
|
2013-03-26 18:47:39 +04:00
|
|
|
CommandLineSwitchCase(arg, "wm-class")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_WmClass, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
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")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_PlayRemoteFxFile, arg->Value))
|
2015-06-18 14:00:10 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PlayRemoteFx, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-05-27 17:28:08 +04:00
|
|
|
}
|
2013-05-27 17:35:25 +04:00
|
|
|
CommandLineSwitchCase(arg, "auth-only")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AuthenticationOnly, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-05-27 17:35:25 +04:00
|
|
|
}
|
2022-10-06 23:47:32 +03:00
|
|
|
CommandLineSwitchCase(arg, "auth-pkg-list")
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_AuthenticationPackageList,
|
|
|
|
arg->Value))
|
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2014-02-28 01:55:07 +04:00
|
|
|
CommandLineSwitchCase(arg, "auto-reconnect")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AutoReconnectionEnabled, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-02-28 01:55:07 +04:00
|
|
|
}
|
2016-12-16 14:56:17 +03:00
|
|
|
CommandLineSwitchCase(arg, "auto-reconnect-max-retries")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, 1000))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_AutoReconnectMaxRetries,
|
|
|
|
(UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2016-12-16 14:56:17 +03:00
|
|
|
}
|
2013-10-22 19:14:29 +04:00
|
|
|
CommandLineSwitchCase(arg, "reconnect-cookie")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_reconnect_cookie_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2013-10-22 19:14:29 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "print-reconnect-cookie")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_PrintReconnectCookie, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-10-22 19:14:29 +04:00
|
|
|
}
|
2015-03-04 17:37:25 +03:00
|
|
|
CommandLineSwitchCase(arg, "pwidth")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPhysicalWidth, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "pheight")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopPhysicalHeight, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "orientation")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 0, UINT16_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint16(settings, FreeRDP_DesktopOrientation, (UINT16)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
2018-10-31 12:27:31 +03:00
|
|
|
CommandLineSwitchCase(arg, "old-license")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_OldLicenseBehaviour, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2018-10-31 12:27:31 +03:00
|
|
|
}
|
2015-03-04 17:37:25 +03:00
|
|
|
CommandLineSwitchCase(arg, "scale")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_scale_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "scale-desktop")
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 100, 500))
|
|
|
|
return FALSE;
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_DesktopScaleFactor, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "scale-device")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_scale_device_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2015-03-04 17:37:25 +03:00
|
|
|
}
|
2017-02-06 07:54:54 +03:00
|
|
|
CommandLineSwitchCase(arg, "action-script")
|
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_ActionScript, arg->Value))
|
2017-02-06 07:54:54 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2021-08-25 11:02:46 +03:00
|
|
|
CommandLineSwitchCase(arg, RDP2TCP_DVC_CHANNEL_NAME)
|
2019-05-14 21:02:31 +03:00
|
|
|
{
|
2022-02-02 11:41:25 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_RDP2TCPArgs, arg->Value))
|
2019-05-14 21:02:31 +03:00
|
|
|
return COMMAND_LINE_ERROR_MEMORY;
|
|
|
|
}
|
2017-04-08 00:54:08 +03:00
|
|
|
CommandLineSwitchCase(arg, "fipsmode")
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_FIPSMode, enable))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2017-04-08 00:54:08 +03:00
|
|
|
}
|
2018-09-04 16:49:21 +03:00
|
|
|
CommandLineSwitchCase(arg, "smartcard-logon")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_smartcard_logon_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2018-09-04 16:49:21 +03:00
|
|
|
}
|
2020-04-11 12:55:11 +03:00
|
|
|
CommandLineSwitchCase(arg, "tune")
|
|
|
|
{
|
2023-11-17 11:49:22 +03:00
|
|
|
const int rc = parse_tune_options(settings, arg);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
2020-04-11 12:55:11 +03:00
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
2023-10-21 15:39:43 +03:00
|
|
|
if (handle_option)
|
|
|
|
{
|
|
|
|
const int rc = handle_option(arg, handle_userdata);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
|
|
|
}
|
2012-11-06 07:11:13 +04:00
|
|
|
}
|
|
|
|
CommandLineSwitchEnd(arg)
|
2019-11-06 17:24:51 +03:00
|
|
|
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2012-11-06 07:11:13 +04:00
|
|
|
|
2017-02-16 22:16:56 +03:00
|
|
|
if (user)
|
2015-06-18 12:35:22 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_get_string(settings, FreeRDP_Domain) && user)
|
2017-02-10 23:38:52 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Username, NULL))
|
2023-12-13 15:40:25 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
2023-10-13 10:48:44 +03:00
|
|
|
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, NULL))
|
2023-12-13 15:40:25 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
2017-05-15 14:43:51 +03:00
|
|
|
|
2023-12-13 15:40:25 +03:00
|
|
|
if (!freerdp_parse_username_settings(user, settings, FreeRDP_Username, FreeRDP_Domain))
|
2017-02-10 23:38:52 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
2023-10-13 10:48:44 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Username, user))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
2015-06-18 12:35:22 +03:00
|
|
|
}
|
|
|
|
|
2017-11-10 13:52:23 +03:00
|
|
|
if (promptForPassword)
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
freerdp* instance = freerdp_settings_get_pointer_writable(settings, FreeRDP_instance);
|
|
|
|
if (!freerdp_settings_get_string(settings, FreeRDP_Password))
|
2017-11-10 13:52:23 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
char buffer[512 + 1] = { 0 };
|
2017-11-10 13:52:23 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_passphrase_read(instance->context, "Password: ", buffer,
|
|
|
|
ARRAYSIZE(buffer) - 1, 1))
|
2017-11-10 13:52:23 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_Password, buffer))
|
2017-11-10 13:52:23 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_GatewayEnabled) &&
|
|
|
|
!freerdp_settings_get_bool(settings, FreeRDP_GatewayUseSameCredentials))
|
2017-11-10 13:52:23 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_get_string(settings, FreeRDP_GatewayPassword))
|
2017-11-10 13:52:23 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
char buffer[512 + 1] = { 0 };
|
2017-11-10 13:52:23 +03:00
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_passphrase_read(instance->context, "Gateway Password: ", buffer,
|
|
|
|
ARRAYSIZE(buffer) - 1, 1))
|
2017-11-10 13:52:23 +03:00
|
|
|
return COMMAND_LINE_ERROR;
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayPassword, buffer))
|
2017-11-10 13:52:23 +03:00
|
|
|
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
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteFxCodec) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_NSCodec) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_SupportGraphicsPipeline))
|
2014-07-03 22:35:03 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_FastPathOutput, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_FrameMarkerCommandEnabled, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-07-03 22:35:03 +04:00
|
|
|
}
|
|
|
|
|
2019-10-28 12:10:14 +03:00
|
|
|
arg = CommandLineFindArgumentA(largs, "port");
|
2014-02-05 20:54:42 +04:00
|
|
|
if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
LONGLONG val = 0;
|
2017-11-14 18:10:52 +03:00
|
|
|
|
2018-11-22 18:28:30 +03:00
|
|
|
if (!value_to_int(arg->Value, &val, 1, UINT16_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, (UINT32)val))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2014-02-05 20:54:42 +04:00
|
|
|
}
|
|
|
|
|
2023-02-01 13:20:21 +03:00
|
|
|
fill_credential_strings(largs);
|
2012-12-06 01:04:01 +04:00
|
|
|
|
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
|
|
|
|
2024-01-19 11:22:09 +03:00
|
|
|
static void argv_free(int* pargc, char** pargv[])
|
2023-05-16 10:39:31 +03:00
|
|
|
{
|
2024-01-19 11:22:09 +03:00
|
|
|
WINPR_ASSERT(pargc);
|
|
|
|
WINPR_ASSERT(pargv);
|
|
|
|
const int argc = *pargc;
|
|
|
|
char** argv = *pargv;
|
|
|
|
*pargc = 0;
|
|
|
|
*pargv = NULL;
|
|
|
|
|
2023-05-16 10:39:31 +03:00
|
|
|
if (!argv)
|
|
|
|
return;
|
|
|
|
for (int x = 0; x < argc; x++)
|
|
|
|
free(argv[x]);
|
|
|
|
free(argv);
|
|
|
|
}
|
|
|
|
|
2024-04-17 22:56:37 +03:00
|
|
|
static BOOL argv_append(int* pargc, char** pargv[], char* what)
|
2023-05-16 10:39:31 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(pargc);
|
|
|
|
WINPR_ASSERT(pargv);
|
|
|
|
|
|
|
|
if (*pargc < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!what)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
int nargc = *pargc + 1;
|
|
|
|
char** tmp = realloc(*pargv, nargc * sizeof(char*));
|
|
|
|
if (!tmp)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tmp[*pargc] = what;
|
|
|
|
*pargv = tmp;
|
|
|
|
*pargc = nargc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-01-24 10:21:47 +03:00
|
|
|
static BOOL argv_append_dup(int* pargc, char** pargv[], const char* what)
|
|
|
|
{
|
|
|
|
char* copy = NULL;
|
|
|
|
if (what)
|
|
|
|
copy = _strdup(what);
|
|
|
|
|
|
|
|
const BOOL rc = argv_append(pargc, pargv, copy);
|
|
|
|
if (!rc)
|
|
|
|
free(copy);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2023-06-05 11:53:30 +03:00
|
|
|
static BOOL args_from_fp(FILE* fp, int* aargc, char** aargv[], const char* file, const char* cmd)
|
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
|
|
|
|
WINPR_ASSERT(aargc);
|
|
|
|
WINPR_ASSERT(aargv);
|
|
|
|
WINPR_ASSERT(cmd);
|
|
|
|
|
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Failed to read command line options from file '%s'", file);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2024-01-24 10:21:47 +03:00
|
|
|
if (!argv_append_dup(aargc, aargv, cmd))
|
2023-06-05 11:53:30 +03:00
|
|
|
goto fail;
|
|
|
|
while (!feof(fp))
|
|
|
|
{
|
|
|
|
char* line = NULL;
|
|
|
|
size_t size = 0;
|
|
|
|
INT64 rc = GetLine(&line, &size, fp);
|
|
|
|
if ((rc < 0) || !line)
|
|
|
|
{
|
|
|
|
/* abort if GetLine failed due to reaching EOF */
|
|
|
|
if (feof(fp))
|
|
|
|
break;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (rc > 0)
|
|
|
|
{
|
|
|
|
const char cur = (line[rc - 1]);
|
|
|
|
if ((cur == '\n') || (cur == '\r'))
|
|
|
|
{
|
|
|
|
line[rc - 1] = '\0';
|
|
|
|
rc--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* abort on empty lines */
|
|
|
|
if (rc == 0)
|
|
|
|
{
|
|
|
|
free(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!argv_append(aargc, aargv, line))
|
2024-01-24 10:21:47 +03:00
|
|
|
{
|
|
|
|
free(line);
|
2023-06-05 11:53:30 +03:00
|
|
|
goto fail;
|
2024-01-24 10:21:47 +03:00
|
|
|
}
|
2023-06-05 11:53:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
success = TRUE;
|
|
|
|
fail:
|
|
|
|
fclose(fp);
|
|
|
|
if (!success)
|
2024-01-19 11:22:09 +03:00
|
|
|
argv_free(aargc, aargv);
|
2023-06-05 11:53:30 +03:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL args_from_env(const char* name, int* aargc, char** aargv[], const char* arg,
|
|
|
|
const char* cmd)
|
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
char* env = NULL;
|
|
|
|
|
|
|
|
WINPR_ASSERT(aargc);
|
|
|
|
WINPR_ASSERT(aargv);
|
|
|
|
WINPR_ASSERT(cmd);
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s - environment variable name empty", arg);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DWORD size = GetEnvironmentVariableX(name, env, 0);
|
|
|
|
if (size == 0)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s - no environment variable '%s'", arg, name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
env = calloc(size + 1, sizeof(char));
|
|
|
|
if (!env)
|
|
|
|
goto cleanup;
|
|
|
|
const DWORD rc = GetEnvironmentVariableX(name, env, size);
|
|
|
|
if (rc != size - 1)
|
|
|
|
goto cleanup;
|
|
|
|
if (rc == 0)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "%s - environment variable '%s' is empty", arg);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2024-01-24 10:21:47 +03:00
|
|
|
if (!argv_append_dup(aargc, aargv, cmd))
|
2023-06-05 11:53:30 +03:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
char* context = NULL;
|
|
|
|
char* tok = strtok_s(env, "\n", &context);
|
|
|
|
while (tok)
|
|
|
|
{
|
2024-01-24 10:21:47 +03:00
|
|
|
if (!argv_append_dup(aargc, aargv, tok))
|
2023-06-05 11:53:30 +03:00
|
|
|
goto cleanup;
|
|
|
|
tok = strtok_s(NULL, "\n", &context);
|
|
|
|
}
|
|
|
|
|
|
|
|
success = TRUE;
|
|
|
|
cleanup:
|
|
|
|
free(env);
|
|
|
|
if (!success)
|
2024-01-19 11:22:09 +03:00
|
|
|
argv_free(aargc, aargv);
|
2023-06-05 11:53:30 +03:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2023-05-16 10:39:31 +03:00
|
|
|
int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, int oargc,
|
|
|
|
char* oargv[], BOOL allowUnknown)
|
2023-10-21 15:39:43 +03:00
|
|
|
{
|
|
|
|
return freerdp_client_settings_parse_command_line_arguments_ex(
|
|
|
|
settings, oargc, oargv, allowUnknown, NULL, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_client_settings_parse_command_line_arguments_ex(
|
|
|
|
rdpSettings* settings, int oargc, char** oargv, BOOL allowUnknown,
|
|
|
|
COMMAND_LINE_ARGUMENT_A* args, size_t count,
|
|
|
|
int (*handle_option)(const COMMAND_LINE_ARGUMENT* arg, void* custom), void* handle_userdata)
|
2023-05-16 10:39:31 +03:00
|
|
|
{
|
|
|
|
int argc = oargc;
|
|
|
|
char** argv = oargv;
|
2023-10-21 15:39:43 +03:00
|
|
|
int res = -1;
|
2023-05-16 10:39:31 +03:00
|
|
|
int aargc = 0;
|
|
|
|
char** aargv = NULL;
|
|
|
|
if ((argc == 2) && option_starts_with("/args-from:", argv[1]))
|
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
const char* file = strchr(argv[1], ':') + 1;
|
|
|
|
FILE* fp = stdin;
|
|
|
|
|
|
|
|
if (option_starts_with("fd:", file))
|
|
|
|
{
|
|
|
|
ULONGLONG result = 0;
|
|
|
|
const char* val = strchr(file, ':') + 1;
|
|
|
|
if (!value_to_uint(val, &result, 0, INT_MAX))
|
|
|
|
return -1;
|
|
|
|
fp = fdopen((int)result, "r");
|
2023-06-05 11:53:30 +03:00
|
|
|
success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
|
2023-05-16 10:39:31 +03:00
|
|
|
}
|
2023-06-05 11:53:30 +03:00
|
|
|
else if (strncmp(file, "env:", 4) == 0)
|
2023-05-16 10:39:31 +03:00
|
|
|
{
|
2023-06-05 11:53:30 +03:00
|
|
|
const char* name = strchr(file, ':') + 1;
|
|
|
|
success = args_from_env(name, &aargc, &aargv, oargv[1], oargv[0]);
|
2023-05-16 10:39:31 +03:00
|
|
|
}
|
2023-06-05 11:53:30 +03:00
|
|
|
else if (strcmp(file, "stdin") != 0)
|
2023-05-16 10:39:31 +03:00
|
|
|
{
|
2023-06-05 11:53:30 +03:00
|
|
|
fp = winpr_fopen(file, "r");
|
|
|
|
success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
|
2023-05-16 10:39:31 +03:00
|
|
|
}
|
2023-06-05 11:53:30 +03:00
|
|
|
else
|
|
|
|
success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
|
2023-05-16 10:39:31 +03:00
|
|
|
|
|
|
|
if (!success)
|
|
|
|
return -1;
|
|
|
|
argc = aargc;
|
|
|
|
argv = aargv;
|
|
|
|
}
|
|
|
|
|
2023-10-21 15:39:43 +03:00
|
|
|
size_t lcount = 0;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* largs = create_merged_args(args, count, &lcount);
|
|
|
|
if (!largs)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
res = freerdp_client_settings_parse_command_line_arguments_int(
|
|
|
|
settings, argc, argv, allowUnknown, largs, lcount, handle_option, handle_userdata);
|
|
|
|
fail:
|
|
|
|
free(largs);
|
2024-01-19 11:22:09 +03:00
|
|
|
argv_free(&aargc, &aargv);
|
2023-05-16 10:39:31 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
|
2021-04-22 13:55:41 +03:00
|
|
|
const 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;
|
2019-11-06 17:24:51 +03:00
|
|
|
entryEx = (PVIRTUALCHANNELENTRYEX)(void*)freerdp_load_channel_addin_entry(
|
|
|
|
name, NULL, NULL, 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)
|
|
|
|
{
|
2022-03-03 12:48:15 +03:00
|
|
|
WLog_DBG(TAG, "loading channelEx %s", name);
|
2016-11-15 18:58:38 +03:00
|
|
|
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
|
|
|
{
|
2022-03-03 12:48:15 +03:00
|
|
|
WLog_DBG(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
|
|
|
}
|
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
typedef struct
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
2023-10-16 20:37:36 +03:00
|
|
|
FreeRDP_Settings_Keys_Bool settingId;
|
2022-09-14 14:53:27 +03:00
|
|
|
const char* channelName;
|
|
|
|
void* args;
|
|
|
|
} ChannelToLoad;
|
2012-11-21 18:30:06 +04:00
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
ChannelToLoad dynChannels[] = {
|
2022-01-17 16:21:17 +03:00
|
|
|
#if defined(CHANNEL_AINPUT_CLIENT)
|
2023-10-16 21:44:25 +03:00
|
|
|
{ FreeRDP_BOOL_UNUSED, AINPUT_CHANNEL_NAME, NULL }, /* always loaded */
|
2022-01-17 16:21:17 +03:00
|
|
|
#endif
|
2023-11-01 09:07:44 +03:00
|
|
|
{ FreeRDP_AudioCapture, AUDIN_CHANNEL_NAME, NULL },
|
2022-09-14 14:53:27 +03:00
|
|
|
{ FreeRDP_AudioPlayback, RDPSND_CHANNEL_NAME, NULL },
|
|
|
|
#ifdef CHANNEL_RDPEI_CLIENT
|
2023-11-01 09:07:44 +03:00
|
|
|
{ FreeRDP_MultiTouchInput, RDPEI_CHANNEL_NAME, NULL },
|
2022-09-14 14:53:27 +03:00
|
|
|
#endif
|
2023-11-01 09:07:44 +03:00
|
|
|
{ FreeRDP_SupportGraphicsPipeline, RDPGFX_CHANNEL_NAME, NULL },
|
|
|
|
{ FreeRDP_SupportEchoChannel, ECHO_CHANNEL_NAME, NULL },
|
2022-09-14 14:53:27 +03:00
|
|
|
{ FreeRDP_SupportSSHAgentChannel, "sshagent", NULL },
|
|
|
|
{ FreeRDP_SupportDisplayControl, DISP_CHANNEL_NAME, NULL },
|
2023-11-01 09:07:44 +03:00
|
|
|
{ FreeRDP_SupportGeometryTracking, GEOMETRY_CHANNEL_NAME, NULL },
|
|
|
|
{ FreeRDP_SupportVideoOptimized, VIDEO_CHANNEL_NAME, NULL },
|
2022-09-14 14:53:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
ChannelToLoad staticChannels[] = {
|
|
|
|
{ FreeRDP_AudioPlayback, RDPSND_CHANNEL_NAME, NULL },
|
|
|
|
{ FreeRDP_RedirectClipboard, CLIPRDR_SVC_CHANNEL_NAME, NULL },
|
|
|
|
#if defined(CHANNEL_ENCOMSP_CLIENT)
|
|
|
|
{ FreeRDP_EncomspVirtualChannel, ENCOMSP_SVC_CHANNEL_NAME, settings },
|
|
|
|
#endif
|
|
|
|
{ FreeRDP_RemdeskVirtualChannel, REMDESK_SVC_CHANNEL_NAME, settings },
|
|
|
|
{ FreeRDP_RemoteApplicationMode, RAIL_SVC_CHANNEL_NAME, settings }
|
|
|
|
};
|
2022-01-17 16:21:17 +03:00
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
/**
|
|
|
|
* Step 1: first load dynamic channels according to the settings
|
|
|
|
*/
|
2023-10-16 17:32:56 +03:00
|
|
|
for (size_t i = 0; i < ARRAYSIZE(dynChannels); i++)
|
2019-07-30 13:30:15 +03:00
|
|
|
{
|
2023-10-16 21:44:25 +03:00
|
|
|
if ((dynChannels[i].settingId == FreeRDP_BOOL_UNUSED) ||
|
2022-09-14 14:53:27 +03:00
|
|
|
freerdp_settings_get_bool(settings, dynChannels[i].settingId))
|
|
|
|
{
|
|
|
|
const char* p[] = { dynChannels[i].channelName };
|
2019-07-30 13:30:15 +03:00
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(p), p))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-07-30 13:30:15 +03:00
|
|
|
}
|
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
/**
|
|
|
|
* step 2: do various adjustements in the settings, to handle channels and settings dependencies
|
|
|
|
*/
|
2021-08-25 13:10:48 +03:00
|
|
|
if ((freerdp_static_channel_collection_find(settings, RDPSND_CHANNEL_NAME)) ||
|
|
|
|
(freerdp_dynamic_channel_collection_find(settings, RDPSND_CHANNEL_NAME))
|
2020-02-25 17:21:16 +03:00
|
|
|
#if defined(CHANNEL_TSMF_CLIENT)
|
|
|
|
|| (freerdp_dynamic_channel_collection_find(settings, "tsmf"))
|
|
|
|
#endif
|
|
|
|
)
|
2012-11-26 10:34:40 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR; /* rdpsnd requires rdpdr to be registered */
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioPlayback, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR; /* 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
|
|
|
|
2023-11-01 09:07:44 +03:00
|
|
|
if (freerdp_dynamic_channel_collection_find(settings, AUDIN_CHANNEL_NAME))
|
2013-05-17 17:29:53 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_AudioCapture, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2013-05-17 17:29:53 +04:00
|
|
|
}
|
|
|
|
|
2022-10-10 13:02:32 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_NetworkAutoDetect) ||
|
2023-10-13 10:48:44 +03:00
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_SupportHeartbeatPdu) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_SupportMultitransport))
|
2014-01-30 07:53:32 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR; /* these RDP8 features require rdpdr to be registered */
|
2014-01-30 07:53:32 +04:00
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
const char* DrivesToRedirect = freerdp_settings_get_string(settings, FreeRDP_DrivesToRedirect);
|
|
|
|
|
|
|
|
if (DrivesToRedirect && (strlen(DrivesToRedirect) != 0))
|
2019-08-23 12:47:31 +03:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Drives to redirect:
|
|
|
|
*
|
|
|
|
* Very similar to DevicesToRedirect, but can contain a
|
|
|
|
* comma-separated list of drive letters to redirect.
|
|
|
|
*/
|
2024-01-23 18:49:54 +03:00
|
|
|
char* value = NULL;
|
|
|
|
char* tok = NULL;
|
2019-08-23 12:47:31 +03:00
|
|
|
char* context = NULL;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
value = _strdup(DrivesToRedirect);
|
2019-08-23 12:47:31 +03:00
|
|
|
if (!value)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tok = strtok_s(value, ";", &context);
|
|
|
|
if (!tok)
|
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
WLog_ERR(TAG, "DrivesToRedirect contains invalid data: '%s'", DrivesToRedirect);
|
2019-08-23 12:47:31 +03:00
|
|
|
free(value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
while (tok)
|
2019-08-23 12:47:31 +03:00
|
|
|
{
|
|
|
|
/* Syntax: Comma seperated list of the following entries:
|
|
|
|
* '*' ... Redirect all drives, including hotplug
|
|
|
|
* 'DynamicDrives' ... hotplug
|
2021-03-09 14:09:58 +03:00
|
|
|
* '%' ... user home directory
|
2019-08-23 12:47:31 +03:00
|
|
|
* <label>(<path>) ... One or more paths to redirect.
|
|
|
|
* <path>(<label>) ... One or more paths to redirect.
|
|
|
|
* <path> ... One or more paths to redirect.
|
|
|
|
*/
|
|
|
|
/* TODO: Need to properly escape labels and paths */
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL success = 0;
|
2019-08-23 12:47:31 +03:00
|
|
|
const char* name = NULL;
|
|
|
|
const char* drive = tok;
|
2020-05-18 12:18:55 +03:00
|
|
|
char* subcontext = NULL;
|
|
|
|
char* start = strtok_s(tok, "(", &subcontext);
|
|
|
|
char* end = strtok_s(NULL, ")", &subcontext);
|
2019-11-20 11:16:12 +03:00
|
|
|
if (start && end)
|
2019-08-23 12:47:31 +03:00
|
|
|
name = end;
|
|
|
|
|
|
|
|
if (freerdp_path_valid(name, NULL) && freerdp_path_valid(drive, NULL))
|
|
|
|
{
|
|
|
|
success = freerdp_client_add_drive(settings, name, NULL);
|
|
|
|
if (success)
|
|
|
|
success = freerdp_client_add_drive(settings, drive, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
success = freerdp_client_add_drive(settings, drive, name);
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
{
|
|
|
|
free(value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
tok = strtok_s(NULL, ";", &context);
|
|
|
|
}
|
|
|
|
free(value);
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR;
|
2019-08-23 12:47:31 +03:00
|
|
|
}
|
2023-10-13 10:48:44 +03:00
|
|
|
else if (freerdp_settings_get_bool(settings, FreeRDP_RedirectDrives))
|
2014-04-28 05:29:44 +04:00
|
|
|
{
|
2013-02-15 04:38:45 +04:00
|
|
|
if (!freerdp_device_collection_find(settings, "drive"))
|
|
|
|
{
|
2021-10-06 10:44:26 +03:00
|
|
|
const char* params[] = { "drive", "media", "*" };
|
2013-02-15 04:38:45 +04:00
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
if (!freerdp_client_add_device_channel(settings, ARRAYSIZE(params), params))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2013-02-15 04:38:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RedirectDrives) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_RedirectHomeDrive) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_RedirectSerialPorts) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_RedirectSmartCards) ||
|
|
|
|
freerdp_settings_get_bool(settings, FreeRDP_RedirectPrinters))
|
2019-10-01 16:38:31 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
|
|
|
|
return COMMAND_LINE_ERROR; /* All of these features require rdpdr */
|
2019-10-01 16:38:31 +03:00
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RedirectHomeDrive))
|
2013-02-15 04:38:45 +04:00
|
|
|
{
|
|
|
|
if (!freerdp_device_collection_find(settings, "drive"))
|
|
|
|
{
|
2021-10-06 10:44:26 +03:00
|
|
|
const char* params[] = { "drive", "home", "%" };
|
2013-02-15 04:38:45 +04:00
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
if (!freerdp_client_add_device_channel(settings, ARRAYSIZE(params), params))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2013-02-15 04:38:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_DeviceRedirection))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2021-09-22 15:27:21 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, RDPDR_SVC_CHANNEL_NAME,
|
|
|
|
settings))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
|
2021-08-25 13:10:48 +03:00
|
|
|
if (!freerdp_static_channel_collection_find(settings, RDPSND_CHANNEL_NAME) &&
|
|
|
|
!freerdp_dynamic_channel_collection_find(settings, RDPSND_CHANNEL_NAME))
|
2012-11-09 04:01:52 +04:00
|
|
|
{
|
2021-10-06 10:44:26 +03:00
|
|
|
const char* params[] = { RDPSND_CHANNEL_NAME, "sys:fake" };
|
2012-11-21 18:30:06 +04:00
|
|
|
|
2021-10-06 10:44:26 +03:00
|
|
|
if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(params), params))
|
2016-02-01 17:09:51 +03:00
|
|
|
return FALSE;
|
2022-10-10 13:02:32 +03:00
|
|
|
|
|
|
|
if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(params), params))
|
|
|
|
return FALSE;
|
2012-11-09 04:01:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RedirectSmartCards))
|
2014-04-28 05:29:44 +04:00
|
|
|
{
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_SMARTCARD))
|
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
RDPDR_DEVICE* smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, 0, NULL);
|
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
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, smartcard))
|
|
|
|
{
|
|
|
|
freerdp_device_free(smartcard);
|
2016-02-26 16:50:27 +03:00
|
|
|
return FALSE;
|
2021-10-07 11:43:16 +03:00
|
|
|
}
|
2016-02-26 16:50:27 +03:00
|
|
|
}
|
2014-04-28 05:29:44 +04:00
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RedirectPrinters))
|
2014-04-28 05:29:44 +04:00
|
|
|
{
|
2016-02-26 16:50:27 +03:00
|
|
|
if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_PRINT))
|
|
|
|
{
|
2021-10-07 11:43:16 +03:00
|
|
|
RDPDR_DEVICE* printer = freerdp_device_new(RDPDR_DTYP_PRINT, 0, NULL);
|
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
|
|
|
|
2021-10-07 11:43:16 +03:00
|
|
|
if (!freerdp_device_collection_add(settings, printer))
|
|
|
|
{
|
|
|
|
freerdp_device_free(printer);
|
2016-02-26 16:50:27 +03:00
|
|
|
return FALSE;
|
2021-10-07 11:43:16 +03:00
|
|
|
}
|
2016-02-26 16:50:27 +03:00
|
|
|
}
|
2014-04-28 05:29:44 +04:00
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_LyncRdpMode))
|
2014-11-21 23:10:39 +03:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_EncomspVirtualChannel, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemdeskVirtualChannel, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_CompressionEnabled, FALSE))
|
|
|
|
return FALSE;
|
2014-11-21 23:10:39 +03:00
|
|
|
}
|
|
|
|
|
2023-10-13 10:48:44 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceMode))
|
2014-06-29 02:33:46 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_EncomspVirtualChannel, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemdeskVirtualChannel, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, FALSE))
|
|
|
|
return FALSE;
|
2014-11-21 23:10:39 +03:00
|
|
|
}
|
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
/* step 3: schedule some static channels to load depending on the settings */
|
2023-10-16 17:32:56 +03:00
|
|
|
for (size_t i = 0; i < ARRAYSIZE(staticChannels); i++)
|
2016-02-01 17:09:51 +03:00
|
|
|
{
|
2022-09-14 14:53:27 +03:00
|
|
|
if ((staticChannels[i].settingId == 0) ||
|
|
|
|
freerdp_settings_get_bool(settings, staticChannels[i].settingId))
|
|
|
|
{
|
|
|
|
if (staticChannels[i].args)
|
|
|
|
{
|
|
|
|
if (!freerdp_client_load_static_channel_addin(
|
|
|
|
channels, settings, staticChannels[i].channelName, staticChannels[i].args))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char* p[] = { staticChannels[i].channelName };
|
|
|
|
if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(p), p))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 21:02:31 +03:00
|
|
|
}
|
|
|
|
|
2023-12-13 12:39:15 +03:00
|
|
|
char* RDP2TCPArgs = freerdp_settings_get_string_writable(settings, FreeRDP_RDP2TCPArgs);
|
2023-10-13 10:48:44 +03:00
|
|
|
if (RDP2TCPArgs)
|
2022-09-21 11:55:53 +03:00
|
|
|
{
|
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, RDP2TCP_DVC_CHANNEL_NAME,
|
2023-10-13 10:48:44 +03:00
|
|
|
RDP2TCPArgs))
|
2022-09-21 11:55:53 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-09-14 14:53:27 +03:00
|
|
|
/* step 4: do the static channels loading and init */
|
2023-10-13 10:48:44 +03:00
|
|
|
for (UINT32 i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount); i++)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
2023-10-13 10:48:44 +03:00
|
|
|
ADDIN_ARGV* _args =
|
|
|
|
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_StaticChannelArray, i);
|
2016-08-04 17:13:37 +03:00
|
|
|
|
2021-07-28 17:27:59 +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
|
|
|
}
|
|
|
|
|
2022-03-24 13:07:11 +03:00
|
|
|
if (freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount) > 0)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDynamicChannels, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-08-15 03:23:48 +04:00
|
|
|
|
2022-03-24 13:07:11 +03:00
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_SupportDynamicChannels))
|
2012-11-19 02:32:18 +04:00
|
|
|
{
|
2021-08-25 11:02:46 +03:00
|
|
|
if (!freerdp_client_load_static_channel_addin(channels, settings, DRDYNVC_SVC_CHANNEL_NAME,
|
|
|
|
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
|
|
|
}
|
2023-03-01 10:33:05 +03:00
|
|
|
|
2023-08-21 14:33:26 +03:00
|
|
|
void freerdp_client_warn_unmaintained(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
const char* app = (argc > 0) ? argv[0] : "INVALID_ARGV";
|
|
|
|
const DWORD log_level = WLOG_WARN;
|
|
|
|
wLog* log = WLog_Get(TAG);
|
|
|
|
WINPR_ASSERT(log);
|
|
|
|
|
|
|
|
if (!WLog_IsLevelActive(log, log_level))
|
|
|
|
return;
|
|
|
|
|
|
|
|
WLog_Print_unchecked(log, log_level, "[unmaintained] %s client is currently unmaintained!",
|
|
|
|
app);
|
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
" If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
|
2023-12-07 20:16:09 +03:00
|
|
|
"known issues!");
|
2023-08-21 14:33:26 +03:00
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
"Be prepared to fix issues yourself though as nobody is actively working on this.");
|
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
" Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
|
|
|
|
"- dont hesitate to ask some questions. (replies might take some time depending "
|
|
|
|
"on your timezone) - if you intend using this component write us a message");
|
|
|
|
}
|
|
|
|
|
2023-03-01 10:33:05 +03:00
|
|
|
void freerdp_client_warn_experimental(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
const char* app = (argc > 0) ? argv[0] : "INVALID_ARGV";
|
2023-08-21 14:33:26 +03:00
|
|
|
const DWORD log_level = WLOG_WARN;
|
|
|
|
wLog* log = WLog_Get(TAG);
|
|
|
|
WINPR_ASSERT(log);
|
|
|
|
|
|
|
|
if (!WLog_IsLevelActive(log, log_level))
|
|
|
|
return;
|
|
|
|
|
|
|
|
WLog_Print_unchecked(log, log_level, "[experimental] %s client is currently experimental!",
|
|
|
|
app);
|
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
" If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
|
2023-12-07 20:16:09 +03:00
|
|
|
"known issues or create a new one!");
|
2023-08-21 14:33:26 +03:00
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
" Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
|
|
|
|
"- dont hesitate to ask some questions. (replies might take some time depending "
|
|
|
|
"on your timezone)");
|
2023-03-01 10:33:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_client_warn_deprecated(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
const char* app = (argc > 0) ? argv[0] : "INVALID_ARGV";
|
2023-08-21 14:33:26 +03:00
|
|
|
const DWORD log_level = WLOG_WARN;
|
|
|
|
wLog* log = WLog_Get(TAG);
|
|
|
|
WINPR_ASSERT(log);
|
|
|
|
|
|
|
|
if (!WLog_IsLevelActive(log, log_level))
|
|
|
|
return;
|
|
|
|
|
|
|
|
WLog_Print_unchecked(log, log_level, "[deprecated] %s client has been deprecated", app);
|
|
|
|
WLog_Print_unchecked(log, log_level, "As replacement there is a SDL based client available.");
|
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
"If you are interested in keeping %s alive get in touch with the developers", app);
|
|
|
|
WLog_Print_unchecked(
|
|
|
|
log, log_level,
|
|
|
|
"The project is hosted at https://github.com/freerdp/freerdp and "
|
|
|
|
" developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
|
|
|
|
"- dont hesitate to ask some questions. (replies might take some time depending "
|
|
|
|
"on your timezone)");
|
2023-03-01 10:33:05 +03:00
|
|
|
}
|