Re: writing Maildir subscriptions file outside of dovecot

2021-10-07 Thread David Mandelberg

Op 07-10-2021 om 02:33 schreef Aki Tuomi:



On 06/10/2021 22:52 David Mandelberg  wrote:

  
Hi,


Is it safe to write to the Maildir subscriptions file directly?

I'm trying to figure out a way to make sure the subscriptions match the
actual folders exactly. I know how to subscribe to existing mailboxes
with `doveadm mailbox list` and `doveadm mailbox subscribe`, but the
latter seems to only accept mailboxes on the command line, and any local
user can see the command line of any other user's commands. Also, that
doesn't handle unsubscribing from non-existent mailboxes. I think
unsubscribing from any mailboxes listed in `doveadm mailbox list -s` but
not in `doveadm mailbox list` would work, but it has the same issue of
mailboxes on the command line.

It looks like I could do what I want with something like this command,
but I'm not sure if it's safe to write directly to the subscriptions file:

{ echo INBOX; ls -1A | grep '^\.' | cut -c 2-; } > subscriptions

(I was also thinking about using `doveadm mailbox list` to write the
subscriptions file directly, but it looks like they use different
separators and encodings.)



You could also use the doveadm HTTP API to handle subscription changes? It 
should be safe to modify that file though, especially if the user is not logged 
in.


That API looks easy to use, thanks for the pointer! Though I'd rather 
not add credentials for it, and I don't see an easy way to make HTTP 
requests over a unix socket in Python. Oh well.


I also realized that if/when I set up dsync replication, writing 
directly to a file could get complicated. Maybe I'll just make a cron 
job to compare `doveadm mailbox list` and `doveadm mailbox list -s`, and 
send an email if there's any difference.


Re: writing Maildir subscriptions file outside of dovecot

2021-10-07 Thread Aki Tuomi


> On 06/10/2021 22:52 David Mandelberg  wrote:
> 
>  
> Hi,
> 
> Is it safe to write to the Maildir subscriptions file directly?
> 
> I'm trying to figure out a way to make sure the subscriptions match the 
> actual folders exactly. I know how to subscribe to existing mailboxes 
> with `doveadm mailbox list` and `doveadm mailbox subscribe`, but the 
> latter seems to only accept mailboxes on the command line, and any local 
> user can see the command line of any other user's commands. Also, that 
> doesn't handle unsubscribing from non-existent mailboxes. I think 
> unsubscribing from any mailboxes listed in `doveadm mailbox list -s` but 
> not in `doveadm mailbox list` would work, but it has the same issue of 
> mailboxes on the command line.
> 
> It looks like I could do what I want with something like this command, 
> but I'm not sure if it's safe to write directly to the subscriptions file:
> 
> { echo INBOX; ls -1A | grep '^\.' | cut -c 2-; } > subscriptions
> 
> (I was also thinking about using `doveadm mailbox list` to write the 
> subscriptions file directly, but it looks like they use different 
> separators and encodings.)


You could also use the doveadm HTTP API to handle subscription changes? It 
should be safe to modify that file though, especially if the user is not logged 
in.

Aki


writing Maildir subscriptions file outside of dovecot

2021-10-06 Thread David Mandelberg

Hi,

Is it safe to write to the Maildir subscriptions file directly?

I'm trying to figure out a way to make sure the subscriptions match the 
actual folders exactly. I know how to subscribe to existing mailboxes 
with `doveadm mailbox list` and `doveadm mailbox subscribe`, but the 
latter seems to only accept mailboxes on the command line, and any local 
user can see the command line of any other user's commands. Also, that 
doesn't handle unsubscribing from non-existent mailboxes. I think 
unsubscribing from any mailboxes listed in `doveadm mailbox list -s` but 
not in `doveadm mailbox list` would work, but it has the same issue of 
mailboxes on the command line.


It looks like I could do what I want with something like this command, 
but I'm not sure if it's safe to write directly to the subscriptions file:


{ echo INBOX; ls -1A | grep '^\.' | cut -c 2-; } > subscriptions

(I was also thinking about using `doveadm mailbox list` to write the 
subscriptions file directly, but it looks like they use different 
separators and encodings.)