Fixed uid resolving in bindlists

master
xSmurf 10 years ago
parent 9462c3584a
commit cb0e5b8fea

@ -5,7 +5,6 @@ import (
"os"
"os/user"
"path"
"strconv"
"strings"
"syscall"
@ -25,7 +24,6 @@ type Filesystem struct {
base string
root string
xpra string
userID string
noDefaults bool
noSysAndProc bool
fullDevices bool
@ -117,7 +115,6 @@ func NewFilesystem(name string, user *user.User, basePath string, log *logging.L
fs.base = path.Join(basePath, name)
fs.root = path.Join(fs.base, "rootfs")
fs.user = user
fs.userID = strconv.Itoa(os.Getuid())
return fs
}

@ -20,6 +20,7 @@ func (fs *Filesystem) resolveVars(p string) (string, error) {
const pathVar = "${PATH}/"
const homeVar = "${HOME}"
const uidVar = "${UID}"
const userVar = "${USER}"
switch {
case strings.HasPrefix(p, pathVar):
@ -32,8 +33,11 @@ func (fs *Filesystem) resolveVars(p string) (string, error) {
case strings.HasPrefix(p, homeVar):
return path.Join(fs.user.HomeDir, p[len(homeVar):]), nil
case strings.HasPrefix(p, uidVar):
return strings.Replace(p, uidVar, fs.userID, -1), nil
case strings.Contains(p, uidVar):
return strings.Replace(p, uidVar, fs.user.Uid, -1), nil
case strings.Contains(p, userVar):
return strings.Replace(p, userVar, fs.user.Username, -1), nil
}
return p, nil
}

Loading…
Cancel
Save