Commit 40fffffb 40fffffb6c6b5b10642428408f49bec401668f68 by Sergey Poznyakoff

Finish removing mail.local and mail.remote

1 parent 4d8141cf
......@@ -244,7 +244,7 @@ mailutils-specific configuration options:
The following options enable DBM support in Mailutils. DBM support is
necessary if you wish to use APOP authentication in POP3 daemon or to
use DBM-based mail box quotas with mail.local.
use DBM-based mail box quotas with maildag.
--with-gdbm
......
......@@ -42,8 +42,6 @@
* sieve: (mailutils)sieve. Mail Filtering Utility.
* mimeview: (mailutils)mimeview. View MIME Messages.
* mailutils-config: (mailutils)mailutils-config. List Information about Mailutils.
* mail.local: (mailutils)mail.local. Deliver Mail to UNIX Mailboxes.
* mail.remote: (mailutils)mail.remote. Forward Mail to Remote Machine.
@end direntry
@end ifinfo
......
......@@ -12,8 +12,8 @@ mailbox.
To invoke the script directly by its name, add executable bit to its
permissions.
The same script may be used by mail.local to sieve the incoming mail upon
its arrival, see node "Programs -> mail.local" in the accompanying
The same script may be used by maidag to sieve the incoming mail upon
its arrival, see node "Programs -> maidag" in the accompanying
documentation for more information on this.
To execute the sieve script directly, without saving the produced Scheme
......
Makefile
Makefile.in
mail.local
.deps
.libs
.gdbinit
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2002, 2007 Free Software Foundation, Inc.
##
## GNU Mailutils 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 3, 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 License
## along with this program; if not, write to the Free Software
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
INCLUDES = -I${top_srcdir} @MU_COMMON_INCLUDES@ @GUILE_INCLUDES@
SUBDIRS = testsuite
libexec_PROGRAMS = mail.local
mail_local_SOURCES = main.c mailquota.c script.c mail.local.h
mail_local_LDADD = \
@LIBMU_SCM@ @GUILE_LIBS@\
@LIBMU_SCM_DEPS@\
${MU_APP_LIBRARIES}\
${MU_LIB_SIEVE}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
${MU_LIB_NNTP}\
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS} \
@MU_COMMON_LIBRARIES@
install-exec-hook:
for i in $(libexec_PROGRAMS); do\
chown root:mail $(DESTDIR)$(libexecdir)/$$i;\
chmod 4755 $(DESTDIR)$(libexecdir)/$$i;\
done
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2007 Free Software Foundation, Inc.
GNU Mailutils 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 3, or (at your option)
any later version.
GNU Mailutils 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 License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA */
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <errno.h>
#include <grp.h>
#include <netdb.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_SYSEXITS_H
# include <sysexits.h>
#else
# define EX_OK 0 /* successful termination */
# define EX__BASE 64 /* base value for error messages */
# define EX_USAGE 64 /* command line usage error */
# define EX_DATAERR 65 /* data format error */
# define EX_NOINPUT 66 /* cannot open input */
# define EX_NOUSER 67 /* addressee unknown */
# define EX_NOHOST 68 /* host name unknown */
# define EX_UNAVAILABLE 69 /* service unavailable */
# define EX_SOFTWARE 70 /* internal software error */
# define EX_OSERR 71 /* system error (e.g., can't fork) */
# define EX_OSFILE 72 /* critical OS file missing */
# define EX_CANTCREAT 73 /* can't create (user) output file */
# define EX_IOERR 74 /* input/output error */
# define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
# define EX_PROTOCOL 76 /* remote error in protocol */
# define EX_NOPERM 77 /* permission denied */
# define EX_CONFIG 78 /* configuration error */
# define EX__MAX 78 /* maximum listed value */
#endif
#ifndef INADDR_LOOPBACK
# define INADDR_LOOPBAK 0x7f000001
#endif
#include <mailutils/attribute.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/list.h>
#include <mailutils/locker.h>
#include <mailutils/mailbox.h>
#include <mailutils/message.h>
#include <mailutils/mutil.h>
#include <mailutils/registrar.h>
#include <mailutils/stream.h>
#include <mailutils/url.h>
#include <mailutils/mu_auth.h>
#include <mailutils/sieve.h>
#include <mailutils/nls.h>
#include <mu_dbm.h>
#include <mu_asprintf.h>
#if defined (USE_DBM) || defined (USE_SQL)
# define USE_MAILBOX_QUOTAS 1
#endif
/* Debug */
extern int debug_level;
#define dbg() if (debug_level) debug
/* mailquota settings */
#define MQUOTA_OK 0
#define MQUOTA_EXCEEDED 1
#define MQUOTA_UNLIMITED 2
extern char *quotadbname;
extern char *quota_query;
extern int exit_code;
extern void setgroupquota (char *str);
extern int check_quota (struct mu_auth_data *auth,
mu_off_t size, mu_off_t *rest);
int mda (mu_mailbox_t mbx, char *username);
int switch_user_id (struct mu_auth_data *auth, int user);
void mailer_err (const char *msg, const char *arg, const char *fmt, ...)
MU_PRINTFLIKE(3,4);
#ifdef WITH_GUILE
struct mda_data
{
mu_mailbox_t mbox;
char *progfile;
char *progfile_pattern;
char **argv;
};
int prog_mda (struct mda_data *data);
extern int debug_guile;
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005, 2007 Free Software Foundation, Inc.
GNU Mailutils 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 3, or (at your option)
any later version.
GNU Mailutils 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 License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA */
#include <mail.local.h>
#if defined (USE_MAILBOX_QUOTAS)
#define DEFRETVAL MQUOTA_UNLIMITED
mu_off_t groupquota = 5*1024*1024UL;
static int get_size (char *, mu_off_t *, char **);
int
get_size (char *str, mu_off_t *size, char **endp)
{
mu_off_t s;
s = strtol (str, &str, 0);
switch (*str)
{
case 0:
break;
case 'k':
case 'K':
s *= 1024;
break;
case 'm':
case 'M':
s *= 1024*1024;
break;
default:
*endp = str;
return -1;
}
*size = s;
return 0;
}
#define RETR_OK 0
#define RETR_UNLIMITED -1
#define RETR_FAILURE 1
int
fail_retrieve_quota (char *name, mu_off_t *quota)
{
mu_error (_("No quota retrieving mechanism"));
return RETR_FAILURE;
}
#ifdef USE_DBM
int
dbm_retrieve_quota (char *name, mu_off_t *quota)
{
DBM_FILE db;
DBM_DATUM named, contentd;
char buffer[64];
int unlimited = 0;
int rc;
if (!quotadbname)
return RETR_FAILURE;
if (mu_dbm_open (quotadbname, &db, MU_STREAM_READ, 0600))
{
mu_error (_("Cannot open %s: %s"), quotadbname, mu_strerror (errno));
return RETR_FAILURE;
}
memset (&named, 0, sizeof named);
memset (&contentd, 0, sizeof contentd);
MU_DATUM_PTR (named) = name;
MU_DATUM_SIZE (named) = strlen (name);
rc = mu_dbm_fetch (db, named, &contentd);
if (rc || !MU_DATUM_PTR (contentd))
{
/* User not in database, try default quota */
memset (&named, 0, sizeof named);
MU_DATUM_PTR (named) = "DEFAULT";
MU_DATUM_SIZE (named) = strlen ("DEFAULT");
rc = mu_dbm_fetch (db, named, &contentd);
if (rc)
{
/*mu_error (_("can't fetch data: %s"), strerror (rc));*/
return RETR_FAILURE;
}
if (!MU_DATUM_PTR (contentd))
return RETR_FAILURE;
}
if (strncasecmp("none",
MU_DATUM_PTR (contentd),
MU_DATUM_SIZE (contentd)) == 0)
unlimited = 1;
else if (MU_DATUM_SIZE (contentd) > sizeof(buffer)-1)
{
mu_error (ngettext ("Mailbox quota for `%s' is too big: %d digit",
"Mailbox quota for `%s' is too big: %d digits",
MU_DATUM_SIZE (contentd)),
name, MU_DATUM_SIZE (contentd));
*quota = groupquota;
}
else
{
char *p;
strncpy(buffer, MU_DATUM_PTR (contentd), MU_DATUM_SIZE (contentd));
buffer[MU_DATUM_SIZE (contentd)] = 0;
*quota = strtoul (buffer, &p, 0);
if (get_size (buffer, quota, &p))
{
mu_error (_("Bogus mailbox quota for `%s' (near `%s')"), name, p);
*quota = groupquota;
}
}
mu_dbm_close (db);
return unlimited ? RETR_UNLIMITED : RETR_OK;
}
# define default_retrieve_quota dbm_retrieve_quota
#else
# define default_retrieve_quota fail_retrieve_quota
#endif
#ifdef USE_SQL
#include <mailutils/sql.h>
/* FIXME: defined in libmu_auth/sql.c */
#include <libmu_auth/sql.h>
int
sql_retrieve_quota (char *name, mu_off_t *quota)
{
mu_sql_connection_t conn;
char *query_str;
int rc, status;
char *tmp;
size_t n;
query_str = mu_sql_expand_query (quota_query, name);
if (!query_str)
return RETR_FAILURE;
status = mu_sql_connection_init (&conn,
mu_sql_module_config.interface,
mu_sql_module_config.host,
mu_sql_module_config.port,
mu_sql_module_config.user,
mu_sql_module_config.passwd,
mu_sql_module_config.db);
if (status)
{
mu_error ("%s. SQL error: %s",
mu_strerror (status), mu_sql_strerror (conn));
mu_sql_connection_destroy (&conn);
free (query_str);
return RETR_FAILURE;
}
status = mu_sql_connect (conn);
if (status)
{
mu_error ("%s. SQL error: %s",
mu_strerror (status), mu_sql_strerror (conn));
mu_sql_connection_destroy (&conn);
free (query_str);
return RETR_FAILURE;
}
status = mu_sql_query (conn, query_str);
free (query_str);
if (status)
{
mu_error (_("SQL Query failed: %s"),
(status == MU_ERR_SQL) ? mu_sql_strerror (conn) :
mu_strerror (status));
mu_sql_connection_destroy (&conn);
return RETR_FAILURE;
}
status = mu_sql_store_result (conn);
if (status)
{
mu_error (_("Cannot store SQL result: %s"),
(status == MU_ERR_SQL) ? mu_sql_strerror (conn) :
mu_strerror (status));
mu_sql_connection_destroy (&conn);
return RETR_FAILURE;
}
mu_sql_num_tuples (conn, &n);
if (n == 0)
{
rc = RETR_FAILURE;
}
else
{
rc = RETR_OK;
tmp = NULL;
status = mu_sql_get_column (conn, 0, 0, &tmp);
if (status)
{
mu_error (_("Cannot retrieve mailbox quota from SQL: %s"),
(status == MU_ERR_SQL) ? mu_sql_strerror (conn) :
mu_strerror (status));
rc = RETR_FAILURE;
}
else if (tmp == NULL || tmp[0] == 0 || strcasecmp (tmp, "none") == 0)
rc = RETR_UNLIMITED;
else
{
char *p;
if (get_size (tmp, quota, &p))
{
mu_error (_("Bogus mailbox quota for `%s' (near `%s')"),
name, p);
*quota = groupquota;
}
}
}
mu_sql_release_result (conn);
mu_sql_disconnect (conn);
mu_sql_connection_destroy (&conn);
return rc;
}
#endif
static int
retrieve_quota (struct mu_auth_data *auth, mu_off_t *quota)
{
if (MU_HAS_QUOTA (auth))
{
if (auth->quota == 0)
return RETR_UNLIMITED;
*quota = auth->quota;
return RETR_OK;
}
#ifdef USE_SQL
if (quota_query)
return sql_retrieve_quota (auth->name, quota);
#endif
return default_retrieve_quota (auth->name, quota);
}
int
check_quota (struct mu_auth_data *auth, mu_off_t size, mu_off_t *rest)
{
mu_off_t quota;
switch (retrieve_quota (auth, &quota))
{
case RETR_FAILURE:
return DEFRETVAL;
case RETR_UNLIMITED:
return MQUOTA_UNLIMITED;
case RETR_OK:
if (quota < size) /* Mailbox full */
return MQUOTA_EXCEEDED;
if (rest)
*rest = quota - size;
}
return MQUOTA_OK;
}
#endif /* USE_MAIL_QUOTA */
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2007 Free Software Foundation, Inc.
GNU Mailutils 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 3, or (at your option)
any later version.
GNU Mailutils 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 License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA */
#include <mail.local.h>
#ifdef WITH_GUILE
#include <mailutils/guile.h>
int debug_guile;
SCM mda_catch_body (void *data, mu_mailbox_t mbox);
SCM mda_catch_handler (void *unused, SCM tag, SCM throw_args);
int mda_next (void *data, mu_mailbox_t mbox);
int mda_exit (void *data, mu_mailbox_t mbox);
int mda_init (void *data);
int
prog_mda (struct mda_data *data)
{
char *x_argv[2];
mu_guimb_param_t param;
x_argv[0] = "mail.local";
x_argv[1] = NULL;
param.debug_guile = debug_guile;
param.mbox = data->mbox;
param.user_name = NULL;
param.init = mda_init;
param.catch_body = mda_catch_body;
param.catch_handler = mda_catch_handler;
param.next = mda_next;
param.exit = mda_exit;
param.data = data;
mu_process_mailbox (1, x_argv, &param);
return EX_UNAVAILABLE;
}
int
mda_init (void *data)
{
struct mda_data *md = data;
md->progfile = mu_expand_path_pattern (md->progfile_pattern, md->argv[0]);
return 0;
}
static void
mda_switch_to_user (struct mda_data *md)
{
struct mu_auth_data *auth = NULL;
if (md && *md->argv != NULL)
auth = mu_get_auth_by_name (*md->argv);
if (auth)
{
switch_user_id (auth, 1);
chdir (auth->dir);
mu_auth_data_free (auth);
}
else
{
switch_user_id (auth, 0);
chdir ("/");
}
}
SCM
mda_catch_body (void *data, mu_mailbox_t mbox)
{
struct mda_data *md = data;
mu_message_t mesg = NULL;
mu_attribute_t attr = NULL;
if (access (md->progfile, R_OK))
{
if (debug_level > 2)
mu_diag_output (MU_DIAG_DEBUG, _("Access to %s failed: %m"), md->progfile);
}
else
{
mda_switch_to_user (md);
scm_primitive_load (scm_makfrom0str (md->progfile));
}
mu_mailbox_get_message (mbox, 1, &mesg);
mu_message_get_attribute (mesg, &attr);
if (mu_attribute_is_deleted (attr))
return SCM_BOOL_F;
mda_switch_to_user (NULL);
mda (md->mbox, md->argv[0]);
return SCM_BOOL_F;
}
SCM
mda_catch_handler (void *data, SCM tag, SCM throw_args)
{
exit_code = EX_TEMPFAIL;
return scm_handle_by_message_noexit ("mail.local", tag, throw_args);
}
int
mda_next (void *data, mu_mailbox_t mbox)
{
struct mda_data *md = data;
mu_message_t mesg = NULL;
mu_attribute_t attr = NULL;
md->argv++;
if (*md->argv == NULL)
return 0;
if (md->progfile)
free (md->progfile);
md->progfile = mu_expand_path_pattern (md->progfile_pattern, *md->argv);
mu_mailbox_get_message (mbox, 1, &mesg);
mu_message_get_attribute (mesg, &attr);
mu_attribute_unset_deleted (attr);
return md->progfile != NULL;
}
int
mda_exit (void *data, mu_mailbox_t mbox)
{
return exit_code;
}
#endif
Makefile
Makefile.in
*.log
*.sum
site.exp
remote.exp
data
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007 Free Software Foundation
#
# 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 3 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 License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
MESSAGE Simple mail
FROM gray@gnu.org
TO user
BODY BEGIN
From: gray@gnu.org
To: bug-mailutils@gnu.org
Subject: Simple mail
This is a simple mail.
Data goes here.
BODY END
MESSAGE END
MESSAGE Second mail
FROM gray@runasimi.org
TO user
BODY BEGIN
From: gray@runasimi.org
To: bug-mailutils@gnu.org
Subject: Simple mail
This is a simple mail.
Data goes here.
BODY END
MESSAGE END
# end of data
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2002, 2007 Free Software Foundation, Inc.
##
## GNU Mailutils 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 3, 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 License
## along with this program; if not, write to the Free Software
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
AUTOMAKE_OPTIONS = dejagnu
DEJATOOL = mail.local
RUNTESTFLAGS =
CLEANFILES = *.log
test_dirs = lib mail.local
EXTRA_DIST = Data
dist-hook:
here=`cd $(top_builddir)/$(subdir) && pwd`; \
srcdir=`cd $(srcdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
for dir in $(test_dirs); \
do \
cd $$srcdir;\
mkdir $$distdir/$$dir;\
cd $$dir;\
for file in DISTFILES `cat DISTFILES`; do \
d=$$srcdir/$$dir; \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $$distdir/$$dir/$$file; \
else \
test -f $$distdir/$$dir/$$file \
|| cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
fi; \
done;\
done;\
cd $$here
site.exp: Makefile remote.exp
@echo 'Making a new site.exp file...'
@test ! -f site.bak || rm -f site.bak
@echo '## these variables are automatically generated by make ##' > $@-t
@echo '# Do not edit here. If you wish to override these values' >> $@-t
@echo '# edit the last section' >> $@-t
@echo 'set tool $(DEJATOOL)' >> $@-t
@echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
@echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
@echo 'set objdir' `pwd` >> $@-t
@echo 'set host_alias "$(host_alias)"' >> $@-t
@echo 'set host_triplet $(host_triplet)' >> $@-t
@echo 'set target_alias "$(target_alias)"' >> $@-t
@echo 'set target_triplet $(target_triplet)' >> $@-t
@echo 'set build_alias "$(build_alias)"' >> $@-t
@echo 'set build_triplet $(build_triplet)' >> $@-t
@echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
@test ! -f site.exp || mv site.exp site.bak
@mv $@-t site.exp
remote.exp:;
@echo 'Making a new remote.exp file...'
@test ! -f remote.bak || rm -f remote.bak
@echo '## These variables are used to set up for the remote testing.' >> $@-t
@echo '## Please, read file README in this directory for instructions' >> $@-t
@echo '## on how to use this file' >> $@-t
@echo "set host_board `hostname`" >> $@-t
@echo 'set board_info($$host_board,connect) rlogin' >> $@-t
@echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
@test ! -f remote.exp || mv remote.exp remote.bak
@mv $@-t remote.exp
DISTCLEANFILES=*.exp *.log *.sum
distclean-local:
-rm -rf data
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008 Free Software Foundation
#
# 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 3 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 License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
source $top_srcdir/testsuite/lib/mailutils.exp
mu_init "--authentication generic --authorization virtdomain"
mu_version
if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
clone_output "WARNING: Support for virtual domains not compiled in"
clone_output "WARNING: Skipping tests for mail.local"
exit 0
}
mu_prepare_spools
set ETC_DIR "$MU_DATA_DIR/etc"
mu_makespool "$MU_RC_DIR" "$ETC_DIR"
append MU_TOOL_FLAGS " --virtual-passwd-dir $ETC_DIR"
set mu_filename "$MU_SPOOL_DIR/INBOX"
set env(MTA_DIAG) "$mu_filename"
# mail_local_test [-message MESSAGE][-default (FAIL|XFAIL)]
# [-input INPUT-LIST]
# [-args ARGS][-pattern PATTERN-LIST][PATTERN...]
# INPUT-LIST - List of input strings for MU_TOOL
# PATTERN - Sequence to expect in return.
# MESSAGE - [optional] message to output
# ARGS - Additional arguments to MU_TOOL
proc mail_local_test { args } {
global MU_TOOL
global top_builddir
global verbose
global suppress_flag;
global mu_filename
upvar timeout timeout
set default ""
set message ""
set invocation ""
set input ""
set pattern ""
set invocation ""
for {set i 0} {$i < [llength $args]} {incr i} {
set a [lindex $args $i]
if {"$a" == "-default"} {
incr i
set default [lindex $args $i]
} elseif {"$a" == "-message"} {
incr i
set message [lindex $args $i]
} elseif {"$a" == "-pattern"} {
incr i
set pattern [lindex $args $i]
} elseif {"$a" == "-input"} {
incr i
set input [lindex $args $i]
} elseif {"$a" == "-args"} {
incr i
set a [lindex $args $i]
if {[llength $a] > 0} {
append invocation $a
}
} else {
set args [lrange $args $i end]
break
}
}
if {"$message" == ""} {
set message [lindex $args 0]
}
if $verbose>2 then {
send_user "Message is \"$message\"\n"
}
return [mailer_test -default $default -message $message -input $input -pattern $pattern -file $mu_filename -args $invocation]
}
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007 Free Software Foundation
#
# 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 3 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 License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
set chan [open ${srcdir}/Data r]
# States are:
# INITIAL 0
# MESSAGE 1
# BODY 2
# PATTERN 3
set state 0
# Current pattern. Notice that it is cumulative (i.e. it is not reset
# before each test) since the mailbox itself is cumulative too.
set pattern [list]
for {gets $chan line} {![eof $chan]} {gets $chan line} {
verbose "LINE $line" 1
switch -regexp -- "$line" {
"^#.*" { }
"^MESSAGE END" {
verbose "MAIL FROM $from" 1
verbose "MAIL TO $to" 1
verbose "INPUT $input" 1
verbose "PATTERN $pattern" 1
set args ""
if {$from != ""} {
append args " --from $from"
}
if {$to != ""} {
append args " ${to}@passwd"
}
if {$pattern == ""} {
set pattern [concat [list -re "From $from\[^\r\n\]*"] $input]
}
mail_local_test -message $message -input $input \
-pattern $pattern -args $args
lappend pattern ""
set state 0
}
"^MESSAGE" {
regexp "^MESSAGE (.*)" $line dummy message
set from ""
set to ""
set input [list]
set state 1
}
"^FROM" {
regexp "^FROM (.*)" $line dummy from
}
"^TO" {
regexp "^TO (.*)" $line dummy to
}
"^BODY BEGIN" {
set state 2
}
"^BODY END" {
set state 1
}
"^PATTERN BEGIN" {
set state 3
}
"^PATTERN END" {
set state 1
}
"^STOP" {
break
}
default {
if {$state == 2} {
lappend input $line
} elseif {$state == 3} {
lappend pattern $line
}
}
}
}
close $chan
# End of deliver.exp
Makefile
Makefile.in
mail.remote
out.sendmail
.gdbinit
.deps
.libs
.*.swp
_*
.gdbinit
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2002, 2007 Free Software Foundation, Inc.
##
## GNU Mailutils 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 3, 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 License
## along with this program; if not, write to the Free Software
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
INCLUDES = @MU_COMMON_INCLUDES@
SUBDIRS = testsuite
MU_SMTP_PROGRAMS_LIST = mail.remote$(EXEEXT)
EXTRA_PROGRAMS = mail.remote
libexec_PROGRAMS = @MU_SMTP_PROGRAMS_BUILD@
mail_remote_SOURCES = mail.remote.c
mail_remote_LDADD = \
${MU_APP_LIBRARIES}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}\
@MU_COMMON_LIBRARIES@
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005, 2007, 2008 Free Software Foundation, Inc.
GNU Mailutils 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 3, or (at your option)
any later version.
GNU Mailutils 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 License
along with GNU Mailutils; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <mailutils/address.h>
#include <mailutils/debug.h>
#include <mailutils/errno.h>
#include <mailutils/list.h>
#include <mailutils/mailer.h>
#include <mailutils/mutil.h>
#include <mailutils/message.h>
#include <mailutils/registrar.h>
#include <mailutils/stream.h>
#include <mailutils/property.h>
#include <mailutils/error.h>
#include <mailutils/nls.h>
#include <mailutils/mu_auth.h>
#include "mailutils/libargp.h"
#include "mu_umaxtostr.h"
const char *program_version = "mail.remote (" PACKAGE_STRING ")";
static char doc[] =
N_("GNU mail.remote -- pseudo-sendmail interface for mail delivery")
"\v"
N_("This is a simple drop-in replacement for sendmail to forward mail directly\n\
to an SMTP gateway.\n\
You should always specify your SMTP gateway using --mailer option\n\
(the best place to do so is in your configuration file).\n\
\n\
Examples:\n\
\n\
Deliver mail via SMTP gateway at \"mail.example.com\", reading its\n\
contents for recipients of the message.\n\
\n\
mail.remote --mailer smtp://mail.example.com -t\n\
\n\
Deliver mail only to \"devnull@foo.bar\"\n\
\n\
mail.remote --mailer smtp://mail.example.com devnull@foo.bar\n\
\n\
Deliver mail to \"devnull@foo.bar\" as well as to the recipients\n\
specified in the message itself:\n\
\n\
mail.remote --mailer smtp://mail.example.com -t devnull@foo.bar\n");
static struct argp_option options[] = {
{"from", 'f', N_("ADDR"), 0, N_("Override the default from address")},
{"read-recipients", 't', NULL, 0, N_("Read message for recipients.") },
{"debug", 'd', NULL, 0, N_("Print envelope commands in the SMTP protocol transaction. If specified more than once, the data part of the protocol transaction will also be printed.")},
{ NULL, 'o', N_("OPT"), 0, N_("Ignored for sendmail compatibility")},
{ NULL, 'b', N_("OPT"), 0, N_("Ignored for sendmail compatibility")},
{ NULL, 'i', NULL, 0, N_("Ignored for sendmail compatibility")},
{ NULL }
};
static int optdebug;
static const char *optfrom;
static int read_recipients; /* Read recipients from the message */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
static struct mu_argp_node_list lst;
static int dbug = 0;
switch (key)
{
case 'f':
mu_argp_node_list_new (&lst, "from", arg);
break;
case 'd':
dbug++;
break;
case 'o':
case 'b':
case 'i':
break;
case 't':
mu_argp_node_list_new (&lst, "read-recipients", "yes");
break;
case ARGP_KEY_INIT:
mu_argp_node_list_init (&lst);
break;
case ARGP_KEY_FINI:
if (dbug)
mu_argp_node_list_new (&lst, "debug", mu_umaxtostr (0, dbug));
mu_argp_node_list_finish (&lst, NULL, NULL);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp argp = {
options,
parse_opt,
N_("[TO-ADDR]..."),
doc,
};
struct mu_cfg_param mail_remote_cfg_param[] = {
{ "from", mu_cfg_string, &optfrom, 0, NULL,
N_("Set sender email address."),
N_("email") },
{ "read-recipients", mu_cfg_string, &read_recipients, 0, NULL,
N_("Read recipient addresses from the message.") },
{ "debug", mu_cfg_int, &optdebug, 0, NULL,
N_("Set debug verbosity level. Level 1 prints envelope commands in "
"the SMTP protocol transaction. Levels 2 and above print the data "
"part of the transaction as well.") },
{ NULL }
};
static const char *capa[] = {
"auth",
"common",
"debug",
"mailer",
"address",
"license",
NULL
};
mu_mailer_t mailer; /* Mailer object */
mu_address_t from; /* Sender address */
mu_address_t to; /* Recipient addresses */
mu_stream_t in; /* Input stream */
void
mr_exit (int status)
{
mu_address_destroy (&from);
mu_address_destroy (&to);
mu_stream_destroy (&in, NULL);
mu_mailer_destroy (&mailer);
exit (status ? 1 : 0);
}
int
main (int argc, char **argv)
{
int status = 0;
int optind = 0;
mu_message_t msg = 0;
int mailer_flags = 0;
/* Native Language Support */
MU_APP_INIT_NLS ();
/* Register mailers. */
mu_registrar_record (mu_smtp_record);
MU_AUTH_REGISTER_ALL_MODULES();
mu_argp_init (program_version, NULL);
if (mu_app_init (&argp, capa, mail_remote_cfg_param,
argc, argv, 0, &optind, NULL))
exit (1);
if (optfrom)
{
if ((status = mu_address_create (&from, optfrom)))
{
mu_error (_("Parsing from addresses failed: %s"),
mu_strerror (status));
mr_exit (status);
}
}
if (argv[optind])
{
if ((status = mu_address_createv (&to, (const char **) (argv + optind), -1)))
{
mu_error (_("Parsing recipient addresses failed: %s"),
mu_strerror (status));
mr_exit (status);
}
}
if ((status = mu_stdio_stream_create (&in, stdin, MU_STREAM_SEEKABLE)))
{
mu_error (_("Failed: %s"), mu_strerror (status));
mr_exit (status);
}
if ((status = mu_stream_open (in)))
{
mu_error (_("Opening stdin failed: %s"), mu_strerror (status));
mr_exit (status);
}
if ((status = mu_message_create (&msg, NULL)))
{
mu_error (_("Failed: %s"), mu_strerror (status));
mr_exit (status);
}
if ((status = mu_message_set_stream (msg, in, NULL)))
{
mu_error (_("Failed: %s"), mu_strerror (status));
mr_exit (status);
}
if ((status = mu_mailer_create (&mailer, NULL)))
{
const char *url = NULL;
mu_mailer_get_url_default (&url);
mu_error (_("Creating mailer `%s' failed: %s"),
url, mu_strerror (status));
mr_exit (status);
}
if (optdebug)
{
mu_debug_t debug;
mu_mailer_get_debug (mailer, &debug);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
if (optdebug > 1)
mailer_flags = MAILER_FLAG_DEBUG_DATA;
}
if (read_recipients)
{
mu_property_t property = NULL;
mu_mailer_get_property (mailer, &property);
mu_property_set_value (property, "READ_RECIPIENTS", "true", 1);
}
if ((status = mu_mailer_open (mailer, mailer_flags)))
{
const char *url = NULL;
mu_mailer_get_url_default (&url);
mu_error (_("Opening mailer `%s' failed: %s"),
url, mu_strerror (status));
mr_exit (status);
}
if ((status = mu_mailer_send_message (mailer, msg, from, to)))
{
mu_error (_("Sending message failed: %s"), mu_strerror (status));
mr_exit (status);
}
if ((status = mu_mailer_close (mailer)))
{
mu_error (_("Closing mailer failed: %s"), mu_strerror (status));
mr_exit (status);
}
mr_exit (status);
}
Makefile
Makefile.in
*.log
*.sum
site.exp
remote.exp
data
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2004, 2007 Free Software Foundation
#
# 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 3 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 License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
MESSAGE Simple mail
BODY BEGIN
From: gray@gnu.org
To: bug-mailutils@gnu.org
Subject: Simple mail
This is a simple mail.
Data goes here.
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <bug-mailutils@gnu.org>
0: From: gray@gnu.org
1: To: bug-mailutils@gnu.org
2: Subject: Simple mail
3:
4: This is a simple mail.
5: Data goes here.
6:
END OF MESSAGE
PATTERN END
MESSAGE END
MESSAGE Explicit from
FROM <gray@localhost>
BODY BEGIN
From: gray@gnu.org
To: bug-mailutils@gnu.org
Subject: Explicit from test.
This is a simple mail.
Data goes here.
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@localhost>
ENVELOPE TO: <bug-mailutils@gnu.org>
0: From: gray@gnu.org
1: To: bug-mailutils@gnu.org
2: Subject: Explicit from test.
3:
4: This is a simple mail.
5: Data goes here.
6:
END OF MESSAGE
PATTERN END
MESSAGE END
MESSAGE Explicit To
TO <alainm@gnu.org> <jbailey@gnu.org>
BODY BEGIN
From: gray@gnu.org
Subject: Expicit destinations
This is a test for working explicit destinations.
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <alainm@gnu.org>,<jbailey@gnu.org>
0: To: <alainm@gnu.org>,<jbailey@gnu.org>
1: From: gray@gnu.org
2: Subject: Expicit destinations
3:
4: This is a test for working explicit destinations.
5:
END OF MESSAGE
PATTERN END
MESSAGE END
MESSAGE CC
BODY BEGIN
From: gray@gnu.org
To: bug-mailutils@gnu.org
Cc: alainm@gnu.org
Subject: Carbon copy test
CC works.
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <bug-mailutils@gnu.org>,<alainm@gnu.org>
0: From: gray@gnu.org
1: To: bug-mailutils@gnu.org
2: Cc: alainm@gnu.org
3: Subject: Carbon copy test
4:
5: CC works.
6:
END OF MESSAGE
PATTERN END
MESSAGE END
MESSAGE BCC
BODY BEGIN
From: gray@gnu.org
To: alainm@gnu.org
Bcc: bug-mailutils@gnu.org
Subject: Blind carbon copy test.
Bcc works too.
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <alainm@gnu.org>
0: From: gray@gnu.org
1: To: alainm@gnu.org
2: Subject: Blind carbon copy test.
3:
4: Bcc works too.
5:
END OF MESSAGE
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <bug-mailutils@gnu.org>
0: Bcc: bug-mailutils@gnu.org
1: From: gray@gnu.org
2: To: alainm@gnu.org
3: Subject: Blind carbon copy test.
4:
5: Bcc works too.
6:
END OF MESSAGE
PATTERN END
MESSAGE END
MESSAGE Complex
TO <root@localhost>
BODY BEGIN
From: gray@gnu.org
Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org>
Bcc: bug-mailutils@gnu.org
Subject: A complex test
It works?
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <root@localhost>
0: To: <root@localhost>
1: From: gray@gnu.org
2: Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org>
3: Subject: A complex test
4:
5: It works?
6:
END OF MESSAGE
PATTERN END
MESSAGE END
MESSAGE Complex+Read recipients
OPTIONS -t
TO <root@localhost>
BODY BEGIN
From: gray@gnu.org
Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org>
Bcc: bug-mailutils@gnu.org
Subject: A complex test
It works?
BODY END
PATTERN BEGIN
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <root@localhost>,<alainm@gnu.org>,<jbailey@gnu.org>
0: To: <root@localhost>,<alainm@gnu.org>,<jbailey@gnu.org>
1: From: gray@gnu.org
2: Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org>
3: Subject: A complex test
4:
5: It works?
6:
END OF MESSAGE
ENVELOPE FROM: <gray@gnu.org>
ENVELOPE TO: <bug-mailutils@gnu.org>
0: To: <bug-mailutils@gnu.org>
1: Bcc: bug-mailutils@gnu.org
2: From: gray@gnu.org
3: Cc: "Alain Magloire" <alainm@gnu.org>, "Jeff Bailey" <jbailey@gnu.org>
4: Subject: A complex test
5:
6: It works?
7:
END OF MESSAGE
PATTERN END
MESSAGE END
# End of data
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2002, 2007 Free Software Foundation, Inc.
##
## GNU Mailutils 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 3, 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 License
## along with this program; if not, write to the Free Software
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
AUTOMAKE_OPTIONS = dejagnu
SMTP_DEJATOOL = mail.remote
DEJATOOL = @MU_SMTP_DEJATOOL@
RUNTESTFLAGS =
CLEANFILES = *.log
test_dirs = lib mail.remote
EXTRA_DIST = Data
dist-hook:
here=`cd $(top_builddir)/$(subdir) && pwd`; \
srcdir=`cd $(srcdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
for dir in $(test_dirs); \
do \
cd $$srcdir;\
mkdir $$distdir/$$dir;\
cd $$dir;\
for file in DISTFILES `cat DISTFILES`; do \
d=$$srcdir/$$dir; \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $$distdir/$$dir/$$file; \
else \
test -f $$distdir/$$dir/$$file \
|| cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
fi; \
done;\
done;\
cd $$here
site.exp: Makefile remote.exp
@echo 'Making a new site.exp file...'
@test ! -f site.bak || rm -f site.bak
@echo '## these variables are automatically generated by make ##' > $@-t
@echo '# Do not edit here. If you wish to override these values' >> $@-t
@echo '# edit the last section' >> $@-t
@echo 'set tool $(DEJATOOL)' >> $@-t
@echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
@echo "set top_builddir `cd $(top_builddir); pwd`" >> $@-t
@echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
@echo 'set objdir' `pwd` >> $@-t
@echo 'set host_alias "$(host_alias)"' >> $@-t
@echo 'set host_triplet $(host_triplet)' >> $@-t
@echo 'set target_alias "$(target_alias)"' >> $@-t
@echo 'set target_triplet $(target_triplet)' >> $@-t
@echo 'set build_alias "$(build_alias)"' >> $@-t
@echo 'set build_triplet $(build_triplet)' >> $@-t
@echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
@test ! -f site.exp || mv site.exp site.bak
@mv $@-t site.exp
remote.exp:;
@echo 'Making a new remote.exp file...'
@test ! -f remote.bak || rm -f remote.bak
@echo '## These variables are used to set up for the remote testing.' >> $@-t
@echo '## Please, read file README in this directory for instructions' >> $@-t
@echo '## on how to use this file' >> $@-t
@echo "set host_board `hostname`" >> $@-t
@echo 'set board_info($$host_board,connect) rlogin' >> $@-t
@echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
@echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
@test ! -f remote.exp || mv remote.exp remote.bak
@mv $@-t remote.exp
DISTCLEANFILES=*.exp *.log *.sum
distclean-local:
-rm -rf data
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2004, 2007 Free Software Foundation
#
# 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 3 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 License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
source $top_srcdir/testsuite/lib/mailutils.exp
mu_init -noflags
mu_prepare_spools
set mu_filename "$MU_FOLDER_DIR/mta.diag"
set env(MTA_DIAG) "$mu_filename"
# mail_remote_test [-message MESSAGE][-default (FAIL|XFAIL)]
# [-input INPUT-LIST]
# [-args ARGS][-pattern PATTERN-LIST][PATTERN...]
# INPUT-LIST - List of input strings for MU_TOOL
# PATTERN - Sequence to expect in return.
# MESSAGE - [optional] message to output
# ARGS - Additional arguments to MU_TOOL
proc mail_remote_test { args } {
global MU_TOOL
global top_builddir
global verbose
global suppress_flag;
global mu_filename
upvar timeout timeout
set default ""
set message ""
set invocation ""
set input ""
set pattern ""
for {set i 0} {$i < [llength $args]} {incr i} {
set a [lindex $args $i]
if {"$a" == "-default"} {
incr i
set default [lindex $args $i]
} elseif {"$a" == "-message"} {
incr i
set message [lindex $args $i]
} elseif {"$a" == "-pattern"} {
incr i
set pattern [lindex $args $i]
} elseif {"$a" == "-input"} {
incr i
set input [lindex $args $i]
} elseif {"$a" == "-args"} {
incr i
set a [lindex $args $i]
if {[llength $a] > 0} {
append invocation $a
}
} else {
set args [lrange $args $i end]
break
}
}
set res [remote_spawn host "${top_builddir}/examples/mta -bd"]
if { $res < 0 || $res == "" } {
perror "Spawning mta failed."
return 1
}
remote_expect host 60 {
-re "\[0-9\]\[0-9\]*" {
set port $expect_out(buffer)
set url "smtp://127.0.0.1:$port"
verbose "URL: $url" 1
}
default {
perror "Spawning mta failed."
return 1
}
}
if {"$message" == ""} {
set message [lindex $args 0]
}
if $verbose>2 then {
send_user "Message is \"$message\"\n"
}
return [mailer_test -default $default -message $message \
-input $input -pattern $pattern -file \
$mu_filename -args "--mailer $url $invocation"]
}
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2004, 2007 Free Software Foundation
#
# 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 3 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 License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
set chan [open ${srcdir}/Data r]
set state 0
set command ""
for {gets $chan line} {![eof $chan]} {gets $chan line} {
verbose "LINE $line" 1
switch -regexp -- "$line" {
"^#.*" { }
"^MESSAGE END" {
verbose "MAIL FROM $from" 1
verbose "MAIL TO $to" 1
verbose "INPUT $input" 1
verbose "OPTIONS $options" 1
verbose "PATTERN $pattern" 1
set args ""
if {$from != ""} {
append args " --from $from"
}
if {$options != ""} {
append args " $options"
}
if {$to != ""} {
append args " $to"
}
mail_remote_test -message $message -input $input \
-pattern $pattern -args $args
set state 0
}
"^MESSAGE" {
regexp "^MESSAGE (.*)" $line dummy message
set from ""
set to ""
set options ""
set input [list]
set pattern [list]
set state 1
}
"^FROM" {
regexp "^FROM (.*)" $line dummy from
}
"^TO" {
regexp "^TO (.*)" $line dummy to
}
"^OPTIONS" {
regexp "^OPTIONS (.*)" $line dummy options
}
"^BODY BEGIN" {
set state 2
}
"^BODY END" {
set state 1
}
"^PATTERN BEGIN" {
set state 3
}
"^PATTERN END" {
set state 1
}
"^STOP" {
break
}
default {
if {$state == 2} {
lappend input $line
} elseif {$state == 3} {
lappend pattern $line
}
}
}
}
close $chan
# End of send.exp
......@@ -31,8 +31,8 @@ BuildRequires: python
GNU Mailutils contains a series of useful mail clients, servers, and
libraries. These are the primary mail utilities of the GNU system.
This package provides a replacement for /bin/mail(x) conforming to
the UNIX98 specification for mailx. Provides also mail.local,
mail.remote, and other tools including guimb, dotlock, movemail,
the UNIX98 specification for mailx. It provides also a mail delivery
agent maidag, and other tools including guimb, dotlock, movemail,
frm.
%package -n libmailutils
......
......@@ -99,12 +99,6 @@ maidag/mailquota.c
maidag/mailtmp.c
maidag/script.c
mail.local/mailquota.c
mail.local/main.c
mail.local/script.c
mail.remote/mail.remote.c
mail/alias.c
mail/alt.c
mail/cd.c
......