- FileOwnership option to Ownership
- FilePermissions option to Permissions
This commit is contained in:
Quentin McGaw (desktop)
2020-02-08 15:29:27 +00:00
parent 1f873e7d66
commit 6620ba52d2
8 changed files with 18 additions and 16 deletions

3
go.mod
View File

@@ -4,6 +4,7 @@ go 1.13
require ( require (
github.com/kyokomi/emoji v2.1.0+incompatible github.com/kyokomi/emoji v2.1.0+incompatible
github.com/qdm12/golibs v0.0.0-20200206031633-f9e9b1bea1db github.com/qdm12/golibs v0.0.0-20200208143139-ccf3a2b4be96
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
golang.org/x/sys v0.0.0-20190412213103-97732733099d
) )

5
go.sum
View File

@@ -44,8 +44,8 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qdm12/golibs v0.0.0-20200206031633-f9e9b1bea1db h1:Q3bR2GWwvDxQ0EqLKUupzHswsBsEi3eMWxAPfvzKTbM= github.com/qdm12/golibs v0.0.0-20200208143139-ccf3a2b4be96 h1:TAhod+kjxTQHdqMNnDkg6IbLRrGovtI+3l1Isjd1wbI=
github.com/qdm12/golibs v0.0.0-20200206031633-f9e9b1bea1db/go.mod h1:YULaFjj6VGmhjak6f35sUWwEleHUmngN5IQ3kdvd6XE= github.com/qdm12/golibs v0.0.0-20200208143139-ccf3a2b4be96/go.mod h1:YULaFjj6VGmhjak6f35sUWwEleHUmngN5IQ3kdvd6XE=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -73,6 +73,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

View File

@@ -24,8 +24,8 @@ func (c *configurator) MakeUnboundConf(settings settings.DNS, uid, gid int) (err
return c.fileManager.WriteLinesToFile( return c.fileManager.WriteLinesToFile(
string(constants.UnboundConf), string(constants.UnboundConf),
lines, lines,
files.FileOwnership(uid, gid), files.Ownership(uid, gid),
files.FilePermissions(0400)) files.Permissions(0400))
} }
// MakeUnboundConf generates an Unbound configuration from the user provided settings // MakeUnboundConf generates an Unbound configuration from the user provided settings

View File

@@ -18,8 +18,8 @@ func (c *configurator) DownloadRootHints(uid, gid int) error {
return c.fileManager.WriteToFile( return c.fileManager.WriteToFile(
string(constants.RootHints), string(constants.RootHints),
content, content,
files.FileOwnership(uid, gid), files.Ownership(uid, gid),
files.FilePermissions(0400)) files.Permissions(0400))
} }
func (c *configurator) DownloadRootKey(uid, gid int) error { func (c *configurator) DownloadRootKey(uid, gid int) error {
@@ -33,6 +33,6 @@ func (c *configurator) DownloadRootKey(uid, gid int) error {
return c.fileManager.WriteToFile( return c.fileManager.WriteToFile(
string(constants.RootKey), string(constants.RootKey),
content, content,
files.FileOwnership(uid, gid), files.Ownership(uid, gid),
files.FilePermissions(0400)) files.Permissions(0400))
} }

View File

@@ -18,6 +18,6 @@ func (c *configurator) WriteAuthFile(user, password string, uid, gid int) error
return c.fileManager.WriteLinesToFile( return c.fileManager.WriteLinesToFile(
string(constants.OpenVPNAuthConf), string(constants.OpenVPNAuthConf),
[]string{user, password}, []string{user, password},
files.FileOwnership(uid, gid), files.Ownership(uid, gid),
files.FilePermissions(0400)) files.Permissions(0400))
} }

View File

@@ -81,6 +81,6 @@ func (c *configurator) BuildConf(region models.PIARegion, protocol models.Networ
"</ca>", "</ca>",
"", "",
}...) }...)
err = c.fileManager.WriteLinesToFile(string(constants.OpenVPNConf), lines, files.FileOwnership(uid, gid), files.FilePermissions(0400)) err = c.fileManager.WriteLinesToFile(string(constants.OpenVPNConf), lines, files.Ownership(uid, gid), files.Permissions(0400))
return IPs, port, err return IPs, port, err
} }

View File

@@ -14,8 +14,8 @@ func (c *configurator) MakeConf(port uint16, password string, uid, gid int) (err
return c.fileManager.WriteToFile( return c.fileManager.WriteToFile(
string(constants.ShadowsocksConf), string(constants.ShadowsocksConf),
data, data,
files.FileOwnership(uid, gid), files.Ownership(uid, gid),
files.FilePermissions(0400)) files.Permissions(0400))
} }
func generateConf(port uint16, password string) (data []byte) { func generateConf(port uint16, password string) (data []byte) {

View File

@@ -14,8 +14,8 @@ func (c *configurator) MakeConf(logLevel models.TinyProxyLogLevel, port uint16,
lines := generateConf(logLevel, port, user, password) lines := generateConf(logLevel, port, user, password)
return c.fileManager.WriteLinesToFile(string(constants.TinyProxyConf), return c.fileManager.WriteLinesToFile(string(constants.TinyProxyConf),
lines, lines,
files.FileOwnership(uid, gid), files.Ownership(uid, gid),
files.FilePermissions(0400)) files.Permissions(0400))
} }
func generateConf(logLevel models.TinyProxyLogLevel, port uint16, user, password string) (lines []string) { func generateConf(logLevel models.TinyProxyLogLevel, port uint16, user, password string) (lines []string) {