Commit 736f4530 736f45309f3463345750cebf8616910b67b4c722 by Sergey Poznyakoff

* configure.ac (MU_APP_LIBRARIES): Load libmuaux after libmuargp

and libcfg.
(fgetpwent): Use AC_CHECK_FUNCS
* auth/virtual.c: Use mu_fgetpwent if fgetpwent is not available.

* lib/Makefile.am: Add back utmp.c
* lib/utmp.c: Restore after unintended remove.
* m4/utmp.m4: Fix quoting.

* libcfg/gsasl.c, libcfg/ldap.c, libcfg/pam.c, libcfg/radius.c,
libcfg/sieve.c, libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c:
Include stdlib.h

* libproto/imap/folder.c, libproto/mbox/mbox.c,
libproto/mbox/mbox0.h, libproto/pop/mbox.c, mailbox/attachment.c,
mailbox/mailbox.c, mailbox/parsedate.y:	Do not use alloca.

* mailbox/Makefile.am (libmailutils_la_SOURCES): Add fgetpwent.c
and intprops.h.
* mailbox/fgetpwent.c (fgetpwent): Rename to mu_fgetpwent.
* mailbox/gocs.c: Revert recent change. It broke the testsuite in
sieve.
* mailbox/syslog.c (log_facility): Initialize to LOG_FACILITY.
1 parent df054f40
2007-11-26 Sergey Poznyakoff <gray@gnu.org.ua>
* configure.ac (MU_APP_LIBRARIES): Load libmuaux after libmuargp
and libcfg.
(fgetpwent): Use AC_CHECK_FUNCS
* auth/virtual.c: Use mu_fgetpwent if fgetpwent is not available.
* lib/Makefile.am: Add back utmp.c
* lib/utmp.c: Restore after unintended remove.
* m4/utmp.m4: Fix quoting.
* libcfg/gsasl.c, libcfg/ldap.c, libcfg/pam.c, libcfg/radius.c,
libcfg/sieve.c, libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c:
Include stdlib.h
* libproto/imap/folder.c, libproto/mbox/mbox.c,
libproto/mbox/mbox0.h, libproto/pop/mbox.c, mailbox/attachment.c,
mailbox/mailbox.c, mailbox/parsedate.y: Do not use alloca.
* mailbox/Makefile.am (libmailutils_la_SOURCES): Add fgetpwent.c
and intprops.h.
* mailbox/fgetpwent.c (fgetpwent): Rename to mu_fgetpwent.
* mailbox/gocs.c: Revert recent change. It broke the testsuite in
sieve.
* mailbox/syslog.c (log_facility): Initialize to LOG_FACILITY.
* configure.ac, NEWS: Add LDAP support.
* auth/Makefile.am (libmuauth_la_SOURCES): Add ldap.c.
* auth/ldap.c: New file.
......
......@@ -70,6 +70,12 @@ mu_virtual_module_init (void *data)
return 0;
}
#if !HAVE_FGETPWENT
/* FIXME: A temporary solution. Need proper declaration in .h */
extern struct passwd *mu_fgetpwent (FILE *fp);
#define fgetpwent mu_fgetpwent
#endif
static struct passwd *
getpwnam_virtual (const char *u)
{
......
......@@ -50,7 +50,7 @@ dnl Other variables
AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)')
AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)')
AC_SUBST(MU_APP_LIBRARIES,'../lib/libmuaux.la ../libargp/libmuargp.a ../libcfg/libmucfg.la')
AC_SUBST(MU_APP_LIBRARIES,'../libargp/libmuargp.a ../libcfg/libmucfg.la ../lib/libmuaux.la')
AC_SUBST(MU_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_builddir}/lib -I${top_builddir} -I${top_builddir}/include -I${top_srcdir}/mailbox -I${top_srcdir}/libargp -I${top_srcdir}/libcfg')
......@@ -438,7 +438,7 @@ AH_BOTTOM([
#endif
])
AC_CHECK_FUNC(fgetpwent)
AC_CHECK_FUNCS(fgetpwent)
## Check for presence of utmp.h and utmp-related functions
MU_CHECK_UTMP
......
......@@ -31,4 +31,8 @@ noinst_HEADERS +=\
mu_dbm.h\
mu_asprintf.h
EXTRA_DIST += utmp.c
gl_LIBOBJS += @LIBOBJS@
gl_LTLIBOBJS += @LTLIBOBJS@
......
/* utmp.c -- Replacements for {set,get,end}utmp functions
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
Licensealong with this program; if not, write to the Free
SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA. */
#include <sys/types.h>
#include <sys/time.h>
#include <utmp.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
static char *utmp_name = _PATH_UTMP;
static int fd = -1;
static struct utmp ut;
void
endutent ()
{
if (fd > 0)
close (fd);
fd = -1;
}
void
setutent ()
{
endutent ();
if ((fd = open (utmp_name, O_RDWR)) < 0
&& ((fd = open (utmp_name, O_RDONLY)) < 0))
perror ("setutent: Can't open utmp file");
}
struct utmp *
getutent ()
{
if (fd < 0)
setutent ();
if (fd < 0 || read (fd, &ut, sizeof ut) != sizeof ut)
return NULL;
return &ut;
}
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
#include <mailutils/gsasl.h>
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
#include "mailutils/mutil.h"
#include "mailutils/ldap.h"
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
static char *pam_settings;
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
#include <mailutils/radius.h>
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
#include <mailutils/libsieve.h>
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
#include <mailutils/sql.h>
#include <mailutils/mutil.h>
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
#include <mailutils/tls.h>
......
......@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include "mailutils/libcfg.h"
static char *virtdomain_settings;
......
......@@ -31,10 +31,6 @@
#include <assert.h>
#include <fnmatch.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
......@@ -1388,7 +1384,9 @@ imap_list (f_imap_t f_imap)
int argc;
char **argv;
buffer = alloca (len);
buffer = malloc (len);
if (!buffer)
return ENOMEM;
memcpy (buffer, f_imap->buffer, len);
buffer[len] = '\0';
......@@ -1475,7 +1473,7 @@ imap_list (f_imap_t f_imap)
}
}
mu_argcv_free (argc, argv);
free (buffer);
return status;
}
......@@ -1769,16 +1767,22 @@ imap_body (f_imap_t f_imap, char **ptr)
if (**ptr == '[')
{
char *sep = strchr (*ptr, ']');
(*ptr)++; /* Move pass the '[' */
(*ptr)++; /* Move past the '[' */
if (sep)
{
size_t len = sep - *ptr;
char *section = alloca (len + 1);
char *p = section;
char *section = malloc (len + 1);
char *p;
if (!section)
return ENOMEM;
strncpy (section, *ptr, len);
section[len] = '\0';
/* strupper. */
for (; *p; p++) if (isupper((unsigned)*p)) *p = toupper ((unsigned)*p);
for (p = section; *p; p++)
*p = toupper ((unsigned)*p);
/* Set the string type to update the correct line count. */
/*if (!strstr (section, "FIELD"))*/
{
......@@ -1795,7 +1799,8 @@ imap_body (f_imap_t f_imap, char **ptr)
f_imap->string.type = IMAP_MESSAGE;
}
}
sep++; /* Move pass the ']' */
free (section);
sep++; /* Move past the ']' */
*ptr = sep;
}
}
......
......@@ -485,7 +485,9 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted)
/* Create temporary mu_mailbox_t. */
{
mbox_data_t tmp_mud;
char *m = alloca (5 + strlen (tmpmboxname) + 1);
char *m = malloc (5 + strlen (tmpmboxname) + 1);
if (!m)
return ENOMEM;
/* Try via the mbox: protocol. */
sprintf (m, "mbox:%s", tmpmboxname);
status = mu_mailbox_create (&tmpmailbox, m);
......@@ -499,11 +501,12 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted)
/* Ok give up. */
close (tempfile);
remove (tmpmboxname);
free (m);
free (tmpmboxname);
return status;
}
}
free (m);
/* Must be flag CREATE if not the mu_mailbox_open will try to mmap()
the file. */
status = mu_mailbox_open (tmpmailbox, MU_STREAM_CREAT | MU_STREAM_RDWR);
......
......@@ -38,10 +38,6 @@
# endif
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
......
......@@ -34,10 +34,6 @@
#include <stdarg.h>
#include <ctype.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
......
......@@ -2,7 +2,7 @@ dnl MU_CHECK_UTMP -- Check for the presence of utmp.h, setutent, getutent
dnl and endutent calls.
AC_DEFUN([MU_CHECK_UTMP],
[
AC_CHECK_HEADERS(utmp.h)
AC_CHECK_HEADERS([utmp.h])
# The three functions setutent,getutent and endutent depend on each other,
# so it seems reasonable to provide replacements for all three if getutent
# is not present.
......@@ -10,5 +10,5 @@ AC_DEFUN([MU_CHECK_UTMP],
AC_DEFINE(HAVE_GETUTENT_CALLS,,
[Define if your system has the three ???utent functions]),
[if test "$ac_cv_header_utmp_h" = "yes"; then
AC_LIBOBJ(utmp)
AC_LIBOBJ([utmp])
fi])])
......
......@@ -52,6 +52,7 @@ libmailutils_la_SOURCES = \
cfg_lexer.c\
cfg_parser.c\
envelope.c\
fgetpwent.c\
file_stream.c\
filter.c\
filter_iconv.c\
......@@ -100,7 +101,7 @@ libmailutils_la_SOURCES = \
url.c\
version.c\
wicket.c\
imaxtostr.c offtostr.c umaxtostr.c
imaxtostr.c offtostr.c umaxtostr.c intprops.h
BUILT_SOURCES = parsedate.c muerrno.c cfg_parser.c cfg_parser.h
MOSTLYCLEANFILES=
......
......@@ -28,10 +28,6 @@
#include <unistd.h>
#include <ctype.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_LIBGEN_H
# include <libgen.h>
#endif
......@@ -74,7 +70,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
mu_header_t hdr;
mu_body_t body;
mu_stream_t fstream = NULL, tstream = NULL;
char *header, *name = NULL, *fname = NULL;
char *header = NULL, *name = NULL, *fname = NULL;
int ret;
if (newmsg == NULL)
......@@ -96,7 +92,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
else
name = fname;
if ((header =
alloca (strlen (MSG_HDR) + strlen (content_type) +
malloc (strlen (MSG_HDR) + strlen (content_type) +
strlen (name) * 2 + strlen (encoding) + 1)) == NULL)
ret = ENOMEM;
else
......@@ -124,6 +120,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
}
}
}
free (header);
}
}
}
......@@ -326,7 +323,6 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
size_t size;
size_t nbytes;
mu_header_t hdr;
char *content_encoding;
const char *fname = NULL;
char *partname = NULL;
......@@ -353,20 +349,26 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
{
if ((ret = mu_stream_open (info->fstream)) == 0)
{
char *content_encoding;
char *content_encoding_mem = NULL;
mu_header_get_value (hdr, "Content-Transfer-Encoding", NULL, 0,
&size);
if (size)
{
if ((content_encoding = alloca (size + 1)) == NULL)
content_encoding_mem = malloc (size + 1);
if (content_encoding_mem == NULL)
ret = ENOMEM;
content_encoding = content_encoding_mem;
mu_header_get_value (hdr, "Content-Transfer-Encoding",
content_encoding, size + 1, 0);
}
else
content_encoding = (char *) "7bit";
content_encoding = "7bit";
ret =
mu_filter_create (&info->stream, istream, content_encoding,
MU_FILTER_DECODE, MU_STREAM_READ);
free (content_encoding_mem);
}
}
}
......@@ -402,8 +404,8 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
}
/* Free fname if we allocated it. */
if(partname)
free(partname);
if (partname)
free (partname);
return ret;
}
......@@ -473,7 +475,6 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
{
size_t size, nbytes;
int ret = 0;
char *content_type;
mu_header_t hdr;
mu_stream_t istream, ostream;
struct _msg_info *info = NULL;
......@@ -489,12 +490,14 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
mu_header_get_value (hdr, "Content-Type", NULL, 0, &size);
if (size)
{
if ((content_type = alloca (size + 1)) == NULL)
char *content_type;
if ((content_type = malloc (size + 1)) == NULL)
return ENOMEM;
mu_header_get_value (hdr, "Content-Type", content_type, size + 1, 0);
if (strncasecmp
(content_type, "message/rfc822",
strlen ("message/rfc822")) != 0)
ret = strncasecmp (content_type, "message/rfc822",
strlen ("message/rfc822"));
free (content_type);
if (ret != 0)
return EINVAL;
}
else
......
......@@ -40,7 +40,6 @@ static char *buffer;
static size_t buflen;
static struct passwd pw;
static char *
parse_line (char *s, char **p)
{
......@@ -81,7 +80,7 @@ getentry (char *s)
}
struct passwd *
fgetpwent (FILE *fp)
mu_fgetpwent (FILE *fp)
{
size_t pos = 0;
int done = 0;
......
......@@ -212,10 +212,7 @@ mu_gocs_logging_init (void *data)
mu_debug_default_printer = mu_debug_syslog_printer;
}
else
{
log_facility = LOG_FACILITY;
mu_debug_default_printer = mu_debug_stderr_printer;
}
mu_debug_default_printer = mu_debug_stderr_printer;
/* FIXME: Tag */
return 0;
......
......@@ -23,7 +23,6 @@
#include <stdlib.h>
#include <errno.h>
#include <alloca.h>
#include <string.h>
#include <mailutils/debug.h>
......@@ -85,28 +84,11 @@ mu_mailbox_get_default_proto ()
return default_proto ? default_proto : "/";
}
/* The Mailbox Factory.
Create an iterator for registrar and see if any url scheme match,
Then we call the mailbox's mu_url_create() to parse the URL. Last
initialize the concrete mailbox and folder. */
int
mu_mailbox_create (mu_mailbox_t *pmbox, const char *name)
static int
_create_mailbox (mu_mailbox_t *pmbox, const char *name)
{
mu_record_t record = NULL;
if (pmbox == NULL)
return MU_ERR_OUT_PTR_NULL;
if (!mu_is_proto (name) && default_proto)
{
char *tmp_name = alloca (strlen (default_proto) + strlen (name) + 1);
if (!tmp_name)
return ENOMEM;
strcpy (tmp_name, default_proto);
strcat (tmp_name, name);
name = tmp_name;
}
if (mu_registrar_lookup (name, MU_FOLDER_ATTRIBUTE_FILE, &record, NULL) == 0)
{
int (*m_init) (mu_mailbox_t) = NULL;
......@@ -159,10 +141,34 @@ mu_mailbox_create (mu_mailbox_t *pmbox, const char *name)
return status;
}
}
return MU_ERR_NO_HANDLER;
}
/* The Mailbox Factory.
Create an iterator for registrar and see if any url scheme match,
Then we call the mailbox's mu_url_create() to parse the URL. Last
initialize the concrete mailbox and folder. */
int
mu_mailbox_create (mu_mailbox_t *pmbox, const char *name)
{
int rc;
if (pmbox == NULL)
return MU_ERR_OUT_PTR_NULL;
if (!mu_is_proto (name) && default_proto)
{
char *tmp_name = malloc (strlen (default_proto) + strlen (name) + 1);
strcpy (tmp_name, default_proto);
strcat (tmp_name, name);
rc = _create_mailbox (pmbox, name);
free (name);
}
else
rc = _create_mailbox (pmbox, name);
return rc;
}
void
mu_mailbox_destroy (mu_mailbox_t *pmbox)
{
......
......@@ -26,9 +26,6 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# endif
#endif
#include <stdio.h>
......
......@@ -107,4 +107,4 @@ mu_syslog_priority_to_string (int n)
}
int log_facility;
int log_facility = LOG_FACILITY;
......