@@ -3207,6 +3207,106 @@ xrdp_mm_display_server_connect(struct xrdp_mm *self)
32073207 return rv ;
32083208}
32093209
3210+ /*****************************************************************************/
3211+ static int
3212+ xrdp_mm_send_save_session_info (struct xrdp_mm * self )
3213+ {
3214+ int rv = 0 ;
3215+ int bytes ;
3216+ const char * username ;
3217+ size_t username_len ;
3218+ struct stream * s ;
3219+
3220+ make_stream (s );
3221+ init_stream (s , 8192 );
3222+
3223+ /* Get username */
3224+ if ((username = xrdp_mm_get_value (self , "username" )) == NULL )
3225+ {
3226+ username = "???" ;
3227+ username_len = 3 ;
3228+ }
3229+ else
3230+ {
3231+ username_len = g_strlen (username );
3232+ }
3233+ /* Check for overflow */
3234+ if (username_len > INFO_CLIENT_MAX_CB_LEN - 2 )
3235+ {
3236+ rv = 1 ;
3237+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_ERROR , "Username too big !" );
3238+ goto cleanup ;
3239+ }
3240+
3241+ /* [MS-RDPBCGR] sect 3.3.5.10.1 - Sending Save Session Info PDU */
3242+
3243+ /* "A logon notification of type INFOTYPE_LOGON or INFOTYPE_LOGON_LONG SHOULD
3244+ * be sent if the INFO_LOGONNOTIFY flag was set by the client
3245+ * in the Client Info PDU or if the username or domain used to log on to
3246+ * the session is different from what was sent in the Client Info PDU." */
3247+
3248+ if ((self -> wm -> client_info -> rdp_logonnotify ||
3249+ g_strcmp (self -> wm -> client_info -> username , username ) != 0 ) && 0 )
3250+ {
3251+ /* We should send a logon notification */
3252+ if (!self -> wm -> client_info -> long_credentials_supported )
3253+ {
3254+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_DEBUG ,
3255+ "Sending Session Info 'INFOTYPE_LOGON'" );
3256+ /* infoType */
3257+ out_uint32_le (s , INFOTYPE_LOGON );
3258+ /* [MS-RDPBCGR] sect 2.2.10.1.1.1 */
3259+ out_uint32_le (s , 2 ); /* cbDomain */
3260+ out_uint8s (s , 52 ); /* Domain (empty) */
3261+ out_uint32_le (s , username_len + 2 ); /* cbUserName */
3262+ out_utf8_as_utf16_le (s , username ,
3263+ username_len ); /* Username */
3264+ out_uint8s (s , 512 - 2 - username_len ); /* Delimiter + pad */
3265+ out_uint32_le (s , 0 ); /* SessionId */
3266+ }
3267+ else
3268+ {
3269+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_DEBUG ,
3270+ "Sending Session Info 'INFOTYPE_LOGON_LONG'" );
3271+ /* infoType */
3272+ out_uint32_le (s , INFOTYPE_LOGON_LONG );
3273+ /* [MS-RDPBCGR] sect 2.2.10.1.1.2 */
3274+ out_uint32_le (s , 0x0001 ); /* Version */
3275+ out_uint32_le (s , 574 ); /* Size */
3276+ out_uint32_le (s , 0 ); /* SessionId */
3277+ out_uint32_le (s , 2 ); /* cbDomain */
3278+ out_uint32_le (s , username_len + 2 ); /* cbUserName */
3279+ out_uint8s (s , 558 ); /* Pad */
3280+ out_uint8s (s , 2 ); /* Domain (empty) */
3281+ out_utf8_as_utf16_le (s , username ,
3282+ username_len ); /* Username */
3283+ out_uint8s (s , 2 ); /* Delimiter */
3284+ }
3285+ }
3286+ else
3287+ {
3288+ /* "A logon notification of type INFOTYPE_LOGON_PLAINNOTIFY SHOULD be sent whenever
3289+ * a notification of type INFOTYPE_LOGON or INFOTYPE_LOGON_LONG would not be sent." */
3290+
3291+ xrdp_wm_log_msg (self -> wm , LOG_LEVEL_DEBUG ,
3292+ "Sending Session Info 'INFOTYPE_LOGON_PLAINNOTIFY'" );
3293+
3294+ /* infoType */
3295+ out_uint32_le (s , INFOTYPE_LOGON_PLAINNOTIFY );
3296+ /* [MS-RDPBCGR] sect 2.2.10.1.1.3 */
3297+ out_uint8s (s , 576 ); /* Pad */
3298+ }
3299+ s_mark_end (s );
3300+
3301+ /* send to client */
3302+ bytes = (int ) (s -> end - s -> data );
3303+ self -> mod -> server_session_info (self -> mod , s -> data , bytes );
3304+
3305+ cleanup :
3306+ free_stream (s );
3307+ return rv ;
3308+ }
3309+
32103310/**************************************************************************/ /**
32113311 * Initialise and start the connect sequence
32123312 *
@@ -3532,6 +3632,12 @@ xrdp_mm_connect_sm(struct xrdp_mm *self)
35323632 }
35333633 break ;
35343634
3635+ case MMCS_SEND_SESSIONINFO :
3636+ {
3637+ status = xrdp_mm_send_save_session_info (self );
3638+ }
3639+ break ;
3640+
35353641 case MMCS_DONE :
35363642 {
35373643 /* Shouldn't get here */
0 commit comments