From 8121d4164e0879130d8a0ed17788fc0ffdc4b9bc Mon Sep 17 00:00:00 2001 From: Tommy Date: Sat, 29 Jun 2024 17:44:37 -0700 Subject: [PATCH] Cleaner code Signed-off-by: Tommy --- usr/local/bin/certbot-ocsp-fetcher | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr/local/bin/certbot-ocsp-fetcher b/usr/local/bin/certbot-ocsp-fetcher index ae937c1..a16410d 100644 --- a/usr/local/bin/certbot-ocsp-fetcher +++ b/usr/local/bin/certbot-ocsp-fetcher @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# This file is the same as https://github.com/GrapheneOS/infrastructure/blob/main/certbot-ocsp-fetcher -# but with an extra line to restore SELinux context +# This file is the same as https://github.com/tomwassenberg/certbot-ocsp-fetcher +# but with extra logic to restore SELinux context # Unofficial Bash strict mode set \ @@ -577,7 +577,12 @@ fetch_ocsp_response() { # If arrived here status was good, so move OCSP staple file to definitive # folder mv "${temp_output_dir}/${lineage_name}.der" "${OUTPUT_DIR}/" - restorecon -R "${OUTPUT_DIR}/" + + # Restore SELinux context on SELinux systems + if [ -f /usr/sbin/restorecon ]; then + restorecon "${OUTPUT_DIR}/${lineage_name}.der" + fi + lineages_processed["${lineage_name}"]=updated }