Răsfoiți Sursa

Add set_umask logic to a function

Continue the 'divide and control' refactor
oz123 11 ani în urmă
părinte
comite
cee1c8ce7b
1 a modificat fișierele cu 14 adăugiri și 10 ștergeri
  1. 14 10
      scripts/pwman3

+ 14 - 10
scripts/pwman3

@@ -105,6 +105,19 @@ def set_win_colors(config):
             config.set_value("Global", "colors", 'no')
 
 
+def set_umask(config):
+    # set umask before creating/opening any files
+    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)
+
+
 def get_conf_options(args, OSX):
 
     global _saveconfig
@@ -122,17 +135,8 @@ def get_conf_options(args, OSX):
     if args.algo:
             config.set_value("Encryption", "algorithm", args.algo)
             _saveconfig = False
-    # set umask before creating/opening any files
-    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)
 
+    set_umask(config)
     dbtype = config.get_value("Database", "type")
     if not dbtype:
         print("Could not read the Database type from the config!")