@@ -3224,6 +3224,106 @@ xrdp_mm_display_server_connect(struct xrdp_mm *self)
32243224 return rv ;
32253225}
32263226
3227+ /*****************************************************************************/
3228+ static int
3229+ xrdp_mm_send_save_session_info (struct xrdp_mm * self )
3230+ {
3231+ int rv = 0 ;
3232+ int bytes ;
3233+ const char * username ;
3234+ size_t username_len ;
3235+ struct stream * s ;
3236+
3237+ make_stream (s );
3238+ init_stream (s , 8192 );
3239+
3240+ /* Get username */
3241+ if ((username = xrdp_mm_get_value (self , "username" )) == NULL )
3242+ {
3243+ username = "???" ;
3244+ username_len = 3 ;
3245+ }
3246+ else
3247+ {
3248+ username_len = g_strlen (username );
3249+ }
3250+ /* Check for overflow */
3251+ if (username_len > INFO_CLIENT_MAX_CB_LEN - 2 )
3252+ {
3253+ rv = 1 ;
3254+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_ERROR , "Username too big !" );
3255+ goto cleanup ;
3256+ }
3257+
3258+ /* [MS-RDPBCGR] sect 3.3.5.10.1 - Sending Save Session Info PDU */
3259+
3260+ /* "A logon notification of type INFOTYPE_LOGON or INFOTYPE_LOGON_LONG SHOULD
3261+ * be sent if the INFO_LOGONNOTIFY flag was set by the client
3262+ * in the Client Info PDU or if the username or domain used to log on to
3263+ * the session is different from what was sent in the Client Info PDU." */
3264+
3265+ if ((self -> wm -> client_info -> rdp_logonnotify ||
3266+ g_strcmp (self -> wm -> client_info -> username , username ) != 0 ) && 0 )
3267+ {
3268+ /* We should send a logon notification */
3269+ if (!self -> wm -> client_info -> long_credentials_supported )
3270+ {
3271+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_DEBUG ,
3272+ "Sending Session Info 'INFOTYPE_LOGON'" );
3273+ /* infoType */
3274+ out_uint32_le (s , INFOTYPE_LOGON );
3275+ /* [MS-RDPBCGR] sect 2.2.10.1.1.1 */
3276+ out_uint32_le (s , 2 ); /* cbDomain */
3277+ out_uint8s (s , 52 ); /* Domain (empty) */
3278+ out_uint32_le (s , username_len + 2 ); /* cbUserName */
3279+ out_utf8_as_utf16_le (s , username ,
3280+ username_len ); /* Username */
3281+ out_uint8s (s , 512 - 2 - username_len ); /* Delimiter + pad */
3282+ out_uint32_le (s , 0 ); /* SessionId */
3283+ }
3284+ else
3285+ {
3286+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_DEBUG ,
3287+ "Sending Session Info 'INFOTYPE_LOGON_LONG'" );
3288+ /* infoType */
3289+ out_uint32_le (s , INFOTYPE_LOGON_LONG );
3290+ /* [MS-RDPBCGR] sect 2.2.10.1.1.2 */
3291+ out_uint32_le (s , 0x0001 ); /* Version */
3292+ out_uint32_le (s , 574 ); /* Size */
3293+ out_uint32_le (s , 0 ); /* SessionId */
3294+ out_uint32_le (s , 2 ); /* cbDomain */
3295+ out_uint32_le (s , username_len + 2 ); /* cbUserName */
3296+ out_uint8s (s , 558 ); /* Pad */
3297+ out_uint8s (s , 2 ); /* Domain (empty) */
3298+ out_utf8_as_utf16_le (s , username ,
3299+ username_len ); /* Username */
3300+ out_uint8s (s , 2 ); /* Delimiter */
3301+ }
3302+ }
3303+ else
3304+ {
3305+ /* "A logon notification of type INFOTYPE_LOGON_PLAINNOTIFY SHOULD be sent whenever
3306+ * a notification of type INFOTYPE_LOGON or INFOTYPE_LOGON_LONG would not be sent." */
3307+
3308+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_DEBUG ,
3309+ "Sending Session Info 'INFOTYPE_LOGON_PLAINNOTIFY'" );
3310+
3311+ /* infoType */
3312+ out_uint32_le (s , INFOTYPE_LOGON_PLAINNOTIFY );
3313+ /* [MS-RDPBCGR] sect 2.2.10.1.1.3 */
3314+ out_uint8s (s , 576 ); /* Pad */
3315+ }
3316+ s_mark_end (s );
3317+
3318+ /* send to client */
3319+ bytes = (int ) (s -> end - s -> data );
3320+ self -> mod -> server_session_info (self -> mod , s -> data , bytes );
3321+
3322+ cleanup :
3323+ free_stream (s );
3324+ return rv ;
3325+ }
3326+
32273327/**************************************************************************/ /**
32283328 * Initialise and start the connect sequence
32293329 *
@@ -3549,6 +3649,12 @@ xrdp_mm_connect_sm(struct xrdp_mm *self)
35493649 }
35503650 break ;
35513651
3652+ case MMCS_SEND_SESSIONINFO :
3653+ {
3654+ status = xrdp_mm_send_save_session_info (self );
3655+ }
3656+ break ;
3657+
35523658 case MMCS_DONE :
35533659 {
35543660 /* Shouldn't get here */
0 commit comments