- 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
29 lines
596 B
Go
29 lines
596 B
Go
package alpine
|
|
|
|
import (
|
|
"os/user"
|
|
|
|
"github.com/qdm12/golibs/files"
|
|
"github.com/qdm12/golibs/logging"
|
|
)
|
|
|
|
const logPrefix = "alpine configurator"
|
|
|
|
type Configurator interface {
|
|
CreateUser(username string, uid int) error
|
|
}
|
|
|
|
type configurator struct {
|
|
fileManager files.FileManager
|
|
lookupUID func(uid string) (*user.User, error)
|
|
lookupUser func(username string) (*user.User, error)
|
|
}
|
|
|
|
func NewConfigurator(logger logging.Logger, fileManager files.FileManager) Configurator {
|
|
return &configurator{
|
|
fileManager: fileManager,
|
|
lookupUID: user.LookupId,
|
|
lookupUser: user.Lookup,
|
|
}
|
|
}
|