Allow parameters for XRDP run bash script

Allows run bash script with parameters on xrdp. For example rdesktop -s "myscript.sh params"
This commit is contained in:
D.V.Yacenko 2020-10-22 18:12:55 +03:00 committed by GitHub
parent 0d00693e54
commit a6a785d7a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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());