Fixed panic

master
xSmurf 10 years ago
parent 47be4813b1
commit 820d4c847a

@ -31,12 +31,21 @@ func (fs *Filesystem) resolveVars(p string) (string, error) {
return resolved, nil return resolved, nil
case strings.HasPrefix(p, homeVar): case strings.HasPrefix(p, homeVar):
if fs.user == nil {
return p, nil
}
return path.Join(fs.user.HomeDir, p[len(homeVar):]), nil return path.Join(fs.user.HomeDir, p[len(homeVar):]), nil
case strings.Contains(p, uidVar): case strings.Contains(p, uidVar):
if fs.user == nil {
return p, nil
}
return strings.Replace(p, uidVar, fs.user.Uid, -1), nil return strings.Replace(p, uidVar, fs.user.Uid, -1), nil
case strings.Contains(p, userVar): case strings.Contains(p, userVar):
if fs.user == nil {
return p, nil
}
return strings.Replace(p, userVar, fs.user.Username, -1), nil return strings.Replace(p, userVar, fs.user.Username, -1), nil
} }
return p, nil return p, nil

Loading…
Cancel
Save