I'm using the postlogin service, following the examples in the wiki. But I can't find any documentation on the behavior (what's allowed/not allowed) of the script-login binary. So, some questions: Question 1: The examples show the following at the end of the post-login.sh script: exec "$@" My understanding is that this would exec each of the command line arguments to the post-login.sh script. But, there are no arguments sent to the post-login.sh script in the examples. So what is this line supposed to do? Question 2: One of the examples shows exporting some environmental variables, followed by the above exec line: export MAIL=maildir:/tmp/test export USERDB_KEYS="$USERDB_KEYS mail" exec "$@" Now, I'm really confused. Can someone explain step-by-step why this does anything at all? Question 3: I'd like to be able to pass some information to the post-login.sh script, such as the service (%s), as a positional parameter. For example: executable = script-login /path/post-login.sh %Ls Or even more explicitly: executable = script-login /path/post-login.sh imap But it appears that the script-login binary is expecting only script names to be passed to it so that it can handle more than one script. Is there a way to pass arguments to the different scripts? Thanks, Michael
No response seen yet. Trying again. Surely someone knows how the postlogin scripts work and can answer these questions easily... Anyone? Thanks, Michael -----Original Message----- From: dovecot [mailto:dovecot-bounces at dovecot.org] On Behalf Of Michael Fox Sent: Sunday, December 11, 2016 8:48 AM To: Dovecot Mailing List <dovecot at dovecot.org> Subject: postlogin script I'm using the postlogin service, following the examples in the wiki. But I can't find any documentation on the behavior (what's allowed/not allowed) of the script-login binary. So, some questions: Question 1: The examples show the following at the end of the post-login.sh script: exec "$@" My understanding is that this would exec each of the command line arguments to the post-login.sh script. But, there are no arguments sent to the post-login.sh script in the examples. So what is this line supposed to do? Question 2: One of the examples shows exporting some environmental variables, followed by the above exec line: export MAIL=maildir:/tmp/test export USERDB_KEYS="$USERDB_KEYS mail" exec "$@" Now, I'm really confused. Can someone explain step-by-step why this does anything at all? Question 3: I'd like to be able to pass some information to the post-login.sh script, such as the service (%s), as a positional parameter. For example: executable = script-login /path/post-login.sh %Ls Or even more explicitly: executable = script-login /path/post-login.sh imap But it appears that the script-login binary is expecting only script names to be passed to it so that it can handle more than one script. Is there a way to pass arguments to the different scripts? Thanks, Michael
On 14.12.2016 05:58, Michael Fox wrote:> No response seen yet. Trying again. > > Surely someone knows how the postlogin scripts work and can answer these > questions easily... Anyone? > > Thanks, > Michael > > > -----Original Message----- > From: dovecot [mailto:dovecot-bounces at dovecot.org] On Behalf Of Michael Fox > Sent: Sunday, December 11, 2016 8:48 AM > To: Dovecot Mailing List <dovecot at dovecot.org> > Subject: postlogin script > > I'm using the postlogin service, following the examples in the wiki. But I > can't find any documentation on the behavior (what's allowed/not allowed) of > the script-login binary. So, some questions: > > > > Question 1: > > The examples show the following at the end of the post-login.sh script: > exec "$@" > > My understanding is that this would exec each of the command line arguments > to the post-login.sh script. But, there are no arguments sent to the > post-login.sh script in the examples. So what is this line supposed to do? > > > > Question 2: > > One of the examples shows exporting some environmental variables, followed > by the above exec line: > > export MAIL=maildir:/tmp/test > > export USERDB_KEYS="$USERDB_KEYS mail" > > exec "$@" > > Now, I'm really confused. Can someone explain step-by-step why this does > anything at all? > > > > Question 3: > > I'd like to be able to pass some information to the post-login.sh script, > such as the service (%s), as a positional parameter. > > For example: executable = script-login /path/post-login.sh %Ls > > Or even more explicitly: executable = script-login /path/post-login.sh imap > > But it appears that the script-login binary is expecting only script names > to be passed to it so that it can handle more than one script. Is there a > way to pass arguments to the different scripts? > > > > Thanks, > > Michael > > > > > > > > > >Hi! You need to use executable = script-login -- /path/post-login.sh -a -r -g -s note the double-dash. it tells getopt to stop processing arguments. Aki
On 15.12.2016 05:54, Michael Fox wrote:>> Hi! >> >> You need to use executable = script-login -- /path/post-login.sh -a -r -g > -s >> note the double-dash. it tells getopt to stop processing arguments. >> >> Aki > Thanks Aki. So that let's me call a single script with arguments. Great. > What if there is more than one script? I'm unable to guess what the > complete syntax would be for calling more than one script, some of which may > have their own arguments.Please keep responses in the list. Maybe you could, I don't know, call multiple scripts in your script?> Also, can you help with my other two questions (below): > >> Question 1: >> >> The examples show the following at the end of the post-login.sh script: >> exec "$@" >> >> My understanding is that this would exec each of the command line arguments >> to the post-login.sh script. But, there are no arguments sent to the >> post-login.sh script in the examples. So what is this line supposed to do?It will execute something dovecot wants in order to import the env variables set in your question 2.>> >> >> Question 2: >> >> One of the examples shows exporting some environmental variables, followed >> by the above exec line: >> >> export MAIL=maildir:/tmp/test >> >> export USERDB_KEYS="$USERDB_KEYS mail" >> >> exec "$@" >> >> Now, I'm really confused. Can someone explain step-by-step why this does >> anything at all? > MichaelAki
Also, if you look at the examples at http://wiki.dovecot.org/PostLoginScripting you can see how it's used and how to call multiple scripts as well. Aki On 15.12.2016 08:49, Aki Tuomi wrote:> > On 15.12.2016 05:54, Michael Fox wrote: >>> Hi! >>> >>> You need to use executable = script-login -- /path/post-login.sh -a -r -g >> -s >>> note the double-dash. it tells getopt to stop processing arguments. >>> >>> Aki >> Thanks Aki. So that let's me call a single script with arguments. Great. >> What if there is more than one script? I'm unable to guess what the >> complete syntax would be for calling more than one script, some of which may >> have their own arguments. > Please keep responses in the list. Maybe you could, I don't know, call > multiple scripts in your script? > >> Also, can you help with my other two questions (below): >> >>> Question 1: >>> >>> The examples show the following at the end of the post-login.sh script: >>> exec "$@" >>> >>> My understanding is that this would exec each of the command line arguments >>> to the post-login.sh script. But, there are no arguments sent to the >>> post-login.sh script in the examples. So what is this line supposed to do? > It will execute something dovecot wants in order to import the env > variables set in your question 2. > >>> >>> Question 2: >>> >>> One of the examples shows exporting some environmental variables, followed >>> by the above exec line: >>> >>> export MAIL=maildir:/tmp/test >>> >>> export USERDB_KEYS="$USERDB_KEYS mail" >>> >>> exec "$@" >>> >>> Now, I'm really confused. Can someone explain step-by-step why this does >>> anything at all? >> Michael > Aki