-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Unix Socket Handling #2280
Unix Socket Handling #2280
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2280 +/- ##
==========================================
+ Coverage 98.38% 98.47% +0.08%
==========================================
Files 41 41
Lines 2296 2293 -3
==========================================
- Hits 2259 2258 -1
+ Misses 21 20 -1
+ Partials 16 15 -1
Continue to review full report at Codecov.
|
gin.go
Outdated
listener, err := net.Listen("unix", file) | ||
if err != nil { | ||
return | ||
} | ||
defer listener.Close() | ||
err = os.Chmod(file, 0777) | ||
defer os.Remove(file) | ||
|
||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* do not set unix socket permissions. Cleanup unix socket. * removed useless error checking
* do not set unix socket permissions. Cleanup unix socket. * removed useless error checking
How can I set the socket file permissions to set it group-writable so that my go program and webserver reading/writing the socket do not need to share the same user? |
The current handling of Unix sockets is not correct.
One of the main reasons to use sockets is for security. Using sockets allows you to lock access down to a specific unix group/user.However, due to the various use cases for unix sockets, it may be a good idea to accept a
net.Listener
interface, so that the socket can be configured before the server is started.