courier-authlib-0.63.0.orig/ 0000755 0000000 0000000 00000000000 11315232541 012520 5 ustar courier-authlib-0.63.0.orig/courier-authlib.lpspec 0000644 0000000 0000000 00000015742 11315232540 017036 0 ustar # $Id: courier-authlib.lpspec.in,v 1.14 2009/12/18 04:24:20 mrsam Exp $
#
# Copyright 2005-2008 Double Precision, Inc. See COPYING for
# distribution information.
Name: courier-authlib
Version: 0.63.0
Release: 1
License: GPL
URL: http://www.courier-mta.org
################################################################################
Source: http://dl.sourceforge.net/courier/%{name}-%{version}.tar.bz2
################################################################################
BuildRequires: libtool
BuildRequires: openldap-devel
BuildRequires: mysql-devel zlib-devel
BuildRequires: postgresql-devel
BuildRequires: gdbm-devel
BuildRequires: pam-devel
BuildRequires: expect
BuildRequires: gcc-c++
BuildRequires: /usr/include/ltdl.h
%{?repository: Repository(pgpkeys.txt): http://download.lpmtool.com//courier-authlib}
%package
Summary: Courier authentication library
Group: System Environment/Daemons
Requires: /sbin/chkconfig
The Courier authentication library provides authentication services for
other Courier applications.
%package devel
Summary: Development libraries for the Courier authentication library
Group: Development/Libraries
Requires: courier-authlib = %{__version}-%{__release}
This package contains the development libraries and files needed to compile
Courier packages that use this authentication library. Install this
package in order to build the rest of the Courier packages. After they are
built and installed this package can be removed. Files in this package
are not needed at runtime.
################################################################################
%package userdb
Summary: userdb support for the Courier authentication library
Group: System Environment/Daemons
Requires: courier-authlib = %{__version}-%{__release}
This package installs the userdb support for the Courier authentication
library. Userdb is a simple way to manage virtual mail accounts using
a GDBM-based database file.
Install this package in order to be able to authenticate with userdb.
################################################################################
%package ldap
Summary: LDAP support for the Courier authentication library
Group: System Environment/Daemons
Requires: courier-authlib = %{__version}-%{__release}
This package installs LDAP support for the Courier authentication library.
Install this package in order to be able to authenticate using LDAP.
################################################################################
%package mysql
Summary: MySQL support for the Courier authentication library
Group: System Environment/Daemons
Requires: courier-authlib = %{__version}-%{__release}
This package installs MySQL support for the Courier authentication library.
Install this package in order to be able to authenticate using MySQL.
################################################################################
%package pgsql
Summary: MySQL support for the Courier authentication library
Group: System Environment/Daemons
Requires: courier-authlib = %{__version}-%{__release}
This package installs PostgreSQL support for the Courier authentication
library.
Install this package in order to be able to authenticate using PostgreSQL.
%begin
%setup
%configure --with-redhat -C
%begin build
%{__make} -s %{_smp_mflags}
%begin install
rm -rf $__installdir
MAKEFLAGS= %{__make} -j 1 install DESTDIR=$__installdir
%{__rm} -f $__installdir%{_libdir}/courier-authlib/*.a
%{__install} -m 555 sysconftool $__installdir%{_libexecdir}/courier-authlib
./courierauthconfig --configfiles >configtmp
. ./configtmp
d=`pwd`
cd $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon || exit 1
$d/authmksock ./socket || exit 1
cd $d || exit 1
touch $__installdir%{_localstatedir}/spool/authdaemon/pid.lock || exit 1
touch $__installdir%{_localstatedir}/spool/authdaemon/pid || exit 1
%{__chmod} 777 $__installdir%{_localstatedir}/spool/authdaemon/socket || exit 1
cat >configfiles.base <configfiles.mysql
echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.ldap
echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.pgsql
echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.userdb
echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.devel
for f in $__installdir%{_sbindir}/*
do
fn=`basename $f`
case "$fn" in
*userdb*)
echo "%{_sbindir}/$fn" >>configfiles.userdb
;;
*)
echo "%{_sbindir}/$fn" >>configfiles.base
;;
esac
done
for f in $__installdir%{_libdir}/courier-authlib/*
do
fn=`basename $f`
case "$fn" in
libauthldap*)
echo "%{_libdir}/courier-authlib/$fn" >>configfiles.ldap
;;
libauthmysql*)
echo "%{_libdir}/courier-authlib/$fn" >>configfiles.mysql
;;
libauthpgsql*)
echo "%{_libdir}/courier-authlib/$fn" >>configfiles.pgsql
;;
libauthldap*)
echo "%{_libdir}/courier-authlib/$fn" >>configfiles.ldap
;;
libauthuserdb*)
echo "%{_libdir}/courier-authlib/$fn" >>configfiles.userdb
;;
*)
echo "%{_libdir}/courier-authlib/$fn" >>configfiles.base
;;
esac
done
%{__mkdir_p} $__installdir%{_sysconfdir}/rc.d/init.d
%{__install} -m 555 courier-authlib.sysvinit \
$__installdir%{_sysconfdir}/rc.d/init.d/courier-authlib
%post
%{_libexecdir}/courier-authlib/sysconftool %{_sysconfdir}/authlib/*.dist >/dev/null
/sbin/chkconfig --del courier-authlib
/sbin/chkconfig --add courier-authlib
%preun
if test -x %{_sbindir}/authdaemond
then
%{_sbindir}/authdaemond >/dev/null 2>&1 || /bin/true
fi
if test "$1" = "0"
then
/sbin/chkconfig --del courier-authlib
fi
%files -f configfiles.base
%defattr(-,root,root,-)
%doc README README*html README.authmysql.myownquery README.ldap
%doc NEWS COPYING* AUTHORS ChangeLog
/etc/rc.d/init.d/*
%ghost %attr(600, root, root) %{_localstatedir}/spool/authdaemon/pid.lock
%ghost %attr(644, root, root) %{_localstatedir}/spool/authdaemon/pid
%ghost %attr(-, root, root) %{_localstatedir}/spool/authdaemon/socket
%{_mandir}/man1/*
%files -f configfiles.userdb userdb
%{_mandir}/man8/*userdb*
%files -f configfiles.devel devel
%defattr(-,root,root,-)
%{_bindir}/courierauthconfig
%{_includedir}/*
%{_mandir}/man3/*
%doc authlib.html auth_*.html
%files -f configfiles.ldap ldap
%defattr(-,root,root,-)
%doc authldap.schema authldap.ldif
%files -f configfiles.mysql mysql
%files -f configfiles.pgsql pgsql
%changelog
* Thu Sep 7 2006 Chris Petersen 0.58-2
- Make the spec a little prettier
- Replace BuildPreReq with BuildRequires
- Remove period from summaries (rpmlint)
- Fix release tag to use %{?dist} macro if it's present
- Change distro-detection to use "rh" and "fc" for version detection, and add support for mandriva
* Sun Oct 3 2004 Mr. Sam 0.50-1
- Initial build.
courier-authlib-0.63.0.orig/auth_getuserinfo.3 0000644 0000000 0000000 00000016123 11054045762 016171 0 ustar .\"
.\"
.\"
.\" Title: auth_getuserinfo
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.73.2
.\" Date: 08/23/2008
.\" Manual: Double Precision, Inc.
.\" Source: Double Precision, Inc.
.\"
.TH "AUTH_GETUSERINFO" "3" "08/23/2008" "Double Precision, Inc." "Double Precision, Inc."
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
auth_getuserinfo - Obtain account information
.SH "SYNOPSIS"
.sp
.RS 4
.nf
#include
.fi
.RE
.HP 24
.BI "int rc=auth_getuserinfo(const\ char\ *" "userid" ", int\ " "(*callback_func)" "(struct\ authinfo\ *,\ void\ *), void\ *" "callback_arg" ");"
.SH "DESCRIPTION"
.PP
If
\fIuserid\fR
is a valid account name, retrieve the account particulars and invoke
\fIcallback_func\fR\.
.SH "RETURNS"
.PP
\fBcallback_func\fR
will be invoked if
\fIuserid\fR
exists, and
\fBcallback_func\fR\'s return value becomes the return value from
\fBauth_getuserinfo\fR
(which should be 0, by convention)\.
\fBcallback_func\fR
will not be invoked if an error occurs, which is reported by a non\-zero return value from
\fBauth_getuserinfo\fR\. By convention, a positive return value indicates an internal, temporary failure, such as the authentication daemon process not running; a negative return value indicates that this request was processed, but it failed (probably because
\fIuserid\fR
does not exist\.
.PP
The second argument to
\fBcallback_func\fR
will be
\fBcallback_arg\fR, which is not interpreted by this function in any way\. The first argument will be a pointer to the following structure:
.PP
\fBExample\ 1.\ struct authinfo\fR
.sp
.RS 4
.nf
struct authinfo {
const char *sysusername;
const uid_t *sysuserid;
gid_t sysgroupid;
const char *homedir;
const char *address;
const char *fullname;
const char *maildir;
const char *quota;
const char *passwd;
const char *clearpasswd;
const char *options;
} ;
.fi
.RE
.PP
Description of the above fields:
.PP
address
.RS 4
The authenticated login ID\.
.RE
.PP
sysusername
.RS 4
The authenticated account\'s userid and groupid can be looked up in the password file using
address\. If this field is
NULL, obtain the userid and the groupid from
sysuserid
and
sysgroupid\.
.RE
.PP
sysuserid
.RS 4
sysuserid
may be
NULL
if
sysusername
is initialized, otherwise it\'s a pointer to the account\'s numeric userid\.
.RE
.PP
sysgroupid
.RS 4
Account\'s numeric groupid\.
sysgroupid
is only used when
sysusername
is
NULL\.
.RE
.PP
fullname
.RS 4
This is the account\'s full name\. This field is optional, it may be
NULL\.
.RE
.PP
homedir
.RS 4
The account\'s home directory\. This field cannot be
NULL\.
.RE
.PP
maildir
.RS 4
The pathname to the account\'s mailbox\. This field is optional, it can be
NULL
in which case the default location is assumed\.
.RE
.PP
quota
.RS 4
Optional maildir quota on the account\'s mailbox (and
NULL
if no quota is set)\.
.RE
.PP
passwd
.RS 4
The account\'s encrypted password, if available\. If the account has a cleartext password defined, this field can be set to
NULL\. The encrypted password can take several formats:
.sp
.RS 4
\h'-04'\(bu\h'+03'A traditional triple\-DES crypted password, or a MD5+salt\-hashed password, as used in Linux\.
.RE
.sp
.RS 4
\h'-04'\(bu\h'+03'
\(lq{MD5}\(rq
followed by a base64\-encoded MD5 hash of the password\.
.RE
.sp
.RS 4
\h'-04'\(bu\h'+03'
\(lq{SHA}\(rq
followed by a base64\-encoded SHA1 hash of the password\.
.RE
.RE
.PP
clearpasswd
.RS 4
The account\'s cleartext password, if available\. If the account has an encrypted password defined, this field can be set to
NULL\.
.RE
.PP
options
.RS 4
A comma\-separated list of miscellaneous account options\. See below for more information\.
.RE
.SS "Account options"
.PP
Depending on the configuration of the Courier authentication library, accounts may have individual options associated with them\. If the authentication library configuration does not implement account options, the option string will be
NULL\. Otherwise it will be a comma\-separated list of
\(lq\fIoption\fR=\fIvalue\fR\(rq
settings\.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
Note
.PP
This is the account option implementation that\'s used by Courier, Courier\-IMAP, and SqWebMail packages\. Some of the following information is obviously not applicable for a particular package\. The inapplicable bits should be obvious\.
.PP
The following options are recognized by the various Courier packages:
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
Note
.PP
The application is responsible for enforcing all the
\(lqdisabled\(rq
option\. An authentication request for service
\(lqimap\(rq, for example, will succeed provided that the userid and the password are valid, even if
\(lqdisableimap=1\(rq
is set\. The application\'s
\fBcallback_func\fR
should check for this condition, and return a negative return code\.
.PP
disableimap=\fIn\fR
.RS 4
If "n" is 1, IMAP access to this account should be disabled\.
.RE
.PP
disablepop3=\fIn\fR
.RS 4
If "n" is 1, POP3 access to this account should be disabled\.
.RE
.PP
disablewebmail=\fIn\fR
.RS 4
If "n" is 1, webmail access to this account should be disabled\.
.RE
.PP
disableshared=\fIn\fR
.RS 4
If "n" is 1, this account should not have access to shared folders or be able to share its own folders with other people\.
.RE
.PP
group=\fIname\fR
.RS 4
This account is a member of access group
\fIname\fR\. Instead of granting access rights on individual mail folders to individual accounts, the access rights can be granted to an access group
\(lqname\(rq, and all members of this group get the specified access rights\.
.sp
The access group name
\(lqadministrators\(rq
is a reserved group\. All accounts in the
administrators
group automatically receive all rights to all accessible folders\.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
Note
This option may be specified multiple times to specify that the account belongs to multiple account groups\.
.RE
.PP
sharedgroup=\fIname\fR
.RS 4
Append "name" to the name of the top level virtual shared folder index file\. This setting restricts which virtual shared folders this account could possibly access (and that\'s on top of whatever else the access control lists say)\. See the virtual shared folder documentation for more information\.
.sp
For technical reasons, group names may not include comma, tab, "/" or "|" characters\.
.RE
.SH "SEE ALSO"
.PP
\fI\fBauthlib\fR(3)\fR\&[1],
\fI\fBauth_generic\fR(3)\fR\&[2],
\fI\fBauth_login\fR(3)\fR\&[3],
\fI\fBauth_enumerate\fR(3)\fR\&[4],
\fI\fBauth_passwd\fR(3)\fR\&[5],
\fI\fBauth_getoption\fR(3)\fR\&[6]\.
.SH "NOTES"
.IP " 1." 4
\fBauthlib\fR(3)
.RS 4
\%authlib.html
.RE
.IP " 2." 4
\fBauth_generic\fR(3)
.RS 4
\%auth_generic.html
.RE
.IP " 3." 4
\fBauth_login\fR(3)
.RS 4
\%auth_login.html
.RE
.IP " 4." 4
\fBauth_enumerate\fR(3)
.RS 4
\%auth_enumerate.html
.RE
.IP " 5." 4
\fBauth_passwd\fR(3)
.RS 4
\%auth_passwd.html
.RE
.IP " 6." 4
\fBauth_getoption\fR(3)
.RS 4
\%auth_getoption.html
.RE
courier-authlib-0.63.0.orig/authldapescape.c 0000644 0000000 0000000 00000002120 11312603051 015635 0 ustar /*
** Copyright 2009 Double Precision, Inc. See COPYING for
** distribution information.
*/
#if HAVE_CONFIG_H
#include "courier_auth_config.h"
#endif
#include
#include
#include
#include
#if HAVE_UNISTD_H
#include
#endif
#include "courierauth.h"
static const char rcsid[]="$Id: authldapescape.c,v 1.2 2009/12/18 04:33:45 mrsam Exp $";
static void escape_specials(const char *str,
char *bufptr,
size_t *sizeptr)
{
static const char specials[]="*()\\";
while (*str)
{
char buf[10];
char *p;
if (strchr(specials, *str))
{
sprintf(buf, "\\%02x", (int)(unsigned char)*str);
}
else
{
buf[0]=*str;
buf[1]=0;
}
for (p=buf; *p; p++)
{
if (bufptr)
*bufptr++=*p;
if (sizeptr)
++*sizeptr;
}
++str;
}
if (bufptr)
*bufptr=0;
}
char *courier_auth_ldap_escape(const char *str)
{
char *escaped;
size_t escaped_cnt=1;
int rc;
escape_specials(str, NULL, &escaped_cnt);
escaped=malloc(escaped_cnt);
if (!escaped)
return NULL;
escape_specials(str, escaped, NULL);
return escaped;
}
courier-authlib-0.63.0.orig/authdaemon.c 0000644 0000000 0000000 00000005010 11031735274 015013 0 ustar /*
** Copyright 2000-2008 Double Precision, Inc. See COPYING for
** distribution information.
*/
#include "auth.h"
#include "authstaticlist.h"
#include "courierauthsasl.h"
#include "authwait.h"
#include "courierauthdebug.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "numlib/numlib.h"
static const char rcsid[]="$Id: authdaemon.c,v 1.18 2008/06/29 16:39:24 mrsam Exp $";
extern int authdaemondo(const char *authreq,
int (*func)(struct authinfo *, void *), void *arg);
extern void auth_daemon_enumerate( void(*cb_func)(const char *name,
uid_t uid,
gid_t gid,
const char *homedir,
const char *maildir,
const char *options,
void *void_arg),
void *void_arg);
int auth_generic(const char *service,
const char *authtype,
char *authdata,
int (*callback_func)(struct authinfo *, void *),
void *callback_arg)
{
char tbuf[NUMBUFSIZE];
size_t l=strlen(service)+strlen(authtype)+strlen(authdata)+2;
char *n=libmail_str_size_t(l, tbuf);
char *buf=malloc(strlen(n)+l+20);
int rc;
courier_authdebug_login_init();
if (!buf)
return 1;
strcat(strcat(strcpy(buf, "AUTH "), n), "\n");
strcat(strcat(buf, service), "\n");
strcat(strcat(buf, authtype), "\n");
strcat(buf, authdata);
rc=strcmp(authtype, "EXTERNAL") == 0
? auth_getuserinfo(service, authdata, callback_func,
callback_arg)
: authdaemondo(buf, callback_func, callback_arg);
free(buf);
if (courier_authdebug_login_level)
{
struct timeval t;
/* short delay to try and allow authdaemond's courierlogger
to finish writing; otherwise items can appear out of order */
t.tv_sec = 0;
t.tv_usec = 100000;
select(0, 0, 0, 0, &t);
}
return rc;
}
int auth_callback_default(struct authinfo *ainfo)
{
if (ainfo->address == NULL)
{
fprintf(stderr, "WARN: No address!!\n");
return (-1);
}
if (ainfo->sysusername)
libmail_changeusername(ainfo->sysusername,
&ainfo->sysgroupid);
else if (ainfo->sysuserid)
libmail_changeuidgid(*ainfo->sysuserid,
ainfo->sysgroupid);
else
{
fprintf(stderr, "WARN: %s: No UID/GID!!\n", ainfo->address);
return (-1);
}
if (!ainfo->homedir)
{
errno=EINVAL;
fprintf(stderr, "WARN: %s: No homedir!!\n", ainfo->address);
return (1);
}
if (chdir(ainfo->homedir))
{
fprintf(stderr, "WARN: %s: chdir(%s) failed!!\n",
ainfo->address, ainfo->homedir);
perror("WARN: error");
return (1);
}
return 0;
}
courier-authlib-0.63.0.orig/courier-authlib.sysvinit.in 0000644 0000000 0000000 00000001574 10240661160 020043 0 ustar #! @SHELL@
#
# chkconfig: 2345 15 85
# description: Authlib - Courier authentication library.
#
#
prefix="@prefix@"
exec_prefix="@exec_prefix@"
sysconfdir="@sysconfdir@"
sbindir="@sbindir@"
if test ! -f @authdaemonrc@
then
echo "@authdaemonrc@ does not exist, forgot make install-configure?"
exit 1
fi
case "$1" in
start)
cd /
# Start daemons.
touch /var/lock/subsys/courier-authlib
echo -n "Starting Courier authentication services:"
$sbindir/authdaemond start
echo " authdaemond"
;;
stop)
echo -n "Stopping Courier authentication services:"
$sbindir/authdaemond stop
echo " authdaemond"
rm -f /var/lock/subsys/courier-authlib
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Starting Courier authentication services:"
$sbindir/authdaemond restart
echo " authdaemond"
;;
esac
exit 0
courier-authlib-0.63.0.orig/authinfo.c 0000644 0000000 0000000 00000004631 10306405350 014504 0 ustar /*
** Copyright 2004 Double Precision, Inc. See COPYING for
** distribution information.
*/
#include "courier_auth_config.h"
#include "auth.h"
#include "pkglibdir.h"
#include "pkgincludedir.h"
#include "authdaemonrc.h"
#include "authldaprc.h"
#include "authmysqlrc.h"
#include "authpgsqlrc.h"
#include "sbindir.h"
#include "mailusergroup.h"
#include "packageversion.h"
#include
#include
#include
#include
#include
static const char rcsid[]="$Id: authinfo.c,v 1.11 2005/09/03 20:43:20 mrsam Exp $";
static int getmuid()
{
struct passwd *pw=getpwnam(MAILUSER);
if (pw == NULL)
{
perror("Cannot obtain information for user " MAILUSER);
exit(1);
}
return (pw->pw_uid);
}
static int getmgid()
{
struct group *gr=getgrnam(MAILGROUP);
if (gr == NULL)
{
perror("Cannot obtain information for groupid " MAILGROUP);
exit(1);
}
return (gr->gr_gid);
}
static unsigned getver(const char **a)
{
unsigned n=0;
static const char dig[]="0123456789";
static const char *p;
while (**a)
{
if (**a == '.')
{
++*a;
break;
}
if ((p=strchr(dig, **a)) != NULL)
n=n*10 + p-dig;
++*a;
}
return n;
}
static int versioncmp(const char *a, const char *b)
{
while (*a && *b)
{
unsigned va=getver(&a);
unsigned vb=getver(&b);
if (va < vb)
return -1;
if (va > vb)
return 1;
}
return 0;
}
int main(int argc, char **argv)
{
int n;
for (n=1; n