Browse Source

hooked signal

fzn 2 years ago
parent
commit
1e0d207754
2 changed files with 17 additions and 3 deletions
  1. 5 1
      TODO
  2. 12 2
      encrypt.py

+ 5 - 1
TODO

@@ -1,4 +1,4 @@
-Check and hook emergency routine!
+Test emergency routine!
 
 More testing!
 
@@ -11,3 +11,7 @@ packager: for air-gapped machines, download all dependences and the script into
 
 
 -> must do kpartx -d /dev/loop[0|1]. bizarre
+
+
+
+TL;DR => test all in a clean, new vm

+ 12 - 2
encrypt.py

@@ -7,6 +7,7 @@ import inspect
 from multiprocessing import Process
 import pdb
 import os
+import signal
 import stat
 import subprocess
 import sys
@@ -282,8 +283,10 @@ def die(s=0):
   cleanup()
   exit(-1)
 
-def emergency():
+def emergency(a, b):
   global LOG_NAME
+  print('emergency called')
+  exit()
   p = Process(target=subprocess.run('sdmem -fll', shell=True))
   q = Process(target=subprocess.run('wipe -q -Q1 '+LOG_NAME, shell=True))
   p.start()
@@ -295,8 +298,14 @@ def emergency():
   q.join()
   r.join()
 
+
+'''
+  hook emergency abort routine to alarm
+'''
+def suSignals():
+  signal.signal(signal.SIGALRM, emergency)
+
 def main():
-#  cleanup()
   if len(sys.argv) < 2:
     return usage()
   checkEntropy()
@@ -307,4 +316,5 @@ def main():
   else:
    die()
 if __name__ == '__main__':
+  suSignals()
   main()