From cb0e5b8feababfbd48254a23ebd8b35a4e6b5c4c Mon Sep 17 00:00:00 2001 From: xSmurf Date: Mon, 15 Jun 2015 05:16:35 +0000 Subject: [PATCH] Fixed uid resolving in bindlists --- fs/fs.go | 3 --- fs/resolve.go | 8 ++++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/fs.go b/fs/fs.go index e8677e3..324ef16 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -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 } diff --git a/fs/resolve.go b/fs/resolve.go index 8856201..e51edb8 100644 --- a/fs/resolve.go +++ b/fs/resolve.go @@ -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 }