[GH-ISSUE #3417] [Feature Request] Please allow the daemon to setuid to a particular user #2733

Closed
opened 2026-05-05 13:45:37 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @yurivict on GitHub (Apr 19, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3417

Describe the feature request

The daemon needs to read certificates as root, but then it is desirable to setuid to some unprivileged user.

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @yurivict on GitHub (Apr 19, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3417 ### Describe the feature request The daemon needs to read certificates as root, but then it is desirable to setuid to some unprivileged user. ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:45:37 -06:00
Author
Owner

@galdor commented on GitHub (Apr 19, 2023):

Being able to drop privileges to a specific user and group would be really nice; this way frp can read files such as TLS key files as root then drop to a non-privileged user for security.

You can easily do that by:

  • Fetching user and group info with user.Lookup and user.LookupGroup.
  • Calling syscall.Setgid and syscall.Setuid (in this order).
<!-- gh-comment-id:1515505247 --> @galdor commented on GitHub (Apr 19, 2023): Being able to drop privileges to a specific user and group would be really nice; this way frp can read files such as TLS key files as root then drop to a non-privileged user for security. You can easily do that by: - Fetching user and group info with `user.Lookup` and `user.LookupGroup`. - Calling `syscall.Setgid` and `syscall.Setuid` (in this order).
Author
Owner

@fatedier commented on GitHub (Apr 20, 2023):

I am not inclined to introduce such complexity, as it is not a universal solution.

<!-- gh-comment-id:1515639552 --> @fatedier commented on GitHub (Apr 20, 2023): I am not inclined to introduce such complexity, as it is not a universal solution.
Author
Owner

@yurivict commented on GitHub (Apr 20, 2023):

Why is it not a universal solution?

A lot of network servers use such strategy to improve security.

<!-- gh-comment-id:1515655983 --> @yurivict commented on GitHub (Apr 20, 2023): Why is it not a universal solution? A lot of network servers use such strategy to improve security.
Author
Owner

@galdor commented on GitHub (Apr 20, 2023):

This is standard procedure for many security-aware daemons. And it is not that complex, you can do it in a couple lines of code!

<!-- gh-comment-id:1516091036 --> @galdor commented on GitHub (Apr 20, 2023): This is standard procedure for many security-aware daemons. And it is not that complex, you can do it in a couple lines of code!
Author
Owner

@fatedier commented on GitHub (Apr 20, 2023):

Doing it this way is very inelegant. A better approach would be a unified solution that is independent of the application.

If we need to support certificate renewal in the future, do we need to switch users regularly?

<!-- gh-comment-id:1516123386 --> @fatedier commented on GitHub (Apr 20, 2023): Doing it this way is very inelegant. A better approach would be a unified solution that is independent of the application. If we need to support certificate renewal in the future, do we need to switch users regularly?
Author
Owner

@galdor commented on GitHub (Apr 20, 2023):

If you want to support dynamic certificate renewal, you are in trouble. What NGINX does is to maintain both a master process running as root and one or more worker processes running as a non-privileged user. This would be a large and complex change though.

But Frp does not support certificate renewal, and restarting the daemon every couple months on certificate rotation is a non issue.

I understand if you believe this feature could be a problem in the future.

If anyone reading this issue needs to run Frp as a non-root user with TLS, I've wrote an article where I explain how to use NGINX as TLS interface to Frp.

<!-- gh-comment-id:1516149991 --> @galdor commented on GitHub (Apr 20, 2023): If you want to support dynamic certificate renewal, you are in trouble. What NGINX does is to maintain both a master process running as root and one or more worker processes running as a non-privileged user. This would be a large and complex change though. But Frp does not support certificate renewal, and restarting the daemon every couple months on certificate rotation is a non issue. I understand if you believe this feature could be a problem in the future. If anyone reading this issue needs to run Frp as a non-root user with TLS, I've wrote an [article](https://www.n16f.net/blog/replacing-ngrok-with-frp/) where I explain how to use NGINX as TLS interface to Frp.
Author
Owner

@github-actions[bot] commented on GitHub (May 21, 2023):

Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:1556051828 --> @github-actions[bot] commented on GitHub (May 21, 2023): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#2733
No description provided.