@@ -25,14 +25,14 @@ def get_serial_number():
2525 if os .geteuid () != 0 :
2626 print ("Process needs to be root." )
2727 subprocess .call (['sudo' , '-E' , 'python3' , * sys .argv ])
28- sys .exit ()
28+ sys .exit (0 )
2929 with open ('/sys/class/dmi/id/product_serial' ) as file :
3030 return file .read ().strip ()
3131 else :
3232 return None
3333 except Exception as error :
3434 print (f"Unexpected error: { error } " )
35- sys . exit ( 1 )
35+ return
3636
3737
3838try :
@@ -72,7 +72,7 @@ def get_serial_number():
7272 except (FileNotFoundError , PermissionError ):
7373 print ('[error] license path does not exist! (or permission was denied)' )
7474
75- sys . exit ( 1 )
75+ return
7676
7777 # Read the machine file
7878 try :
@@ -81,7 +81,7 @@ def get_serial_number():
8181 except (FileNotFoundError , PermissionError ):
8282 print ('[error] machine path does not exist! (or permission was denied)' )
8383
84- sys . exit ( 1 )
84+ return
8585
8686 # Strip the header and footer from the machine file certificate
8787 payload = machine_file .lstrip ('-----BEGIN MACHINE FILE-----\n ' ) \
@@ -98,7 +98,7 @@ def get_serial_number():
9898 if alg != 'aes-256-gcm+ed25519' :
9999 print ('[error] algorithm is not supported!' )
100100
101- sys . exit ( 1 )
101+ return
102102
103103 # Verify using Ed25519
104104 try :
@@ -114,7 +114,7 @@ def get_serial_number():
114114 except (AssertionError , BadSignatureError ):
115115 print ('[error] verification failed!' )
116116
117- sys . exit ( 1 )
117+ return
118118
119119 print ('[info] machine file verification successful!' )
120120
@@ -143,7 +143,7 @@ def get_serial_number():
143143 except (InvalidKey , InvalidTag ):
144144 print ('[error] machine file decryption failed!' )
145145
146- sys . exit ( 1 )
146+ return
147147
148148 print ('[info] machine file decryption successful!' )
149149 # print(json.dumps(json.loads(plaintext.decode()), indent=2)) # Uncomment to see the decrypted machine file
0 commit comments