Q:

Calling Bash script from Sieve script

I'm not sure if something similar has already been asked.
I'm currently trying to push emails to our spam filter when they are moved to or out of the Junk folder so it can learn them as spam/ham. To do that I followed this guide: https://workaround.org/ispmail/stretch/filtering-out-spam-with-rspamd in the section "Learning from user actions".
The sieve scripts are created following the instructions, they have been processed by sievec and permissions have been granted following the guide. The two shell scripts have also been created accordingly. The only real difference is that we don't have the user or group "vmail". I set it to dovecot:root which should be the counterpart of our system. So the folder looks like this:
drwxr-xr-x 2 dovecot root 4,0K Mai  7 10:52 .
drwxr-xr-x 3 root    root 4,0K Jul 29  2019 ..
-rw-r--r-- 1 dovecot root   85 Mai  7 10:47 learn-ham.sieve
-rw-r--r-- 1 root    root  246 Mai  7 10:47 learn-ham.svbin
-rw-r--r-- 1 dovecot root   86 Mai  7 10:47 learn-spam.sieve
-rw-r--r-- 1 root    root  250 Mai  7 10:47 learn-spam.svbin
-rw-r--r-- 1 dovecot root  509 Mär 16 13:57 mailfilter.sieve
-rw-r--r-- 1 root    root  398 Mai  6 18:02 mailfilter.svbin
-rwx------ 1 dovecot root   41 Mai  7 10:52 rspamd-learn-ham.sh
-rwx------ 1 dovecot root   42 Dez 14 10:42 rspamd-learn-spam.sh

When the sieve script executes and is supposed to call the shell scripts, I get the following errors:
Mai 12 17:16:28 mail dovecot[4119]: imap(user)<8778><xIGQ8nSlFMZ/AAAB>: Fatal: execvp(/etc/dovecot/sieve/global/rspamd-learn-spam.sh) failed: Permission denied
Mai 12 17:16:28 mail dovecot[4119]: imap(user)<8778><xIGQ8nSlFMZ/AAAB>: Error: write(program stdin) failed: Broken pipe
Mai 12 17:16:28 mail dovecot[4119]: imap(user)<8778><xIGQ8nSlFMZ/AAAB>: program `/etc/dovecot/sieve/global/rspamd-learn-spam.sh' terminated with non-zero exit code 84
Mai 12 17:16:28 mail dovecot[4119]: imap(user)<8778><xIGQ8nSlFMZ/AAAB>: Error: sieve: pipe action: failed to pipe message to program `rspamd-learn-spam.sh': refer to server log for more information. [2020-05-12 17:16:28]
Mai 12 17:16:28 mail dovecot[4119]: imap(user)<8778><xIGQ8nSlFMZ/AAAB>: sieve: left message in mailbox 'Junk'
Mai 12 17:16:28 mail dovecot[4119]: imap(user)<8778><xIGQ8nSlFMZ/AAAB>: Error: sieve: Execution of script /etc/dovecot/sieve/global/learn-spam.sieve failed

Besides the fact that I have no clue what the "server log" refers to, I just can't figure out what exactly the problem is. Sure it seems like a permission error, but how could it be fixed?
About our system: Debian 10.4 with dovecot 2.3.4.1 and pigeonhole 0.5.4
EDIT:
I found one mistake: I had set the sieve_pipe_bin_dir to the wrong folder. It now points to the folder containing the two .sh files, but still I get those errors:
Mai 22 15:40:06 mail dovecot[18547]: imap(user)<18686><57dcxDymXJ5/AAAB>: Fatal: execvp(/etc/dovecot/sieve/global/rspamd-learn-spam.sh) failed: Permission denied
Mai 22 15:40:06 mail dovecot[18547]: imap(user)<18686><57dcxDymXJ5/AAAB>: Error: write(program stdin) failed: Broken pipe
Mai 22 15:40:06 mail dovecot[18547]: imap(user)<18686><57dcxDymXJ5/AAAB>: program `/etc/dovecot/sieve/global/rspamd-learn-spam.sh' terminated with non-zero exit code 84
Mai 22 15:40:06 mail dovecot[18547]: imap(user)<18686><57dcxDymXJ5/AAAB>: Error: sieve: pipe action: failed to pipe message to program `rspamd-learn-spam.sh': refer to server log for more information. [2020-05-22 15:40:06]
Mai 22 15:40:06 mail dovecot[18547]: imap(user)<18686><57dcxDymXJ5/AAAB>: sieve: left message in mailbox 'Junk'
Mai 22 15:40:06 mail dovecot[18547]: imap(user)<18686><57dcxDymXJ5/AAAB>: Error: sieve: Execution of script /etc/dovecot/sieve/global/learn-spam.sieve failed

No matter which owner I set (root:root or dovecot:root, the only other users that are not "human-users" would be something like _apt, bin, nslcd, daemon, dovenull or www-data) Any idea what could cause that?  
EDIT2:
I now changed my approach by trying to pipe directly to rspamc. Here my learn-spam.sieve script:
require ["vnd.dovecot.pipe", "copy", "imapsieve"];
pipe :copy "rspamc" ["learn_spam"];

Accordingly I changed the 90-plugin.conf to contain
sieve_pipe_bin_dir = /usr/bin/rspamc

where rspamc resides. Now I'm getting the error
Jun 03 09:48:34 mail dovecot[1536]: imap(user)<10486><xVI6QSmnpLN/AAAB>: Error: sieve: pipe action: failed to pipe message to program: program `rspamc' not found
Jun 03 09:48:34 mail dovecot[1536]: imap(user)<10486><xVI6QSmnpLN/AAAB>: sieve: left message in mailbox 'Junk'
Jun 03 09:48:34 mail dovecot[1536]: imap(user)<10486><xVI6QSmnpLN/AAAB>: Error: sieve: Execution of script /etc/dovecot/sieve/global/learn-spam.sieve failed

What went wrong? Or is the pidgeonhole pipe command only able to call shell scripts?

A:

it seems I've found what was not working: for some reason dovecot didn't seem to have execute permission on the shell scripts. So the solution was actually sudo -u dovecot chmod +x *.sh
So correct file permissions in my case look like that:
/etc/dovecot/sieve/global # ls -la
insgesamt 44K
drwxr-xr-x 2 dovecot root 4,0K Jul  8 07:33 .
drwxr-xr-x 3 root    root 4,0K Jul 29  2019 ..
-rw-r--r-- 1 dovecot root  144 Jun  5 10:06 learn-ham.sieve
-rw-r--r-- 1 root    root  306 Jun  5 10:07 learn-ham.svbin
-rw-r--r-- 1 dovecot root   86 Jun 17 15:45 learn-spam.sieve
-rw-r--r-- 1 root    root  250 Jun 17 15:45 learn-spam.svbin
-rw-r--r-- 1 dovecot root  509 Mär 16 13:57 mailfilter.sieve
-rw-r--r-- 1 dovecot root  462 Jul 29  2019 mailfilter.sieve~
-rw-r--r-- 1 root    root  398 Mai  6 18:02 mailfilter.svbin
-rwxrwxr-x 1 dovecot root   41 Jun  5 10:25 rspamd-learn-ham.sh
-rwxrwxr-x 1 dovecot root   42 Jul  8 07:33 rspamd-learn-spam.sh

