$OpenBSD: patch-base_password_py,v 1.7 2018/10/31 14:14:30 ajacoutot Exp $

Index: base/password.py
--- base/password.py.orig
+++ base/password.py
@@ -23,6 +23,7 @@ import os
 import getpass
 import time
 import string
+import platform
 
 from . import utils, tui
 from .g import *
@@ -57,6 +58,7 @@ AUTH_TYPES = {'mepis': 'su',
               'boss': 'su',
               'lfs': 'su',
               'manjarolinux': 'sudo',
+              'openbsd':'su',
               }
 
 
@@ -88,10 +90,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'
@@ -323,7 +328,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'
 
@@ -334,7 +343,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'
