Converted build to gnulib.

This commit is contained in:
Peter Simons 2010-02-24 16:51:54 +01:00
parent 508ce686d4
commit a11f628d97
12 changed files with 106 additions and 743 deletions

27
.gitignore vendored
View File

@ -1,16 +1,31 @@
*.o # files generated by Autoconf, Automake, and Gnulib
.deps .deps
/acl-parser.c /ChangeLog
/acl-parser.h /INSTALL
/acl-scanner.c
/aclocal.m4 /aclocal.m4
/autom4te.cache/* /autom4te.cache/*
/build-aux/* /build-aux
/config.h
/config.h.in
/config.log /config.log
/config.status /config.status
/configure /configure
/petidomo /gnulib
/libgnu
/maint.mk
/petidomo-*.tar.gz /petidomo-*.tar.gz
/petidomo-*.tar.gz.sig
/stamp-h1
Makefile Makefile
Makefile.in Makefile.in
# object files, libraries, binaries, and documentation
*.o
/GNUmakefile
/acl-parser.c
/acl-parser.h
/acl-scanner.c
/petidomo
lib*.a lib*.a

333
ChangeLog
View File

@ -1,333 +0,0 @@
2001-02-18 Peter Simons <simons@peti.cryp.to>
* Per default, Petidomo will not be compiled with '-g -O2' as it
is common for GNU autoconf programs. I don't believe in these kind
of defaults, the user should choose his CFLAGS himself. The '-g'
is particularly annoying.
2001-02-17 Peter Simons <simons@cryp.to>
* Updated the documentation for the new version.
* When posting to a list, Petidomo will now let the "Keywords:"
and "Summary:" headers pass. These headers are uncommon but have
been around for ages.
* Petidomo will not log to syslog() with level LOG_NOTICE anymore
unless it is an error or at least an unusual condition. Lowered
level of most messages to LOG_INFO or below.
* Fixed a type in the example master config file: MTAOptions
should have '-i' set, not '-v'.
2001-01-21 Ralf S. Engelschall <rse@engelschall.com>
* Added DESTDIR support to the Makefile.
* Added "dump" mode to Petidomo, which is used by the
petidomo-kickout script rather than messing in the config files
itself.
2001-01-20 Ralf S. Engelschall <rse@engelschall.com>
* Changed Petidomo so that it will send a separate mail to the
list owner when someone subscribes, rather than just sending a
carbon copy of the mail the user receives. This will prevent
unnecessary confusion.
2001-01-20 Ralf S. Engelschall <rse@engelschall.com>
* Added "dist" and "snap" target to the Makefile. These can be
used to build a distribution or a snapshot respectively.
* Added make targets for increasing or updating version
information the version information: "update-version" will update
the date but keep version number, "new-version" will let you
interactively specify new version number. To specify the new
version number for "new-version" on the command line, provide
"VERSION=0.8.15".
2001-01-20 Peter Simons <simons@cryp.to>
* Underscores in file names suck, because you need an extra
key-press to type them compared to the hyphen. For this reason
(and for consistency) I corrected this horrible, horrible mistake
of the past and renamed everything that contained an underscore.
2001-01-20 Peter Simons <simons@cryp.to>
* Renamed the MTA_Options" tag in the master config file to
"MTAOptions" for consistency.
2001-01-19 Peter Simons <simons@cryp.to>
* Changed ACL semantics: The ACL is processed _only_ if the
posting didn't have a valid password. If it did, the mail is going
through in any case and the ACL is not processed.
* Added a warning message to be logged when no global ACL file exists.
2001-01-19 Peter Simons <simons@cryp.to>
* Greatly enhanced the log messages Petidomo writes. Made the
existing messages more helpful, added lots of new ones, generally
made things real perfect. Remember: Life is BEAUTIFUL.
* Added a message that is logged every time Petidomo starts up.
This message will "dump" the configuration of Petidomo so that the
user has a clue which Petidomo instance is doing what.
* When a un-/subscribe command needs confirmation, the request for
confirmation is sent to the address that is supposed to be added
to or to be removed from the list. If, and only if, this address
is different from the one the request came from, a short mail is
sent to the requestor to inform him what is going on.
* Mailing list config files may now have the suffix ".config" or
".conf". Similarly, if the list config file is in a separate
directory, it may be called <listname>/config or <listname>/conf.
* Added code that will set the real user id of the process equal
to the effective user id. Makes life easier for people who use
Petidomo as a setuid binary.
2001-01-18 Ralf S. Engelschall <rse@engelschall.com>
* Added two useful scripts for list administrators:
petidomo-approve and petidomo-kickout.
2001-01-16 Peter Simons <simons@cryp.to>
* Added the "acknowledge" feature for mailing list postings.
* Added new action keyword to the Access Control Language:
"approve". This keyword will -- unlike "pass" -- not only pass the
mail, but will also make sure that the mail passes all other
authorization controls. This means, the mail will be treated as if
the Petidomo master password had been provided.
* The ACL is now tested _before_ anything else, meaning that you
can use the "approve" action to bypass all other tests.
2001-01-15 Peter Simons <simons@cryp.to>
* The "ListType" keyword is no longer a mandatory directive in the
list's config file; it now defaults to "open".
* List config's "AllowPublicSubscripiton" does not exist anymore.
Now we have "SubscriptionType" with valid values "public", "admin"
or "acknowledged".
* Added "AckQueueDirectory" directive to the master config file.
* Removed the whole concept of "alien subscription". It was stupid
to begin with and now that we'll have acknowledged subscriptions,
it is useless, too.
* Added "acknowledge" feature for un-/subscription requests.
* Added --approved command line parameter, which is treated as a
boolean. Whether it is set or not will be passed through to
listserv_main() and to hermes_main(). The parameter will be used
by the "acknowledge" mechanism.
2001-01-11 Peter Simons <simons@cryp.to>
* Added config entry "AcknowledgementFile" to the mailing list's
config file.
* The requestor will now receive a mail telling him something went
wrong when he tries to un-/subscribe an address without specifying
a (valid) list name.
2001-01-08 Peter Simons <simons@cryp.to>
* Added "install-testlist" target to the Makefile.
* Rewrote Petidomo so that virtually any file's path can be
configured at run-time now. The directives we suppert in the
master config file are "ListDirectory", "HelpFile", "ACLFile", and
"IndexFile". The ones in the list's config file are
"IntroductionFile", "DescriptionFile", "ACLFile", "HeaderFile",
"SignatureFile", and "AddressFile".
* Added "install" target to the Makefile.
2001-01-06 Peter Simons <simons@cryp.to>
* The whole concept of the "petidomo" user is gone. Instead,
compile complete paths into the binary and make them run-time
configurable.
* Added a "Petidomo:" prefix to all subject lines, to distinguish
mail sent by Petidomo from regular mail. Rejection mails
furthermore have the prefix "BOUNCE <listaddress>:", mails that
need approval have the prefix "APPROVE <listaddress>:".
* When a mail is rejected due to ACL, the mail body will tell you
whether the global acl file or the list's local acl file hit.
* If a file "lists/<listname>/header" exists, it contents will be
added to the headers of the article posted to the list. Be careful
not to have blank lines in there, as this will screw the whole
message up.
* The result of the INDEX command is no longer generated on the
fly. Instead, the contents of a file is send back, which the
administrator can edit as he wishes -- very much like the HELP
file thing Petidomo had for ever. Consequently, the "ShowOnIndex"
directive in the list's config file is gone.
2000-12-15 Peter Simons <simons@cryp.to>
* The whole signature stuff the commercial Petidomo is gone; the
free version does not need this. This, the "AppendSignature"
directive in the list's config file is gone.
* Removed options "DetachImmediately" and "ShowStatistics" options
from the master config file. These were never used anyway.
* Removed the mail rescue mechanism and all relating code. I guess
_nobody_ ever used that mechanism anyway, not even me. :-)
* Petidomo no longer cares under what name it has been started.
The different modes of operation will now be distinguished by the
mandatory command line parameter "--mode".
2000-12-14 Peter Simons <simons@cryp.to>
* Removed the complimentary mail2news.c program from the
distribution. The program isn't tested, it isn't documented ... so
away with it.
2000-12-01 Ralf S. Engelschall <rse@engelschall.com>
* Added Perl scripts petidomo-approve and petidomo-kickout which
are useful to reduce the amount of effort required in daily
mailing lists administration.
2000-12-01 Peter Simons <simons@cryp.to>
* CyberSolutions GmbH has released a version of Petidomo 2.2 under
GPL at <http://www.petidomo.com/download/OpenPetidomo/source/>.
Now that Petidomo is available under a free license again, I
imported these sources and started working it. The free version
will be released as part of the Open Structured Server Platform
(OSSP) project. Financing has kindly been provided by the Cable
and Wireless Corporation.
1999-11-15 Peter Simons <simons@petidomo.com>
* Petidomo has been sold to CyberSolutions GmbH, Germany. All work
on it stops here. They will release a new version (Petidomo III)
as a commercial product. The free branch of the program is dead.
1998-08-20 Peter Simons <simons@petidomo.com>
* Released as Petidomo 2.2.
* Fixed a few problems in the binary install script.
* Added rfc2369.sh posting filter to the distribution.
1998-08-17 Peter Simons <simons@petidomo.com>
* Released as Petidomo 2.2 beta 2.
* You can create binary distributions simply by executing "make
build-bin-dist". All users are encouraged to share binaries for
platforms we can not support.
* Petidomo compiles now on SunOS 4.x.
* Added a -real- RFC 822 parser. This will fix all problems with
the more obscure forms of e-mail syntax.
* Added ShowStatistics (bool) keyword to the master config file.
(Only in the commercial version.) This switch allows the
administrator to switch the signature off, listserv appends when
replying a request. The switch is also supported in the CGI
configuration manager.
* Added nice run time statistics to be appended as signature every
time listserv processes an incoming mail.
* Fixed a security hole in the CGI configuration manager, that
could be abused to delete arbitrary mailing lists on a server.
* Added a stand-alone implementation of the regular expression
library which will be used in favor of the one provided in the OS,
if --with-my-regex is specified at configure. This is necessary on
some Solaris versions.
1998-01-27 Peter Simons <simons@petidomo.com>
* Released as Petidomo 2.1, finally. (Phew!)
* Documented that "sendmail -bv" can be used to verify addresses,
in the "misc" chapter of the user manual.
* Added pgp-(encrypt|decrypt).sh scripts to the distribution and
documented their usage in the manual. With them, Petidomo is able
to handle fully encrypted mailing lists.
* Fixed a problem in the code that called sendmail for the
delivery that would cause the exec() call to fail for large lists
(>5000 addresses).
* Petidomo will no longer accept list named that have special
characters of the file system in them, like '/' as this is a
security risk.
* Both hermes and listserv will now set both their real- and
effective user-id to "petidomo" at startup, to avoid permission
problems on systems that restore the real user-id when calling
external problems with exec().
* etc/COPYRIGHT: Added copyright license, which is needed for the
upcoming release of the sources.
* Makefile: Added build-bin-dist target, which can be used to
automatically compile a binary release archive.
* Added --enable-dynamic-link option to configure script, to let
the user choose to link static binaries conveniently.
1998-01-04 Peter Simons <simons@petidomo.com>
* Released as 2.1 beta 5
* Re-wrote the parser for the access control language completely.
The new version uses lex/yacc for parsong and is way more robust
and faster. It will also issue more detailed syntax errors, in
case the acl file is incorrect. The new code also fixed a couple
of weird problems on some platforms.
1997-12-21 Peter Simons <simons@petidomo.com>
* Released as 2.1 beta 4
* When DEBUG is defined at compile time, loads of debugging output
is added to all programs. Debugging can be activated with the -d
switch on the command line. The syntax is "-d module,level", with
level being an integer from 1 to 9, and module being one of the
named as defined in include/debug.h in the sources.
* Hermes will now preserve the "References:" field when posting an
article.
* Fixed a bug in the filter code that could result in hermes
hanging forever in a read() loop.
* Quite a few internal changes that are probably not worth being
listed here.
1997-06-30 Peter Simons <simons@petidomo.com>
* Released as Petidomo 2.0.
Petidomo v1
===========
* There are no ChangeLog entries known for Petidomo v1.

View File

@ -2,21 +2,23 @@
# build petidomo # build petidomo
# #
ACLOCAL_AMFLAGS = -I build-aux
AM_YFLAGS = -d AM_YFLAGS = -d
SUBDIRS = libargv libtext liblists librfc822 libmpools libconfigfile docs SUBDIRS = libgnu libargv libtext liblists librfc822 libmpools libconfigfile doc
sbin_PROGRAMS = petidomo sbin_PROGRAMS = petidomo
petidomo_SOURCES = \ petidomo_SOURCES = \
acl-parser.y acl-scanner.l approve.c config-files.c \ acl-parser.y acl-scanner.l approve.c config-files.c \
handleacl.c index.c parsearray.c queue-posting.c \ handleacl.c index.c parsearray.c queue-posting.c \
tool.c archive.c filter.c help.c io.c main.c \ tool.c archive.c filter.c help.c io.c main.c \
password.c rfcparse.c unsubscribe.c address-db.c \ password.c rfcparse.c unsubscribe.c address-db.c \
authen.c generate-cookie.c hermes.c listserv.c \ authen.c generate-cookie.c hermes.c listserv.c \
members.c mailer.c queue-command.c subscribe.c members.c mailer.c queue-command.c subscribe.c
petidomo_CPPFLAGS = \ petidomo_CPPFLAGS = \
-I${srcdir}/libgnu \
-DMTA=\"${mta}\" \ -DMTA=\"${mta}\" \
-DSYSCONFDIR=\"${sysconfdir}\" \ -DSYSCONFDIR=\"${sysconfdir}\" \
-DLOCALSTATEDIR=\"${localstatedir}\" \ -DLOCALSTATEDIR=\"${localstatedir}\" \
@ -24,13 +26,14 @@ petidomo_CPPFLAGS = \
petidomo_LDADD = \ petidomo_LDADD = \
libconfigfile/libconfigfile.a libtext/libtext.a \ libconfigfile/libconfigfile.a libtext/libtext.a \
liblists/liblists.a librfc822/librfc822.a \ liblists/liblists.a librfc822/librfc822.a \
libmpools/libmpools.a libargv/libargv.a libmpools/libmpools.a libargv/libargv.a libgnu/libgnu.a
noinst_HEADERS = petidomo.h noinst_HEADERS = petidomo.h
BUILT_SOURCES = acl-parser.c acl-scanner.c acl-parser.h BUILT_SOURCES = acl-parser.c acl-scanner.c acl-parser.h
EXTRA_DIST = build-aux/gnulib-cache.m4
CLEANFILES = petidomo-*.tar.gz CLEANFILES = petidomo-*.tar.gz
DISTCLEANFILES = $(BUILT_SOURCES) $(EXTRA_DIST) DISTCLEANFILES = $(BUILT_SOURCES) $(EXTRA_DIST)
MAINTAINERCLEANFILES = \ MAINTAINERCLEANFILES = \
@ -84,3 +87,12 @@ maintainer-clean-local:
# update-version: # update-version:
# @OPT="-s`$(SHTOOL) version -lc -dshort version.c`"; \ # @OPT="-s`$(SHTOOL) version -lc -dshort version.c`"; \
# $(SHTOOL) version -lc -n 'Petidomo' -p petidomo_ $$OPT version.c # $(SHTOOL) version -lc -n 'Petidomo' -p petidomo_ $$OPT version.c
dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version
if test -d .git; then \
$(top_srcdir)/build-aux/gitlog-to-changelog \
>$(distdir)/cl-t $(top_srcdir); \
rm -f $(distdir)/ChangeLog; \
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
fi

14
NEWS
View File

@ -1,11 +1,7 @@
#+TITLE: Petidomo Mailing List Server -*- mode:org;fill-column:79; -*-
#+STARTUP: showall
NEWS * Noteworthy changes in release 4.1 (????-??-??) [stable]
====
This is a list of user-visible and/or major changes to Petidomo.
For more details please have a look at the ChangeLog file.
Changes between 3.0 and 4.0:
*) ...
Moved Petidomo source code to SourceForge and released all files under
GPL version 3 or later.

27
bootstrap.sh Executable file
View File

@ -0,0 +1,27 @@
#! /bin/sh
set -eu
if [ -x "gnulib/gnulib-tool" ]; then
gnulibtool=gnulib/gnulib-tool
else
gnulibtool=gnulib-tool
fi
gnulib_modules=( git-version-gen gitlog-to-changelog gnupload
maintainer-makefile announce-gen crypto/md5 )
$gnulibtool --m4-base build-aux --source-base libgnu --import "${gnulib_modules[@]}"
sed -i -e 's/^sc_prohibit_atoi_atof/disabled_sc_prohibit_atoi_atof/' \
maint.mk
# -e 's/^sc_prohibit_magic_number_exit/disabled_sc_prohibit_magic_number_exit/' \
# -e 's/^sc_prohibit_strcmp/disabled_sc_prohibit_strcmp/' \
# -e 's/^sc_require_config_h/disabled_sc_require_config_h/' \
# -e 's/^sc_useless_cpp_parens/disabled_sc_useless_cpp_parens/' \
build-aux/gitlog-to-changelog >ChangeLog
autoreconf --install -Wall

8
cfg.mk Normal file
View File

@ -0,0 +1,8 @@
# petidomo/cfg.mk
gnu_rel_host := peti,petidomo@frs.sourceforge.net
upload_dest_dir_:= /home/frs/project/p/pe/petidomo
gpg_key_ID := 99089D72
today := $(date "+%Y-%m-%d")
TAR_OPTIONS += --mtime=$(today)
old_NEWS_hash := d41d8cd98f00b204e9800998ecf8427e

View File

@ -1,13 +1,13 @@
dnl configure.ac -- Process this file with autoconf to produce a configure script. dnl configure.ac -- Process this file with autoconf to produce a configure script.
AC_INIT([petidomo], [4.1-beta-1], [simons@cryp.to]) AC_INIT([petidomo], m4_esyscmd([build-aux/git-version-gen .tarball-version]), [simons@cryp.to], [petidomo], [http://petidomo.sourceforge.net/])
AC_CONFIG_SRCDIR([petidomo.h]) AC_CONFIG_SRCDIR([petidomo.h])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall -Werror 1.10 gnu filename-length-max=99 tar-v7]) AM_INIT_AUTOMAKE([1.11 -Wall gnu])
AC_CONFIG_MACRO_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux])
AC_COPYRIGHT([dnl AC_COPYRIGHT([dnl
Copyright (C) 1997-2008 Peter Simons <simons@cryp.to> Copyright (C) 1997-2010 Peter Simons <simons@cryp.to>
Copyright (C) 1999-2000 CyberSolutions GmbH, Germany. Copyright (C) 1999-2000 CyberSolutions GmbH, Germany.
Copyright (C) 2000 Cable & Wireless Corp. Copyright (C) 2000 Cable & Wireless Corp.
@ -24,7 +24,10 @@ more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with Petidomo. If not, see <http://www.gnu.org/licenses/>.]) with Petidomo. If not, see <http://www.gnu.org/licenses/>.])
AC_MSG_NOTICE([mapSoN version $VERSION])
AC_PROG_CC AC_PROG_CC
gl_EARLY
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_PROG_RANLIB AC_PROG_RANLIB
AM_PROG_LEX AM_PROG_LEX
@ -35,10 +38,7 @@ AC_PROG_YACC
if test "$YACC" != "bison -y"; then if test "$YACC" != "bison -y"; then
AC_MSG_WARN([$YACC might not work; install bison if the build fails.]) AC_MSG_WARN([$YACC might not work; install bison if the build fails.])
fi fi
gl_INIT
AC_CHECK_SIZEOF(unsigned short, 2)
AC_CHECK_SIZEOF(unsigned int, 4)
AC_CHECK_SIZEOF(unsigned long, 4)
AC_SUBST(mta) AC_SUBST(mta)
AC_ARG_WITH(mta, [ --with-mta=PATH location of the mail transport agent (sendmail?)], AC_ARG_WITH(mta, [ --with-mta=PATH location of the mail transport agent (sendmail?)],
@ -85,9 +85,11 @@ AC_SYS_LARGEFILE
dnl Grande Finale dnl Grande Finale
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
docs/Makefile doc/Makefile
libgnu/Makefile
libargv/Makefile libargv/Makefile
libconfigfile/Makefile libconfigfile/Makefile
liblists/Makefile liblists/Makefile

3
doc/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
#
# Petidomo User Manual
#

View File

@ -1,17 +0,0 @@
#
# Petidomo User Manual
#
# .tex.dvi:
# latex \\nonstopmode\\input $<; \
# while grep 'Rerun to' $*.log; do \
# latex \\nonstopmode\\input $<; \
# done
#
# .dvi.ps:
# dvips $< -o $@
#
# all: petidomo.ps
#
# clean distclean realclean:
# rm -f petidomo.aux petidomo.dvi petidomo.log petidomo.ps petidomo.toc

View File

@ -18,51 +18,9 @@
*/ */
#include "petidomo.h" #include "petidomo.h"
#include "md5.h"
#include <string.h> #include <string.h>
typedef unsigned char * POINTER;
#if (SIZEOF_UNSIGNED_INT == 4)
typedef unsigned int UINT4;
#else
# if (SIZEOF_UNSIGNED_LONG == 4)
typedef unsigned long UINT4;
# else
# if (SIZEOF_UNSIGNED_SHORT == 4)
typedef unsigned short UINT4;
# else
# error "Ooops, we don't have a 4 byte type in C on this machine?"
# endif
# endif
#endif
typedef struct MD5Context
{
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
}
MD5_CTX;
static void MD5Init(MD5_CTX*);
static void MD5Update(MD5_CTX*, const unsigned char*, unsigned int);
static void MD5Final(unsigned char[16], MD5_CTX*);
static char* encode_digest_to_ascii(unsigned char digest[16]);
char* generate_cookie(const char* buffer)
{
MD5_CTX context;
unsigned char digest[16];
MD5Init(&context);
MD5Update(&context, (unsigned char *) buffer, strlen((char *) buffer));
MD5Final(digest, &context);
return encode_digest_to_ascii(digest);
}
static char* encode_digest_to_ascii(unsigned char digest[16]) static char* encode_digest_to_ascii(unsigned char digest[16])
{ {
int i; int i;
@ -80,319 +38,9 @@ static char* encode_digest_to_ascii(unsigned char digest[16])
return buffer; return buffer;
} }
char* generate_cookie(const char* buffer)
{
/* unsigned char digest[MD5_DIGEST_SIZE];
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All md5_buffer(buffer, strlen(buffer), digest);
* rights reserved. return encode_digest_to_ascii(digest);
* }
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#define ZEROIZE(d, l) memset((d), 0, (l))
/*
* Constants for MD5Transform routine.
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
static void MD5Transform(UINT4 [4], const unsigned char [64]);
static void Encode(unsigned char *, UINT4 *, unsigned int);
static void Decode(UINT4 *, const unsigned char *, unsigned int);
/*
* Encodes input (UINT4) into output (unsigned char). Assumes len is
* a multiple of 4.
*/
static void
Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/*
* Decodes input (unsigned char) into output (UINT4). Assumes len is
* a multiple of 4.
*/
static void
Decode (output, input, len)
UINT4 *output;
const unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*
* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/*
* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/*
* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
* Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/*
* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
static void
MD5Init(context)
MD5_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/*
* MD5 block update operation. Continues an MD5 message-digest
* operation, processing another message block, and updating the
* context.
*/
static void
MD5Update(context, input, inputLen)
MD5_CTX *context; /* context */
const unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, idx, partLen;
/* Compute number of bytes mod 64 */
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - idx;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
memcpy((POINTER)&context->buffer[idx],
(POINTER)input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
idx = 0;
} else
i = 0;
/* Buffer remaining input */
memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i],
inputLen - i);
}
/*
* MD5 finalization. Ends an MD5 message-digest operation, writing the
* message digest and zeroing the context.
*/
static void
MD5Final(digest, context)
unsigned char digest[16]; /* message digest */
MD5_CTX *context; /* context */
{
unsigned char bits[8];
unsigned int idx, padLen;
/* Save number of bits */
Encode(bits, context->count, 8);
/* Pad out to 56 mod 64. */
idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (idx < 56) ? (56 - idx) : (120 - idx);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
MD5Update(context, bits, 8);
/* Store state in digest */
Encode(digest, context->state, 16);
/* Zeroize sensitive information. */
ZEROIZE((POINTER)context, sizeof(*context));
}
/*
* MD5 basic transformation. Transforms state based on block.
*/
static void
MD5Transform(state, block)
UINT4 state[4];
const unsigned char block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode(x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information. */
ZEROIZE((POINTER)x, sizeof (x));
}

View File

@ -20,6 +20,8 @@
#ifndef __PETIDOMO_H__ #ifndef __PETIDOMO_H__
#define __PETIDOMO_H__ 1 #define __PETIDOMO_H__ 1
#include "config.h"
/********** Useful defines and declarations **********/ /********** Useful defines and declarations **********/
#ifndef __HAVE_DEFINED_BOOL__ #ifndef __HAVE_DEFINED_BOOL__
@ -78,7 +80,7 @@ enum list_type_t
LIST_ACKED_ONCE LIST_ACKED_ONCE
}; };
typedef enum typedef enum
{ {
ACL_PRE, ACL_PRE,
ACL_POST ACL_POST