debauchee / barrier

Open-source KVM software
Other
27.62k stars 1.52k forks source link

Plea to Developer: Portable barrier #961

Open NikoMuffin opened 3 years ago

NikoMuffin commented 3 years ago

Hello, I've noticed Barrier stores its settings in multiple folders. This is my #1 request for this beautiful & useful software.

Settings are stored in: C:\Program Files\Barrier C:\Users\user\AppData\Local\Barrier C:\ProgramData\Barrier

Is it possible implement the -portable command argument so that I can run Barrier from another directory and all settings get stored in the program directory? Pretty please? D:\Applications\Barrier

ArmandoRl1 commented 3 years ago

This would be wonderful to have

albertony commented 3 years ago

I agree, an easy to use, official portable mode would be nice! Combined with a zip distribution for copy-deploy.

If you can manage with just the command line editions (barriers.exe and barrierc.exe), I think it is possible already:

From what I can see, nothing will be written to outside of the configured profile-dir!

If you want a minimal, copy-install, command-line-only deploy, you only need the following files, which you can copy from an existing installation, or extract from .exe installer using innounp:

barrierc.exe
barriers.exe

Due to dependency to OpenSSL, used for encryption (argument --enable-crypto), you need these files in addition (originally thought these were not needed unless using --enable-crypto, but found out they are a "hard" dependency):

libeay32.dll
ssleay32.dll

Optionally, if you want to be able to generate certificate, you also need these (on the server):

openssl.exe
barrier.conf

You will need the Microsoft Visual C++ Redistributable for Visual Studio 2019 installed, although it is possible to copy-install msvcp140.dll, vcruntime140.dll and vcruntime140_1.dll into the application directory.

If you want to use encryption, you can generate certificate and fingerprint in a SSL directory structure the same way as the GUI application does, like this:

mkdir "D:\Applications\Barrier\SSL\Fingerprints" >NUL 2>&1
set OPENSSL_CONF=D:\Applications\Barrier\barrier.conf
"D:\Applications\Barrier\openssl.exe" req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:2048 -keyout "D:\Applications\Barrier\SSL\Barrier.pem" -out "D:\Applications\Barrier\SSL\Barrier.pem"
"D:\Applications\Barrier\openssl.exe" x509 -fingerprint -sha1 -noout -in "D:\Applications\Barrier\SSL\Barrier.pem" > "D:\Applications\Barrier\SSL\Fingerprints\Local.txt"

Edit: I realize --profile-dir is undocumented. Not listed in --help output, nor mentioned in wiki. That should be a small first step, I think.

NikoMuffin commented 3 years ago

@albertony thank you! I discovered this just yesterday and appreciate the summary.

I want to ask if the dev can make a "-portable" command argument that would do all this automatically. That would be wonderful.

NikoMuffin commented 3 years ago

@albertony unfortunately neither command works and it's a triple whammy.

This is what I used:

D:\Applications\Barrier\barrier.exe --profile-dir "D:\Applications\Barrier\settings\"

I got a folder created in: C:\Users\Nightcrawler\AppData\Local\Barrier C:\Users\Nightcrawler\AppData\Local\Barrier\SSL\ C:\Users\Nightcrawler\AppData\Local\Barrier\SSL\Fingerprints

and nothing I do stops Barrier from creating registry entries: HKEY_CURRENT_USER\Software\Debauchee\Barrier HKEY_LOCAL_MACHINE\SOFTWARE\Barrier

albertony commented 3 years ago

D:\Applications\Barrier\barrier.exe --profile-dir "D:\Applications\Barrier\settings"

You are probably running the full GUI application? I haven't tried that myself, as I wanted to use it as a portable application from the start. Running the command line applications only, I don't get any of those folders or registry entries. But ok, if so, you have confirmed my suspicion that it does not work with that one.

Then, unfortunately, you will have to use the command line versions: barriers.exe (server) and barrierc.exe (client), and create a text file with configuration for the server as described here https://github.com/debauchee/barrier/wiki/Command-Line#server-configuration-file. If you want to try this and have more questions, just ask.

setushah1 commented 2 years ago

I did this so far -

  1. Downloaded BarrierSetup-2.4.0-release

  2. Downloaded innounp

  3. Extracted all files from BarrierSetup-2.4.0-release using innounp

  4. Created a new folder D:\Temp\base and copied barriers.exe, barrierc.exe, ssleay32.dll, libeay32.dll to the base folder (though libeay32.dll was not necessary)

  5. created barrier.sgc in the base folder

  6. Configured barrier.sgc as - section: screens Thinkpad: Dell: end section: links Thinkpad: right = Dell Dell: left = Thinkpad end section: aliases PC13F21F: Thinkpad DESKTOP-IEBI2GF: Dell end

  7. Issued this command - barriers --profile-dir .\

It creates this error - [2022-04-25T21:33:21] ERROR: cannot read configuration ".\barrier.sgc": read error: line 12: unknown screen name "PC13F21F" barriers: no configuration available

Executed hostname on command prompt. It gave the same name - PC13F21F

Tried searching about this error but couldn't find any reference in context for portable/command line execution.

albertony commented 2 years ago

If you surround your configuration snippet with three ` (backticks) its easier to read (assuming you have some indentation in it), like this:

section: screens
    Thinkpad:
    Dell:
end
section: links
    Thinkpad:
        right = Dell
    Dell:
        left = Thinkpad
end
section: aliases
    PC13F21F:
        Thinkpad
    DESKTOP-IEBI2GF:
        Dell
end

I'm not very familiar with aliases... maybe you can try without it, use the real names directly?

setushah1 commented 2 years ago

Yes, the file is indented the way you have done.

As per your suggestion I have removed real names and recreated the file -

section: screens
    PC13F21F:
    DESKTOP-IEBI2GF:
end

section: aliases
end

section: links
    PC13F21F:
        right = DESKTOP-IEBI2GF
    DESKTOP-IEBI2GF:
        left = PC13F21F
end

Then executed it with barriers --profile-dir .\ --disable-crypto --debug DEBUG2

On client side, I could install with installer. And executed the GUI and configured as Client. On client, when I use the name of the server - PC13F21F, the server doesnt recognize it. But if I use IP - 192.168.1.7 then the connection becomes successful. However, the mouse still doesn't move to the client.

albertony commented 2 years ago

Try to make the server listen for IPv6 in addition to IPv4 by adding argument --address "::".

If that does not work, I'm not sure what is going on. Maybe try this:

-n, --name <screen-name> use screen-name instead the hostname to identify this screen in the configuration.
shinji257 commented 1 year ago

Similar to above I did the following. I have no admin rights on the target client system.

Copied in barrierc.exe, libssleay32.dll, libeay32.dll from another Windows install. Launched it with the following command (I'm not using SSL in my network) barrierc --disable-crypto --exit-pause 10.0.0.160

--exit-pause isn't really needed but I got it in a batch file. Just wanted it pause in case there was an issue. You do not need barrier.exe or barriers.exe if it is just going to be a client. You also do not need any of the QT libraries (they are for barrier.exe).

nigerninja commented 1 year ago

Similar to above I did the following. I have no admin rights on the target client system.

Copied in barrierc.exe, libssleay32.dll, libeay32.dll from another Windows install. Launched it with the following command (I'm not using SSL in my network) barrierc --disable-crypto --exit-pause 10.0.0.160

--exit-pause isn't really needed but I got it in a batch file. Just wanted it pause in case there was an issue. You do not need barrier.exe or barriers.exe if it is just going to be a client. You also do not need any of the QT libraries (they are for barrier.exe).

Works like a charm. Thanks.

pgyogesh commented 1 year ago

Similar to above I did the following. I have no admin rights on the target client system. Copied in barrierc.exe, libssleay32.dll, libeay32.dll from another Windows install. Launched it with the following command (I'm not using SSL in my network) barrierc --disable-crypto --exit-pause 10.0.0.160 --exit-pause isn't really needed but I got it in a batch file. Just wanted it pause in case there was an issue. You do not need barrier.exe or barriers.exe if it is just going to be a client. You also do not need any of the QT libraries (they are for barrier.exe).

@shinji257 I tried this but getting below error: The system cannot execute the specified program

igalech commented 1 year ago

Similar to above I did the following. I have no admin rights on the target client system.

Copied in barrierc.exe, libssleay32.dll, libeay32.dll from another Windows install. Launched it with the following command (I'm not using SSL in my network) barrierc --disable-crypto --exit-pause 10.0.0.160

--exit-pause isn't really needed but I got it in a batch file. Just wanted it pause in case there was an issue. You do not need barrier.exe or barriers.exe if it is just going to be a client. You also do not need any of the QT libraries (they are for barrier.exe).

I've followed this options in a Win11 machine where I don't have admin rights. After copying .pem and .cfg files and recreating the SSL directory barrierc.exe <I.P.ADDR.ESS> does work. Now I'm facing an odd issue. This runs in a CMD (powershell or cmd) window in win11 in the foreground where you can see all the logging from barrierc. Certain apps that take foreground (e.g. notepad++) automatically disable barrier, while others don't (e.g. FF, Chrome, even notepad.exe, etc.) Not sure why.

@shinji257 can you post instructions for how to run this in a batch file/job and have the client running 'silently' in the background?

shinji257 commented 1 year ago

@pgyogesh If this is a work machine then your IT is likely implementing a policy to restrict which executables can be run.

@igalech Sorry. I run it rather verbose so I don't know how I might run it 'silently'.

igalech commented 1 year ago

@shinji257 Thanks. By silenced I meant running it via conhost, powershell or similar, but without an actual console in the foregruond (like nohup or &). After some digging I've managed to put together a bat file and run barrierc at startup with your list of files and configuration instructions plus the certificates and it runs almost ok. I thought that was the issue, but I was wrong. Most of the apps from W11 that runs barrierc are responsive to barriers that runs in a central ubuntu box. However, when some apps start in W11 they leave barrierc unresponsive despite still running fine - I can see barrierc in taskmanager and barriers is not complaining (log says entering screen of W11 box). I've made the process realtime and changed process to run in admin mode to no avail. Examples: Windows task manager, notepad++.