[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-mailutils] sieve MDA
From: |
Sergey Poznyakoff |
Subject: |
Re: [bug-mailutils] sieve MDA |
Date: |
Tue, 20 Jun 2006 19:43:31 +0300 |
Dimitrios Apostolou <address@hidden> wrote:
> Thanks, that helps, though it is not exactly what I need. I really need to
> feed it a single mail from stdin.
In other words, you want to use it with `mda' keyword. OK, then please
try the enclosed (untested) patch. Sample usage:
mda mail.local --sieve /path/to/script
Regards,
Sergey
Index: mail.local/main.c
===================================================================
RCS file: /cvsroot/mailutils/mailutils/mail.local/main.c,v
retrieving revision 1.59
diff -p -u -r1.59 main.c
--- mail.local/main.c 15 Nov 2005 20:01:37 -0000 1.59
+++ mail.local/main.c 20 Jun 2006 16:32:55 -0000
@@ -24,7 +24,7 @@ int ex_quota_tempfail; /* Return tem
exceeded. If this variable is not set, mail.local
will return "service unavailable" */
int exit_code = EX_OK; /* Exit code to be used */
-uid_t uid; /* Current user name */
+uid_t uid; /* Current user id */
char *quotadbname = NULL; /* Name of mailbox quota database */
char *quota_query = NULL; /* SQL query to retrieve mailbox quota */
@@ -335,9 +335,15 @@ main (int argc, char *argv[])
mu_sieve_argp_init ();
/* Parse command line */
mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, NULL);
+
+ uid = getuid ();
+
+ if (uid == 0)
+ {
+ openlog ("mail.local", LOG_PID, log_facility);
+ mu_error_set_print (mu_syslog_error_printer);
+ }
- openlog ("mail.local", LOG_PID, log_facility);
- mu_error_set_print (mu_syslog_error_printer);
if (debug_flags)
{
int rc;
@@ -361,12 +367,31 @@ main (int argc, char *argv[])
}
}
- uid = getuid ();
-
argc -= arg_index;
argv += arg_index;
- if (!argc)
+ if (uid)
+ {
+ if (argc)
+ {
+ mu_error (_("Excess arguments in user mode"));
+ return EX_USAGE;
+ }
+ else
+ {
+ static char *s_argv[2];
+ struct mu_auth_data *auth = mu_get_auth_by_uid (uid);
+ if (!uid)
+ {
+ mu_error (_("Cannot get username"));
+ return EX_UNAVAILABLE;
+ }
+ s_argv[0] = auth->name;
+ argv = s_argv;
+ argc = 1;
+ }
+ }
+ else if (!argc)
{
mu_error (_("Missing arguments. Try --help for more info."));
return EX_USAGE;
@@ -665,7 +690,9 @@ deliver (mu_mailbox_t imbx, char *name)
exit_code = EX_UNAVAILABLE;
return;
}
-
+ if (uid)
+ auth->change_uid = 0;
+
if (!sieve_test (auth, imbx))
{
exit_code = EX_OK;
- Re: [bug-mailutils] sieve MDA, (continued)
- Re: [bug-mailutils] sieve MDA, Sergey Poznyakoff, 2006/06/20
- Re: [bug-mailutils] sieve MDA, Dimitrios Apostolou, 2006/06/20
- Re: [bug-mailutils] sieve MDA, Kostas Zorbadelos, 2006/06/20
- Re: [bug-mailutils] sieve MDA, Sergey Poznyakoff, 2006/06/20
- Re: Re: [bug-mailutils] sieve MDA, Dimitris Apostolou, 2006/06/20
- Re: Re: [bug-mailutils] sieve MDA, Sergey Poznyakoff, 2006/06/20
- Re: [bug-mailutils] sieve MDA, Dimitrios Apostolou, 2006/06/20
- Re: [bug-mailutils] sieve MDA,
Sergey Poznyakoff <=
- Re: [bug-mailutils] sieve MDA, Dimitrios Apostolou, 2006/06/22
- Re: [bug-mailutils] sieve MDA, Sergey Poznyakoff, 2006/06/24