mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 06:05:53 -05:00
Fixed server file permissions for device groups, #3294
This commit is contained in:
parent
48f6d1e251
commit
b0726e9a13
27
meshuser.js
27
meshuser.js
@ -6799,22 +6799,19 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
try { files.filetree.f[user._id].f = readFilesRec(parent.path.join(parent.filespath, domainx + '/user-' + usersplit[2])); } catch (e) { }
|
||||
}
|
||||
|
||||
// Add files for each mesh // TODO: Get all meshes including groups!!
|
||||
for (var i in user.links) {
|
||||
if ((user.links[i].rights & 32) != 0) { // Check that we have file permissions
|
||||
var mesh = parent.meshes[i];
|
||||
if (mesh) {
|
||||
var meshsplit = mesh._id.split('/');
|
||||
files.filetree.f[mesh._id] = { t: 4, n: mesh.name, f: {} };
|
||||
files.filetree.f[mesh._id].maxbytes = parent.getQuota(mesh._id, domain);
|
||||
// Add files for each mesh
|
||||
const meshes = parent.GetAllMeshWithRights(user, MESHRIGHT_SERVERFILES);
|
||||
for (var i in meshes) {
|
||||
const mesh = meshes[i];
|
||||
var meshsplit = mesh._id.split('/');
|
||||
files.filetree.f[mesh._id] = { t: 4, n: mesh.name, f: {} };
|
||||
files.filetree.f[mesh._id].maxbytes = parent.getQuota(mesh._id, domain);
|
||||
|
||||
// Read all files recursively
|
||||
try {
|
||||
files.filetree.f[mesh._id].f = readFilesRec(parent.path.join(parent.filespath, domainx + '/mesh-' + meshsplit[2]));
|
||||
} catch (e) {
|
||||
files.filetree.f[mesh._id].f = {}; // Got an error, return empty folder. We will create the folder only when needed.
|
||||
}
|
||||
}
|
||||
// Read all files recursively
|
||||
try {
|
||||
files.filetree.f[mesh._id].f = readFilesRec(parent.path.join(parent.filespath, domainx + '/mesh-' + meshsplit[2]));
|
||||
} catch (e) {
|
||||
files.filetree.f[mesh._id].f = {}; // Got an error, return empty folder. We will create the folder only when needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
16
webserver.js
16
webserver.js
@ -7050,20 +7050,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
||||
if (i.startsWith('mesh/')) {
|
||||
// Grant access to a device group thru a direct link
|
||||
const m = obj.meshes[i];
|
||||
if ((m) && (m.deleted == null) && ((rights == null) || ((user.links[i].rights & rights) != 0))) {
|
||||
if (r.indexOf(m) == -1) { r.push(m); }
|
||||
}
|
||||
if ((m) && (r.indexOf(m) == -1) && (m.deleted == null) && ((rights == null) || ((user.links[i].rights & rights) != 0))) { r.push(m); }
|
||||
} else if (i.startsWith('ugrp/')) {
|
||||
// Grant access to a device group thru a user group
|
||||
const g = obj.userGroups[i];
|
||||
if (g && (g.links != null) && ((rights == null) || ((user.links[i].rights & rights) != 0))) {
|
||||
for (var j in g.links) {
|
||||
if (j.startsWith('mesh/')) {
|
||||
const m = obj.meshes[j];
|
||||
if ((m) && (m.deleted == null)) {
|
||||
if (r.indexOf(m) == -1) { r.push(m); }
|
||||
}
|
||||
}
|
||||
for (var j in g.links) {
|
||||
if (j.startsWith('mesh/') && ((rights == null) || ((g.links[j].rights != null) && (g.links[j].rights & rights) != 0))) {
|
||||
const m = obj.meshes[j];
|
||||
if ((m) && (m.deleted == null) && (r.indexOf(m) == -1)) { r.push(m); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user