ls: Show S in long mode if SUID/SGID bit is set for non-executable files

This commit is contained in:
Tim Ledbetter 2024-01-19 19:25:19 +00:00 committed by Tim Flynn
parent ad89aea1fe
commit 0266a32580
Notes: sideshowbarker 2024-07-17 02:42:21 +09:00

View File

@ -365,10 +365,14 @@ static bool print_filesystem_object(ByteString const& path, ByteString const& na
printf("%c%c%c%c%c%c%c%c",
st.st_mode & S_IRUSR ? 'r' : '-',
st.st_mode & S_IWUSR ? 'w' : '-',
st.st_mode & S_ISUID ? 's' : (st.st_mode & S_IXUSR ? 'x' : '-'),
st.st_mode & S_ISUID
? (st.st_mode & S_IXUSR ? 's' : 'S')
: (st.st_mode & S_IXUSR ? 'x' : '-'),
st.st_mode & S_IRGRP ? 'r' : '-',
st.st_mode & S_IWGRP ? 'w' : '-',
st.st_mode & S_ISGID ? 's' : (st.st_mode & S_IXGRP ? 'x' : '-'),
st.st_mode & S_ISGID
? (st.st_mode & S_IXGRP ? 's' : 'S')
: (st.st_mode & S_IXGRP ? 'x' : '-'),
st.st_mode & S_IROTH ? 'r' : '-',
st.st_mode & S_IWOTH ? 'w' : '-');