$OpenBSD: patch-base_password_py,v 1.10 2020/08/13 13:55:25 ajacoutot Exp $

Index: base/password.py
--- base/password.py.orig
+++ base/password.py
@@ -57,6 +57,7 @@ AUTH_TYPES = {'mepis': 'su',
               'boss': 'su',
               'lfs': 'su',
               'manjarolinux': 'sudo',
+              'openbsd':'su',
               }
 
 
@@ -93,10 +94,13 @@ def get_distro_name():
         name.close()
 
     if not os_name:
-        name = os.popen("cat /etc/issue | awk '{print $1}' | head -n 1")
+        name = os.popen("cat /etc/issue 2>/dev/null | awk '{print $1}' | head -n 1")
         os_name = name.read().strip()
         name.close()
 
+    if not os_name:
+        os_name = platform.system()
+
     os_name = os_name.lower()
     if "redhatenterprise" in os_name:
         os_name = 'rhel'
@@ -333,7 +337,11 @@ class Password(object):
 
     def __get_password_utils(self):
         if self.__authType == "su":
-            AuthType, AuthCmd = 'su', 'su -c "%s"'
+            # in this context, `-c' refers to the BSD login class
+            if sys.platform.startswith('openbsd'):
+                AuthType, AuthCmd = 'su', 'su root -c "%s"'
+            else:
+                AuthType, AuthCmd = 'su', 'su -c "%s"'
         else:
             AuthType, AuthCmd = 'sudo', 'sudo %s'
 
@@ -344,7 +352,11 @@ class Password(object):
         if self.__authType == "sudo":
             AuthType, AuthCmd = 'sudo', 'sudo %s'
         else:
-            AuthType, AuthCmd = 'su', 'su -c "%s"'
+            # in this context, `-c' refers to the BSD login class
+            if sys.platform.startswith('openbsd'):
+                AuthType, AuthCmd = 'su', 'su root -c "%s"'
+            else:
+                AuthType, AuthCmd  = 'su', 'su -c "%s"'
         '''
         if utils.which('kdesu'):
             AuthType, AuthCmd = 'kdesu', 'kdesu -- %s'
