On 01/03/2023 20:39 EET Dan Conway <darkc0de@archnix6.net> wrote:
Hello, I'm having trouble understanding how to execute separate scripts with postlogin. According to the documentation, it should be as simple as:
You can run multiple post-login scripts by just giving multiple scripts as parameters to script-login, for example: executable = script-login rawlog /usr/local/bin/postlogin.sh /usr/local/bin/postlogin2.sh
Given this information, I supplied two scripts to service imap-postlogin below: service imap { executable = imap imap-postlogin }
service imap-postlogin { executable = script-login -d rawlog /usr/local/bin/postlogin.pl /usr/local/bin/postlogin2.pl user = $default_internal_user unix_listener imap-postlogin { } }
Both scripts simply print "Script 1" and "Script 2" to STDERR. Here is what they look like: #!/usr/bin/perl
use strict; use warnings;
print STDERR "Script 1\n"; system("/usr/lib/dovecot/script-login");
After logging in, only the first script is executed. The second one is ignored. I tried not executing "/usr/lib/dovecot/script-login" in the first script, in hopes that it would execute the second script, but it only denies the connection after printing "Script 1"
imap-postlogin: Error: Script 1 imap(<user>): Error: Post-login script denied access to user <user> Am I missing something? Thanks.
You need to use exec, not system. system executes it as child process, and then returns to your current script, exec replaces your execution with script-login.
Aki