neutrinolabs / xrdp

xrdp: an open source RDP server
http://www.xrdp.org/
Apache License 2.0
5.77k stars 1.73k forks source link

prevent the use of "alternate shell" #850

Closed robanybody closed 1 year ago

robanybody commented 7 years ago

Hi, is there a way to prevent Users from executing a single application instead of running the intended Desktop? I guess it would make sense to have an option in sesman.ini to set the intended behavior.

evanlinde commented 7 years ago

You can edit startwm.sh (specifically the wm_start function) to start a specific desktop.

For example, on CentOS 7, instead of calling the wm_start function, you could add a line like:

. /etc/X11/xinit/Xsession /prog/to/start

where /prog/to/start could be something like /bin/gnome-session or a custom script.

robanybody commented 7 years ago

well that does not prevent a user from runing an "alternate shell" . Looks like startwm.sh would not run if "start a program" option is set to an existing program like usr\bin\lxterminal. By the way my startwm.sh looks like this: #!/bin/sh exec /usr/bin/awesome exit 1

robanybody commented 7 years ago

found the place in code and commented it out: sesman/session.c

            if (s->directory != 0)
           {
              if (s->directory[0] != 0)
               {
                 /* don't do anything 
                  g_set_current_dir(s->directory);
                 */
               }
           }
           if (s->program != 0)
           {
               if (s->program[0] != 0)
               {
                  /* prevent use of alternate shell
                   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());
                  */
                   log_message(LOG_LEVEL_ALWAYS,
                               "attention user %s tried to start program %s for - pid %d we don't allow this",
                               s->username, s->program,  g_getpid()); 
               }
           }

works !

metalefty commented 7 years ago

I think removing/commenting out the code that you show is the only solution so far.

robanybody commented 7 years ago

so then this is a feature request :-)

Would be nice to have an option to disable "alternative shell / startup program" via config would be even more great if you could put a default program in config would be super awesome, if you could enter an array of allowed programs

Thanks for the review I was not 100% sure whether "g_set_current_dir (s-> directory);" part of the alternative shell

metalefty commented 7 years ago

I cannot promise to implement it but I stack it feature request.

lennartS-lfb commented 1 year ago

Would you be willing to have a look at a pull request implementing a simple configuration option (alternative 1 as suggested by @robanybody) for this?

matt335672 commented 1 year ago

If you submit one, we'll look at it - thanks!

I take it you're thinking of putting an option in sesman.ini?

lennartS-lfb commented 1 year ago

Great to hear :)

Yes, I was thinking about the Security section of the sesman.ini, since the code knows about that config anyway. It won't be this week, but I'll take a stab at it.

matt335672 commented 1 year ago

Sounds like a good place.

A couple of thoughts:-

Any questions, come back to me. I'm fairly occupied for a few days now anyway so there's no rush.

matt335672 commented 1 year ago

Most importantly, thanks for looking at this!

matt335672 commented 1 year ago

Fixed by #2634