Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifybar does not close on Linux when disconnected #220

Open
wdlut opened this issue Dec 6, 2023 · 4 comments
Open

Notifybar does not close on Linux when disconnected #220

wdlut opened this issue Dec 6, 2023 · 4 comments

Comments

@wdlut
Copy link

wdlut commented Dec 6, 2023

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 added a commit to wdlut/MeshAgent that referenced this issue Jan 4, 2024
wdlut added a commit to wdlut/MeshAgent that referenced this issue Jan 10, 2024
Fix-Ylianst#220-Notifybar-does-not-close-on-Linux-when-disconnected

- Call XDestroyWindow() in the close()-function of x_notifybar. This closes the notifybar, when the desktop connection is closed.
- Removed the XCloseDisplay() and _windows.clear() calls in the on( 'readset' ) function. The calls caused meshagent crashes, if  the notifybar is closed with the mouse, disconnected and then reconnected. They seem to be unnecessary. The notifybar is closed by the close() function.
-  Moved the setAlwaysOnTop() call down after the XMapWindow() call. The notifybar window must be mapped, otherwise the setAlwaysOnTop() call has no effect.
@wdlut
Copy link
Author

wdlut commented Jan 10, 2024

I fixed the error and opened a pull request.

@si458
Copy link
Collaborator

si458 commented Jan 18, 2024

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
Copy link
Author

wdlut commented Jan 19, 2024

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
Copy link
Collaborator

si458 commented Jan 19, 2024

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.
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants