Commit 02634d3b 02634d3bf0932b8bde43a881d67760f38e3f9e9f by Sergey Poznyakoff

Bugfixes.

* comsat/action.c (action_echo): Set omit_newline.
* libmailutils/mailbox/mbx_default.c: Return 0 on success.
Fix memory overrun.

* libproto/mailer/smtp.c (smtp_open): Protect tls-related
code with #ifdef WITH_TLS.
* libproto/pop/mbox.c (pop_open): Likewise.
* mu/imap.c (com_connect): Likewise.

* mh/mhn.c (split_args): Preserve quotes.
(mhn_compose_command): Handle type arguments (%a escape).
(mhn_show_command): Likewise.
(store_handler): Fix call to mh_getyn.
(edit_mime): Pass typeargs to mhn_compose_command.
Fix test for missing filename.
* mh/tests/ali.at (ali04): The test wrongly assumed that the
`root' group has some members.
* mh/tests/folder.at: Always sort the output from find.
* mh/tests/rmf.at: Likewise.
* mh/tests/mhn.at: Likewise.
Filter out timestamps from the tar output produced by mhn.

* tests/testsuite.at (MH_SETUP): Define moreproc.
* mh/tests/mhparam.at: Account for changes in mh_profile
1 parent 0ac52e06
......@@ -353,6 +353,9 @@ action_echo (struct biffrc_environ *env, size_t argc, char **argv)
omit_newline = 1;
i++;
}
else
omit_newline = 0;
for (;;)
{
echo_string (env->tty, argv[i]);
......
......@@ -136,14 +136,13 @@ mu_folder_directory ()
int
mu_construct_user_mailbox_url (char **pout, const char *name)
{
int rc;
const char *pat = mu_mailbox_url ();
const char *env[3];
struct mu_wordsplit ws;
env[0] = "user";
env[1] = (char*) name;
env[3] = NULL;
env[2] = NULL;
ws.ws_env = env;
if (mu_wordsplit (pat, &ws,
MU_WRDSF_NOSPLIT | MU_WRDSF_NOCMD |
......@@ -162,7 +161,7 @@ mu_construct_user_mailbox_url (char **pout, const char *name)
mu_wordsplit_free (&ws);
if (!*pout)
return ENOMEM;
return rc;
return 0;
}
/* Is this a security risk? */
......
......@@ -182,6 +182,7 @@ smtp_open (mu_mailer_t mailer, int flags)
if (rc)
return rc;
#ifdef WITH_TLS
if (!notls && mu_tls_enable &&
mu_smtp_capa_test (smtp_mailer->smtp, "STARTTLS", NULL) == 0)
{
......@@ -193,7 +194,7 @@ smtp_open (mu_mailer_t mailer, int flags)
return rc;
}
}
#endif
if (!noauth && mu_smtp_capa_test (smtp_mailer->smtp, "AUTH", NULL) == 0)
{
rc = mu_smtp_auth (smtp_mailer->smtp);
......
......@@ -173,7 +173,8 @@ pop_open (mu_mailbox_t mbox, int flags)
if (status)
break;
if (WITH_TLS && !mpd->pops &&
#ifdef WITH_TLS
if (!mpd->pops &&
mu_url_sget_param (mbox->url, "notls", NULL) == MU_ERR_NOENT &&
mu_pop3_capa_test (mpd->pop3, "STLS", NULL) == 0)
{
......@@ -181,7 +182,7 @@ pop_open (mu_mailbox_t mbox, int flags)
if (status)
break;
}
#endif
status = mu_authority_authenticate (mbox->folder->authority);
}
while (0);
......
......@@ -208,7 +208,8 @@ split_args (const char *argstr, size_t len, int *pargc, char ***pargv)
ws.ws_delim = ";";
if (mu_wordsplit_len (argstr, len, &ws,
MU_WRDSF_DEFFLAGS | MU_WRDSF_DELIM | MU_WRDSF_WS))
(MU_WRDSF_DEFFLAGS & ~MU_WRDSF_QUOTE) |
MU_WRDSF_DELIM | MU_WRDSF_WS))
{
mu_error (_("cannot split line `%s': %s"), argstr,
mu_wordsplit_strerror (&ws));
......@@ -629,10 +630,11 @@ _mhn_profile_get (const char *prefix, const char *type, const char *subtype,
}
char *
mhn_compose_command (char *typestr, int *flags, char *file)
mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file)
{
const char *p, *str;
char *type, *subtype, *typeargs;
char *type, *subtype, **typeargv = NULL;
int typeargc = 0;
struct obstack stk;
split_content (typestr, &type, &subtype);
......@@ -660,7 +662,20 @@ mhn_compose_command (char *typestr, int *flags, char *file)
{
case 'a':
/* additional arguments */
obstack_grow (&stk, typeargs, strlen (typeargs));
if (typeargs)
{
int i;
if (!typeargv)
split_args (typeargs, strlen (typeargs),
&typeargc, &typeargv);
for (i = 0; i < typeargc; i++)
{
if (i > 0)
obstack_1grow (&stk, ' ');
obstack_grow (&stk, typeargv[i], strlen (typeargv[i]));
}
}
break;
case 'F':
......@@ -688,7 +703,8 @@ mhn_compose_command (char *typestr, int *flags, char *file)
free (type);
free (subtype);
mu_argcv_free (typeargc, typeargv);
str = obstack_finish (&stk);
p = mu_str_skip_class (str, MU_CTYPE_SPACE);
if (!*p)
......@@ -755,6 +771,8 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
struct obstack stk;
mu_header_t hdr;
char *temp_cmd = NULL;
int typeargc = 0;
char **typeargv = NULL;
mu_message_get_header (msg, &hdr);
_get_content_type (hdr, &typestr, &typeargs);
......@@ -824,7 +842,20 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
{
case 'a':
/* additional arguments */
obstack_grow (&stk, typeargs, strlen (typeargs));
if (typeargs)
{
int i;
if (!typeargv)
split_args (typeargs, strlen (typeargs),
&typeargc, &typeargv);
for (i = 0; i < typeargc; i++)
{
if (i > 0)
obstack_1grow (&stk, ' ');
obstack_grow (&stk, typeargv[i], strlen (typeargv[i]));
}
}
break;
case 'e':
......@@ -883,6 +914,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
free (type);
free (subtype);
free (temp_cmd);
mu_argcv_free (typeargc, typeargv);
str = obstack_finish (&stk);
p = mu_str_skip_class (str, MU_CTYPE_SPACE);
......@@ -1745,12 +1777,9 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
if (!(mode_options & OPT_QUIET) && access (name, R_OK) == 0)
{
char *p;
int ok;
mu_asprintf (&p, _("File %s already exists. Rewrite"), name);
ok = mh_getyn (p);
free (p);
ok = mh_getyn (_("File %s already exists. Rewrite"), name);
if (!ok)
{
free (name);
......@@ -2429,7 +2458,7 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
mu_body_t body;
mu_stream_t in, out = NULL, fstr;
char *encoding;
char *p, *typestr;
char *typestr, *typeargs;
char *shell_cmd;
int flags;
......@@ -2442,8 +2471,8 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
mu_rtrim_class (cmd, MU_CTYPE_SPACE);
_get_content_type (hdr, &typestr, NULL);
shell_cmd = mhn_compose_command (typestr, &flags, cmd);
_get_content_type (hdr, &typestr, &typeargs);
shell_cmd = mhn_compose_command (typestr, typeargs, &flags, cmd);
free (typestr);
/* Open the input stream, whatever it is */
......@@ -2452,7 +2481,7 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
if (mhn_exec (&in, cmd, flags))
return 1;
}
else if (p == cmd)
else if (cmd[0] == 0)
{
mu_error (_("%s:%lu: missing filename"),
input_file,
......
......@@ -74,11 +74,10 @@ ali: mh_aliases2:2: `mh_aliases' already included at top level
])
MH_CHECK([ali: group name],[ali04 ali-group-name],[
grep ^root: /etc/group >/dev/null || AT_SKIP_TEST
AT_DATA([mh_aliases],[
korzen: =root
])
awk -F : '$1=="root" { print $4 }' /etc/group | tr -d ' ' > expout
awk -F : '$4!="" { print $1; print $4; exit 0 }' /etc/group > tmpout
test -s tmpout || AT_SKIP_TEST
sed -n '1s/.*/korzen: =&/p' tmpout > mh_aliases
sed '1d' tmpout | tr -d ' ' > expout
ali -a ./mh_aliases korzen | tr -d ' '
],
[0],
......
......@@ -87,7 +87,7 @@ do
mv Mail/inbox/$i Mail/inbox/${i}0
done
folder -pack || exit $?
find Mail/inbox
find Mail/inbox | sort
],
[0],
[Mail/inbox
......@@ -105,7 +105,7 @@ do
mv Mail/inbox/$i Mail/inbox/${i}0
done
folder --pack=1 || exit $?
find Mail/inbox
find Mail/inbox | sort
],
[0],
[Mail/inbox
......
......@@ -21,7 +21,7 @@ AT_CHECK([
mkdir home
dir=`cd home; pwd`
HOME=$dir MH=$dir/mh_profile install-mh -auto || exit $?
find home
find home | sort
HOME=$dir MH=$dir/mh_profile install-mh -auto 2>errout
echo $?
cat errout
......
......@@ -192,7 +192,7 @@ chmod +w Mail/inbox/4
echo "mhn-store-application: %%-%m%P.%s-%p" >> $MH
mhn +inbox -store 4 | remove_curdir || exit $?
find . -name '%*'
find . -name '%*' | sort
],
[0],
[storing message 4 part 1 as file 4.1.plain
......@@ -333,7 +333,12 @@ And the mome raths outgrabe.
MH_CHECK([mhn-show type=tar],[mhn13 mhn-show-type=tar],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mime,[Mail/inbox])
mhn -show 2 | sed /^X-IMAPbase/d
AT_DATA([filter.awk],[
/^X-IMAPbase/ { next }
/^-rw-r--r--/ { print $1, $2, $3, $6; next }
{ print }
])
mhn -show 2 | awk -f filter.awk
],
[0],
[Date: Mon, 29 Nov 2010 14:04:19 +0200
......@@ -348,8 +353,8 @@ X-Envelope-Sender: gray@example.net
part 1 text/plain 15
Initial text.
-rw-r--r-- gray/staff 1418 2010-11-29 13:58 Father_William
-rw-r--r-- gray/staff 937 2010-11-29 13:58 Jabberwocky
-rw-r--r-- gray/staff 1418 Father_William
-rw-r--r-- gray/staff 937 Jabberwocky
])
# FIXME: What about exit code?
......@@ -379,7 +384,12 @@ MH_CHECK([mhn-show- variable (with subtype)],
[mhn15 mhn-show-with-subtype],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mime,[Mail/inbox])
echo "mhn-show-application/x-tar: %ltar tvf '%F'" >> $MH
mhn -show 1 | sed '/^X-IMAPbase/d;s/ *$//'
AT_DATA([filter.awk],[
/^X-IMAPbase/ { next }
/^-rw-r--r--/ { print $1, $2, $3, $6; next }
{ sub(/ *$/,""); print }
])
mhn -show 1 | awk -f filter.awk
],
[0],
[Date: Mon, 29 Nov 2010 14:00:03 +0200
......@@ -395,15 +405,20 @@ part 1 text/plain 15
Initial text.
part 2 application/x-tar 13835
-rw-r--r-- gray/staff 1418 2010-11-29 13:58 Father_William
-rw-r--r-- gray/staff 937 2010-11-29 13:58 Jabberwocky
-rw-r--r-- gray/staff 1418 Father_William
-rw-r--r-- gray/staff 937 Jabberwocky
])
MH_CHECK([mhn-show- variable (without subtype)],
[mhn16 mhn-show-without-subtype],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mime,[Mail/inbox])
echo "mhn-show-application: %ltar tvf '%F'" >> $MH
mhn -show 1 | sed '/^X-IMAPbase/d;s/ *$//'
AT_DATA([filter.awk],[
/^X-IMAPbase/ { next }
/^-rw-r--r--/ { print $1, $2, $3, $6; next }
{ sub(/ *$/,""); print }
])
mhn -show 1 | awk -f filter.awk
],
[0],
[Date: Mon, 29 Nov 2010 14:00:03 +0200
......@@ -419,8 +434,8 @@ part 1 text/plain 15
Initial text.
part 2 application/x-tar 13835
-rw-r--r-- gray/staff 1418 2010-11-29 13:58 Father_William
-rw-r--r-- gray/staff 937 2010-11-29 13:58 Jabberwocky
-rw-r--r-- gray/staff 1418 Father_William
-rw-r--r-- gray/staff 937 Jabberwocky
])
dnl -------------------------------------------------------------------
......
......@@ -27,6 +27,7 @@ mhparam -all | tr '\t' ' ' | sed 's/^Path:.*/Path: Mail/;s/^mhetcdir:.*/mhetcdir
[0],
[Path: Mail
mhetcdir: dir
moreproc: /bin/cat
Sequence-Negation: not
Draft-Folder: Mail/drafts
Aliasfile: .mh_aliases
......
......@@ -21,7 +21,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: inbox' > Mail/context
rmf +teaparty || exit $?
find Mail -type d
find Mail -type d | sort
],
[0],
[Mail
......@@ -33,7 +33,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail])
echo 'Current-Folder: teaparty' > Mail/context
rmf || exit $?
find Mail -type d
find Mail -type d | sort
],
[0],
[[[+inbox now current]]
......
......@@ -66,7 +66,7 @@ export MTA_APPEND
send ./input.1 ./input.2 || exit $?
sed 's/: Date: .*/: Date: now/' $MTA_DIAG
find . -name ',input.[[12]]'
find . -name ',input.[[12]]' | sort
],
[0],
[ENVELOPE FROM: mhtester@example.net
......
......@@ -24,6 +24,7 @@ export MH
cat > $MH <<EOT
Path: $curdir/Mail
mhetcdir: $abs_top_srcdir/mh/etc
moreproc: /bin/cat
EOT
MTSTAILOR=$curdir/mtstailor
export MTSTAILOR
......
......@@ -180,13 +180,12 @@ com_connect (int argc, char **argv)
{
if (strcmp (argv[i], "-tls") == 0)
{
if (WITH_TLS)
#ifdef WITH_TLS
tls = 1;
else
{
mu_error ("TLS not supported");
return 0;
}
#else
mu_error ("TLS not supported");
return 0;
#endif
}
else
break;
......