fb4fde3f22f83188d00fe150685eb0491af0cdab
[freerdp-ubuntu-pcb-backport.git] / libfreerdp-core / connection.c
1 /**
2  * FreeRDP: A Remote Desktop Protocol Client
3  * Connection Sequence
4  *
5  * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include "per.h"
21 #include "info.h"
22 #include "input.h"
23
24 #include "connection.h"
25
26 /**
27  *                                      Connection Sequence
28  *     client                                                                    server
29  *        |                                                                         |
30  *        |-----------------------X.224 Connection Request PDU--------------------->|
31  *        |<----------------------X.224 Connection Confirm PDU----------------------|
32  *        |-------MCS Connect-Initial PDU with GCC Conference Create Request------->|
33  *        |<-----MCS Connect-Response PDU with GCC Conference Create Response-------|
34  *        |------------------------MCS Erect Domain Request PDU-------------------->|
35  *        |------------------------MCS Attach User Request PDU--------------------->|
36  *        |<-----------------------MCS Attach User Confirm PDU----------------------|
37  *        |------------------------MCS Channel Join Request PDU-------------------->|
38  *        |<-----------------------MCS Channel Join Confirm PDU---------------------|
39  *        |----------------------------Security Exchange PDU----------------------->|
40  *        |-------------------------------Client Info PDU-------------------------->|
41  *        |<---------------------License Error PDU - Valid Client-------------------|
42  *        |<-----------------------------Demand Active PDU--------------------------|
43  *        |------------------------------Confirm Active PDU------------------------>|
44  *        |-------------------------------Synchronize PDU-------------------------->|
45  *        |---------------------------Control PDU - Cooperate---------------------->|
46  *        |------------------------Control PDU - Request Control------------------->|
47  *        |--------------------------Persistent Key List PDU(s)-------------------->|
48  *        |--------------------------------Font List PDU--------------------------->|
49  *        |<------------------------------Synchronize PDU---------------------------|
50  *        |<--------------------------Control PDU - Cooperate-----------------------|
51  *        |<-----------------------Control PDU - Granted Control--------------------|
52  *        |<-------------------------------Font Map PDU-----------------------------|
53  *
54  */
55
56 /**
57  * Establish RDP Connection.\n
58  * @msdn{cc240452}
59  * @param rdp RDP module
60  */
61
62 boolean rdp_client_connect(rdpRdp* rdp)
63 {
64         boolean status;
65         uint32 selectedProtocol;
66         rdpSettings* settings = rdp->settings;
67
68         nego_init(rdp->nego);
69         nego_set_target(rdp->nego, settings->hostname, settings->port);
70         nego_set_cookie(rdp->nego, settings->username);
71         nego_enable_rdp(rdp->nego, settings->rdp_security);
72         nego_enable_nla(rdp->nego, settings->nla_security);
73         nego_enable_tls(rdp->nego, settings->tls_security);
74
75         if (nego_connect(rdp->nego) != true)
76         {
77                 printf("Error: protocol security negotiation failure\n");
78                 return false;
79         }
80
81         selectedProtocol = rdp->nego->selected_protocol;
82
83         if ((selectedProtocol & PROTOCOL_TLS) || (selectedProtocol == PROTOCOL_RDP))
84         {
85                 if ((settings->username != NULL) && ((settings->password != NULL) || (settings->password_cookie != NULL && settings->password_cookie->length > 0)))
86                         settings->autologon = true;
87         }
88
89         status = false;
90         if (selectedProtocol & PROTOCOL_NLA)
91                 status = transport_connect_nla(rdp->transport);
92         else if (selectedProtocol & PROTOCOL_TLS)
93                 status = transport_connect_tls(rdp->transport);
94         else if (selectedProtocol == PROTOCOL_RDP) /* 0 */
95                 status = transport_connect_rdp(rdp->transport);
96
97         if (status != true)
98                 return false;
99
100         rdp_set_blocking_mode(rdp, false);
101         rdp->state = CONNECTION_STATE_NEGO;
102         rdp->finalize_sc_pdus = 0;
103
104         if (mcs_send_connect_initial(rdp->mcs) != true)
105         {
106                 printf("Error: unable to send MCS Connect Initial\n");
107                 return false;
108         }
109
110         while (rdp->state != CONNECTION_STATE_ACTIVE)
111         {
112                 if (rdp_check_fds(rdp) < 0)
113                         return false;
114         }
115
116         return true;
117 }
118
119 boolean rdp_client_disconnect(rdpRdp* rdp)
120 {
121         return transport_disconnect(rdp->transport);
122 }
123
124 boolean rdp_client_redirect(rdpRdp* rdp)
125 {
126         rdpSettings* settings = rdp->settings;
127         rdpRedirection* redirection = rdp->redirection;
128
129         rdp_client_disconnect(rdp);
130
131         mcs_free(rdp->mcs);
132         nego_free(rdp->nego);
133         license_free(rdp->license);
134         transport_free(rdp->transport);
135         rdp->transport = transport_new(settings);
136         rdp->license = license_new(rdp);
137         rdp->nego = nego_new(rdp->transport);
138         rdp->mcs = mcs_new(rdp->transport);
139
140         rdp->transport->layer = TRANSPORT_LAYER_TCP;
141         settings->redirected_session_id = redirection->sessionID;
142
143         if (redirection->flags & LB_LOAD_BALANCE_INFO)
144         {
145                 nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);
146         }
147         else
148         {
149                 if (redirection->flags & LB_TARGET_NET_ADDRESS)
150                 {
151                         xfree(settings->hostname);
152                         settings->hostname = xstrdup(redirection->targetNetAddress.ascii);
153                 }
154                 else if (redirection->flags & LB_TARGET_FQDN)
155                 {
156                         xfree(settings->hostname);
157                         settings->hostname = xstrdup(redirection->targetFQDN.ascii);
158                 }
159                 else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
160                 {
161                         xfree(settings->hostname);
162                         settings->hostname = xstrdup(redirection->targetNetBiosName.ascii);
163                 }
164         }
165
166         if (redirection->flags & LB_USERNAME)
167         {
168                 xfree(settings->username);
169                 settings->username = xstrdup(redirection->username.ascii);
170         }
171
172         if (redirection->flags & LB_DOMAIN)
173         {
174                 xfree(settings->domain);
175                 settings->domain = xstrdup(redirection->domain.ascii);
176         }
177
178         if (redirection->flags & LB_PASSWORD)
179         {
180                 settings->password_cookie = &redirection->password_cookie;
181         }
182
183         return rdp_client_connect(rdp);
184 }
185
186 static boolean rdp_client_establish_keys(rdpRdp* rdp)
187 {
188         uint8 client_random[CLIENT_RANDOM_LENGTH];
189         uint8 crypt_client_random[256 + 8];
190         uint32 key_len;
191         uint8* mod;
192         uint8* exp;
193         uint32 length;
194         STREAM* s;
195
196         if (rdp->settings->encryption == false)
197         {
198                 /* no RDP encryption */
199                 return true;
200         }
201
202         /* encrypt client random */
203         memset(crypt_client_random, 0, sizeof(crypt_client_random));
204         crypto_nonce(client_random, sizeof(client_random));
205         key_len = rdp->settings->server_cert->cert_info.modulus.length;
206         mod = rdp->settings->server_cert->cert_info.modulus.data;
207         exp = rdp->settings->server_cert->cert_info.exponent;
208         crypto_rsa_public_encrypt(client_random, sizeof(client_random), key_len, mod, exp, crypt_client_random);
209
210         /* send crypt client random to server */
211         length = RDP_PACKET_HEADER_MAX_LENGTH + RDP_SECURITY_HEADER_LENGTH + 4 + key_len + 8;
212         s = transport_send_stream_init(rdp->mcs->transport, length);
213         rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID);
214         rdp_write_security_header(s, SEC_EXCHANGE_PKT);
215         length = key_len + 8;
216         stream_write_uint32(s, length);
217         stream_write(s, crypt_client_random, length);
218         if (transport_write(rdp->mcs->transport, s) < 0)
219         {
220                 return false;
221         }
222
223         /* now calculate encrypt / decrypt and update keys */
224         if (!security_establish_keys(client_random, rdp))
225         {
226                 return false;
227         }
228
229         rdp->do_crypt = true;
230         if (rdp->settings->secure_checksum)
231                 rdp->do_secure_checksum = true;
232
233         if (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS)
234         {
235                 uint8 fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
236                 rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec);
237                 rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec);
238
239                 rdp->fips_hmac = crypto_hmac_new();
240                 return true;
241         }
242
243         rdp->rc4_decrypt_key = crypto_rc4_init(rdp->decrypt_key, rdp->rc4_key_len);
244         rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len);
245
246         return true;
247 }
248
249 static boolean rdp_server_establish_keys(rdpRdp* rdp, STREAM* s)
250 {
251         uint8 client_random[64]; /* Should be only 32 after successfull decryption, but on failure might take up to 64 bytes. */
252         uint8 crypt_client_random[256 + 8];
253         uint32 rand_len, key_len;
254         uint16 channel_id, length, sec_flags;
255         uint8* mod;
256         uint8* priv_exp;
257
258         if (rdp->settings->encryption == false)
259         {
260                 /* No RDP Security. */
261                 return true;
262         }
263
264         if (!rdp_read_header(rdp, s, &length, &channel_id))
265         {
266                 printf("rdp_server_establish_keys: invalid RDP header\n");
267                 return false;
268         }
269         rdp_read_security_header(s, &sec_flags);
270         if ((sec_flags & SEC_EXCHANGE_PKT) == 0)
271         {
272                 printf("rdp_server_establish_keys: missing SEC_EXCHANGE_PKT in security header\n");
273                 return false;
274         }
275         stream_read_uint32(s, rand_len);
276         key_len = rdp->settings->server_key->modulus.length;
277         if (rand_len != key_len + 8)
278         {
279                 printf("rdp_server_establish_keys: invalid encrypted client random length\n");
280                 return false;
281         }
282         memset(crypt_client_random, 0, sizeof(crypt_client_random));
283         stream_read(s, crypt_client_random, rand_len);
284         /* 8 zero bytes of padding */
285         stream_seek(s, 8);
286         mod = rdp->settings->server_key->modulus.data;
287         priv_exp = rdp->settings->server_key->private_exponent.data;
288         crypto_rsa_private_decrypt(crypt_client_random, rand_len - 8, key_len, mod, priv_exp, client_random);
289
290         /* now calculate encrypt / decrypt and update keys */
291         if (!security_establish_keys(client_random, rdp))
292         {
293                 return false;
294         }
295
296         rdp->do_crypt = true;
297         if (rdp->settings->secure_checksum)
298                 rdp->do_secure_checksum = true;
299
300         if (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS)
301         {
302                 uint8 fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
303                 rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec);
304                 rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec);
305
306                 rdp->fips_hmac = crypto_hmac_new();
307                 return true;
308         }
309
310         rdp->rc4_decrypt_key = crypto_rc4_init(rdp->decrypt_key, rdp->rc4_key_len);
311         rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len);
312
313         return true;
314 }
315
316 boolean rdp_client_connect_mcs_connect_response(rdpRdp* rdp, STREAM* s)
317 {
318         if (!mcs_recv_connect_response(rdp->mcs, s))
319         {
320                 printf("rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed\n");
321                 return false;
322         }
323         if (!mcs_send_erect_domain_request(rdp->mcs))
324                 return false;
325         if (!mcs_send_attach_user_request(rdp->mcs))
326                 return false;
327
328         rdp->state = CONNECTION_STATE_MCS_ATTACH_USER;
329
330         return true;
331 }
332
333 boolean rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, STREAM* s)
334 {
335         if (!mcs_recv_attach_user_confirm(rdp->mcs, s))
336                 return false;
337
338         if (!mcs_send_channel_join_request(rdp->mcs, rdp->mcs->user_id))
339                 return false;
340
341         rdp->state = CONNECTION_STATE_MCS_CHANNEL_JOIN;
342
343         return true;
344 }
345
346 boolean rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, STREAM* s)
347 {
348         int i;
349         uint16 channel_id;
350         boolean all_joined = true;
351
352         if (!mcs_recv_channel_join_confirm(rdp->mcs, s, &channel_id))
353                 return false;
354
355         if (!rdp->mcs->user_channel_joined)
356         {
357                 if (channel_id != rdp->mcs->user_id)
358                         return false;
359                 rdp->mcs->user_channel_joined = true;
360
361                 if (!mcs_send_channel_join_request(rdp->mcs, MCS_GLOBAL_CHANNEL_ID))
362                         return false;
363         }
364         else if (!rdp->mcs->global_channel_joined)
365         {
366                 if (channel_id != MCS_GLOBAL_CHANNEL_ID)
367                         return false;
368                 rdp->mcs->global_channel_joined = true;
369
370                 if (rdp->settings->num_channels > 0)
371                 {
372                         if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->channels[0].channel_id))
373                                 return false;
374
375                         all_joined = false;
376                 }
377         }
378         else
379         {
380                 for (i = 0; i < rdp->settings->num_channels; i++)
381                 {
382                         if (rdp->settings->channels[i].joined)
383                                 continue;
384
385                         if (rdp->settings->channels[i].channel_id != channel_id)
386                                 return false;
387
388                         rdp->settings->channels[i].joined = true;
389                         break;
390                 }
391                 if (i + 1 < rdp->settings->num_channels)
392                 {
393                         if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->channels[i + 1].channel_id))
394                                 return false;
395
396                         all_joined = false;
397                 }
398         }
399
400         if (rdp->mcs->user_channel_joined && rdp->mcs->global_channel_joined && all_joined)
401         {
402                 if (!rdp_client_establish_keys(rdp))
403                         return false;
404                 if (!rdp_send_client_info(rdp))
405                         return false;
406                 rdp->state = CONNECTION_STATE_LICENSE;
407         }
408
409         return true;
410 }
411
412 boolean rdp_client_connect_license(rdpRdp* rdp, STREAM* s)
413 {
414         if (!license_recv(rdp->license, s))
415                 return false;
416
417         if (rdp->license->state == LICENSE_STATE_ABORTED)
418         {
419                 printf("license connection sequence aborted.\n");
420                 return false;
421         }
422
423         if (rdp->license->state == LICENSE_STATE_COMPLETED)
424         {
425                 rdp->state = CONNECTION_STATE_CAPABILITY;
426         }
427
428         return true;
429 }
430
431 boolean rdp_client_connect_demand_active(rdpRdp* rdp, STREAM* s)
432 {
433         uint8* mark;
434         uint16 width;
435         uint16 height;
436
437         width = rdp->settings->width;
438         height = rdp->settings->height;
439
440         stream_get_mark(s, mark);
441
442         if (!rdp_recv_demand_active(rdp, s))
443         {
444                 stream_set_mark(s, mark);
445                 stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH);
446
447                 if (rdp_recv_out_of_sequence_pdu(rdp, s) != true)
448                         return false;
449
450                 return true;
451         }
452
453         if (rdp->disconnect)
454                 return true;
455
456         if (!rdp_send_confirm_active(rdp))
457                 return false;
458
459         input_register_client_callbacks(rdp->input);
460
461         /**
462          * The server may request a different desktop size during Deactivation-Reactivation sequence.
463          * In this case, the UI should be informed and do actual window resizing at this point.
464          */
465         if (width != rdp->settings->width || height != rdp->settings->height)
466         {
467                 IFCALL(rdp->update->DesktopResize, rdp->update->context);
468         }
469
470         rdp->state = CONNECTION_STATE_FINALIZATION;
471         update_reset_state(rdp->update);
472
473         rdp_client_connect_finalize(rdp);
474
475         return true;
476 }
477
478 boolean rdp_client_connect_finalize(rdpRdp* rdp)
479 {
480         /**
481          * [MS-RDPBCGR] 1.3.1.1 - 8.
482          * The client-to-server PDUs sent during this phase have no dependencies on any of the server-to-
483          * client PDUs; they may be sent as a single batch, provided that sequencing is maintained.
484          */
485
486         if (!rdp_send_client_synchronize_pdu(rdp))
487                 return false;
488         if (!rdp_send_client_control_pdu(rdp, CTRLACTION_COOPERATE))
489                 return false;
490         if (!rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL))
491                 return false;
492
493         rdp->input->SynchronizeEvent(rdp->input, 0);
494
495         if (!rdp_send_client_persistent_key_list_pdu(rdp))
496                 return false;
497         if (!rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST))
498                 return false;
499
500         return true;
501 }
502
503 boolean rdp_server_accept_nego(rdpRdp* rdp, STREAM* s)
504 {
505         boolean ret;
506
507         transport_set_blocking_mode(rdp->transport, true);
508
509         if (!nego_read_request(rdp->nego, s))
510                 return false;
511
512         rdp->nego->selected_protocol = 0;
513
514         printf("Requested protocols:");
515         if ((rdp->nego->requested_protocols & PROTOCOL_TLS))
516         {
517                 printf(" TLS");
518                 if (rdp->settings->tls_security)
519                 {
520                         printf("(Y)");
521                         rdp->nego->selected_protocol |= PROTOCOL_TLS;
522                 }
523                 else
524                         printf("(n)");
525         }
526         if ((rdp->nego->requested_protocols & PROTOCOL_NLA))
527         {
528                 printf(" NLA");
529                 if (rdp->settings->nla_security)
530                 {
531                         printf("(Y)");
532                         rdp->nego->selected_protocol |= PROTOCOL_NLA;
533                 }
534                 else
535                         printf("(n)");
536         }
537         printf(" RDP");
538         if (rdp->settings->rdp_security && rdp->nego->selected_protocol == 0)
539         {
540                 printf("(Y)");
541                 rdp->nego->selected_protocol = PROTOCOL_RDP;
542         }
543         else
544                 printf("(n)");
545         printf("\n");
546
547         if (!nego_send_negotiation_response(rdp->nego))
548                 return false;
549
550         ret = false;
551         if (rdp->nego->selected_protocol & PROTOCOL_NLA)
552                 ret = transport_accept_nla(rdp->transport);
553         else if (rdp->nego->selected_protocol & PROTOCOL_TLS)
554                 ret = transport_accept_tls(rdp->transport);
555         else if (rdp->nego->selected_protocol == PROTOCOL_RDP) /* 0 */
556                 ret = transport_accept_rdp(rdp->transport);
557
558         if (!ret)
559                 return false;
560
561         transport_set_blocking_mode(rdp->transport, false);
562
563         rdp->state = CONNECTION_STATE_NEGO;
564
565         return true;
566 }
567
568 boolean rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, STREAM* s)
569 {
570         int i;
571
572         if (!mcs_recv_connect_initial(rdp->mcs, s))
573                 return false;
574
575         printf("Accepted client: %s\n", rdp->settings->client_hostname);
576         printf("Accepted channels:");
577         for (i = 0; i < rdp->settings->num_channels; i++)
578         {
579                 printf(" %s", rdp->settings->channels[i].name);
580         }
581         printf("\n");
582
583         if (!mcs_send_connect_response(rdp->mcs))
584                 return false;
585
586         rdp->state = CONNECTION_STATE_MCS_CONNECT;
587
588         return true;
589 }
590
591 boolean rdp_server_accept_mcs_erect_domain_request(rdpRdp* rdp, STREAM* s)
592 {
593         if (!mcs_recv_erect_domain_request(rdp->mcs, s))
594                 return false;
595
596         rdp->state = CONNECTION_STATE_MCS_ERECT_DOMAIN;
597
598         return true;
599 }
600
601 boolean rdp_server_accept_mcs_attach_user_request(rdpRdp* rdp, STREAM* s)
602 {
603         if (!mcs_recv_attach_user_request(rdp->mcs, s))
604                 return false;
605
606         if (!mcs_send_attach_user_confirm(rdp->mcs))
607                 return false;
608
609         rdp->state = CONNECTION_STATE_MCS_ATTACH_USER;
610
611         return true;
612 }
613
614 boolean rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, STREAM* s)
615 {
616         int i;
617         uint16 channel_id;
618         boolean all_joined = true;
619
620         if (!mcs_recv_channel_join_request(rdp->mcs, s, &channel_id))
621                 return false;
622
623         if (!mcs_send_channel_join_confirm(rdp->mcs, channel_id))
624                 return false;
625
626         if (channel_id == rdp->mcs->user_id)
627                 rdp->mcs->user_channel_joined = true;
628         else if (channel_id == MCS_GLOBAL_CHANNEL_ID)
629                 rdp->mcs->global_channel_joined = true;
630
631         for (i = 0; i < rdp->settings->num_channels; i++)
632         {
633                 if (rdp->settings->channels[i].channel_id == channel_id)
634                         rdp->settings->channels[i].joined = true;
635
636                 if (!rdp->settings->channels[i].joined)
637                         all_joined = false;
638         }
639
640         if (rdp->mcs->user_channel_joined && rdp->mcs->global_channel_joined && all_joined)
641                 rdp->state = CONNECTION_STATE_MCS_CHANNEL_JOIN;
642
643         return true;
644 }
645
646 boolean rdp_server_accept_client_keys(rdpRdp* rdp, STREAM* s)
647 {
648
649         if (!rdp_server_establish_keys(rdp, s))
650                 return false;
651
652         rdp->state = CONNECTION_STATE_ESTABLISH_KEYS;
653
654         return true;
655 }
656
657 boolean rdp_server_accept_client_info(rdpRdp* rdp, STREAM* s)
658 {
659
660         if (!rdp_recv_client_info(rdp, s))
661                 return false;
662
663         if (!license_send_valid_client_error_packet(rdp->license))
664                 return false;
665
666         rdp->state = CONNECTION_STATE_LICENSE;
667
668         return true;
669 }
670
671 boolean rdp_server_accept_confirm_active(rdpRdp* rdp, STREAM* s)
672 {
673         if (!rdp_recv_confirm_active(rdp, s))
674                 return false;
675
676         rdp->state = CONNECTION_STATE_ACTIVE;
677         update_reset_state(rdp->update);
678
679         if (!rdp_send_server_synchronize_pdu(rdp))
680                 return false;
681
682         if (!rdp_send_server_control_cooperate_pdu(rdp))
683                 return false;
684
685         return true;
686 }
687
688 boolean rdp_server_reactivate(rdpRdp* rdp)
689 {
690         if (!rdp_send_deactivate_all(rdp))
691                 return false;
692
693         rdp->state = CONNECTION_STATE_LICENSE;
694
695         if (!rdp_send_demand_active(rdp))
696                 return false;
697
698         return true;
699 }
700