Introduce instance_name field into xrdp.ini and xrdp-sesrun, along with

the N policy in sesman.ini, allowing xrdp sessions to be tagged with an
instance name to enable persistent association with a specific
xrdp instance, to allow experiences where users reconnect to specific
sessions based on e.g. the xrdp listening port used.
This commit is contained in:
Leonard Nielsen
2026-01-20 12:00:40 +01:00
parent 259dc937bf
commit 0edde4c090
28 changed files with 162 additions and 51 deletions
+14 -4
View File
@@ -103,6 +103,7 @@ struct session_params
const char *ip_addr;
const char *username;
const char *instance_name;
char password[MAX_PASSWORD_LEN + 1];
};
@@ -181,6 +182,7 @@ usage(void)
g_printf(" -t <type> Default:%s\n", DEFAULT_SESSION_TYPE);
g_printf(" -D <directory> Default: $HOME\n"
" -S <shell> Default: Defined window manager\n"
" -N <instance-name> Default: Empty\n"
" -p <password> TESTING ONLY - DO NOT USE IN PRODUCTION\n"
" -F <file-descriptor> Read password from this file descriptor\n"
" -c <sesman_ini> Alternative sesman.ini file\n");
@@ -189,6 +191,8 @@ usage(void)
g_printf("\nIf username is omitted, the current user is used.\n"
"If username is provided, password is needed.\n"
" Password is prompted for if -p or -F are not specified\n");
g_printf("\nThe instance name is used to associate the session with an xrdp\n"
"\ndaemon tagged with that particular name.\n");
}
@@ -297,11 +301,12 @@ parse_program_args(int argc, char *argv[], struct session_params *sp,
sp->directory = "";
sp->shell = "";
sp->ip_addr = "";
sp->instance_name = "";
sp->username = NULL;
sp->password[0] = '\0';
while ((opt = getopt(argc, argv, "g:b:s:t:D:S:p:F:c:")) != -1)
while ((opt = getopt(argc, argv, "g:b:s:t:D:S:p:F:c:N:")) != -1)
{
switch (opt)
{
@@ -367,6 +372,10 @@ parse_program_args(int argc, char *argv[], struct session_params *sp,
}
break;
case 'N':
sp->instance_name = optarg;
break;
case 'c':
*sesman_ini = optarg;
break;
@@ -491,13 +500,14 @@ send_create_session_request(struct trans *t, const struct session_params *sp)
{
LOG(LOG_LEVEL_DEBUG,
"width:%d height:%d bpp:%d code:%d\n"
"directory:\"%s\" shell:\"%s\"",
"directory:\"%s\" shell:\"%s\" instance_name:\"%s\"",
sp->width, sp->height, sp->bpp, sp->session_type,
sp->directory, sp->shell);
sp->directory, sp->shell, sp->instance_name);
return scp_send_create_session_request(
t, sp->session_type,
sp->width, sp->height, sp->bpp, sp->shell, sp->directory);
sp->width, sp->height, sp->bpp, sp->shell,
sp->directory, sp->instance_name);
}
/**************************************************************************//**