keywords: obtain all permission bits

Fixes #7. Upper 3 bits are 'special' mode bits, and are not
included when calling info.Mode().Perm(). Need to mask
the info.Mode() with the corresponding mode bit defined
by the go library to see if these bits are set or not.

Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
Stephen Chung 2016-07-15 15:35:56 -04:00
parent a29236e678
commit e29b993aa2
1 changed files with 11 additions and 1 deletions

View File

@ -166,7 +166,17 @@ var (
var (
modeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
return fmt.Sprintf("mode=%#o", info.Mode().Perm()), nil
permissions := info.Mode().Perm()
if os.ModeSetuid&info.Mode() > 0 {
permissions |= (1 << 11)
}
if os.ModeSetgid&info.Mode() > 0 {
permissions |= (1 << 10)
}
if os.ModeSticky&info.Mode() > 0 {
permissions |= (1 << 9)
}
return fmt.Sprintf("mode=%#o", permissions), nil
}
sizeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
return fmt.Sprintf("size=%d", info.Size()), nil