From 1cbce322feb8a3a93c5a6df4ec6992d65593fd80 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Mon, 26 Nov 2012 08:51:18 -0600
Subject: autofs: 5.0.7

---
 .../0001-autofs-5.0.5-include-krb5-library.patch   | 206 +++++++++++++++++++++
 ....0.5-remove-ERR_remove_state-openssl-call.patch |  59 ++++++
 abs/extra/autofs/Changelog                         |   6 -
 abs/extra/autofs/PKGBUILD                          |  77 ++++----
 abs/extra/autofs/autofs.install                    |   5 +-
 abs/extra/autofs/finish                            |   9 -
 abs/extra/autofs/heimdal.patch                     |  44 -----
 abs/extra/autofs/log.run                           |   2 -
 8 files changed, 308 insertions(+), 100 deletions(-)
 create mode 100644 abs/extra/autofs/0001-autofs-5.0.5-include-krb5-library.patch
 create mode 100644 abs/extra/autofs/0002-autofs-5.0.5-remove-ERR_remove_state-openssl-call.patch
 delete mode 100755 abs/extra/autofs/Changelog
 mode change 100755 => 100644 abs/extra/autofs/PKGBUILD
 delete mode 100755 abs/extra/autofs/finish
 delete mode 100644 abs/extra/autofs/heimdal.patch
 delete mode 100755 abs/extra/autofs/log.run

diff --git a/abs/extra/autofs/0001-autofs-5.0.5-include-krb5-library.patch b/abs/extra/autofs/0001-autofs-5.0.5-include-krb5-library.patch
new file mode 100644
index 0000000..572ca97
--- /dev/null
+++ b/abs/extra/autofs/0001-autofs-5.0.5-include-krb5-library.patch
@@ -0,0 +1,206 @@
+From e467755fac27630730be25c4b41e5d0cfcd89c67 Mon Sep 17 00:00:00 2001
+From: Ian Kent <raven@themaw.net>
+Date: Tue, 10 Aug 2010 15:48:21 +0800
+Subject: [PATCH 1/2] autofs-5.0.5 - include krb5 library
+
+Since the Cyrus SASL module calls Kerberos directly we should be
+linking against the Kerberos librarys.
+---
+ Makefile.conf.in |    2 +
+ aclocal.m4       |   19 +++++++++++++++
+ configure        |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
+ configure.in     |    5 +++-
+ modules/Makefile |    4 +-
+ 5 files changed, 93 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile.conf.in b/Makefile.conf.in
+index f0287c3..a9bcf8c 100644
+--- a/Makefile.conf.in
++++ b/Makefile.conf.in
+@@ -31,6 +31,8 @@ XML_FLAGS = @XML_FLAGS@
+ SASL = @HAVE_SASL@
+ LIBSASL= @LIBSASL@
+ SASL_FLAGS = @SASL_FLAGS@
++KRB5_LIBS=@KRB5_LIBS@
++KRB5_FLAGS=@KRB5_FLAGS@
+ 
+ # NIS+ support: yes (1) no (0)
+ NISPLUS = @HAVE_NISPLUS@
+diff --git a/aclocal.m4 b/aclocal.m4
+index e7f1a30..750a159 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -215,6 +215,25 @@ else
+ fi])
+ 
+ dnl --------------------------------------------------------------------------
++dnl AF_CHECK_KRB5
++dnl
++dnl Check for Kerberos 5
++dnl --------------------------------------------------------------------------
++AC_DEFUN([AF_CHECK_KRB5],
++[AC_PATH_PROGS(KRB5_CONFIG, krb5-config, no)
++AC_MSG_CHECKING(for Kerberos library)
++if test "$KRB5_CONFIG" = "no"
++then
++  AC_MSG_RESULT(no)
++  HAVE_KRB5=0
++else
++  AC_MSG_RESULT(yes)
++  HAVE_KRB5=1
++  KRB5_LIBS=`$KRB5_CONFIG --libs`
++  KRB5_FLAGS=`$KRB5_CONFIG --cflags`
++fi])
++
++dnl --------------------------------------------------------------------------
+ dnl AF_CHECK_LIBHESIOD
+ dnl
+ dnl Check for lib hesiod
+diff --git a/configure b/configure
+index 159f25f..500411c 100755
+--- a/configure
++++ b/configure
+@@ -640,6 +640,8 @@ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ DAEMON_LDFLAGS
+ DAEMON_CFLAGS
++KRB5_FLAGS
++KRB5_LIBS
+ LIBSASL
+ HAVE_SASL
+ SASL_FLAGS
+@@ -657,6 +659,7 @@ LIBHESIOD
+ HAVE_HESIOD
+ LIBRESOLV
+ LIBNSL
++KRB5_CONFIG
+ XML_CONFIG
+ PATH_RPCGEN
+ RPCGEN
+@@ -3723,7 +3726,7 @@ $as_echo "no" >&6; }
+   fi
+ fi
+ 
+-# LDAP SASL auth need libxml
++# LDAP SASL auth needs libxml and Kerberos
+ for ac_prog in xml2-config
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+@@ -3801,6 +3804,66 @@ _ACEOF
+     fi
+   fi
+ fi
++for ac_prog in krb5-config
++do
++  # Extract the first word of "$ac_prog", so it can be a program name with args.
++set dummy $ac_prog; ac_word=$2
++{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_path_KRB5_CONFIG+set}" = set; then
++  $as_echo_n "(cached) " >&6
++else
++  case $KRB5_CONFIG in
++  [\\/]* | ?:[\\/]*)
++  ac_cv_path_KRB5_CONFIG="$KRB5_CONFIG" # Let the user override the test with a path.
++  ;;
++  *)
++  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++  for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_path_KRB5_CONFIG="$as_dir/$ac_word$ac_exec_ext"
++    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++done
++IFS=$as_save_IFS
++
++  ;;
++esac
++fi
++KRB5_CONFIG=$ac_cv_path_KRB5_CONFIG
++if test -n "$KRB5_CONFIG"; then
++  { $as_echo "$as_me:$LINENO: result: $KRB5_CONFIG" >&5
++$as_echo "$KRB5_CONFIG" >&6; }
++else
++  { $as_echo "$as_me:$LINENO: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++  test -n "$KRB5_CONFIG" && break
++done
++test -n "$KRB5_CONFIG" || KRB5_CONFIG="no"
++
++{ $as_echo "$as_me:$LINENO: checking for Kerberos library" >&5
++$as_echo_n "checking for Kerberos library... " >&6; }
++if test "$KRB5_CONFIG" = "no"
++then
++  { $as_echo "$as_me:$LINENO: result: no" >&5
++$as_echo "no" >&6; }
++  HAVE_KRB5=0
++else
++  { $as_echo "$as_me:$LINENO: result: yes" >&5
++$as_echo "yes" >&6; }
++  HAVE_KRB5=1
++  KRB5_LIBS=`$KRB5_CONFIG --libs`
++  KRB5_FLAGS=`$KRB5_CONFIG --cflags`
++fi
+ 
+ #
+ # glibc/libc 6 new libraries
+@@ -5178,6 +5241,8 @@ fi
+ 
+ 
+ 
++
++
+ LDFLAGS="${AF_tmp_ldflags}"
+ 
+ #
+diff --git a/configure.in b/configure.in
+index f649a58..70b45e8 100644
+--- a/configure.in
++++ b/configure.in
+@@ -144,8 +144,9 @@ AF_CHECK_PROG(RPCGEN, rpcgen, , $searchpath)
+ #
+ AF_SLOPPY_MOUNT()
+ 
+-# LDAP SASL auth need libxml
++# LDAP SASL auth needs libxml and Kerberos
+ AF_CHECK_LIBXML()
++AF_CHECK_KRB5()
+ 
+ #
+ # glibc/libc 6 new libraries
+@@ -274,6 +275,8 @@ AC_SUBST(XML_LIBS)
+ AC_SUBST(SASL_FLAGS)
+ AC_SUBST(HAVE_SASL)
+ AC_SUBST(LIBSASL)
++AC_SUBST(KRB5_LIBS)
++AC_SUBST(KRB5_FLAGS)
+ LDFLAGS="${AF_tmp_ldflags}"
+ 
+ #
+diff --git a/modules/Makefile b/modules/Makefile
+index 13b3bd8..2389196 100644
+--- a/modules/Makefile
++++ b/modules/Makefile
+@@ -42,8 +42,8 @@ ifeq ($(LDAP), 1)
+   MODS += lookup_ldap.so
+   ifeq ($(SASL), 1)
+     SASL_OBJ = cyrus-sasl.o
+-    LDAP_FLAGS += $(SASL_FLAGS) $(XML_FLAGS) -DLDAP_THREAD_SAFE
+-    LIBLDAP += $(LIBSASL) $(XML_LIBS)
++    LDAP_FLAGS += $(SASL_FLAGS) $(XML_FLAGS) $(KRB5_FLAGS) -DLDAP_THREAD_SAFE
++    LIBLDAP += $(LIBSASL) $(XML_LIBS) $(KRB5_LIBS)
+   endif
+ endif
+ 
+-- 
+1.7.5.1
+
diff --git a/abs/extra/autofs/0002-autofs-5.0.5-remove-ERR_remove_state-openssl-call.patch b/abs/extra/autofs/0002-autofs-5.0.5-remove-ERR_remove_state-openssl-call.patch
new file mode 100644
index 0000000..e4e480e
--- /dev/null
+++ b/abs/extra/autofs/0002-autofs-5.0.5-remove-ERR_remove_state-openssl-call.patch
@@ -0,0 +1,59 @@
+From 205c305922cdbded91ff8fadbaad7959bdb497bc Mon Sep 17 00:00:00 2001
+From: Ian Kent <raven@themaw.net>
+Date: Wed, 11 Aug 2010 09:33:09 +0800
+Subject: [PATCH 2/2] autofs-5.0.5 - remove ERR_remove_state() openssl call
+
+autofs should never have had to use ERR_remove_state() so remove that call.
+
+Lukas: Resolve a conflict in "CHANGELOG" that occured due to cherry
+picking Kerberos related patches from the 5.0.6 development branch.
+
+Conflicts:
+
+	CHANGELOG
+
+Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
+---
+ CHANGELOG             |    4 ++++
+ modules/lookup_ldap.c |   12 +-----------
+ 2 files changed, 5 insertions(+), 11 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index e734cb3..1a20a81 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -1,3 +1,7 @@
++??/??/20?? autofs-5.0.6
++-----------------------
++- remove ERR_remove_state() openssl call.
++
+ 03/09/2009 autofs-5.0.5
+ -----------------------
+ - fix dumb libxml2 check
+diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
+index 2ecf5fe..1221c2c 100644
+--- a/modules/lookup_ldap.c
++++ b/modules/lookup_ldap.c
+@@ -168,18 +168,8 @@ int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *c
+ 	int rv;
+ 
+ #ifdef WITH_SASL
+-	/*
+-	 * The OpenSSL library can't handle having its message and error
+-	 * string database loaded multiple times and segfaults if the
+-	 * TLS environment is not reset at the right times. As there
+-	 * is no ldap_stop_tls call in the openldap library we have
+-	 * to do the job ourselves, here and in lookup_done when the
+-	 * module is closed.
+-	 */
+-	if (ctxt->use_tls == LDAP_TLS_RELEASE) {
+-		ERR_remove_state(0);
++	if (ctxt->use_tls == LDAP_TLS_RELEASE)
+ 		ctxt->use_tls = LDAP_TLS_INIT;
+-	}
+ 	autofs_sasl_unbind(ctxt);
+ #endif
+ 
+-- 
+1.7.5.1
+
diff --git a/abs/extra/autofs/Changelog b/abs/extra/autofs/Changelog
deleted file mode 100755
index d8df4dc..0000000
--- a/abs/extra/autofs/Changelog
+++ /dev/null
@@ -1,6 +0,0 @@
-5.0.4-5 4/29/09
-Cecil - Added run and finish files for runit.
-6/28/10
-Britney - Updated run to manage automount; removed finish and /etc/rc.d/autofs; added logger
-5.0.5-1 6/12/10
-Britney - Updated to 5.0.5 based on arch autofs 5.0.5 PKGBUILD and heimdal.patch with runit support added.
diff --git a/abs/extra/autofs/PKGBUILD b/abs/extra/autofs/PKGBUILD
old mode 100755
new mode 100644
index ae04100..3663f03
--- a/abs/extra/autofs/PKGBUILD
+++ b/abs/extra/autofs/PKGBUILD
@@ -1,50 +1,55 @@
-# $Id: PKGBUILD 75323 2010-04-01 10:16:24Z allan $
-# Maintainer: Andrea Scarpino <andrea@archlinux.org>
+# $Id: PKGBUILD 75188 2012-08-15 18:36:09Z lfleischer $
+# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
+# Contributor: Andrea Scarpino <andrea@archlinux.org>
 # Contributor: Dale Blount <dale@archlinux.org>
 # Contributor: Manolis Tzanidakis
 
 pkgname=autofs
-pkgver=5.0.5
-pkgrel=3
-pkgdesc="A kernel-based automounter for Linux"
+pkgver=5.0.7
+pkgrel=1
+pkgdesc='A kernel-based automounter for Linux.'
 arch=('i686' 'x86_64')
-url="http://wiki.autofs.net/FrontPage"
+url='http://freshmeat.net/projects/autofs'
 license=('GPL2')
-depends=('libldap' 'libxml2' 'heimdal')
-backup=(etc/autofs/auto.master etc/autofs/auto.misc etc/conf.d/autofs)
-install=${pkgname}.install
+depends=('libxml2')
+makedepends=('libldap' 'krb5')
+optdepends=('krb5: for LDAP support')
+backup=('etc/autofs/auto.master'
+        'etc/autofs/auto.misc'
+        'etc/conf.d/autofs')
+options=(!makeflags)
+install='autofs.install'
 source=("http://www.kernel.org/pub/linux/daemons/${pkgname}/v5/${pkgname}-${pkgver}.tar.bz2"
-        'autofs' 'autofs.conf.d' 'auto.master' 'auto.misc'
-        'heimdal.patch')
-md5sums=('a1d262cb6ebef0c2dd0fe22232fb3d5a'
-         'e307bf6d2638e46eeb916cf42fe029b2'
-         '47f597c870410055e0fdb66103daf928'
-         'a6cefb591e77b31b79dbb7243646c96b'
-         'd8a15ec9186c5c0b36e5cea1e2739e8a'
-         'efd46b6406b940cb48f7c6197790fb8e')
+        'autofs'
+        'autofs.conf.d'
+        'auto.master'
+        'auto.misc')
 
 build() {
-  export MAKEFLAGS="-j1"
-  cd ${srcdir}/${pkgname}-${pkgver}
+  cd "${srcdir}/${pkgname}-${pkgver}"
 
-  sed -i "s:SUBDIRS = lib daemon modules man samples:SUBDIRS = lib daemon modules man:" Makefile.rules
-  patch -Np1 -i ${srcdir}/heimdal.patch
+  sed -i "s:SUBDIRS = lib daemon modules man samples:SUBDIRS = lib daemon modules man:" \
+    Makefile.rules
 
-  ./configure --prefix=/usr \
-    --sysconfdir=/etc/autofs \
-    --with-mapdir=/etc/autofs \
-    --without-hesiod
-  make || return 1
-
-  sed -i "s:/etc:/etc/autofs:g" man/auto.master.5
+  ./configure --prefix=/usr --sysconfdir=/etc/autofs --with-mapdir=/etc/autofs --without-hesiod \
+    --enable-ignore-busy --with-systemd
+  make
 }
 
-package(){
-  cd ${srcdir}/${pkgname}-${pkgver}
-  make INSTALLROOT=${pkgdir} install
-  
-  install -Dm644 ${srcdir}/auto.master ${pkgdir}/etc/autofs/auto.master || return 1
-  install -Dm644 ${srcdir}/auto.misc ${pkgdir}/etc/autofs/auto.misc || return 1
-  install -Dm755 ${srcdir}/autofs ${pkgdir}/etc/rc.d/autofs || return 1
-  install -Dm644 ${srcdir}/autofs.conf.d ${pkgdir}/etc/conf.d/autofs || return 1
+package() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+
+  make INSTALLROOT="${pkgdir}" install
+
+  install -Dm0644 "${srcdir}/auto.master" "${pkgdir}/etc/autofs/auto.master"
+  install -Dm0644 "${srcdir}/auto.misc" "${pkgdir}/etc/autofs/auto.misc"
+  install -Dm0755 "${srcdir}/autofs" "${pkgdir}/etc/rc.d/autofs"
+  install -Dm0644 "${srcdir}/autofs.conf.d" "${pkgdir}/etc/conf.d/autofs"
+
+  install -Dm0644 "samples/autofs.service" "${pkgdir}/usr/lib/systemd/system/autofs.service"
 }
+md5sums=('bc46838dece83c02d800ff144ed9f431'
+         'e307bf6d2638e46eeb916cf42fe029b2'
+         '47f597c870410055e0fdb66103daf928'
+         'a6cefb591e77b31b79dbb7243646c96b'
+         'd8a15ec9186c5c0b36e5cea1e2739e8a')
diff --git a/abs/extra/autofs/autofs.install b/abs/extra/autofs/autofs.install
index 7806efa..34ae75f 100644
--- a/abs/extra/autofs/autofs.install
+++ b/abs/extra/autofs/autofs.install
@@ -1,5 +1,4 @@
 post_install(){
-	echo "#########################################################"
-	echo "In autofs5 --ghost option isn't valid. In order to start autofs"
-	echo "you must remove that option from your /etc/conf.d/autofs. "
+  echo "> In autofs5 --ghost option isn't valid. In order to start autofs you"
+  echo "> must remove that option from your /etc/conf.d/autofs."
 }
diff --git a/abs/extra/autofs/finish b/abs/extra/autofs/finish
deleted file mode 100755
index 40d2fdc..0000000
--- a/abs/extra/autofs/finish
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-exec 2>&1
-
-. /etc/rc.conf
-. /etc/rc.d/functions
-
-stat_runit "Stopping autofs4 kernel module" && echo ""
-set -e  # barf if modprobe fails
-/sbin/modprobe -r autofs4
diff --git a/abs/extra/autofs/heimdal.patch b/abs/extra/autofs/heimdal.patch
deleted file mode 100644
index 4aa3218..0000000
--- a/abs/extra/autofs/heimdal.patch
+++ /dev/null
@@ -1,44 +0,0 @@
---- autofs-5.0.5/modules/cyrus-sasl.c~	2010-03-03 01:38:41.582901786 +0100
-+++ autofs-5.0.5/modules/cyrus-sasl.c	2010-03-03 01:41:32.313704755 +0100
-@@ -66,6 +66,15 @@
- #endif
- #endif
- 
-+/**
-+ * The type of a principal is different for MIT Krb5 and Heimdal.
-+ * These macros are provided by Heimdal, and introduced here for MIT.
-+ */
-+#ifndef krb5_realm_length
-+#define krb5_realm_length(r) ((r).length)
-+#define krb5_realm_data(r) ((r).data)
-+#endif
-+
- /*
-  *  Once a krb5 credentials cache is setup, we need to set the KRB5CCNAME
-  *  environment variable so that the library knows where to find it.
-@@ -452,11 +452,11 @@
- 
- 	/* setup a principal for the ticket granting service */
- 	ret = krb5_build_principal_ext(ctxt->krb5ctxt, &tgs_princ,
--		krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->length,
--		krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->data,
-+		krb5_realm_length(*krb5_principal_get_realm(ctxt->krb5ctxt, krb5_client_princ)),
-+		krb5_realm_data(*krb5_principal_get_realm(ctxt->krb5ctxt, krb5_client_princ)),
- 		strlen(KRB5_TGS_NAME), KRB5_TGS_NAME,
--		krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->length,
--		krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->data,
-+		krb5_realm_length(*krb5_principal_get_realm(ctxt->krb5ctxt, krb5_client_princ)),
-+		krb5_realm_data(*krb5_principal_get_realm(ctxt->krb5ctxt, krb5_client_princ)),
- 		0);
- 	if (ret) {
- 		error(logopt,
---- autofs-5.0.5/modules/Makefile~	2010-03-03 01:42:18.532868539 +0100
-+++ autofs-5.0.5/modules/Makefile	2010-03-03 01:42:35.360367371 +0100
-@@ -43,7 +43,7 @@
-   ifeq ($(SASL), 1)
-     SASL_OBJ = cyrus-sasl.o
-     LDAP_FLAGS += $(SASL_FLAGS) $(XML_FLAGS) -DLDAP_THREAD_SAFE
--    LIBLDAP += $(LIBSASL) $(XML_LIBS)
-+    LIBLDAP += $(LIBSASL) $(XML_LIBS) -lkrb5
-   endif
- endif
\ No newline at end of file
diff --git a/abs/extra/autofs/log.run b/abs/extra/autofs/log.run
deleted file mode 100755
index d184328..0000000
--- a/abs/extra/autofs/log.run
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/usr/bin/logger -p info -i -t autofs
-- 
cgit v0.12

