Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the Windows service as a non-SYSTEM account #858

Open
rgl opened this issue Feb 11, 2024 · 3 comments
Open

Run the Windows service as a non-SYSTEM account #858

rgl opened this issue Feb 11, 2024 · 3 comments

Comments

@rgl
Copy link

rgl commented Feb 11, 2024

Unless I'm missing something, the DnsService Windows Services does not need to run as the SYSTEM account, as such, it should run as NT SERVICE\DnsService.

These types of accounts are automatically managed by Windows and do not need a password.

They also have a predictable SID in the form of S-1-5-80-<SHA-1(uppercase(service name))> (e.g. S-1-5-80-908493856-1104173099-1205760238-637266923-2292294691).

The gist to configure a Windows service to use then is:

sc.exe sidtype $serviceName unrestricted
sc.exe config $serviceName obj= "NT SERVICE\$serviceName"

The full example is at:

@ShreyasZare
Copy link
Member

Thanks for the suggestion. I tried it and the issue with it is that the service does not have privilege to create the C:\Program Files (x86)\Technitium\DNS Server\config folder thus it fails to start. Need to find a way to fix this to be able to use this.

@rgl
Copy link
Author

rgl commented Feb 12, 2024

That is normally done by the setup application, while executing as Administrator/SYSTEM. The setup application should create the directories with the appropriate permissions (e.g. prevent ACL propagation/inheritance from the parent directory, and grant Full Permission to SYSTEM, Administrators, and NT SERVICE\DnsService).

PS Probably the application should also be modified to write somewhere inside C:\ProgramData (e.g. C:\ProgramData\Technitium\DnsServer). If possible, C:\Program Files should be treated as read-only.

@pricerc
Copy link

pricerc commented Feb 15, 2024

Thanks for the suggestion. I tried it and the issue with it is that the service does not have privilege to create the C:\Program Files (x86)\Technitium\DNS Server\config folder thus it fails to start. Need to find a way to fix this to be able to use this.

As mentioned by @rgl, data should not be stored in "Program Files", it should be in "C:\ProgramData". Or in "%systemroot%\System32\config\systemprofile" (typically "C:\WINDOWS\system32\config\systemprofile").

You would still need to create the ProgramData folder in your setup script.

edit to add: "C:\Program Files" on Windows is like "/usr/bin" on unix/linux - you don't put data in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants