xfreerdp: add --authonly switch to xfreerdp client
Signed-off-by: Rex Tsai <chihchun@kalug.linux.org.tw>
This commit is contained in:
parent
cc9e584301
commit
28075f5ebb
@ -288,6 +288,14 @@
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>--authonly</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Only authenticates. This is useful to test your credentials (username and password). Returns status code 0 if the client can connect, 1 otherwise. Requires a username, password and connection host at the command line.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>--no-fastpath</term>
|
||||
<listitem>
|
||||
|
@ -479,7 +479,7 @@ boolean xf_pre_connect(freerdp* instance)
|
||||
if (arg_parse_result < 0)
|
||||
{
|
||||
if (arg_parse_result == FREERDP_ARGS_PARSE_FAILURE)
|
||||
printf("failed to parse arguments.\n");
|
||||
fprintf(stderr, "%s:%d: failed to parse arguments.\n", __FILE__, __LINE__);
|
||||
|
||||
exit(XF_EXIT_PARSE_ARGUMENTS);
|
||||
}
|
||||
@ -521,6 +521,22 @@ boolean xf_pre_connect(freerdp* instance)
|
||||
|
||||
freerdp_channels_pre_connect(xfi->_context->channels, instance);
|
||||
|
||||
|
||||
if (settings->authentication_only) {
|
||||
/* Check --authonly has a username and password. */
|
||||
if (settings->username == NULL ) {
|
||||
fprintf(stderr, "--authonly, but no -u username. Please provide one.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (settings->password == NULL ) {
|
||||
fprintf(stderr, "--authonly, but no -p password. Please provide one.\n");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "%s:%d: Authenication only. Don't connect to X.\n", __FILE__, __LINE__);
|
||||
// Avoid XWindows initialization and configuration below.
|
||||
return true;
|
||||
}
|
||||
|
||||
xfi->display = XOpenDisplay(NULL);
|
||||
|
||||
if (xfi->display == NULL)
|
||||
@ -1072,6 +1088,11 @@ int xfreerdp_run(freerdp* instance)
|
||||
xf_free(((xfContext*) instance->context)->xfi);
|
||||
return XF_EXIT_CONN_FAILED;
|
||||
}
|
||||
/* Connection succeeded. --authonly ? */
|
||||
if (instance->settings->authentication_only) {
|
||||
freerdp_disconnect(instance);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
xfi = ((xfContext*) instance->context)->xfi;
|
||||
channels = instance->context->channels;
|
||||
|
@ -293,7 +293,8 @@ struct rdp_settings
|
||||
ALIGN64 char* tsg_username; /* 66 */
|
||||
ALIGN64 char* tsg_password; /* 67 */
|
||||
ALIGN64 boolean local; /* 68 */
|
||||
ALIGN64 uint64 paddingC[80 - 69]; /* 69 */
|
||||
ALIGN64 boolean authentication_only; /* 69 */
|
||||
ALIGN64 uint64 paddingC[80 - 70]; /* 70 */
|
||||
|
||||
/* User Interface Parameters */
|
||||
ALIGN64 boolean sw_gdi; /* 80 */
|
||||
|
@ -61,11 +61,16 @@ boolean freerdp_connect(freerdp* instance)
|
||||
if(!connectErrorCode){
|
||||
connectErrorCode = PREECONNECTERROR;
|
||||
}
|
||||
printf("freerdp_pre_connect failed\n");
|
||||
fprintf(stderr, "%s:%d: freerdp_pre_connect failed\n", __FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
status = rdp_client_connect(rdp);
|
||||
// --authonly tests the connection without a UI
|
||||
if (instance->settings->authentication_only) {
|
||||
fprintf(stderr, "%s:%d: Authentication only, exit status %d\n", __FILE__, __LINE__, !status);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (status)
|
||||
{
|
||||
|
@ -73,6 +73,7 @@ rdpSettings* settings_new(void* instance)
|
||||
settings->encryption_level = ENCRYPTION_LEVEL_NONE;
|
||||
|
||||
settings->authentication = true;
|
||||
settings->authentication_only = false;
|
||||
|
||||
settings->received_caps = xzalloc(32);
|
||||
settings->order_support = xzalloc(32);
|
||||
|
@ -81,6 +81,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
|
||||
" --app: RemoteApp connection. This implies -g workarea\n"
|
||||
" --ext: load an extension\n"
|
||||
" --no-auth: disable authentication\n"
|
||||
" --authonly: authentication only, no UI\n"
|
||||
" --no-fastpath: disable fast-path\n"
|
||||
" --no-motion: don't send mouse motion events\n"
|
||||
" --gdi: graphics rendering (hw, sw)\n"
|
||||
@ -306,6 +307,10 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
|
||||
{
|
||||
settings->authentication = false;
|
||||
}
|
||||
else if (strcmp("--authonly", argv[index]) == 0)
|
||||
{
|
||||
settings->authentication_only = true;
|
||||
}
|
||||
else if (strcmp("--ignore-certificate", argv[index]) == 0)
|
||||
{
|
||||
settings->ignore_certificate = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user