From a6a785d7a46018221aa7de0f6db541650d4efba3 Mon Sep 17 00:00:00 2001 From: "D.V.Yacenko" Date: Thu, 22 Oct 2020 18:12:55 +0300 Subject: [PATCH] Allow parameters for XRDP run bash script Allows run bash script with parameters on xrdp. For example rdesktop -s "myscript.sh params" --- sesman/session.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sesman/session.c b/sesman/session.c index dd3dbb18..413cae39 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -46,7 +46,6 @@ #define PR_SET_NO_NEW_PRIVS 38 #endif - extern unsigned char g_fixedkey[8]; extern struct config_sesman *g_cfg; /* in sesman.c */ extern int g_sck; /* in sesman.c */ @@ -544,7 +543,18 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c, { if (s->program[0] != 0) { - g_execlp3(s->program, s->program, 0); + log_message(LOG_LEVEL_DEBUG, + "starting program with parameters: %s ", + s->program); + if(g_strchr(s->program, ' ') != 0 || g_strchr(s->program, '\t') != 0) + { + const char *params[] = {"sh", "-c", s->program, NULL}; + g_execvp("/bin/sh", (char **)params); + } + else + { + g_execlp3(s->program, s->program, 0); + } log_message(LOG_LEVEL_ALWAYS, "error starting program %s for user %s - pid %d", s->program, s->username, g_getpid());