Skip to content

3.0 alpha ignores serviceaccount value #646

@pashagolub

Description

@pashagolub

I'm trying to start PostgreSQL server with winsw. postgres process must be started under unprivileged user. This is the part of a greater task, so please ignore patroni names here. Right now the issue is to start postgres.

Steps to reproduce

<service>
	<id>patroni</id>
	<name>Patroni HA Windows Service</name>
	<description>Patroni high-availability solution using Python and etcd</description>
	<executable>C:\Users\pasha\Code\pgsql\bin\postgres.exe</executable>
	<arguments>-D C:\Users\pasha\Code\pgsql\data</arguments>
	<stopparentprocessfirst>true</stopparentprocessfirst>
	<log mode="roll"></log>
	<logpath>%BASE%\log</logpath>
	<serviceaccount>
		<user>postgres</user>
		<password>12345</password>
		<allowservicelogon>true</allowservicelogon>
	</serviceaccount>
</service>
$ .\patroni_service.exe install
13:35:06,941 - Installing service 'Patroni HA Windows Service (patroni)'...
13:35:07,102 - Service 'Patroni HA Windows Service (patroni)' was installed successfully.
$ sc qc patroni
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: patroni
        TYPE               : 10  WIN32_OWN_PROCESS
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "C:\PES\patroni_service.exe"
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : Patroni HA Windows Service
        DEPENDENCIES       :
        SERVICE_START_NAME : LocalSystem

I'm not sure if this is correct SERVICE_START_NAME : LocalSystem, I'm waiting for something like SERVICE_START_NAME : postgres

When I'm trying to start:

$ .\patroni_service.exe start
13:42:56,990 - Starting service 'Patroni HA Windows Service (patroni)'...
13:42:58,599 - Failed to start the service.

Log:

2020-08-13 14:08:59,573 INFO  - Starting service 'Patroni HA Windows Service (patroni)'...
2020-08-13 14:09:00,072 DEBUG - Starting WinSW in service mode.
2020-08-13 14:09:00,112 INFO  - Starting C:\Users\pasha\Code\pgsql\bin\postgres.exe
2020-08-13 14:09:00,208 INFO  - Started process postgres (9656).
2020-08-13 14:09:00,216 ERROR - Failed to start service.
System.InvalidOperationException: Cannot process request because the process (9656) has exited.
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access)
   at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
   at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
   at WinSW.WrapperService.StartProcess(String executable, String arguments, LogHandler logHandler, Action`1 onExited)
   at WinSW.WrapperService.DoStart()
   at WinSW.WrapperService.OnStart(String[] args)
2020-08-13 14:09:00,288 FATAL - Unhandled exception
System.InvalidOperationException: Cannot process request because the process (9656) has exited.
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access)
   at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
   at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
   at WinSW.WrapperService.StartProcess(String executable, String arguments, LogHandler logHandler, Action`1 onExited)
   at WinSW.WrapperService.DoStart()
   at WinSW.WrapperService.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.ServiceProcess.ServiceBase.Run(ServiceBase[] services)
   at System.ServiceProcess.ServiceBase.Run(ServiceBase service)
   at WinSW.Program.<>c.<Main>b__6_14(String pathToConfig)
2020-08-13 14:09:01,144 FATAL - Failed to start the service.

Event Log:

Execution of PostgreSQL by a user with administrative permissions is not  permitted. 
The server must be started under an unprivileged user ID to prevent  possible system security compromises. 
See the documentation for more information  on how to properly start the server.
--

Environment

  • WinSW version: v3.0.0-alpha.3
  • WinSW package type: WinSW.NETCore.x64.exe
  • Windows version: 10
  • Wrapped executable and version: postgres.exe (PostgreSQL 13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions