Bugfixes
* maidag/deliver.c: Run filter scripts with user privileges. * maidag/script.c (apply_script): Use stat, not access, to check for the existence of the script file. Access takes into account accessibility of intermediate directories, which is irrelevant in this case. * mailbox/mutil.c (mu_expand_path_pattern): Bugfix. Remove the % format specifiers after expanding them.
Showing
3 changed files
with
35 additions
and
21 deletions
... | @@ -307,7 +307,12 @@ deliver_url (mu_url_t url, mu_message_t msg, const char *name, char **errp) | ... | @@ -307,7 +307,12 @@ deliver_url (mu_url_t url, mu_message_t msg, const char *name, char **errp) |
307 | if (current_uid) | 307 | if (current_uid) |
308 | auth->change_uid = 0; | 308 | auth->change_uid = 0; |
309 | 309 | ||
310 | if (script_apply (msg, auth)) | 310 | if (switch_user_id (auth, 1)) |
311 | return EX_TEMPFAIL; | ||
312 | status = script_apply (msg, auth); | ||
313 | if (switch_user_id (auth, 0)) | ||
314 | return EX_TEMPFAIL; | ||
315 | if (status) | ||
311 | { | 316 | { |
312 | exit_code = EX_OK; | 317 | exit_code = EX_OK; |
313 | mu_auth_data_free (auth); | 318 | mu_auth_data_free (auth); | ... | ... |
... | @@ -120,12 +120,18 @@ apply_script (void *item, void *data) | ... | @@ -120,12 +120,18 @@ apply_script (void *item, void *data) |
120 | struct apply_script_closure *clos = data; | 120 | struct apply_script_closure *clos = data; |
121 | char *progfile; | 121 | char *progfile; |
122 | int rc; | 122 | int rc; |
123 | struct stat st; | ||
123 | 124 | ||
124 | progfile = mu_expand_path_pattern (scr->pat, clos->auth->name); | 125 | progfile = mu_expand_path_pattern (scr->pat, clos->auth->name); |
125 | if (access (progfile, R_OK)) | 126 | if (stat (progfile, &st)) |
126 | { | 127 | { |
127 | if (debug_level > 2) | 128 | if (debug_level > 2) |
128 | mu_diag_output (MU_DIAG_DEBUG, _("Access to %s failed: %m"), progfile); | 129 | mu_diag_output (MU_DIAG_DEBUG, _("cannot stat %s: %s"), |
130 | progfile, mu_strerror (errno)); | ||
131 | else if (errno != ENOENT) | ||
132 | mu_diag_output (MU_DIAG_NOTICE, _("cannot stat %s: %s"), | ||
133 | progfile, mu_strerror (errno)); | ||
134 | |||
129 | free (progfile); | 135 | free (progfile); |
130 | return 0; | 136 | return 0; |
131 | } | 137 | } | ... | ... |
... | @@ -883,27 +883,30 @@ mu_expand_path_pattern (const char *pattern, const char *username) | ... | @@ -883,27 +883,30 @@ mu_expand_path_pattern (const char *pattern, const char *username) |
883 | q += strlen (auth->dir); | 883 | q += strlen (auth->dir); |
884 | p++; | 884 | p++; |
885 | } | 885 | } |
886 | else if (*p) | 886 | else if (*p == '%') |
887 | switch (*++p) | 887 | { |
888 | { | 888 | switch (*++p) |
889 | case 'u': | 889 | { |
890 | strcpy (q, username); | 890 | case 'u': |
891 | q += strlen (username); | 891 | strcpy (q, username); |
892 | break; | 892 | q += strlen (username); |
893 | break; | ||
893 | 894 | ||
894 | case 'h': | 895 | case 'h': |
895 | strcpy (q, auth->dir); | 896 | strcpy (q, auth->dir); |
896 | q += strlen (auth->dir); | 897 | q += strlen (auth->dir); |
897 | break; | 898 | break; |
898 | 899 | ||
899 | case '%': | 900 | case '%': |
900 | *q++ = '%'; | 901 | *q++ = '%'; |
901 | break; | 902 | break; |
902 | 903 | ||
903 | default: | 904 | default: |
904 | *q++ = '%'; | 905 | *q++ = '%'; |
905 | *q++ = *p; | 906 | *q++ = *p; |
906 | } | 907 | } |
908 | p++; | ||
909 | } | ||
907 | } | 910 | } |
908 | 911 | ||
909 | *q = 0; | 912 | *q = 0; | ... | ... |
-
Please register or sign in to post a comment