x509crypt.git

commit 5a2dc2abc809eccea10ba1e07b8eb9c1c5f57544

Author: Paolo Lulli <paolo@lulli.net>

Add file size semaphore (500M)

 x509crypt | 5 +++++


diff --git a/x509crypt b/x509crypt
index bc3e468ee1c7219df1369bedb1f3fee2a4c37ebb..f1b4f3840f140d7052b7094f5542c432f39f3617 100755
--- a/x509crypt
+++ b/x509crypt
@@ -66,6 +66,11 @@ }
 
 file_encrypt(){
   echo "FILE ENCRYPT: $1"
+  file_size=$(du -s $1 | awk -e '{print $1}')
+  if [ ${file_size} -gt 500000 ]; then
+    echo "File too big to encrypt with smime"
+    exit 1
+  fi
   encrypted_file=$1".enc"
   CONFIG_CERT_NAME=${profile_name}
   openssl smime -encrypt -binary -aes-256-cbc -in $1 -out $encrypted_file  -outform DER $CONFIG_DIR/$profile_name/certs/$CONFIG_CERT_NAME.crt