Skip to content

Commit

Permalink
Umasks are weird
Browse files Browse the repository at this point in the history
  • Loading branch information
kotauskas committed Apr 3, 2024
1 parent 5b7918a commit 7c3c3f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/os/unix/c_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ pub(super) fn bind_and_listen_with_mode(
}
}
// Sad path, either got false or fell through from the second match arm
let _dg = (mode != 0o666).then(|| WithUmask::set(mode));
let _dg = (mode != 0o666).then(|| {
// The value that permissions get ANDed with is actually the inverse of the umask
let umask = !mode & 0o777;
WithUmask::set(umask)
});
// We race in this muthafucka, better get yo secure code ass back to Linux
let sock = create_socket(ty, nonblocking)?;
bind(sock.as_fd(), addr)?;
Expand Down

0 comments on commit 7c3c3f3

Please sign in to comment.