From 23eab8f3a81fc48e2ee58e0a31d4896680042077 Mon Sep 17 00:00:00 2001 From: Corey Butler Date: Wed, 29 Jul 2020 16:25:51 -0500 Subject: [PATCH] Moved allowServiceLogon to a confirguation option. See issue #266. --- README.md | 6 +++++- lib/daemon.js | 3 ++- lib/winsw.js | 17 +++++++++++------ package.json | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bd90486..9ffc7d5 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ var svc = new Service({ '--max_old_space_size=4096' ] //, workingDirectory: '...' + //, allowServiceLogon: true }); // Listen for the "install" event, which indicates the @@ -205,7 +206,8 @@ var Service = require('node-windows').Service; // Create a new service object var svc = new Service({ name:'Hello World', - script: require('path').join(__dirname,'helloworld.js') + script: require('path').join(__dirname,'helloworld.js'), + //, allowServiceLogon: true }); svc.logOnAs.domain = 'mydomain.local'; @@ -218,6 +220,8 @@ Both the account and password must be explicitly defined if you want the service run commands as a specific user. By default, it will run using the user account that launched the process (i.e. who launched `node app.js`). +If you want to instruct winsw to allow service account logins, specify `allowServiceLogon: true`. This is disabled by default since some users have experienced issues running this without service logons. + The other attribute is `sudo`. This attribute has a single property called `password`. By supplying this, the service module will attempt to run commands using the user account that launched the process and the password for that account. This should only be used for accounts with administrative diff --git a/lib/daemon.js b/lib/daemon.js index 97474d7..77acc51 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -131,7 +131,8 @@ var daemon = function(config){ stopparentfirst: this.stopparentfirst, stoptimeout: this.stoptimeout, logmode: this.logmode, - logging: config.logging + logging: config.logging, + allowServiceLogon: config.allowServiceLogon }); } }, diff --git a/lib/winsw.js b/lib/winsw.js index 3368020..8882ba8 100644 --- a/lib/winsw.js +++ b/lib/winsw.js @@ -121,13 +121,18 @@ module.exports = { // optionally set the service logon credentials if (config.logOnAs) { + var serviceaccount = [ + { domain: config.logOnAs.domain || 'NT AUTHORITY' }, + { user: config.logOnAs.account || 'LocalSystem' }, + { password: config.logOnAs.password || '' } + ] + + if (config.allowServiceLogon) { + serviceaccount.push({ allowservicelogon: 'true' }) + } + xml.push({ - serviceaccount: [ - {domain: config.logOnAs.domain || 'NT AUTHORITY'}, - {user: config.logOnAs.account || 'LocalSystem'}, - {password: config.logOnAs.password || ''}, - {allowservicelogon: 'true'} - ] + serviceaccount: serviceaccount }); } diff --git a/package.json b/package.json index 8e9b06e..050c778 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-windows", - "version": "1.0.0-beta.4", + "version": "1.0.0-beta.5", "description": "Support for Windows services, event logging, UAC, and several helper methods for interacting with the OS.", "keywords": [ "ngn",