Rename UID and GID to PUID and PGID

This commit is contained in:
Quentin McGaw
2020-12-29 16:44:35 +00:00
parent 8d5f2fec09
commit cb64302294
14 changed files with 68 additions and 59 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ import (
)
// WriteAuthFile writes the OpenVPN auth file to disk with the right permissions.
func (c *configurator) WriteAuthFile(user, password string, uid, gid int) error {
func (c *configurator) WriteAuthFile(user, password string, puid, pgid int) error {
const filepath = string(constants.OpenVPNAuthConf)
file, err := c.os.OpenFile(filepath, os.O_RDONLY, 0)
@@ -27,7 +27,7 @@ func (c *configurator) WriteAuthFile(user, password string, uid, gid int) error
_ = file.Close()
return err
}
err = file.Chown(uid, gid)
err = file.Chown(puid, pgid)
if err != nil {
_ = file.Close()
return err
@@ -59,7 +59,7 @@ func (c *configurator) WriteAuthFile(user, password string, uid, gid int) error
_ = file.Close()
return err
}
err = file.Chown(uid, gid)
err = file.Chown(puid, pgid)
if err != nil {
_ = file.Close()
return err
+6 -6
View File
@@ -35,8 +35,8 @@ type looper struct {
state state
// Fixed parameters
username string
uid int
gid int
puid int
pgid int
// Configurators
conf Configurator
fw firewall.Configurator
@@ -56,7 +56,7 @@ type looper struct {
}
func NewLooper(settings settings.OpenVPN,
username string, uid, gid int, allServers models.AllServers,
username string, puid, pgid int, allServers models.AllServers,
conf Configurator, fw firewall.Configurator, routing routing.Routing,
logger logging.Logger, client *http.Client, openFile os.OpenFileFunc,
streamMerger command.StreamMerger, cancel context.CancelFunc) Looper {
@@ -67,8 +67,8 @@ func NewLooper(settings settings.OpenVPN,
allServers: allServers,
},
username: username,
uid: uid,
gid: gid,
puid: puid,
pgid: pgid,
conf: conf,
fw: fw,
routing: routing,
@@ -123,7 +123,7 @@ func (l *looper) Run(ctx context.Context, wg *sync.WaitGroup) {
return
}
if err := l.conf.WriteAuthFile(settings.User, settings.Password, l.uid, l.gid); err != nil {
if err := l.conf.WriteAuthFile(settings.User, settings.Password, l.puid, l.pgid); err != nil {
l.logger.Error(err)
l.cancel()
return
+1 -1
View File
@@ -12,7 +12,7 @@ import (
type Configurator interface {
Version(ctx context.Context) (string, error)
WriteAuthFile(user, password string, uid, gid int) error
WriteAuthFile(user, password string, puid, pgid int) error
CheckTUN() error
CreateTUN() error
Start(ctx context.Context) (stdout io.ReadCloser, waitFn func() error, err error)