On Thu, May 11, 2017 at 09:01:08PM -0500, Edgar Pettijohn wrote:
> 
> 
> On 05/11/17 10:04, Philippe Meunier wrote:
> > Hello,
> > 
> > I'm running a default OpenSMTPD on OpenBSD 6.1 (and several previous
> > versions of it before).  I've noticed that OpenSMTPD creates two
> > directories in /var/spool/smtpd/purge every time it is started but never
> > deletes these directories when shutting down.  This might be fine on an
> > email server that's always up and running but this is on a laptop computer
> > that's turned on and off several times a day...  The result is that I have
> > now hundreds of these empty directories in /var/sppol/smtpd/purge and just
> > doing an "ls" in that directory is very noticeably slow as a result.  I
> > obviously can easily delete all these directories but it's kind of annoying
> > to have to do that by hand every few months, so:
> > - is there any special reason why OpenSMTPD doesn't clean up after itself
> > when it shuts down?
> > - out of curiosity, what are these folders for anyway?  I've look at all
> > the man pages related to OpenSMTPD and there's no explanation I could find
> > for the purge directory anywhere...
> > 
> > Thanks,
> > 
> > Philippe
> > 
> > 
> > 
> I think its because the directory is owned by _smtpq and it looks like the
> intent was to clean up these files in purge_task(). However, it is running
> as _smtpd and can't rmtree() because of this. Of course that is if I have
> interpreted this correctly.

You are right.

Messages and envelopes are purged asynchronously by a background process
triggered by purge_task() and since we want to make sure things don't go
wrong we drop privileges for that process.

A long time ago, we decided to give the queue a different ownership so a
compromise of the lookup process would not allow read/write to the queue
but it seems that I forgot to switch the purge_task() user which means a
transaction that's aborted will leave leftovers that purge_task() cannot
delete.

Your fix makes sense but I haven't looked in this code for a while, I'll
read it again and commit your diff this week-end.

Thanks,
Gilles

-- 
Gilles Chehade

https://www.poolp.org                                          @poolpOrg

-- 
You received this mail because you are subscribed to [email protected]
To unsubscribe, send a mail to: [email protected]

Reply via email to