Fixed syslogauth feature.
Ylian Saint-Hilaire committed
Apr 20, 2020 at 11:43 UTC
0244e7d139a47f8a18f61265797b7728961e5672
1 file changed
+5
-4
meshcentral.js
+5
-4
@@ -623,6 +623,7 @@ function CreateMeshCentralServer(config, args) {
623
obj.syslogjson.log(obj.syslogjson.LOG_INFO, "MeshCentral v" + getCurrentVerion() + " Server Start");
624
}
625
if (typeof config.settings.syslogauth == 'string') {
626
+ obj.authlog = true;
627
obj.syslogauth = require('modern-syslog');
628
console.log('Starting ' + config.settings.syslogauth + ' auth syslog.');
629
obj.syslogauth.init(config.settings.syslogauth, obj.syslogauth.LOG_PID | obj.syslogauth.LOG_ODELAY, obj.syslogauth.LOG_LOCAL0);
@@ -946,7 +947,7 @@ function CreateMeshCentralServer(config, args) {
947
// Linux format /var/log/auth.log
948
if (obj.config.settings.authlog != null) {
949
obj.fs.open(obj.config.settings.authlog, 'a', function (err, fd) {
949
- if (err == null) { obj.authlog = fd; } else { console.log('ERROR: Unable to open: ' + obj.config.settings.authlog); }
950
+ if (err == null) { obj.authlogfile = fd; obj.authlog = true; } else { console.log('ERROR: Unable to open: ' + obj.config.settings.authlog); }
951
})
952
}
953
@@ -2320,12 +2321,12 @@ function CreateMeshCentralServer(config, args) {
2321
// auth.log functions
2322
obj.authLog = function (server, msg) {
2323
if (typeof msg != 'string') return;
2323
- if (obj.syslogauth) { try { obj.syslogauth.log(obj.syslogauth.LOG_INFO, msg); } catch (ex) { } }
2324
- if (obj.authlog != null) { // Write authlog to file
2324
+ if (obj.syslogauth != null) { try { obj.syslogauth.log(obj.syslogauth.LOG_INFO, msg); } catch (ex) { } }
2325
+ if (obj.authlogfile != null) { // Write authlog to file
2326
try {
2327
var d = new Date(), month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()];
2328
var msg = month + ' ' + d.getDate() + ' ' + obj.common.zeroPad(d.getHours(), 2) + ':' + obj.common.zeroPad(d.getMinutes(), 2) + ':' + d.getSeconds() + ' meshcentral ' + server + '[' + process.pid + ']: ' + msg + ((obj.platform == 'win32') ? '\r\n' : '\n');
2328
- obj.fs.write(obj.authlog, msg, function (err, written, string) { });
2329
+ obj.fs.write(obj.authlogfile, msg, function (err, written, string) { });
2330
} catch (ex) { }
2331
}
2332
}