Creating/Learning about services

Aki Tuomi aki.tuomi at open-xchange.com
Wed Aug 25 20:44:08 EEST 2021


> On 25/08/2021 20:41 Aki Tuomi <aki.tuomi at open-xchange.com> wrote:
> 
>  
> > On 25/08/2021 20:22 Dan Conway <darkc0de at archnix6.net> wrote:
> > 
> >  
> > Hello,
> > 
> > I'm currently researching how services work within Dovecot and what 
> > scope these services are capable of. For example, I created a service as 
> > such:
> > 
> > service myservice {
> >    executable = /home/me/executable
> >    type          = worker
> >    unix_listener myservice {
> >      mode = 0666
> >    }
> > }
> > 
> > 
> > When data is provided to the myservice unix socket, Dovecot appears to 
> > create a new process by executing "/home/me/executable". I found out 
> > about "status updates" through examining the logs. At first I received this:
> > 
> > master: Error: service(myservice): Initial status notification not 
> > received in 30 seconds, killing the process
> > 
> > What is this status notification?
> > 
> > I found out that writing to file descriptor 5 from the executable does 
> > seem to be valid. When I write out 12 bytes I don't get an error, but 
> > when I write out 13 bytes I get the following:
> > 
> > master: Error: service(dmon): service sent partial status update (13 bytes)
> > 
> > What I've also noticed is that exiting 0 will cause Dovecot to spawn the 
> > process again, in what appears to be infinitely.
> > 
> > Are there any resources/documentation that I could reference to learn 
> > more about how services work on a lower level besides just looking at 
> > the source code?
> > 
> > Thanks.
> 
> Making native services requires practically C program using lib-master. We provide a simple helpers called `script` and `login-script` which wrap your program as a Dovecot service and provide you parameters from stdin and, when possible, lets you write into stdout your reply.
> 
> See https://github.com/dovecot/core/blob/master/src/util/script.c#L83 for provided input.
> 
> You can use it like
> 
> service foobar {
>   executable = script /path/to/your/stuff
>   unix_listener myservice {
>     mode = 0666
>   }
> }
> 
> btw, there is no `type = worker` setting, see
> https://doc.dovecot.org/configuration_manual/service_configuration/
> 
> Aki

I mean `script-login` of course. These are both bit underdocumented currently. The script-login is used to execute post-login scripts.

Aki


More information about the dovecot mailing list