From 24415511565baf5f537603ca7d8353823c299942 Mon Sep 17 00:00:00 2001 From: fritz-hh Date: Sun, 28 Apr 2013 15:54:31 +0200 Subject: [PATCH] OCRmyPDF.sh: final pdf same owner & permissions fixes #9 --- OCRmyPDF.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OCRmyPDF.sh b/OCRmyPDF.sh index af09406c..9236d892 100644 --- a/OCRmyPDF.sh +++ b/OCRmyPDF.sh @@ -151,6 +151,7 @@ FILE_SIZE_PAGES="$TMP_FLD/page-sizes.txt" # size in pt of the respective page o FILES_OCRed_PDFS="${TMP_FLD}/*-ocred.pdf" # string matching all 1 page PDF files that need to be merged FILE_OUTPUT_PDF="${TMP_FLD}/ocred.pdf" # name of the OCRed PDF file before conversion to PDF/A FILE_VALIDATION_LOG="${TMP_FLD}/pdf_validation.log" # log file containing the results of the validation of the PDF/A file +FILE_INPUT_PDF_ACL="${TMP_FLD}/input_pdf.acl" # Create tmp folder [ $VERBOSITY -ge $LOG_DEBUG ] && echo "Creating temporary folder" @@ -324,6 +325,19 @@ grep -i 'Status.*Not well-formed' "$FILE_VALIDATION_LOG" && pdf_valid=0 + +# remember the owner / group / permissions for the input file +OWNER=`stat -f "%Su" "$FILE_INPUT_PDF"` +GROUP=`stat -f "%Sg" "$FILE_INPUT_PDF"` +getfacl "$FILE_INPUT_PDF" > "$FILE_INPUT_PDF_ACL" + +# set the owner / group / permissions of the output (equal to those of the intput file) +[ $VERBOSITY -ge $LOG_DEBUG ] && echo "Output file: restoring owner, group, permissions" +chown $OWNER:$GROUP "$FILE_OUTPUT_PDFA" +setfacl -M "$FILE_INPUT_PDF_ACL" "$FILE_OUTPUT_PDFA" + + + # delete temporary files if [ $KEEP_TMP -eq 0 ]; then rm -r -f "${TMP_FLD}"