Added more user permissions removal. #3065

Ylian Saint-Hilaire committed Aug 28, 2021 at 09:51 UTC bc948328cb50c8da1ceb209e5e8fe72d7c98e808
5 files changed +49 -14
agents/meshcore.js
+1 -1
@@ -874,7 +874,7 @@ function handleServerCommand(data) {
874 case 'msg': {
875 switch (data.type) {
876 case 'console': { // Process a console command
877 - if ((typeof data.rights != 'number') || ((data.rights & 16) == 0)) break; // Check console rights
877 + if ((typeof data.rights != 'number') || ((data.rights & 8) == 0) || ((data.rights & 16) == 0)) break; // Check console rights (Remote Control and Console)
878 if (data.value && data.sessionid) {
879 MeshServerLogEx(17, [data.value], "Processing console command: " + data.value, data);
880 var args = splitArgs(data.value);
agents/recoverycore.js
+1 -1
@@ -911,7 +911,7 @@ require('MeshAgent').AddCommandHandler(function (data) {
911 {
912 switch (data.type) {
913 case 'console': { // Process a console command
914 - if ((typeof data.rights != 'number') || ((data.rights & 16) == 0)) break; // Check console rights
914 + if ((typeof data.rights != 'number') || ((data.rights & 8) == 0) || ((data.rights & 16) == 0)) break; // Check console rights (Remote Control and Console)
915 if (data.value && data.sessionid) {
916 var args = splitArgs(data.value);
917 processConsoleCommand(args[0].toLowerCase(), parseArgs(args), data.rights, data.sessionid);
views/default-mobile.handlebars
+5
@@ -6363,11 +6363,16 @@
6363 function removeUserRights(rights, userid) {
6364 if ((userid != userinfo._id) || (userinfo.removeRights == null)) return rights;
6365 var add = 0, substract = 0;
6366 + if ((userinfo.removeRights & 0x00000008) != 0) { substract += 0x00000008; } // No Remote Control
6367 if ((userinfo.removeRights & 0x00010000) != 0) { add += 0x00010000; } // No Desktop
6368 if ((userinfo.removeRights & 0x00000100) != 0) { add += 0x00000100; } // Desktop View Only
6369 if ((userinfo.removeRights & 0x00000200) != 0) { add += 0x00000200; } // No Terminal
6370 if ((userinfo.removeRights & 0x00000400) != 0) { add += 0x00000400; } // No Files
6371 if ((userinfo.removeRights & 0x00000010) != 0) { substract += 0x00000010; } // No Console
6372 + if ((userinfo.removeRights & 0x00008000) != 0) { substract += 0x00008000; } // No Uninstall
6373 + if ((userinfo.removeRights & 0x00020000) != 0) { substract += 0x00020000; } // No Remote Command
6374 + if ((userinfo.removeRights & 0x00000040) != 0) { substract += 0x00000040; } // No Wake
6375 + if ((userinfo.removeRights & 0x00040000) != 0) { substract += 0x00040000; } // No Reset/Off
6376 if (rights != 0xFFFFFFFF) {
6377 // If not administrator, add and subsctract restrictions
6378 rights |= add;
views/default.handlebars
+37 -12
@@ -14073,11 +14073,17 @@
14073 var userFeatures = [];
14074 if ((serverinfo.usersSessionRecording == 1) && (user.flags) && (user.flags & 2)) { userFeatures.push("Record Sessions"); }
14075 if (user.removeRights) {
14076 - if ((user.removeRights & 0x00010000) != 0) { userFeatures.push("No Desktop"); }
14077 - else if ((user.removeRights & 0x00000100) != 0) { userFeatures.push("Desktop View Only"); }
14078 - if ((user.removeRights & 0x00000200) != 0) { userFeatures.push("No Terminal"); }
14079 - if ((user.removeRights & 0x00000400) != 0) { userFeatures.push("No Files"); }
14076 + if ((user.removeRights & 0x00000008) != 0) { userFeatures.push("No Remote Control"); } else {
14077 + if ((user.removeRights & 0x00010000) != 0) { userFeatures.push("No Desktop"); }
14078 + else if ((user.removeRights & 0x00000100) != 0) { userFeatures.push("Desktop View Only"); }
14079 + if ((user.removeRights & 0x00000200) != 0) { userFeatures.push("No Terminal"); }
14080 + if ((user.removeRights & 0x00000400) != 0) { userFeatures.push("No Files"); }
14081 + }
14082 if ((user.removeRights & 0x00000010) != 0) { userFeatures.push("No Console"); }
14083 + if ((user.removeRights & 0x00008000) != 0) { userFeatures.push("No Uninstall"); }
14084 + if ((user.removeRights & 0x00020000) != 0) { userFeatures.push("No Remote Command"); }
14085 + if ((user.removeRights & 0x00000040) != 0) { userFeatures.push("No Wake"); }
14086 + if ((user.removeRights & 0x00040000) != 0) { userFeatures.push("No Reset/Off"); }
14087 }
14088 userFeatures = userFeatures.join(', ');
14089 if (userFeatures == '') { userFeatures = '<i>' + "None" + '</i>'; }
@@ -14204,17 +14210,25 @@
14210 if (serverinfo.usersSessionRecording == 1) {
14211 x += '<div><label><input type=checkbox id=d20flag1 onchange=p20edituserfeaturesValidate() ' + ((flags & 2) ? 'checked' : '') + '>' + "Record sessions" + '</label><br></div>';
14212 }
14207 - x += '<div><label><input type=checkbox id=d20flag2 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00010000) ? 'checked' : '') + '>' + "No Desktop Access" + '</label><br></div>';
14213 + x += '<div><label><input type=checkbox id=d20flag7 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000008) ? 'checked' : '') + '>' + "No Remote Control" + '</label><br></div>';
14214 + x += '<div style=margin-left:8px><label><input type=checkbox id=d20flag2 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00010000) ? 'checked' : '') + '>' + "No Desktop Access" + '</label><br></div>';
14215 x += '<div style=margin-left:8px><label><input type=checkbox id=d20flag3 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000100) ? 'checked' : '') + '>' + "Remote View Only" + '</label><br></div>';
14209 - x += '<div><label><input type=checkbox id=d20flag4 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000200) ? 'checked' : '') + '>' + "No Terminal Access" + '</label><br></div>';
14210 - x += '<div><label><input type=checkbox id=d20flag5 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000400) ? 'checked' : '') + '>' + "No File Access" + '</label><br></div>';
14216 + x += '<div style=margin-left:8px><label><input type=checkbox id=d20flag4 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000200) ? 'checked' : '') + '>' + "No Terminal Access" + '</label><br></div>';
14217 + x += '<div style=margin-left:8px><label><input type=checkbox id=d20flag5 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000400) ? 'checked' : '') + '>' + "No File Access" + '</label><br></div>';
14218 x += '<div><label><input type=checkbox id=d20flag6 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000010) ? 'checked' : '') + '>' + "No Agent Console" + '</label><br></div>';
14219 + x += '<div><label><input type=checkbox id=d20flag8 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00008000) ? 'checked' : '') + '>' + "No Uninstall" + '</label><br></div>';
14220 + x += '<div><label><input type=checkbox id=d20flag9 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00020000) ? 'checked' : '') + '>' + "No Remote Command" + '</label><br></div>';
14221 + x += '<div><label><input type=checkbox id=d20flag10 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00000040) ? 'checked' : '') + '>' + "No Wake" + '</label><br></div>';
14222 + x += '<div><label><input type=checkbox id=d20flag11 onchange=p20edituserfeaturesValidate() ' + ((removeRights & 0x00040000) ? 'checked' : '') + '>' + "No Reset/Off" + '</label><br></div>';
14223 setDialogMode(2, "Edit User Features", 3, p20edituserfeaturesEx, x);
14224 p20edituserfeaturesValidate();
14225 }
14226
14227 function p20edituserfeaturesValidate() {
14217 - QE('d20flag3', !Q('d20flag2').checked);
14228 + QE('d20flag2', !Q('d20flag7').checked);
14229 + QE('d20flag3', !Q('d20flag7').checked && !Q('d20flag2').checked);
14230 + QE('d20flag4', !Q('d20flag7').checked);
14231 + QE('d20flag5', !Q('d20flag7').checked);
14232 }
14233
14234 // Send to the server the new user's real name
@@ -14226,11 +14240,17 @@
14240
14241 // Setup user permission removal
14242 var r = 0;
14229 - if (Q('d20flag2').checked) { r += 0x00010000; }
14230 - else if (Q('d20flag3').checked) { r += 0x00000100; }
14231 - if (Q('d20flag4').checked) { r += 0x00000200; }
14232 - if (Q('d20flag5').checked) { r += 0x00000400; }
14243 + if (Q('d20flag7').checked) { r += 0x00000008; } else {
14244 + if (Q('d20flag2').checked) { r += 0x00010000; }
14245 + else if (Q('d20flag3').checked) { r += 0x00000100; }
14246 + if (Q('d20flag4').checked) { r += 0x00000200; }
14247 + if (Q('d20flag5').checked) { r += 0x00000400; }
14248 + }
14249 if (Q('d20flag6').checked) { r += 0x00000010; }
14250 + if (Q('d20flag8').checked) { r += 0x00008000; }
14251 + if (Q('d20flag9').checked) { r += 0x00020000; }
14252 + if (Q('d20flag10').checked) { r += 0x00000040; }
14253 + if (Q('d20flag11').checked) { r += 0x00040000; }
14254 meshserver.send({ action: 'edituser', id: currentUser._id, flags: f, removeRights: r });
14255 }
14256
@@ -15841,11 +15861,16 @@
15861 function removeUserRights(rights, userid) {
15862 if ((userid != userinfo._id) || (userinfo.removeRights == null)) return rights;
15863 var add = 0, substract = 0;
15864 + if ((userinfo.removeRights & 0x00000008) != 0) { substract += 0x00000008; } // No Remote Control
15865 if ((userinfo.removeRights & 0x00010000) != 0) { add += 0x00010000; } // No Desktop
15866 if ((userinfo.removeRights & 0x00000100) != 0) { add += 0x00000100; } // Desktop View Only
15867 if ((userinfo.removeRights & 0x00000200) != 0) { add += 0x00000200; } // No Terminal
15868 if ((userinfo.removeRights & 0x00000400) != 0) { add += 0x00000400; } // No Files
15869 if ((userinfo.removeRights & 0x00000010) != 0) { substract += 0x00000010; } // No Console
15870 + if ((userinfo.removeRights & 0x00008000) != 0) { substract += 0x00008000; } // No Uninstall
15871 + if ((userinfo.removeRights & 0x00020000) != 0) { substract += 0x00020000; } // No Remote Command
15872 + if ((userinfo.removeRights & 0x00000040) != 0) { substract += 0x00000040; } // No Wake
15873 + if ((userinfo.removeRights & 0x00040000) != 0) { substract += 0x00040000; } // No Reset/Off
15874 if (rights != 0xFFFFFFFF) {
15875 // If not administrator, add and subsctract restrictions
15876 rights |= add;
webserver.js
+5
@@ -6803,11 +6803,16 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
6803 function removeUserRights(rights, user) {
6804 if (user.removeRights == null) return rights;
6805 var add = 0, substract = 0;
6806 + if ((user.removeRights & 0x00000008) != 0) { substract += 0x00000008; } // No Remote Control
6807 if ((user.removeRights & 0x00010000) != 0) { add += 0x00010000; } // No Desktop
6808 if ((user.removeRights & 0x00000100) != 0) { add += 0x00000100; } // Desktop View Only
6809 if ((user.removeRights & 0x00000200) != 0) { add += 0x00000200; } // No Terminal
6810 if ((user.removeRights & 0x00000400) != 0) { add += 0x00000400; } // No Files
6811 if ((user.removeRights & 0x00000010) != 0) { substract += 0x00000010; } // No Console
6812 + if ((user.removeRights & 0x00008000) != 0) { substract += 0x00008000; } // No Uninstall
6813 + if ((user.removeRights & 0x00020000) != 0) { substract += 0x00020000; } // No Remote Command
6814 + if ((user.removeRights & 0x00000040) != 0) { substract += 0x00000040; } // No Wake
6815 + if ((user.removeRights & 0x00040000) != 0) { substract += 0x00040000; } // No Reset/Off
6816 if (rights != 0xFFFFFFFF) {
6817 // If not administrator, add and subsctract restrictions
6818 rights |= add;