#JavaScript (ES6), 61 5151 50 bytes
Takes 6 distinct parameters as input, in the order described in the challenge. Expects the last parameter to be 1
for read, 2
for write or 3
for execute. Returns 0
or 1
.
(p,u,g,a,G,P)=>!a|p[(ua|p[u-a&&6a?6-3*G.includes(g))+P]>'Z'+P:P]>'Z'
###Test cases
let f =
(p,u,g,a,G,P)=>!a|p[(ua|p[u-a&&6a?6-3*G.includes(g))+P]>'Z'+P:P]>'Z'
// p u g a G P
console.log(f('-rwx------', 13, 15, 13, [15, 24], 1)) // True (user)
console.log(f('-rwxr-xr-x', 13, 24, 24, [15, 24], 2)) // False (group)
console.log(f('-rwxr-Sr-T', 13, 15, 24, [15, 35], 3)) // False (group)
console.log(f('-rwsr-xr-t', 13, 15, 24, [24, 35], 3)) // True (others)
console.log(f('----------', 13, 15, 0, [0, 1, 2], 1)) // True (superuser)
console.log(f('----------', 13, 15, 1, [0, 1, 2], 1)) // False (others)
console.log(f('----rwxrwx', 13, 15, 13, [15, 24], 1)) // False (user)