📜 ⬆️ ⬇️

Learn xrdp to connect to past sessions.

XRDP is a good thing, but there is one drawback - if you have already opened for the session, and then disconnected (without leaving the session), then later it’s not a fact that you can connect to it. I had a decent time with this until the inconvenience reached a critical point and I decided to take it and look at the source code to find out how to fix it.

The method does not claim to be ideal, of course it would be good of course to even put a commit to the developer, but for this you need not just stupidly comment out the lines below, but add at least an option that allows you to turn on a less intelligible mode when defining - open a new session or use the old one. In addition, it is necessary to check the correctness of the algorithm with the legible mode turned off, which I have not done yet, because I tested it - it works, and I am glad, because for me now, first of all, practical value is important.

Well, let's start. The essence of the method is to comment on the following five lines in the sessman / session.c file:
if (g_strncmp(name, tmp->item->name, 255) == 0 //&& //tmp->item->width == width && //tmp->item->height == height && //tmp->item->bpp == bpp && //tmp->item->type == type ) 

I will explain. Here existing sessions are scanned and a check is made from which user and which resolution, color depth, type (VNC, XRDP) is planned to open the session. If there is a session with the same parameters, then connect to the same session. If not, open a new one. Conditions: resolution, color depth, session type, I decided to disable.

')
Now I will describe how I implement it using the example of, say, the Scientific Linux distribution (it will also work for Fedora, Red Hat, CentOS). We also take into account that xrdp is not in the standard Scientific Linux repositories, we will have to connect additional ones (I’m not going to write about this here, the topic is being googled at a time).
Install the necessary tools:
 # yum groupinstall "Development tools" # yum install yum-utils rpmdevtools tar 

Download the project's raws, and install them in the working directory of the rpm collector:
 $ yumdownloader --source xrdp $ rpm -ivh xrdp-0.5.0-0.13.el6.src.rpm 

The file name will not necessarily be xrdp-0.5.0-0.13.el6.src.rpm, depending on what you downloaded the first command. Here is the file downloaded for Scientific Linux.

Files will appear in the working folder of the rpm collector, incl. ~ / rpmbuild / SOURCES / xrdp-HEAD - *. tar.gz. This file will not need to be unpacked, ie:
 $ cd ~/rpmbuild/SOURCES $ tar -xzf xrdp-HEAD-a9cfc23.tar.gz 


Install everything you need to build:
 # yum-builddep ~/rpmbuild/SPECS/xrdp.spec 


Now we look for the file we specified at the beginning and open it with some kind of text editor, for example, nano:
 $ nano ~/rpmbuild/SOURCES/xrdp-HEAD-a9cfc23/sesman/session.c 

We find the necessary lines, modify them exactly as I indicated above, be sure not to forget to move the bracket in the last line to a new one and comment out the ampersands at the end of the first line (I moved them to a new line for clarity).

We pack this case back:
 $ cd ~/rpmbuild/SOURCES $ tar -czf xrdp-HEAD-a9cfc23.tar.gz xrdp-HEAD-a9cfc23 


It remains the case for small - to collect the modified rpm:
 $ rpmbuild -ba ~/rpmbuild/SPECS/xrdp.spec 

If everything went fine, then in ~ / rpmbuild / RPMS / x86_64 / we get two rpm files:
 $ ls -l  664 -rw-rw-r--. 1 rafaelrs rafaelrs 243152  5 07:41 xrdp-0.5.0-0.13.el6.x86_64.rpm -rw-rw-r--. 1 rafaelrs rafaelrs 430620  5 07:41 xrdp-debuginfo-0.5.0-0.13.el6.x86_64.rpm 

Install the first package, start the service and enjoy life :)
 yum install ~/rpmbuild/RPMS/x86_64/xrdp-0.5.0-0.13.el6.x86_64.rpm service xrdp start 


By the way, yes, do not forget that if suddenly the package is updated, the changes we have made will be lost. You can repeat the operation, you can include xrdp in the list of exceptions, you can rename the application altogether. There is a matter of taste, I stopped at the first, the benefit of xrdp is not so often updated.

Source: https://habr.com/ru/post/189074/


All Articles