$OpenBSD: patch-configure_ac,v 1.4 2010/09/30 07:36:45 ajacoutot Exp $
--- configure.ac.orig	Wed Sep 29 00:40:53 2010
+++ configure.ac	Thu Sep 30 07:58:28 2010
@@ -630,6 +630,7 @@ have_shadow_enhanced=no
 have_shadow_adjunct=no
 have_shadow_hpux=no
 have_passwd_helper=no
+have_bsdauth=no
 
 with_shadow_req=unspecified
 
@@ -846,6 +847,44 @@ esac
 AM_CONDITIONAL(HAVE_PASSWD_HELPER, test x$have_passwd_helper = xyes)
 AC_SUBST(HAVE_PASSWD_HELPER)
 
+#
+# 	check for BSD Authentication bsd_auth(3) (OpenBSD)
+#
+
+have_bsdauth=no
+with_bsdauth_req=unspecified
+
+case "$host" in                                                                                       
+  *-openbsd*)                                                                                         
+    with_bsdauth=yes                                                                          
+esac  
+
+AC_ARG_WITH(bsdauth,
+[  --with-bsdauth    Include support for BSD Authentication (OpenBSD).],
+  [with_bsdauth="$withval"; with_bsdauth_req="$withval"],[with_bsdauth=no])
+
+if test "$enable_locking" = no ; then
+  with_bsdauth_req=no
+  with_bsdauth=no
+fi
+
+HANDLE_X_PATH_ARG(with_bsdauth, --with-bsdauth, BSD Authentication)
+
+if test "$with_bsdauth" = yes ; then
+  AC_CACHE_CHECK([for BSD Authentication], ac_cv_bsdauth,
+    [AC_TRY_X_COMPILE([#include <stdlib.h>
+                       #include <unistd.h>
+                       #include <sys/types.h>
+                       #include <bsd_auth.h>],
+      [int ok = auth_userokay("x", 0, "x", "x");],
+      [have_bsdauth=yes],
+      [have_bsdauth=no])])
+  if test "$have_bsdauth" = yes; then
+    AC_DEFINE(HAVE_BSDAUTH, 1, [Define if you have bsd_auth(3) authentication])
+    need_setuid=yes
+  fi
+fi
+
 if test "$need_setuid" = yes -a "$have_pam" != yes ; then
   NEED_SETUID=yes
 else
@@ -858,7 +897,7 @@ dnl  Authentication scheme
 dnl ---------------------------------------------------------------------------
 
 AC_ARG_ENABLE(authentication-scheme,
-  [  --enable-authentication-scheme=[auto/pam/helper/pwent]  Choose a specific
+  [  --enable-authentication-scheme=[auto/pam/helper/bsdauth/pwent]  Choose a specific
                           authentication scheme [default=auto]],,
   enable_authentication_scheme=auto)
 
@@ -870,11 +909,16 @@ fi
 if test x$enable_authentication_scheme = xhelper -a x$have_passwd_helper = xno ; then
 	AC_MSG_ERROR(Password helper support requested but not available)
 fi
+if test x$enable_authentication_scheme = xbsdauth -a x$have_bsdauth = xno ; then
+	AC_MSG_ERROR(BSD Authentication support requested but not available)
+fi
 
 if test x$enable_authentication_scheme = xpam ; then
         AUTH_SCHEME="pam"
 elif test x$enable_authentication_scheme = xhelper ; then
         AUTH_SCHEME="helper"
+elif test x$enable_authentication_scheme = xbsdauth ; then
+        AUTH_SCHEME="bsdauth"
 elif test x$enable_authentication_scheme = xpwent ; then
         AUTH_SCHEME="pwent"
 elif test x$enable_authentication_scheme = xauto ; then
@@ -882,6 +926,8 @@ elif test x$enable_authentication_scheme = xauto ; the
 		AUTH_SCHEME="pam"
 	elif test x$have_passwd_helper != xno ; then
 		AUTH_SCHEME="helper"
+	elif test x$have_bsdauth != xno ; then
+		AUTH_SCHEME="bsdauth"
 	else
 		AUTH_SCHEME="pwent"
         fi
