]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
win32: backport sining tools
authorEric Bollengier <eric@baculasystems.com>
Thu, 4 Feb 2021 08:17:45 +0000 (09:17 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 4 Feb 2021 14:59:35 +0000 (15:59 +0100)
bacula/src/win32/sign-binaries [new file with mode: 0755]
bacula/src/win32/sign-check [new file with mode: 0755]

diff --git a/bacula/src/win32/sign-binaries b/bacula/src/win32/sign-binaries
new file mode 100755 (executable)
index 0000000..a715218
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2000-2021 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Sign binaries if possible with sign_exe script
+
+DIR=$1
+
+if [ "$DIR" = "" ]; then
+    echo "Usage: $0 <directory> | <file> <file> <file>"
+    exit 1
+fi
+
+if ! which sign_exe > /dev/null 2> /dev/null
+then
+   exit 0
+fi
+
+RET=0
+
+if [ -d "$DIR" ]; then
+    for F in "$DIR"/*.exe "$DIR"/*.dll
+    do
+        sign_exe "$F"
+        RET=`expr $RET + $?`
+    done
+
+else
+    for F in $*
+    do
+        sign_exe "$F"
+        RET=`expr $RET + $?`
+    done
+fi
+
+exit $RET
diff --git a/bacula/src/win32/sign-check b/bacula/src/win32/sign-check
new file mode 100755 (executable)
index 0000000..4eb3506
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Copyright (C) 2000-2021 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Check if binaries are signed
+
+DIR=$1
+
+if [ "$DIR" = "" ]; then
+    echo "Usage: $0 <directory> | <file> <file> <file>"
+    exit 1
+fi
+
+if ! which osslsigncode > /dev/null 2> /dev/null
+then
+   echo "INFO: Not checking signature"
+   exit 0
+fi
+
+# Custom program to sign an executable
+if ! which sign_exe > /dev/null 2> /dev/null
+then
+   echo "INFO: Not checking signature"
+   exit 0
+fi
+
+RET=0
+
+if [ -d "$DIR" ]; then
+    for F in "$DIR"/*.exe "$DIR"/*.dll
+    do
+        osslsigncode verify "$F" | grep "Signature verification: ok"
+        if [ $? != 0 ]; then
+            echo "Signature verification: failed for $F"
+            RET=1
+        fi
+    done
+
+else
+    for F in $*
+    do
+        osslsigncode verify "$F" | grep "Signature verification: ok"
+        if [ $? != 0 ]; then
+            echo "Signature verification: failed for $F"
+            RET=1
+        fi
+    done
+fi
+
+if [ $RET != 0 ]; then
+    echo "ERROR: Some files are not signed correctly"
+fi
+exit $RET