Ylianst / MeshAgent

MeshAgent used along with MeshCentral to remotely manage computers. Many variations of the background management agent are included as binaries in the MeshCentral project.
https://meshcentral.com
231 stars 89 forks source link

Notifybar does not close on Linux when disconnected #220

Open wdlut opened 11 months ago

wdlut commented 11 months ago

The version of the software you are using Latest version from github. Server: 1.1.16, agent: "openssl": "1.1.1s", "duktape": "v2.6.0", "commitDate": 2023-12-05T09:15:06.000Z", "compileTime": "11:58:43, Dec 6 2023"

The Operating System and version Browser: Windows 11, Server: Debian GNU/Linux 11 (bullseye), meshagent: self-compiled buildroot, kernel 4.9.13, X, fluxbox

The observed output Users need to see that someone is connected to the computer. That's why the config.json contains the block: "userConsentFlags": { "desktopnotify": true,... When a desktop connection is established to the Linux computer, the Notiry Bar appears. If you close the connection, the Notify bar remains visible. When you reconnect, another notify bar is created on top of the first. If you close the connection, close the notify bars with the mouse on x and reconnect, the meshagent crashes with a segmentation fault.

The expected output The behavior under Windows is correct: When you connect, the Notify Bar appears, when the connection is closed, the Notify Bar disappears and if you close the Notify Bar with the mouse while connected, the connection is terminated.

Any troubleshooting you took to resolve the issue yourself I tried to find the error in notifybar-desktop.js but gave up after a few hours. My knowledge of X11 programming and javascript is not deep enough to analyze the program in detail. The stack traces of the crashes end in X11.XPending(). I can add them if necessary. However, the error can be reproduced easily and reliably.

Any other similar reports Not that I knew of.

wdlut commented 10 months ago

I fixed the error and opened a pull request.

si458 commented 10 months ago

i dont seem to have this issue with ubuntu 22.04? when i connect i see a bar, when i disconnect i dont see the bar?

> info
Current Core: Nov 21 2022, 2437202558
Agent Time: 2024-01-18 23:06:50.973+00:00.
User Rights: 0xffffffff.
Platform: linux.
Capabilities: 15.
Server URL: wss://mc.myserver.com:443/agent.ashx.
OS: Ubuntu 22.04.3 LTS.
Modules: amt-apfclient, amt-lme, amt-manage, amt-mei, computer-identifiers, linux-dhcp, monitor-border, smbios, sysinfo, util-agentlog, wifi-scanner-windows, wifi-scanner.
Server Connection: true, State: 1.
X11 support: true.
wdlut commented 9 months ago

You are right. I tried it again with

Current Core: Nov 21 2022, 598124670
Agent Time: 2024-01-19 08:48:25.606+01:00.
User Rights: 0xffffffff.
Platform: linux.
Capabilities: 15.
Server URL: wss://xxxx/agent.ashx.
OS: Debian GNU/Linux 11 (bullseye).
Modules: amt-apfclient, amt-lme, amt-manage, amt-mei, computer-identifiers, linux-dhcp, monitor-border, smbios, sysinfo, util-agentlog, wifi-scanner-windows, wifi-scanner.
Server Connection: true, State: 1.
X11 support: true.

on Mint 20.2 and Debian 11 and it worked. The problem seems to have to do with our buildroot embedded linux, which uses fluxbox as window manager.

I closed the pull request.

Yet one minor problem also exists with Debian and Mint: The meshagent crashes, when you close the notifybar with the mouse and then log-in again. Normally you would not notice it, because it restarts immediately. If you start the meshagent in a terminal, you see it crashing with a segmentation fault. My pull request would solve that problem, but I dont't know if it has other problems with other linux versions...

si458 commented 9 months ago

in theory if you want to test it yourself, do the following: (this will only work because its javascript files, this wont work if you have to modify any C files)...

  1. copy modules/notifybar-desktop.js from the meshagent repo to agents/modules_meshcore/ in your meshcentral repo
  2. rename the file to something like notifybar-desktop-modified.js in your meshcentral repo
  3. edit the JS file to patch it/fix it
  4. replace EVERY SINGLE INSTANCE of require('notifybar-desktop') with require('notifybar-desktop-modified') in meshcore.js
  5. restart your meshcentral server
  6. wait about 10-60 seconds while EVERY AGENT gets the new meshcore.js and the new module (you will see them come online, then offline then back online again)
  7. pick a device, go to its console tab, type info, and you should see the module listed
    Modules: amt-apfclient, amt-lme, amt-manage, amt-mei, computer-identifiers, monitor-border, smbios, sysinfo, util-agentlog, wifi-scanner-windows, wifi-scanner, win-console, win-deskutils, win-info, win-securitycenter, win-terminal, win-virtual-terminal, win-volumes.
  8. then try again and see if your bug is fixed!

EDIT: this is how i fixed the identifiers.js, the problem with it was inside the agent, so for quicker fixes/patches you can move them to server side, and mesh will push the modules to your devices, BUT they cant have the same name! so i renamed the fixes for identifiers to computer-identifiers