Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
3.68k stars 511 forks source link

added optional installflags to AgentDownload #6133

Closed schories closed 1 month ago

schories commented 1 month ago

The helpful MeshCtrl was missing the "installflags" option for the AgentDownload feature.

I've added:

Please let me know if there is anything I missed, and feel free to amend as necessary.

schories commented 1 month ago

Should be fixed now. Please check.

si458 commented 1 month ago

the is a few bugs with the code, for example if you specify installflags but no number, it still downloads the file even tho it should error out also if you specify 0 for installflags, it errors out too and still downloads the file it should NOT carry on downloading the file, i believe you should be using else if rather than if

simon@testmc:~/meshcentral/MeshCentral$ node meshctrl.js agentdownload --id '@4WLPzjluG0i1sDV62zYxxxxxx' --type 4 --installflags
Invalid installflags, must be a number.
Downloaded 3518312 byte(s) to "myremoteagent64-mygroup.exe"

edit: the section at line 239 for agentdownload, is only for REQUIRED values not OPTIONAL ones, so you should add a checker at line 1673 for the optional values instead

si458 commented 1 month ago

ok ive pushed a slightly different version to your for you! https://github.com/Ylianst/MeshCentral/commit/17cf36edd9eb51d9d08fcb4e3690cde474b795cd https://github.com/Ylianst/MeshCentral/commit/2b3c329a549fbef3be87bf7884f2930e2c7b58ed also includes a fix which should error out rather than carrying on

thank you for the helpful code tho!

schories commented 1 month ago

for example if you specify installflags but no number, it still downloads the file even tho it should error out also if you specify 0 for installflags, it errors out too and still downloads the file

Oops, skipped testing for those. :-(

Thanks for checking & fixing so quickly! And, most importantly, for accepting the PR.

schories commented 1 month ago

I am a bit confused, did you merge this into upstream?

si458 commented 1 month ago

@schories no i didn't merge ur request BUT I pushed my own slightly altered version as the was a bug with agentdownload because it would download regardless of the values u set even if the values where invalid which was worrying! https://github.com/Ylianst/MeshCentral/pull/6133#issuecomment-2135768741

schories commented 1 month ago

Excellent, thank you, my browser still showed me an old meshctrl.js - I failed to reload. I'd like to apologize for all the hassle. Obviously I need a break..^^ Thank you such much once again!

si458 commented 1 month ago

@schories no worries we all have those days including myself! And thank u for doing the pull request in the first place! Because of this I wouldn't of spotted the fact it downloaded an agent regardless of what options u set which was a little worrying!