Skip to content

Commit

Permalink
Moved allowServiceLogon to a confirguation option. See issue #266.
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Jul 29, 2020
1 parent 55f4940 commit 23eab8f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ var svc = new Service({
'--max_old_space_size=4096'
]
//, workingDirectory: '...'
//, allowServiceLogon: true
});

// Listen for the "install" event, which indicates the
Expand Down Expand Up @@ -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';
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
},
Expand Down
17 changes: 11 additions & 6 deletions lib/winsw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 23eab8f

Please sign in to comment.