diff options
author | Martin Pool <mbp@samba.org> | 2001-11-27 07:05:33 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2001-11-27 07:05:33 +0000 |
commit | 087173c887686611d039e10be0e3698843c26930 (patch) | |
tree | 902f8dea3f84fb3f5470f495212c0628b0cdf3e6 | |
parent | 57835c00ad83d218d12dc6c777c5d9f66b926d3f (diff) | |
download | rsync-087173c887686611d039e10be0e3698843c26930.tar.gz |
When producing a ls-style permissions string, also handle
sticky/setuid/setgid bits the same way as GNU ls.
-rw-r--r-- | lib/permstring.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/permstring.c b/lib/permstring.c index 4275dfea..525a9acb 100644 --- a/lib/permstring.c +++ b/lib/permstring.c @@ -37,6 +37,19 @@ void permstring(char *perms, for (i=0;i<9;i++) { if (mode & (1<<i)) perms[9-i] = perm_map[8-i]; } + + /* Handle setuid/sticky bits. You might think the indices are + * off by one, but remember there's a type char at the + * start. */ + if (mode & S_ISUID) + perms[3] = (mode & S_IXUSR) ? 's' : 'S'; + + if (mode & S_ISGID) + perms[6] = (mode & S_IXGRP) ? 's' : 'S'; + + if (mode & S_ISVTX) + perms[9] = (mode & S_IXOTH) ? 't' : 'T'; + if (S_ISLNK(mode)) perms[0] = 'l'; if (S_ISDIR(mode)) perms[0] = 'd'; if (S_ISBLK(mode)) perms[0] = 'b'; |