Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
/ xz Public archive

Commit

Permalink
xz: Make Capsicum sandbox more strict with stdin and stdout.
Browse files Browse the repository at this point in the history
  • Loading branch information
Larhzu authored and JiaT75 committed Mar 8, 2023
1 parent 916448d commit a0eecc2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/xz/file_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,19 @@ io_sandbox_enter(int src_fd)
CAP_EVENT, CAP_FCNTL, CAP_LOOKUP, CAP_READ, CAP_SEEK)))
goto capsicum_error;

if (src_fd != STDIN_FILENO && cap_rights_limit(
STDIN_FILENO, cap_rights_clear(&rights)))
goto capsicum_error;

if (cap_rights_limit(STDOUT_FILENO, cap_rights_init(&rights,
CAP_EVENT, CAP_FCNTL, CAP_FSTAT, CAP_LOOKUP,
CAP_WRITE, CAP_SEEK)))
goto capsicum_error;

if (cap_rights_limit(STDERR_FILENO, cap_rights_init(&rights,
CAP_WRITE)))
goto capsicum_error;

if (cap_rights_limit(user_abort_pipe[0], cap_rights_init(&rights,
CAP_EVENT)))
goto capsicum_error;
Expand Down

0 comments on commit a0eecc2

Please sign in to comment.