Skip to content

Commit

Permalink
0005200: Allow specification of local user/password for running Windows
Browse files Browse the repository at this point in the history
service
  • Loading branch information
Philip Marzullo committed Jan 20, 2022
1 parent dd6592d commit 71a7af4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions symmetric-server/src/main/deploy/conf/sym_service.conf
Expand Up @@ -92,6 +92,7 @@ wrapper.displayname=SymmetricDS
wrapper.description=Database Synchronization

wrapper.run.as.user=
wrapper.run.as.password=

#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
Expand Down
Expand Up @@ -345,10 +345,18 @@ public void install() {
}
dependencies = sb.append("\0").toString();
}
String runAsUser = config.getRunAsUser();
if (runAsUser != null && runAsUser.trim().length() == 0) {
runAsUser = null;
}
String runAsPassword = config.getRunAsPassword();
if (runAsPassword != null && runAsPassword.trim().length() == 0) {
runAsPassword = null;
}
service = advapi.CreateService(manager, config.getName(), config.getDisplayName(), Winsvc.SERVICE_ALL_ACCESS,
WinsvcEx.SERVICE_WIN32_OWN_PROCESS, config.isAutoStart() || config.isDelayStart() ? WinsvcEx.SERVICE_AUTO_START
: WinsvcEx.SERVICE_DEMAND_START, WinsvcEx.SERVICE_ERROR_NORMAL,
commandToString(getWrapperCommand("init", true)), null, null, dependencies, null, null);
commandToString(getWrapperCommand("init", true)), null, null, dependencies, runAsUser, runAsPassword);
if (service != null) {
Advapi32Ex.SERVICE_DESCRIPTION desc = new Advapi32Ex.SERVICE_DESCRIPTION(config.getDescription());
advapi.ChangeServiceConfig2(service, WinsvcEx.SERVICE_CONFIG_DESCRIPTION, desc);
Expand Down
Expand Up @@ -148,6 +148,10 @@ public List<String> getOptions() {
public String getRunAsUser() {
return getProperty(prop, "wrapper.run.as.user", "");
}

public String getRunAsPassword() {
return getProperty(prop, "wrapper.run.as.password", "");
}

public List<String> getApplicationParameters() {
return getListProperty(prop, "wrapper.app.parameter");
Expand Down

0 comments on commit 71a7af4

Please sign in to comment.