Custom UID and GID for subprocesses and files written (#116) Fix #116

- Environment variables `UID` and `GID`, both defaulting to `1000`
- All subprocesses (openvpn, tinyproxy, etc.) run using the UID and GID given
- All files are written with an ownership for the UID and GID given
- Port forwarded file has also ownership for UID, GID and read permission only
This commit is contained in:
Quentin McGaw
2020-03-29 19:52:49 -04:00
committed by GitHub
parent 76cea56864
commit e5adccd9c5
12 changed files with 193 additions and 30 deletions

View File

@@ -18,6 +18,8 @@ type Settings struct {
Firewall Firewall
TinyProxy TinyProxy
ShadowSocks ShadowSocks
UID int
GID int
}
func (s *Settings) String() string {
@@ -32,6 +34,7 @@ func (s *Settings) String() string {
}
return strings.Join([]string{
"Settings summary below:",
fmt.Sprintf("|-- Using UID %d and GID %d", s.UID, s.GID),
s.OpenVPN.String(),
vpnServiceProvider,
s.DNS.String(),
@@ -115,5 +118,13 @@ func GetAllSettings(params params.ParamsReader) (settings Settings, err error) {
if err != nil {
return settings, err
}
settings.UID, err = params.GetUID()
if err != nil {
return settings, err
}
settings.GID, err = params.GetGID()
if err != nil {
return settings, err
}
return settings, nil
}