Skip to content

Commit

Permalink
Windows secure_session(): Minimize and document specific race conditon
Browse files Browse the repository at this point in the history
mkdir.exe always retruns true, regardless of the result, under Windows 11,
unless Windows 11 UAC has granted FULL administrator privileges to Easy-RSA.

Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Aug 9, 2024
1 parent 0081fca commit 91b1036
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,18 @@ secure_session() {
secured_session="${EASYRSA_TEMP_DIR}/${session}"

# atomic:
# ONLY effects Windows 11 "broken" mkdir.exe
# The procedure now is a "poor man's" version
# of an atomic directory creation call.
# The "race condition" still exists but is minimized.
# What remains is equivalent to 32bit hash collision.
[ -d "$secured_session" ] && continue
if mkdir "$secured_session"; then
# Check mkdir.exe has created the directory
[ -d "$secured_session" ] || \
die "secure_session - mkdir FAILED"
[ -f "$secured_session"/temp.0.1 ] && \
die "secure_session - temp-file EXISTS"

# New session requires safe-ssl conf
unset -v OPENSSL_CONF safe_ssl_cnf_tmp \
Expand Down

0 comments on commit 91b1036

Please sign in to comment.