Kaynağa Gözat

Added better controls for the startup script

* make sure that database type  is read from config
* make sure that usmak is not garbage
oz123 11 yıl önce
ebeveyn
işleme
b62fcff2d3
1 değiştirilmiş dosya ile 13 ekleme ve 3 silme
  1. 13 3
      scripts/pwman3

+ 13 - 3
scripts/pwman3

@@ -24,6 +24,7 @@ import os
 import os.path
 import argparse
 import sys
+import re
 
 _saveconfig = True
 
@@ -104,12 +105,21 @@ try:
             config.set_value("Encryption", "algorithm", args.algo)
             _saveconfig = False
     # set umask before creating/opening any files
-    umask = int(config.get_value("Global", "umask"))
-    os.umask(umask)
+    try:
+        umask = config.get_value("Global", "umask")
+        if re.search(r'^\d{4}$', umask):
+            os.umask(int(umask))
+        else:
+            raise ValueError
+    except ValueError:
+        print("Could not determine umask from config!")
+        sys.exit(2)
 
     enc = CryptoEngine.get()
     dbtype = config.get_value("Database", "type")
-
+    if not dbtype:
+        printf("Could not read the Database type from the config!")
+        sys.exit(1)
     if os.path.exists(config.get_value("Database", "filename")):
         dbver = pwman.data.factory.check_db_version(dbtype)
         dbver = float(dbver.strip("\'"))