Skip to content

Commit

Permalink
kthd: verify file permissions in exec() handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Oct 1, 2024
1 parent f45fc2d commit bfc77ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kthd/src/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ void exec(ExecCommand *cmd) {
}

cmd->header.header.status = 0;
if(cmd->header.header.requester == st.st_uid) {
if(cmd->uid == st.st_uid) {
if(!(st.st_mode & S_IXUSR)) cmd->header.header.status = -EPERM;
} else if(cmd->gid == st.st_gid) {
if(!(st.st_mode & S_IXGRP)) cmd->header.header.status = -EPERM;
} else {
if(!(st.st_mode & S_IXOTH)) cmd->header.header.status = -EPERM;
}
Expand Down

0 comments on commit bfc77ac

Please sign in to comment.