From 0266a325807b827b9ff4f0b415e4deb4e2988a57 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Fri, 19 Jan 2024 19:25:19 +0000 Subject: [PATCH] ls: Show S in long mode if SUID/SGID bit is set for non-executable files --- Userland/Utilities/ls.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index 2e267cefd4..281650c26c 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -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' : '-');