summaryrefslogtreecommitdiff
path: root/comsat
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-12-07 17:58:15 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-12-07 18:14:03 +0200
commit04c2931bb963fefd4654ef2de2cf0667cf8a333d (patch)
tree6590f36036e32f9aaf84e4eb9355cf810fbfd5e5 /comsat
parentac08a8575ae8ea3b85180bd05464a48768f398ee (diff)
downloadmailutils-04c2931bb963fefd4654ef2de2cf0667cf8a333d.tar.gz
mailutils-04c2931bb963fefd4654ef2de2cf0667cf8a333d.tar.bz2
Rewrite prog stream support.
Two interfaces are provided: mu_prog_stream_create offers full control over the program execution environment (i.e. running privileges, cwd, resource limits) via a set of hints. A simpler interface, mu_command_stream_create, runs the command in the current environment. mu_filter_prog_stream_create is removed, because its functionality can be achieved by a correspondingly crafted set of hints to mu_prog_stream_create. * include/mailutils/prog.h: New file. * include/mailutils/mailutils.h: Include mailutils/prog.h * include/mailutils/Makefile.am (pkginclude_HEADERS): Add prog.h * include/mailutils/stream.h (mu_prog_stream_create) (mu_filter_prog_stream_create): Remove prototypes. * include/mailutils/sys/prog_stream.h (_mu_prog_stream): Change structure. (_mu_prog_limit_codes, _mu_prog_limit_flags): New externs. * include/mailutils/util.h (mu_set_user_privileges) (mu_switch_to_privs): New prototypes. * lib/userprivs.c: Move to libmailutils/base. * lib/Makefile.am (libmuaux_a_SOURCES): Remove userprivs.c * libmailutils/base/Makefile.am (libbase_la_SOURCES): Add userprivs.c * libmailutils/base/userprivs.c (mu_set_user_privileges): New function. (mu_switch_to_privs): Rewrite as another entry point to mu_set_user_privileges. * libmailutils/stream/prog_stream.c (_mu_prog_limit_flags) (_mu_prog_limit_codes): New global variables. (start_program_filter): Use hints to control execution environment. (_prog_stream_create): Save hints. (mu_prog_stream_create): Change signature. (mu_command_stream_create): New function (corresponds to the prior mu_prog_stream_create). (mu_filter_prog_stream_create): Remove function. * comsat/action.c (action_exec): Use new mu_prog_stream_create calling convention. * examples/murun.c: Rewrite. * mh/mhn.c (show_internal): Use new mu_prog_stream_create calling convention. * mh/tests/mhn.at: Reflect changes to mhn. * imap4d/preauth.c: Use mu_command_stream_create. * libmu_sieve/extensions/pipe.c * mail/decode.c * mail/pipe.c * mail/send.c * mh/mhl.c * mu/shell.c * mail/mail.h: Include mailutils/prog.h * mh/mh.h * po/POTFILES.in: Add libmailutils/base/userprivs.c.
Diffstat (limited to 'comsat')
-rw-r--r--comsat/action.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/comsat/action.c b/comsat/action.c
index 97f961c7f..dcb256304 100644
--- a/comsat/action.c
+++ b/comsat/action.c
@@ -18,6 +18,7 @@
#include "comsat.h"
#include <mailutils/io.h>
#include <mailutils/argcv.h>
+#include <mailutils/prog.h>
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
#include <obstack.h>
@@ -225,7 +226,6 @@ action_exec (mu_stream_t tty, int argc, char **argv)
{
mu_stream_t pstream;
struct stat stb;
- char *command;
int status;
if (argc == 0)
@@ -249,25 +249,19 @@ action_exec (mu_stream_t tty, int argc, char **argv)
if (stb.st_mode & (S_ISUID|S_ISGID))
{
- mu_diag_output (MU_DIAG_ERROR, _("will not execute set[ug]id programs"));
+ mu_diag_output (MU_DIAG_ERROR,
+ _("will not execute set[ug]id programs"));
return;
}
- /* FIXME: Redirect stderr to out */
- /* FIXME: need this:
- status = mu_prog_stream_create_argv (&pstream, argv[0], argv,
- MU_STREAM_READ);
- */
- status = mu_argcv_join (argc, argv, " ", mu_argcv_escape_no, &command);
+ status = mu_prog_stream_create (&pstream,
+ argv[0], argc, argv,
+ MU_PROG_HINT_ERRTOOUT,
+ NULL,
+ MU_STREAM_READ);
if (status)
{
- mu_diag_funcall (MU_DIAG_ERROR, "mu_argcv_join", NULL, status);
- return;
- }
- status = mu_prog_stream_create (&pstream, command, MU_STREAM_READ);
- if (status)
- {
- mu_diag_funcall (MU_DIAG_ERROR, "mu_prog_stream_create_argv", argv[0],
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_prog_stream_create", argv[0],
status);
return;
}

Return to:

Send suggestions and report system problems to the System administrator.