Authentication libraries for courier. New versions of maildrop, courier-imap

and friends use these for authentication purposes.
port made with help from bernd, thanks.
This commit is contained in:
mbalmer 2006-11-03 11:45:31 +00:00
parent f73870a0af
commit cf379d32df
24 changed files with 545 additions and 0 deletions

View File

@ -0,0 +1,163 @@
# $OpenBSD: Makefile,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
COMMENT= "authentication library for courier"
COMMENT-ldap= "ldap authentication module for courier-authLib"
COMMENT-mysql= "mysql authentication module for courier-authLib"
COMMENT-pgsql= "pgsql authentication module for courier-authLib"
COMMENT-userdb= "userdb authentication module for courier-authLib"
DISTNAME= courier-authlib-0.58
PKGNAME-ldap= ${DISTNAME:S/lib-/lib-ldap-/}
PKGNAME-mysql= ${DISTNAME:S/lib-/lib-mysql-/}
PKGNAME-pgsql= ${DISTNAME:S/lib-/lib-pgsql-/}
PKGNAME-userdb= ${DISTNAME:S/lib-/lib-userdb-/}
SHARED_LIBS= authpipe 0.0 \
authpwd 0.0 \
courierauth 0.0 \
courierauthcommon 0.0 \
courierauthsasl 0.0 \
courierauthsaslclient 0.0
CATEGORIES= mail security
HOMEPAGE= http://www.courier-mta.org/authlib/
MAINTAINER= Marc Balmer <mbalmer@openbsd.org>
# GPL
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=courier/}
EXTRACT_SUFX= .tar.bz2
USE_GMAKE= Yes
USE_LIBTOOL= Yes
CONFIGURE_STYLE= gnu
CONFIGURE_ENV= LIBS="-L${LOCALBASE}/lib" \
LDFLAGS="-L${LOCALBASE}/lib" \
CPPFLAGS="-I${LOCALBASE}/include"
COURIERSTATE= /var/run/courier-auth
EXAMPLE_DIR= ${PREFIX}/share/examples/courier-authlib
SUBST_VARS= COURIERSTATE EXAMPLE_DIR
CONFIGURE_ARGS+= ${CONFIGURE_SHARED}
CONFIGURE_ARGS+= --enable-static \
--without-authpam \
--without-authvchkpw \
--without-authcustom \
--with-authpwd \
--with-authshadow \
--with-mailuser=_courier \
--with-mailgroup=_courier \
--with-pkgconfdir=${SYSCONFDIR}/courier \
--with-authdaemonvar=${COURIERSTATE} \
--localstatedir=/var \
--libdir=${PREFIX}/lib \
--includedir=${PREFIX}/include \
--enable-ltdl-install=no \
--cache-file=${WRKDIR}/courier-authlib.cache
DOCS= COPYING COPYING.GPL INSTALL NEWS README
MULTI_PACKAGES=
SUBPACKAGE?=
FLAVOR?=
PSEUDO_FLAVORS= no_ldap no_mysql no_pgsql no_userdb
.if !defined(PACKAGING) || ${SUBPACKAGE} == ""
WANTLIB+= c
LIB_DEPENDS+= ltdl::devel/libtool,-ltdl
.endif
.if ${FLAVOR:L:Mno_ldap}
CONFIGURE_ARGS+= --without-authldap
.else
SHARED_LIBS+= authldap 0.0
MULTI_PACKAGES+= -ldap
CONFIGURE_ARGS+= --with-authldap
DOCS+= README.ldap
. if !defined(PACKAGING) || ${SUBPACKAGE} == "-ldap"
WANTLIB+= crypto ssl
LIB_DEPENDS+= ldap,lber::databases/openldap \
sasl2::security/cyrus-sasl2
. if defined(PACKAGING)
LIB_DEPENDS+= courierauthcommon,courierauth::mail/courier-authlib
. endif
. endif
.endif
.if ${FLAVOR:L:Mno_mysql}
CONFIGURE_ARGS+= --without-authmysql
.else
SHARED_LIBS+= authmysql 0.0
MULTI_PACKAGES+= -mysql
CONFIGURE_ARGS+= --with-authmysql \
--with-mysql-libs=${LOCALBASE}/lib/mysql \
--with-mysql-includes=${LOCALBASE}/include/mysql
DOCS+= README.authmysql.myownquery
. if !defined(PACKAGING) || ${SUBPACKAGE} == "-mysql"
WANTLIB+= crypto m ssl z
LIB_DEPENDS+= mysqlclient::databases/mysql
. if defined(PACKAGING)
LIB_DEPENDS+= courierauthcommon,courierauth::mail/courier-authlib
. endif
. endif
.endif
.if ${FLAVOR:L:Mno_pgsql}
CONFIGURE_ARGS+= --without-authpgsql
.else
SHARED_LIBS+= authpgsql 0.0
MULTI_PACKAGES+= -pgsql
CONFIGURE_ARGS+= --with-authpgsql \
--with-pgsql-libs=${LOCALBASE}/lib \
--with-pgsql-includes=${LOCALBASE}/include/postgresql
. if !defined(PACKAGING) || ${SUBPACKAGE} == "-pgsql"
WANTLIB+= m
LIB_DEPENDS+= pq::databases/postgresql
. if defined(PACKAGING)
LIB_DEPENDS+= courierauthcommon,courierauth::mail/courier-authlib
. endif
. endif
.endif
.if ${FLAVOR:L:Mno_userdb}
CONFIGURE_ARGS+= --without-authuserdb \
--without-makedatprog
.else
SHARED_LIBS+= authuserdb 0.0
MULTI_PACKAGES+= -userdb
CONFIGURE_ARGS+= --with-makedatprog \
--with-authuserdb \
--with-db=gdbm
. if !defined(PACKAGING) || ${SUBPACKAGE} == "-userdb"
WANTLIB+= c
LIB_DEPENDS+= gdbm.>=3::databases/gdbm
. if defined(PACKAGING)
LIB_DEPENDS+= courierauthcommon,courierauth::mail/courier-authlib
. endif
. endif
.endif
post-install:
mv ${PREFIX}/lib/courier-authlib/lib* ${PREFIX}/lib
${INSTALL_SCRIPT} ${WRKSRC}/sysconftool \
${PREFIX}/libexec/courier-authlib/sysconftool
${INSTALL_SCRIPT} ${WRKSRC}/authmigrate \
${PREFIX}/libexec/courier-authlib/authmigrate
${INSTALL_DATA_DIR} ${EXAMPLE_DIR}
@mv ${WRKINST}${SYSCONFDIR}/courier/*.dist ${EXAMPLE_DIR}
. if !${FLAVOR:L:Mno_ldap}
${INSTALL_DATA} ${WRKSRC}/authldap.schema ${EXAMPLE_DIR}
. endif
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/courier-authlib
. for i in ${DOCS}
${INSTALL_DATA} ${WRKSRC}/${i} ${PREFIX}/share/doc/courier-authlib
. endfor
.include <bsd.port.mk>

View File

@ -0,0 +1,4 @@
MD5 (courier-authlib-0.58.tar.bz2) = fb691558d611cb191ae6a83002f0195b
RMD160 (courier-authlib-0.58.tar.bz2) = 6474612496cd287f294c7f52239ea853c44e4aa1
SHA1 (courier-authlib-0.58.tar.bz2) = 8bdab3c2e734cc8f47230924ec638ba3609a92a1
SIZE (courier-authlib-0.58.tar.bz2) = 2006735

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-authdaemond_in,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
--- authdaemond.in.orig Sat Aug 6 04:56:27 2005
+++ authdaemond.in Sat Aug 6 04:56:48 2005
@@ -10,7 +10,7 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
sbindir=@sbindir@
-localstatedir=@localstatedir@
+localstatedir=/var/run/courier-auth
set -a
. @authdaemonrc@

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-authldap_h,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
--- authldap.h.orig Wed Feb 1 13:32:09 2006
+++ authldap.h Wed Feb 1 13:32:29 2006
@@ -1,6 +1,8 @@
#ifndef authldap_h
#define authldap_h
+#define LDAP_DEPRECATED
+
/*
** $Id: patch-authldap_h,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
**

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-authpipelib_c,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
--- authpipelib.c.orig Tue Dec 27 15:22:17 2005
+++ authpipelib.c Tue Dec 27 15:22:52 2005
@@ -42,7 +42,7 @@ static void execChild(int to[], int from
close(STDOUT_FILENO); dup2(from[1], STDOUT_FILENO);
close(to[0]); close(to[1]); close(from[0]); close(from[1]);
- execl(PIPE_PROGRAM, PIPE_PROGRAM, NULL);
+ execl(PIPE_PROGRAM, PIPE_PROGRAM, (char *)NULL);
DPRINTF("pipe: failed to execute %s: %s",PIPE_PROGRAM, strerror(errno));
exit(1);

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-configure,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
--- configure.orig Fri Jan 6 20:38:09 2006
+++ configure Fri Jan 6 20:39:31 2006
@@ -25688,8 +25688,8 @@ if test -x "$COURIERCONFIG"
then
$COURIERCONFIG >conftest.out || exit 1
sed -n '/^mail/p' <conftest.out >conftest2.out || exit 1
- . conftest2.out
- rm -f conftest.out conftest2.out
+ . ./conftest2.out
+ rm -f ./conftest.out ./conftest2.out
cmailuser="$mailuser"
cmailgroup="$mailgroup"
@@ -25700,8 +25700,8 @@ if test -x "$bindir/courierauthconfig"
then
$bindir/courierauthconfig --configfiles >conftest.out || exit 1
sed -n '/^mail/p' <conftest.out >conftest2.out || exit 1
- . conftest2.out
- rm -f conftest.out conftest2.out
+ . ./conftest2.out
+ rm -f ./conftest.out ./conftest2.out
cmailuser="$mailuser"
cmailgroup="$mailgroup"

View File

@ -0,0 +1,82 @@
$OpenBSD: patch-liblock_locktest_c,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
--- liblock/locktest.c.orig Mon Dec 6 11:18:55 1999
+++ liblock/locktest.c Fri Jan 6 11:34:58 2006
@@ -5,6 +5,7 @@
/* $Id */
+#include <paths.h>
#include "liblock.h"
#if USE_FCNTL
#include "lockfcntl.c"
@@ -20,11 +21,23 @@
int main()
{
+#define FILENAME "courier-authlib.locktest.XXXXX"
int fd[2];
pid_t p;
int s;
int f;
+ char *name;
+ const char *tmpdir;
+ if ((tmpdir = (char *)getenv("TMPDIR")) == NULL)
+ tmpdir = _PATH_TMP;
+ (void)asprintf(&name, "%s%s%s", tmpdir,
+ (tmpdir[strlen(tmpdir) - 1] == '/') ? "" : "/", FILENAME);
+ if (name == NULL) {
+ perror("get filename");
+ exit(1);
+ }
+
signal(SIGCHLD, SIG_DFL);
if (pipe(fd))
{
@@ -32,6 +45,12 @@ int f;
return (1);
}
+ if ((f=mkstemp(name)) < 0)
+ {
+ perror("open");
+ exit(1);
+ }
+
if ((p=fork()) == (pid_t)-1)
{
perror("fork");
@@ -46,7 +65,7 @@ int f;
read(fd[0], &c, 1);
close(fd[0]);
- if ((f=open("conftest.lock", O_RDWR|O_CREAT, 0644)) < 0)
+ if ((f=open(name, O_RDWR)) < 0)
{
perror("open");
exit(1);
@@ -56,22 +75,18 @@ int f;
if (ll_lockfd(f, ll_writelock, 0, 0))
{
close(f);
+ unlink(name);
exit(0);
}
close(f);
exit(1);
}
-
- if ((f=open("conftest.lock", O_RDWR|O_CREAT, 0644)) < 0)
- {
- perror("open");
- exit(1);
- }
if (ll_lockfd(f, ll_writelock, 0, 0))
{
perror("lock");
close(f);
+ unlink(name);
exit(1);
}
close(fd[1]);

View File

@ -0,0 +1,103 @@
$OpenBSD: patch-userdb_pw2userdb_in,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
--- userdb/pw2userdb.in.orig Fri Jan 6 11:29:43 2006
+++ userdb/pw2userdb.in Fri Jan 6 11:31:23 2006
@@ -7,6 +7,8 @@
# Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
# distribution information.
+# Adapted to BSD master.passwd
+
use Getopt::Long;
#
@@ -22,42 +24,66 @@ die "Invalid options.\n" unless
if $vpopuid;
$passwd="/etc/passwd" unless $passwd =~ /./;
-$shadow="/etc/shadow" unless $shadow =~ /./;
+$shadow="/etc/master.passwd" unless $shadow =~ /./;
$domain="" unless $domain =~ /./;
$domain="\@$domain" if $domain =~ /./;
-open(PASSWD, $passwd) || die "$!\n";
-
-while (<PASSWD>)
+if (! $noshadow && $shadow =~ /master.passwd$/)
{
- chop if /\n$/;
- next if /^#/;
- ($acct,$passwd,$uid,$gid,$name,$home,$shell)=split( /:/ );
+ open(PASSWD, $shadow) || die "$!\n";
- ($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;
+ while (<PASSWD>)
+ {
+ chop if /\n$/;
+ next if /^#/;
+ ($acct,$passwd,$uid,$gid,$class,$change,$expire,$name,$home,$shell)=split( /:/ );
- $PASSWORD{$acct}=$passwd if $passwd ne "x";
- $UID{$acct}=$uid;
- $GID{$acct}=$gid;
- $HOME{$acct}=$home;
- $SHELL{$acct}=$shell;
+ ($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;
+ $name =~ s/\|/./g; # Just in case
- $name =~ s/\|/./g; # Just in case
- $GECOS{$acct}=$name;
-}
-close (PASSWD);
+ $PASSWORD{$acct}=$passwd;
+ $UID{$acct}=$uid;
+ $GID{$acct}=$gid;
+ $HOME{$acct}=$home;
+ $SHELL{$acct}=$shell;
+ $GECOS{$acct}=$name;
+ }
+ close (PASSWD);
+} else {
+ open(PASSWD, $passwd) || die "$!\n";
-if ( -f $shadow && ! $noshadow)
-{
- open (SHADOW, $shadow) || die "$!\n";
- while (<SHADOW>)
+ while (<PASSWD>)
{
+ chop if /\n$/;
next if /^#/;
- ($acct,$passwd,$dummy)=split(/:/);
- $PASSWORD{$acct}=$passwd;
+ ($acct,$passwd,$uid,$gid,$name,$home,$shell)=split( /:/ );
+
+ ($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;
+
+ $PASSWORD{$acct}=$passwd if $passwd ne "x";
+ $UID{$acct}=$uid;
+ $GID{$acct}=$gid;
+ $HOME{$acct}=$home;
+ $SHELL{$acct}=$shell;
+
+ $name =~ s/\|/./g; # Just in case
+ $GECOS{$acct}=$name;
}
- close (SHADOW);
+ close (PASSWD);
+
+ if ( -f $shadow && ! $noshadow)
+ {
+ open (SHADOW, $shadow) || die "$!\n";
+ while (<SHADOW>)
+ {
+
+ next if /^#/;
+ ($acct,$passwd,$dummy)=split(/:/);
+ $PASSWORD{$acct}=$passwd;
+ }
+ close (SHADOW);
+ }
}
while ( defined ($key=each %UID))

View File

@ -0,0 +1,2 @@
The Courier authentication library provides authentication services for
other Courier applications.

View File

@ -0,0 +1,5 @@
This package provides an LDAP authentication backend for Courier-IMAP.
Install this package in order to enable authentication using LDAP.
Documentation is installed in:
${LOCALBASE}/share/doc/courier-authlib

View File

@ -0,0 +1,6 @@
This package provides a MySQL database authentication backend for
Courier-IMAP. Install this package in order to enable authentication
using MySQL.
Documentation is installed in:
${LOCALBASE}/share/doc/courier-authlib

View File

@ -0,0 +1,6 @@
This package provides a PostgreSQL database authentication backend
for Courier-IMAP. Install this package in order to enable to
authenticating using PostgreSQL.
Documentation is installed in:
${LOCALBASE}/share/doc/courier-authlib

View File

@ -0,0 +1,7 @@
This package provides a userDB database authentication backend for
Courier-IMAP. Install this package in order to enable to authenticating
using userdb. The userdb authentication module includes Perl scripts
that maintain a list of available accounts in plain text files.
Documentation is installed in:
${LOCALBASE}/share/doc/courier-authlib

View File

@ -0,0 +1 @@
Sample configuration files are installed in ${SYSCONFDIR}/courier/.

View File

@ -0,0 +1,7 @@
@comment $OpenBSD: PFRAG.shared,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
@lib lib/libauthpipe.so.${LIBauthpipe_VERSION}
@lib lib/libauthpwd.so.${LIBauthpwd_VERSION}
@lib lib/libcourierauth.so.${LIBcourierauth_VERSION}
@lib lib/libcourierauthcommon.so.${LIBcourierauthcommon_VERSION}
@lib lib/libcourierauthsasl.so.${LIBcourierauthsasl_VERSION}
@lib lib/libcourierauthsaslclient.so.${LIBcourierauthsaslclient_VERSION}

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.shared-ldap,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
@lib lib/libauthldap.so.${LIBauthldap_VERSION}

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.shared-mysql,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
@lib lib/libauthmysql.so.${LIBauthmysql_VERSION}

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.shared-pgsql,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
@lib lib/libauthpgsql.so.${LIBauthpgsql_VERSION}

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.shared-userdb,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
@lib lib/libauthuserdb.so.${LIBauthuserdb_VERSION}

View File

@ -0,0 +1,55 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
@conflict courier-authlib-*
@newgroup _courier:556
@newuser _courier:556:556:daemon:Courier Mail Server:/var/empty:/sbin/nologin
%%SHARED%%
bin/courierauthconfig
include/courier_auth_config.h
include/courierauth.h
include/courierauthdebug.h
include/courierauthsasl.h
include/courierauthsaslclient.h
@comment lib/courier-authlib/
@comment lib/libauthpipe.a
@comment lib/libauthpipe.la
@comment lib/libauthpwd.a
@comment lib/libauthpwd.la
@comment lib/libcourierauth.a
@comment lib/libcourierauth.la
@comment lib/libcourierauthcommon.a
@comment lib/libcourierauthcommon.la
@comment lib/libcourierauthsasl.a
@comment lib/libcourierauthsasl.la
@comment lib/libcourierauthsaslclient.a
@comment lib/libcourierauthsaslclient.la
libexec/courier-authlib/
libexec/courier-authlib/authdaemond
libexec/courier-authlib/authmigrate
libexec/courier-authlib/authsystem.passwd
libexec/courier-authlib/sysconftool
@man man/man1/authpasswd.1
@man man/man1/authtest.1
@man man/man1/courierlogger.1
@man man/man3/auth_enumerate.3
@man man/man3/auth_generic.3
@man man/man3/auth_getoption.3
@man man/man3/auth_getuserinfo.3
@man man/man3/auth_login.3
@man man/man3/auth_passwd.3
@man man/man3/auth_sasl.3
@man man/man3/authlib.3
sbin/authdaemond
sbin/authenumerate
sbin/authpasswd
sbin/authtest
sbin/courierlogger
share/doc/courier-authlib/
share/doc/courier-authlib/COPYING
share/doc/courier-authlib/COPYING.GPL
share/doc/courier-authlib/INSTALL
share/doc/courier-authlib/NEWS
share/doc/courier-authlib/README
share/examples/courier-authlib/
@sample ${SYSCONFDIR}/courier/
share/examples/courier-authlib/authdaemonrc.dist
@sample ${SYSCONFDIR}/courier/authdaemonrc

View File

@ -0,0 +1,8 @@
@comment $OpenBSD: PLIST-ldap,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
%%SHARED%%
@comment lib/libauthldap.a
@comment lib/libauthldap.la
share/doc/courier-authlib/README.ldap
share/examples/courier-authlib/authldap.schema
share/examples/courier-authlib/authldaprc.dist
@sample ${SYSCONFDIR}/courier/authldaprc

View File

@ -0,0 +1,7 @@
@comment $OpenBSD: PLIST-mysql,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
%%SHARED%%
@comment lib/libauthmysql.a
@comment lib/libauthmysql.la
share/doc/courier-authlib/README.authmysql.myownquery
share/examples/courier-authlib/authmysqlrc.dist
@sample ${SYSCONFDIR}/courier/authmysqlrc

View File

@ -0,0 +1,6 @@
@comment $OpenBSD: PLIST-pgsql,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
%%SHARED%%
@comment lib/libauthpgsql.a
@comment lib/libauthpgsql.la
share/examples/courier-authlib/authpgsqlrc.dist
@sample ${SYSCONFDIR}/courier/authpgsqlrc

View File

@ -0,0 +1,14 @@
@comment $OpenBSD: PLIST-userdb,v 1.1.1.1 2006/11/03 11:45:31 mbalmer Exp $
%%SHARED%%
@comment lib/libauthuserdb.a
@comment lib/libauthuserdb.la
libexec/courier-authlib/makedatprog
@comment @man man/man8/makeuserdb.8
@comment @man man/man8/userdb.8
@comment @man man/man8/userdbpw.8
sbin/makeuserdb
sbin/pw2userdb
sbin/userdb
sbin/userdb-test-cram-md5
sbin/userdbpw
sbin/vchkpw2userdb