diff options
author | David Fries <David@Fries.net> | 2014-08-19 12:48:23 -0500 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-09-02 18:23:26 +0100 |
commit | 5e66aa4fc767cb99b42ac678363bd5a4d8f94eb4 (patch) | |
tree | 6ca499e539e3785ceaf5de25988f14608a378033 /obnamlib/plugins/show_plugin.py | |
parent | 4396902eb2d5ee31f1fddca9c4e60110eb25fa95 (diff) | |
download | obnam-5e66aa4fc767cb99b42ac678363bd5a4d8f94eb4.tar.gz |
fill in the mode display bits
This fills in the displayed file mode permission mode bits such as
character, block, setuid, sticky, etc.
Diffstat (limited to 'obnamlib/plugins/show_plugin.py')
-rw-r--r-- | obnamlib/plugins/show_plugin.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py index 4591301b..7c933cfb 100644 --- a/obnamlib/plugins/show_plugin.py +++ b/obnamlib/plugins/show_plugin.py @@ -353,10 +353,13 @@ class ShowPlugin(obnamlib.ObnamPlugin): perms = ['?'] + ['-'] * 9 tab = [ - (stat.S_IFREG, 0, '-'), (stat.S_IFDIR, 0, 'd'), - (stat.S_IFLNK, 0, 'l'), + (stat.S_IFCHR, 0, 'c'), # character device + (stat.S_IFBLK, 0, 'b'), # block device + (stat.S_IFREG, 0, '-'), (stat.S_IFIFO, 0, 'p'), + (stat.S_IFLNK, 0, 'l'), + #(stat.S_IFSOCK, 0, 's'), # not stored, listed for completeness (stat.S_IRUSR, 1, 'r'), (stat.S_IWUSR, 2, 'w'), (stat.S_IXUSR, 3, 'x'), @@ -370,6 +373,19 @@ class ShowPlugin(obnamlib.ObnamPlugin): for bitmap, offset, char in tab: if (mode & bitmap) == bitmap: perms[offset] = char + + # set modifiers based on the x bit in that position + tab = [ + (stat.S_ISUID, 3, 's', 'S'), + (stat.S_ISGID, 6, 's', 'S'), + (stat.S_ISVTX, 9, 't', 'T'), + ] + for bitmap, offset, has_X, no_X in tab: + if mode & bitmap: + if perms[offset] == 'x': + perms[offset] = has_X + else: + perms[offset] = no_X perms = ''.join(perms) timestamp = time.strftime( |