cybersecurity · intermediate · ~15 min · safe pentest lab
Extract the owner permission triad.
Extract the owner's permission triad from a Unix mode. A mode packs owner/group/other as three octal digits; the owner is the top one.
Implement int owner_perms(int mode) that returns the owner's rwx bits: (mode >> 6) & 7.
mode: a Unix permission mode (octal), e.g. 0755. The grader passes fixed values.Returns int: the owner's 3-bit permission value (0..7).
owner_perms(0755) -> 7 (rwx)
owner_perms(0644) -> 6 (rw-)
A Unix permission mode (octal int).
An int: the owner's rwx bits (0..7).
Return (mode >> 6) & 7.
int owner_perms(int mode) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.