Skip to content

Commit 23eab8f

Browse files
committed
Moved allowServiceLogon to a confirguation option. See issue #266.
1 parent 55f4940 commit 23eab8f

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ var svc = new Service({
9090
'--max_old_space_size=4096'
9191
]
9292
//, workingDirectory: '...'
93+
//, allowServiceLogon: true
9394
});
9495

9596
// Listen for the "install" event, which indicates the
@@ -205,7 +206,8 @@ var Service = require('node-windows').Service;
205206
// Create a new service object
206207
var svc = new Service({
207208
name:'Hello World',
208-
script: require('path').join(__dirname,'helloworld.js')
209+
script: require('path').join(__dirname,'helloworld.js'),
210+
//, allowServiceLogon: true
209211
});
210212

211213
svc.logOnAs.domain = 'mydomain.local';
@@ -218,6 +220,8 @@ Both the account and password must be explicitly defined if you want the service
218220
run commands as a specific user. By default, it will run using the user account that launched
219221
the process (i.e. who launched `node app.js`).
220222

223+
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.
224+
221225
The other attribute is `sudo`. This attribute has a single property called `password`. By supplying
222226
this, the service module will attempt to run commands using the user account that launched the
223227
process and the password for that account. This should only be used for accounts with administrative

lib/daemon.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ var daemon = function(config){
131131
stopparentfirst: this.stopparentfirst,
132132
stoptimeout: this.stoptimeout,
133133
logmode: this.logmode,
134-
logging: config.logging
134+
logging: config.logging,
135+
allowServiceLogon: config.allowServiceLogon
135136
});
136137
}
137138
},

lib/winsw.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,18 @@ module.exports = {
121121

122122
// optionally set the service logon credentials
123123
if (config.logOnAs) {
124+
var serviceaccount = [
125+
{ domain: config.logOnAs.domain || 'NT AUTHORITY' },
126+
{ user: config.logOnAs.account || 'LocalSystem' },
127+
{ password: config.logOnAs.password || '' }
128+
]
129+
130+
if (config.allowServiceLogon) {
131+
serviceaccount.push({ allowservicelogon: 'true' })
132+
}
133+
124134
xml.push({
125-
serviceaccount: [
126-
{domain: config.logOnAs.domain || 'NT AUTHORITY'},
127-
{user: config.logOnAs.account || 'LocalSystem'},
128-
{password: config.logOnAs.password || ''},
129-
{allowservicelogon: 'true'}
130-
]
135+
serviceaccount: serviceaccount
131136
});
132137
}
133138

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-windows",
3-
"version": "1.0.0-beta.4",
3+
"version": "1.0.0-beta.5",
44
"description": "Support for Windows services, event logging, UAC, and several helper methods for interacting with the OS.",
55
"keywords": [
66
"ngn",

0 commit comments

Comments
 (0)