Просмотр исходного кода

Prevent usb canary from being activated during upgrades

Bob Mottram 6 лет назад
Родитель
Сommit
924577a6f2
2 измененных файлов: 21 добавлений и 8 удалений
  1. 11
    0
      src/freedombone-upgrade
  2. 10
    8
      src/freedombone-usb-canary

+ 11
- 0
src/freedombone-upgrade Просмотреть файл

@@ -61,6 +61,11 @@ if [ $DEVELOPMENT_BRANCH ]; then
61 61
     fi
62 62
 fi
63 63
 
64
+# upgrading file prevents USB canary from activating
65
+if [ ! -f /tmp/.upgrading ]; then
66
+    touch /tmp/.upgrading
67
+fi
68
+
64 69
 if [ -f /usr/bin/backupdatabases ]; then
65 70
     if grep -q "cat /root/dbpass" /usr/bin/backupdatabases; then
66 71
         # update to using the password manager
@@ -91,6 +96,7 @@ if [ -d "$PROJECT_DIR" ]; then
91 96
         fi
92 97
 
93 98
         if ! ${PROJECT_NAME} -c "$CONFIGURATION_FILE"; then
99
+            rm /tmp/.upgrading
94 100
             exit 453536
95 101
         fi
96 102
 
@@ -118,4 +124,9 @@ fi
118 124
 # If logging was left on then turn it off
119 125
 ${PROJECT_NAME}-logging off
120 126
 
127
+# upgrading file prevents USB canary from activating
128
+if [ -f /tmp/.upgrading ]; then
129
+    rm /tmp/.upgrading
130
+fi
131
+
121 132
 # deliberately there is no 'exit 0' here

+ 10
- 8
src/freedombone-usb-canary Просмотреть файл

@@ -28,12 +28,14 @@
28 28
 
29 29
 PROJECT_NAME=freedombone
30 30
 
31
-UPTIME=$(awk -F '.' '{print $1}' < "/proc/uptime")
32
-if [ "$UPTIME" -gt 240 ]; then
33
-    ADMIN_USER=$(grep 'Admin user' /root/${PROJECT_NAME}-completed.txt | awk -F ':' '{print $2}')
34
-    MY_EMAIL_ADDRESS=${ADMIN_USER}@$(cat /etc/hostname)
35
-    echo "USB device connected on ${DEVPATH}" | mail -s "${PROJECT_NAME} USB canary" "${MY_EMAIL_ADDRESS}"
36
-    echo "${ACTION}" > /tmp/usb-canary
37
-    echo "${MY_EMAIL_ADDRESS}" >> /tmp/usb-canary
38
-    date >> /tmp/usb-canary
31
+if [ ! -f /tmp/.upgrading ]; then
32
+    UPTIME=$(awk -F '.' '{print $1}' < "/proc/uptime")
33
+    if [ "$UPTIME" -gt 240 ]; then
34
+        ADMIN_USER=$(grep 'Admin user' /root/${PROJECT_NAME}-completed.txt | awk -F ':' '{print $2}')
35
+        MY_EMAIL_ADDRESS=${ADMIN_USER}@$(cat /etc/hostname)
36
+        echo "USB device connected on ${DEVPATH}" | mail -s "${PROJECT_NAME} USB canary" "${MY_EMAIL_ADDRESS}"
37
+        echo "${ACTION}" > /tmp/usb-canary
38
+        echo "${MY_EMAIL_ADDRESS}" >> /tmp/usb-canary
39
+        date >> /tmp/usb-canary
40
+    fi
39 41
 fi