Added userid to events of power actions.
Ylian Saint-Hilaire committed
Nov 5, 2021 at 17:12 UTC
14283aef12b1cc397f4affa164a6849f9710d034
3 files changed
+99
-85
agents/meshcmd.js
+87
-73
@@ -877,7 +877,7 @@ function performAmtAgentPresenceRegisterRetry(stack, name, response, status, wat
877
tempWatchdogTimer = setTimeout(function () { amtstack.AMT_AgentPresenceWatchdog_RegisterAgent(performAmtAgentPresenceRegisterRetry, watchdog, watchdog.Seq, { 'DeviceID': watchdog.DeviceID }); }, 1000);
878
} else {
879
console.log('Failed to register this watchdog.');
880
- process.exit(0);
880
+ exit(0);
881
}
882
}
883
}
@@ -901,7 +901,7 @@ function performAmtAgentPresenceAssertRetry(stack, name, response, status, watch
901
amtstack.AMT_AgentPresenceWatchdog_AssertPresence(watchdog.Seq, performAmtAgentPresenceAssertRetry, watchdog, 0, { 'DeviceID': watchdog.DeviceID });
902
} else {
903
console.log('Failed to assert presence on this watchdog.');
904
- process.exit(0);
904
+ exit(0);
905
}
906
}
907
}
@@ -916,7 +916,7 @@ function performAmtAgentPresenceEx5(stack, name, response, status, watchdog) {
916
amtstack.AMT_AgentPresenceWatchdog_AssertPresence(watchdog.Seq, performAmtAgentPresenceEx4, watchdog, 0, { 'DeviceID': watchdog.DeviceID });
917
} else {
918
console.log('Failed to assert presence on this watchdog.');
919
- process.exit(0);
919
+ exit(0);
920
}
921
}
922
}
@@ -2042,7 +2042,7 @@ function startRouter() {
2042
} else { options.headers = { 'host': options.host, 'x-meshauth': '*' }; } // Request inner authentication
2043
if (settings.loginkey) { xurlargs.push('key=' + settings.loginkey); }
2044
if (xurlargs.length > 0) { options.path += '?' + xurlargs.join('&'); }
2045
- } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; }
2045
+ } catch (e) { console.log("Unable to parse \"serverUrl\"."); exit(1); return; }
2046
2047
debug(1, "Connecting to " + options.host + ".");
2048
debug(1, "Connection options: " + JSON.stringify(options) + ".");
@@ -2050,8 +2050,8 @@ function startRouter() {
2050
options.rejectUnauthorized = false;
2051
settings.websocket = http.request(options);
2052
settings.websocket.upgrade = OnServerWebSocket;
2053
- settings.websocket.on('error', function (ex) { console.log("Unable to connect to server: " + JSON.stringify(ex)); process.exit(1); return; });
2054
- settings.websocket.on('response', function (rsp) { console.log("Unable to connect to server: " + rsp.statusMessage + " (" + rsp.statusCode + ")"); process.exit(1); return; });
2053
+ settings.websocket.on('error', function (ex) { console.log("Unable to connect to server: " + JSON.stringify(ex)); exit(1); return; });
2054
+ settings.websocket.on('response', function (rsp) { console.log("Unable to connect to server: " + rsp.statusMessage + " (" + rsp.statusCode + ")"); exit(1); return; });
2055
settings.websocket.end();
2056
}
2057
@@ -2083,7 +2083,7 @@ function OnServerWebSocket(msg, s, head) {
2083
console.log("Invalid username/password.");
2084
}
2085
} else { console.log("Server disconnected: " + command.msg); }
2086
- process.exit(1);
2086
+ exit(1);
2087
return;
2088
}
2089
case 'serverinfo': {
@@ -2107,11 +2107,11 @@ function OnServerWebSocket(msg, s, head) {
2107
var hasher = require('SHA384Stream').create();
2108
var certDer = Buffer.from(command.cert, 'base64');
2109
var cert = require('tls').loadCertificate({ der: certDer });
2110
- if (cert.getKeyHash().toString('hex') != settings.serverid) { console.log("Unable to authenticate the server, invalid server identifier."); process.exit(1); return; }
2110
+ if (cert.getKeyHash().toString('hex') != settings.serverid) { console.log("Unable to authenticate the server, invalid server identifier."); exit(1); return; }
2111
2112
// Hash the signed data and verify the server signature
2113
var signDataHash = hasher.syncHash(Buffer.concat([Buffer.from(settings.serverAuthClientNonce, 'base64'), Buffer.from(settings.meshServerTlsHash, 'hex'), Buffer.from(command.nonce, 'base64')]));
2114
- if (require('RSA').verify(require('RSA').TYPES.SHA384, cert, signDataHash, Buffer.from(command.signature, 'base64')) == false) { console.log("Unable to authenticate the server, invalid signature."); process.exit(1); return; }
2114
+ if (require('RSA').verify(require('RSA').TYPES.SHA384, cert, signDataHash, Buffer.from(command.signature, 'base64')) == false) { console.log("Unable to authenticate the server, invalid signature."); exit(1); return; }
2115
debug(1, "Authenticated the server.");
2116
2117
// Switch to using HTTPS TLS certificate for authentication
@@ -2143,8 +2143,8 @@ function OnServerWebSocket(msg, s, head) {
2143
}
2144
}
2145
});
2146
- s.on('error', function () { console.log("Server connection error."); process.exit(1); return; });
2147
- s.on('close', function () { console.log("Server closed the connection."); process.exit(1); return; });
2146
+ s.on('error', function () { console.log("Server connection error."); exit(1); return; });
2147
+ s.on('close', function () { console.log("Server closed the connection."); exit(1); return; });
2148
2149
// Perform inner server authentication
2150
if (settings.serverid != null) {
@@ -2183,7 +2183,7 @@ function OnTcpClientConnected(c) {
2183
var options;
2184
try {
2185
options = http.parseUri(settings.serverurl + '?auth=' + settings.acookie + '&nodeid=' + settings.remotenodeid + '&tcpport=' + settings.remoteport + (settings.remotetarget == null ? '' : '&tcpaddr=' + settings.remotetarget));
2186
- } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; }
2186
+ } catch (e) { console.log("Unable to parse \"serverUrl\"."); exit(1); return; }
2187
options.checkServerIdentity = onVerifyServer;
2188
options.rejectUnauthorized = false;
2189
c.websocket = http.request(options);
@@ -2270,12 +2270,12 @@ iderIdleTimer = null;
2270
2271
// Perform IDER
2272
function performIder() {
2273
- if ((settings.floppy != null) && fs.existsSync(settings.floppy) == false) { console.log("Unable to floppy image file: " + settings.floppy); process.exit(); return; }
2274
- if ((settings.cdrom != null) && fs.existsSync(settings.cdrom) == false) { console.log("Unable to CDROM image file: " + settings.cdrom); process.exit(); return; }
2273
+ if ((settings.floppy != null) && fs.existsSync(settings.floppy) == false) { console.log("Unable to floppy image file: " + settings.floppy); exit(); return; }
2274
+ if ((settings.cdrom != null) && fs.existsSync(settings.cdrom) == false) { console.log("Unable to CDROM image file: " + settings.cdrom); exit(); return; }
2275
try {
2276
var sfloppy = null, scdrom = null;
2277
- if (settings.floppy) { try { if (sfloppy = fs.statSync(settings.floppy)) { sfloppy.file = fs.openSync(settings.floppy, 'rbN'); } } catch (ex) { console.log(ex); process.exit(1); return; } }
2278
- if (settings.cdrom) { try { scdrom = fs.statSync(settings.cdrom); if (scdrom) { scdrom.file = fs.openSync(settings.cdrom, 'rbN'); } } catch (ex) { console.log(ex); process.exit(1); return; } }
2277
+ if (settings.floppy) { try { if (sfloppy = fs.statSync(settings.floppy)) { sfloppy.file = fs.openSync(settings.floppy, 'rbN'); } } catch (ex) { console.log(ex); exit(1); return; } }
2278
+ if (settings.cdrom) { try { scdrom = fs.statSync(settings.cdrom); if (scdrom) { scdrom.file = fs.openSync(settings.cdrom, 'rbN'); } } catch (ex) { console.log(ex); exit(1); return; } }
2279
2280
ider = require('amt-redir-duk')(require('amt-ider')());
2281
ider.onStateChanged = onIderStateChange;
@@ -2294,7 +2294,7 @@ function onIderStateChange(stack, state) { console.log(["Disconnected", "Connect
2294
2295
function iderSectorStats(mode, dev, mediaBlocks, lba, len) {
2296
if (iderIdleTimer != null) { clearTimeout(iderIdleTimer); }
2297
- iderIdleTimer = setTimeout(function () { console.log("Idle timeout"); process.exit(1); }, 1000 * settings.timeout);
2297
+ iderIdleTimer = setTimeout(function () { console.log("Idle timeout"); exit(1); }, 1000 * settings.timeout);
2298
}
2299
2300
//
@@ -2352,8 +2352,8 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2352
else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2353
// Change to STATIC
2354
x['DHCPEnabled'] = false;
2355
- if (args.ip) { x['IPAddress'] = args.ip; } else { console.log("Missing IPv4 address, use --ip 1.2.3.4"); process.exit(1); }
2356
- if (args.subnet) { x['SubnetMask'] = args.subnet; } else { console.log("Missing IPv4 subnet, use --subnet 255.255.255.0"); process.exit(1); }
2355
+ if (args.ip) { x['IPAddress'] = args.ip; } else { console.log("Missing IPv4 address, use --ip 1.2.3.4"); exit(1); }
2356
+ if (args.subnet) { x['SubnetMask'] = args.subnet; } else { console.log("Missing IPv4 subnet, use --subnet 255.255.255.0"); exit(1); }
2357
if (args.gateway) { x['DefaultGateway'] = args.gateway; }
2358
if (args.dns) { x['PrimaryDNS'] = args.dns; }
2359
if (args.dns2) { x['SecondaryDNS'] = args.dns2; }
@@ -2400,11 +2400,11 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2400
}
2401
}
2402
}
2403
- process.exit(0);
2403
+ exit(0);
2404
}
2405
} else {
2406
console.log("Error, status " + status + ".");
2407
- process.exit(1);
2407
+ exit(1);
2408
}
2409
}
2410
@@ -2450,7 +2450,7 @@ function performAmtWifiConfig1(stack, name, response, status, args) {
2450
var w = wifiProfiles[t];
2451
console.log('Profile Name: ' + t + '; Priority: ' + w['Priority'] + '; SSID: ' + w['SSID'] + '; Security: ' + wifiAuthMethod[w['AuthenticationMethod']] + '/' + wifiEncMethod[w['EncryptionMethod']]);
2452
}
2453
- process.exit(0);
2453
+ exit(0);
2454
} else if (args.add) {
2455
if (args.auth == null) { args.auth = 6; } // if not set, default to WPA2 PSK
2456
if (args.enc == null) { args.enc = 3; } // if not set, default to TKIP
@@ -2480,12 +2480,12 @@ function performAmtWifiConfig1(stack, name, response, status, args) {
2480
} else {
2481
console.log("Failed to add wifi profile " + args.name + ".");
2482
}
2483
- process.exit(0);
2483
+ exit(0);
2484
});
2485
} else if (args.del) {
2486
if (wifiProfiles[args.name] == null) {
2487
console.log("Profile " + args.name + " could not be found.");
2488
- process.exit(0);
2488
+ exit(0);
2489
}
2490
stack.Delete('CIM_WiFiEndpointSettings', { InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + args.name },
2491
function (stck, nm, resp, sts) {
@@ -2494,16 +2494,16 @@ function performAmtWifiConfig1(stack, name, response, status, args) {
2494
} else {
2495
console.log("Failed to delete wifi profile " + args.name + ".");
2496
}
2497
- process.exit(0);
2497
+ exit(0);
2498
},
2499
0, 1);
2500
}
2501
} else {
2502
- process.exit(0);
2502
+ exit(0);
2503
}
2504
} else {
2505
console.log("Error, status " + status + ".");
2506
- process.exit(1);
2506
+ exit(1);
2507
}
2508
}
2509
@@ -2557,7 +2557,7 @@ function performAmtWakeConfig0(state, args) {
2557
function performAmtWakeConfig1(stack, name, response, status, args) {
2558
if (status == 200) {
2559
var response = response['IPS_AlarmClockOccurrence'].responses;
2560
- if (!args) { process.exit(0); return; }
2560
+ if (!args) { exit(0); return; }
2561
if (args.list) {
2562
if (response.length == 0) {
2563
console.log('No wake alarms.');
@@ -2572,24 +2572,24 @@ function performAmtWakeConfig1(stack, name, response, status, args) {
2572
console.log(details);
2573
}
2574
}
2575
- process.exit(0);
2575
+ exit(0);
2576
} else if (args.del) {
2577
// Remove a wake alarm, start by looking to see if it exists
2578
var alarmFound = false;
2579
for (var i = 0; i < response.length; i++) { if (response[i]['ElementName'] == args.del) { alarmFound = true; } }
2580
- if (alarmFound == false) { console.log("Wake alarm " + args.del + " could not be found."); process.exit(0); return; }
2580
+ if (alarmFound == false) { console.log("Wake alarm " + args.del + " could not be found."); exit(0); return; }
2581
// Remote the alarm
2582
stack.Delete('IPS_AlarmClockOccurrence', { InstanceID: args.del },
2583
function (stck, nm, resp, sts) {
2584
if (sts == 200) { console.log("Done."); } else { console.log("Failed to delete wake alarm " + args.del + "."); }
2585
- process.exit(0);
2585
+ exit(0);
2586
},
2587
0, 1);
2588
} else if (args.add) {
2589
// Add a wake alarm
2590
var alarmFound = false;
2591
for (var i = 0; i < response.length; i++) { if (response[i]['ElementName'] == args.add) { alarmFound = true; } }
2592
- if (alarmFound) { console.log("Wake alarm " + args.add + " already exists."); process.exit(0); return; }
2592
+ if (alarmFound) { console.log("Wake alarm " + args.add + " already exists."); exit(0); return; }
2593
if (typeof args.time != 'string') { args.time = '00:00:00'; }
2594
if (typeof args.interval != 'string') { args.interval = ''; }
2595
var alarm_name = args.add;
@@ -2607,16 +2607,16 @@ function performAmtWakeConfig1(stack, name, response, status, args) {
2607
if (status != 200) { console.log("Failed to add alarm. Status: " + status + ". Verify the alarm is for a future time."); }
2608
else if (response.Body['ReturnValue'] != 0) { console.log("Failed to add alarm " + response.Body['ReturnValueStr'] + ". Verify the alarm is for a future time."); }
2609
else { console.log("Done."); }
2610
- process.exit(0);
2610
+ exit(0);
2611
}
2612
);
2613
} else {
2614
console.log("Unknown action, specify --list, --del or --add.");
2615
- process.exit(0);
2615
+ exit(0);
2616
}
2617
} else {
2618
console.log("Error, status " + status + ".");
2619
- process.exit(1);
2619
+ exit(1);
2620
}
2621
}
2622
@@ -2626,6 +2626,7 @@ function performAmtWakeConfig1(stack, name, response, status, args) {
2626
//
2627
2628
function performAmtPlatformErase(args) {
2629
+ if (!settings.tls) { console.log("Remote Platfrom Erase (RPE) is only supported over TLS, add --tls"); exit(1); return; }
2630
var transport = require('amt-wsman-duk');
2631
var wsman = require('amt-wsman');
2632
var amt = require('amt');
@@ -2639,7 +2640,7 @@ function performAmtPlatformErase1(stack, name, response, status, args) {
2640
if (status == 200) {
2641
// See that RPE featues are supported
2642
var platfromEraseSupport = response['AMT_BootCapabilities'].response['PlatformErase'];
2642
- if (platfromEraseSupport == null) { console.log("Remote Platfrom Erase (RPE) is not supported on this platform"); process.exit(1); return; }
2643
+ if (platfromEraseSupport == null) { console.log("Remote Platfrom Erase (RPE) is not supported on this platform"); exit(1); return; }
2644
var supportedRpeFeatures = [];
2645
if (platfromEraseSupport == 0) { supportedRpeFeatures.push("None"); } else {
2646
if (platfromEraseSupport & (1 << 1)) { supportedRpeFeatures.push("Pyrite Revert (--pyrite)"); }
@@ -2649,7 +2650,7 @@ function performAmtPlatformErase1(stack, name, response, status, args) {
2650
if (platfromEraseSupport & (1 << 26)) { supportedRpeFeatures.push("BIOS Reload of Golden Configuration (--bios)"); }
2651
if (platfromEraseSupport & (1 << 31)) { supportedRpeFeatures.push("CSME Unconfigure (--csme)"); }
2652
}
2652
- console.log("RPE Supported Features: " + supportedRpeFeatures.join(", "));
2653
+ console.log("RPE supported features: " + supportedRpeFeatures.join(", "));
2654
2655
// Compute requested operations flags
2656
var rpeflags = 0;
@@ -2659,44 +2660,57 @@ function performAmtPlatformErase1(stack, name, response, status, args) {
2660
if (args.nvm) { rpeflags += (1 << 25); }
2661
if (args.bios) { rpeflags += (1 << 26); }
2662
if (args.csme) { rpeflags += (1 << 31); }
2662
- if (rpeflags == 0) { process.exit(1); return; }
2663
- if ((rpeflags | platfromEraseSupport) != platfromEraseSupport) { console.log("Unable to perform unsupported RPE operation."); process.exit(1); return; }
2663
+ if (rpeflags == 0) { exit(1); return; }
2664
+ if ((rpeflags | platfromEraseSupport) != platfromEraseSupport) { console.log("Unable to perform unsupported RPE operation."); exit(1); return; }
2665
settings.rpeflags = rpeflags;
2666
settings.powerAction = 0;
2667
if (args.reset) { settings.powerAction = 10; } else if (args.poweron) { settings.powerAction = 2; }
2667
- if (settings.powerAction == 0) { console.log("--reset or --poweron is required to perform RPE action."); process.exit(1); return; }
2668
+ if (settings.powerAction == 0) { console.log("--reset or --poweron is required to perform RPE action."); exit(1); return; }
2669
2670
// See if OCR and RPE are enabled
2671
var enabledState = response['CIM_BootService'].response['EnabledState'];
2671
- var enabledBootStateStr = { 0: "Unknown", 1: "Other", 2: "Enabled", 3: "Disabled", 4: "Shutting Down", 5: "Not Applicable", 6: "Enabled but Offline", 7: "In Test", 8: "Deferred", 9: "Quiesce", 10: "Starting", 32768: "RPE Disabled", 32769: "All Enabled", 32770: "RPE & OCR Disabled" };
2672
+ var enabledBootStateStr = { 0: "Unknown", 1: "Other", 2: "Enabled", 3: "Disabled", 4: "Shutting Down", 5: "Not Applicable", 6: "Enabled but Offline", 7: "In Test", 8: "Deferred", 9: "Quiesce", 10: "Starting", 32768: "OCR & RPE Disabled", 32769: "OCR Enabled, RPE Disabled", 32770: "OCR Disabled, RPE Enabled", 32771: "OCR Enabled, RPE Enabled" };
2673
var t = enabledBootStateStr[enabledState] ? enabledBootStateStr[enabledState] : ("Unknown, #" + enabledState);
2673
- console.log("BootService Enabled State: " + t);
2674
-
2675
- if (enabledState != 32769) {
2676
- // Enabled OCR and RPE
2677
- console.log("Enabling OCR and RPE features...");
2678
- amtstack.CIM_BootService_RequestStateChange(32769, null, performAmtPlatformErase2);
2674
+ console.log("BootService enabled state: " + t);
2675
+
2676
+ var newEnabledState = enabledState;
2677
+ if (newEnabledState < 32768) { newEnabledState = 32768; }
2678
+ if ((newEnabledState & 2) == 0) {
2679
+ // Enabled RPE
2680
+ newEnabledState |= 2;
2681
+ console.log("Enabling RPE features...");
2682
+ amtstack.CIM_BootService_RequestStateChange(32771, null, performAmtPlatformErase2, args);
2683
} else {
2684
performAmtPlatformErase3(args);
2685
}
2682
- } else { console.log("Error, status " + status + "."); process.exit(1); }
2686
+ } else { console.log("Error, status " + status + "."); exit(1); }
2687
}
2688
2689
function performAmtPlatformErase2(stack, name, response, status, args) {
2690
debug(0, "performAmtPlatformErase2(" + status + "): " + JSON.stringify(response, null, 2));
2691
if (status == 200) {
2688
- if (response.Body['ReturnValueStr'] != 'SUCCESS') { console.log("Error, " + response.Body['ReturnValueStr'] + "."); process.exit(1); }
2689
- else { performAmtPlatformErase3(args); }
2690
- process.exit(0);
2691
- } else { console.log("Error, status " + status + "."); process.exit(1); }
2692
+ if (response.Body['ReturnValueStr'] != 'SUCCESS') { console.log("Error, " + response.Body['ReturnValueStr'] + "."); exit(1); }
2693
+ else { console.log("Checking enabled RPE state..."); amtstack.BatchEnum(null, ['*CIM_BootService'], performAmtPlatformErase2b, args); }
2694
+ } else { console.log("Error, status " + status + "."); exit(1); }
2695
+}
2696
+
2697
+function performAmtPlatformErase2b(stack, name, response, status, args) {
2698
+ debug(0, "performAmtPlatformErase2b(" + status + "): " + JSON.stringify(response, null, 2));
2699
+ if (status == 200) {
2700
+ // See if OCR and RPE are enabled
2701
+ var enabledState = response['CIM_BootService'].response['EnabledState'];
2702
+ if (enabledState < 32768) { enabledState = 32768; }
2703
+ if ((enabledState & 2) == 0) { console.log("RPE can't be enabled, check RPE is enabled in BIOS."); exit(1); } else { performAmtPlatformErase3(args); }
2704
+ } else { console.log("Error, status " + status + "."); exit(1); }
2705
}
2706
2707
function performAmtPlatformErase3(args) {
2708
+ //debug(0, "performAmtPlatformErase3(" + status + "): " + JSON.stringify(response, null, 2));
2709
var tlv = makeUefiBootParam(1, settings.rpeflags, 4), tlvlen = 1;
2710
if ((settings.rpeflags & 2) && (typeof args.pyrite == 'string')) { tlv += makeUefiBootParam(10, args.pyrite); tlvlen++; }
2711
if ((settings.rpeflags & 4) && (typeof args.ssd == 'string')) { tlv += makeUefiBootParam(20, args.ssd); tlvlen++; }
2712
settings.platfromEraseTLV = { tlv: Buffer.from(tlv, 'binary').toString('base64'), tlvlen: tlvlen };
2699
- debug(0, "platfromEraseTLV: " + JSON.stringify(r, null, 2));
2713
+ debug(0, "platfromEraseTLV: " + JSON.stringify(settings.platfromEraseTLV, null, 2));
2714
console.log("Fetching boot information...");
2715
amtstack.Get('AMT_BootSettingData', performAmtPlatformErase4, 0, 1);
2716
}
@@ -2709,40 +2723,40 @@ function performAmtPlatformErase4(stack, name, response, status, args) {
2723
r['UefiBootParametersArray'] = settings.platfromEraseTLV.tlv;
2724
r['UefiBootNumberOfParams'] = settings.platfromEraseTLV.tlvlen;
2725
debug(0, "BootConfig: " + JSON.stringify(r, null, 2));
2712
- console.log("Setting Boot Order...");
2726
+ console.log("Setting boot order...");
2727
amtstack.CIM_BootConfigSetting_ChangeBootOrder(null, function (stack, name, response, status) {
2714
- if (status != 200) { console.log("PUT CIM_BootConfigSetting_ChangeBootOrder, Error #" + status + ((response.Header && response.Header.WsmanError) ? (', ' + response.Header.WsmanError) : '')); process.exit(1); return; }
2715
- if (response.Body['ReturnValue'] != 0) { messagebox("Error, Change Boot Order returns " + response.Body.ReturnValueStr); process.exit(1); return; }
2728
+ if (status != 200) { console.log("PUT CIM_BootConfigSetting_ChangeBootOrder, error #" + status + ((response.Header && response.Header.WsmanError) ? (', ' + response.Header.WsmanError) : '')); exit(1); return; }
2729
+ if (response.Body['ReturnValue'] != 0) { messagebox("Error, change boot order returns " + response.Body.ReturnValueStr); exit(1); return; }
2730
amtstack.Put('AMT_BootSettingData', r, performAmtPlatformErase5, 0, 1);
2731
}, 0, 1);
2718
- } else { console.log("Error, status " + status + "."); process.exit(1); }
2732
+ } else { console.log("Error, status " + status + "."); exit(1); }
2733
}
2734
2735
function performAmtPlatformErase5(stack, name, response, status, args) {
2736
debug(0, "performAmtPlatformErase5(" + status + "): " + JSON.stringify(response, null, 2));
2737
if (status == 200) {
2724
- console.log("Setting Boot Configuration Role...");
2738
+ console.log("Setting boot configuration role...");
2739
amtstack.SetBootConfigRole(1, performAmtPlatformErase6, 0, 1);
2726
- } else { console.log("Error, status " + status + "."); process.exit(1); }
2740
+ } else { console.log("Error, status " + status + "."); exit(1); }
2741
}
2742
2743
function performAmtPlatformErase6(stack, name, response, status, args) {
2744
debug(0, "performAmtPlatformErase6(" + status + "): " + JSON.stringify(response, null, 2));
2745
if (status == 200) {
2732
- if (response.Body['ReturnValueStr'] != 'SUCCESS') { console.log("Error, " + response.Body['ReturnValueStr'] + "."); process.exit(1); }
2746
+ if (response.Body['ReturnValueStr'] != 'SUCCESS') { console.log("Error, " + response.Body['ReturnValueStr'] + "."); exit(1); }
2747
else {
2748
console.log('Performing power state change...');
2749
amtstack.RequestPowerStateChange(settings.powerAction, performAmtPlatformErase7); // 2 = Power Up, 10 = Reset
2750
}
2737
- } else { console.log("Error, status " + status + "."); process.exit(1); }
2751
+ } else { console.log("Error, status " + status + "."); exit(1); }
2752
}
2753
2754
function performAmtPlatformErase7(stack, name, response, status, args) {
2755
debug(0, "performAmtPlatformErase7(" + status + "): " + JSON.stringify(response, null, 2));
2756
if (status == 200) {
2743
- if (response.Body['ReturnValueStr'] != 'SUCCESS') { console.log("Error, " + response.Body['ReturnValueStr'] + "."); process.exit(1); } else { console.log('Done.'); }
2744
- process.exit(0);
2745
- } else { console.log("Error, status " + status + "."); process.exit(1); }
2757
+ if (response.Body['ReturnValueStr'] != 'SUCCESS') { console.log("Error, " + response.Body['ReturnValueStr'] + "."); exit(1); } else { console.log('Done.'); }
2758
+ exit(0);
2759
+ } else { console.log("Error, status " + status + "."); exit(1); }
2760
}
2761
2762
@@ -2836,11 +2850,11 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2850
console.log("Serial-over-LAN : " + (sol ? "Enabled" : "Disabled"));
2851
console.log("IDE Redirection : " + (ider ? "Enabled" : 'Disabled'));
2852
if (response['CIM_KVMRedirectionSAP'] != null) { console.log("Remote desktop (KVM) : " + (kvm ? "Enabled" : "Disabled")); }
2839
- process.exit(0);
2853
+ exit(0);
2854
}
2855
} else {
2856
console.log("Error, status " + status + ".");
2843
- process.exit(1);
2857
+ exit(1);
2858
}
2859
}
2860
@@ -2937,10 +2951,10 @@ function powerActionResponse3(stack, name, response, status) {
2951
function performAmtPowerActionEx(stack, name, response, status) {
2952
if (status == 200) {
2953
console.log(response.Body.ReturnValueStr.split('_').join(' '));
2940
- process.exit(0);
2954
+ exit(0);
2955
} else {
2956
console.log("Error, status " + status + ".");
2943
- process.exit(1);
2957
+ exit(1);
2958
}
2959
}
2960
@@ -2953,10 +2967,10 @@ function performAmtPowerActionEx2(stack, name, response, status) {
2967
} else {
2968
console.log("Current power state: " + DMTFPowerStates[powerNumber]);
2969
}
2956
- process.exit(0);
2970
+ exit(0);
2971
} else {
2972
console.log("Error, status " + status + ".");
2959
- process.exit(1);
2973
+ exit(1);
2974
}
2975
}
2976
@@ -3065,7 +3079,7 @@ if (serviceName == null) {
3079
if (process.execPath.includes('MicroLMS')) { serviceName = 'MicroLMS'; }
3080
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
3081
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
3068
- if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
3082
+ if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); exit(); } } }
3083
if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("Run() error: " + e); } }
3084
} else {
3085
var serviceHost = require('service-host');
@@ -3082,11 +3096,11 @@ if (serviceName == null) {
3096
if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
3097
else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
3098
else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
3085
- else { console.log("Aborting Service Start, because unknown binary: " + process.execPath); process.exit(1); }
3099
+ else { console.log("Aborting Service Start, because unknown binary: " + process.execPath); exit(1); }
3100
});
3101
3102
// Called when the background service is stopping
3089
- meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
3103
+ meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); exit(0); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
3104
3105
// Called when the executable is not running as a service, run normally.
3106
meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("onNormalStart() error: " + e); } });
agents/modules_meshcmd/amt.js
+1
-1
@@ -300,7 +300,7 @@ function AmtStackCreateService(wsmanStack) {
300
obj.CIM_AccountManagementService_CreateAccount = function (System, AccountTemplate, callback_func) { obj.Exec("CIM_AccountManagementService", "CreateAccount", { "System": System, "AccountTemplate": AccountTemplate }, callback_func); }
301
obj.CIM_BootConfigSetting_ChangeBootOrder = function (Source, callback_func) { obj.Exec("CIM_BootConfigSetting", "ChangeBootOrder", { "Source": Source }, callback_func); }
302
obj.CIM_BootService_SetBootConfigRole = function (BootConfigSetting, Role, callback_func) { obj.Exec("CIM_BootService", "SetBootConfigRole", { "BootConfigSetting": BootConfigSetting, "Role": Role }, callback_func, 0, 1); }
303
- obj.CIM_BootService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec('CIM_BootService', 'RequestStateChange', { 'RequestedState': RequestedState, 'TimeoutPeriod': TimeoutPeriod }, callback_func, 0, 1); }
303
+ obj.CIM_BootService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func, tag) { obj.Exec('CIM_BootService', 'RequestStateChange', { 'RequestedState': RequestedState, 'TimeoutPeriod': TimeoutPeriod }, callback_func, tag, 1); }
304
obj.CIM_Card_ConnectorPower = function (Connector, PoweredOn, callback_func) { obj.Exec("CIM_Card", "ConnectorPower", { "Connector": Connector, "PoweredOn": PoweredOn }, callback_func); }
305
obj.CIM_Card_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Card", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
306
obj.CIM_Chassis_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Chassis", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
meshuser.js
+11
-11
@@ -71,16 +71,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
71
const SITERIGHT_ADMIN = 0xFFFFFFFF;
72
73
// Protocol Numbers
74
- const PROTOCOL_TERMINAL = 1;
75
- const PROTOCOL_DESKTOP = 2;
76
- const PROTOCOL_FILES = 5;
77
- const PROTOCOL_AMTWSMAN = 100;
78
- const PROTOCOL_AMTREDIR = 101;
79
- const PROTOCOL_MESSENGER = 200;
80
- const PROTOCOL_WEBRDP = 201;
81
- const PROTOCOL_WEBSSH = 202;
82
- const PROTOCOL_WEBSFTP = 203;
83
- const PROTOCOL_WEBVNC = 204;
74
+ const PROTOCOL_TERMINAL = 1;
75
+ const PROTOCOL_DESKTOP = 2;
76
+ const PROTOCOL_FILES = 5;
77
+ const PROTOCOL_AMTWSMAN = 100;
78
+ const PROTOCOL_AMTREDIR = 101;
79
+ const PROTOCOL_MESSENGER = 200;
80
+ const PROTOCOL_WEBRDP = 201;
81
+ const PROTOCOL_WEBSSH = 202;
82
+ const PROTOCOL_WEBSFTP = 203;
83
+ const PROTOCOL_WEBVNC = 204;
84
85
// Events
86
/*
@@ -3550,7 +3550,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3550
// Mesh Agent power command, get this device and send the power command
3551
const agent = parent.wsagents[node._id];
3552
if (agent != null) {
3553
- try { agent.send(JSON.stringify({ action: 'poweraction', actiontype: command.actiontype })); } catch (ex) { }
3553
+ try { agent.send(JSON.stringify({ action: 'poweraction', actiontype: command.actiontype, userid: user._id, username: user.name, remoteaddr: req.clientIp })); } catch (ex) { }
3554
}
3555
}
3556
}