From: Victor Duchovni on
On Thu, Jul 22, 2010 at 02:35:14PM +0200, Ralf Hildebrandt wrote:

> > Consider using RSYNC to COPY the file from the hold queue to the
> > incoming queue, using the same file name.
>
> Once it's there, will it take the same path as the initial mail (on
> HOLD) would have taken?

No, because only cleanup(8) and postsuper(1) put messages in the "hold"
queue, if you place a mode 700 file in "incoming" it is in the first
stage of output processing and can only be delivered, but not put on HOLD
(except via postsuper).

Note, if rsync propagates file permissions before it copies file contents,
an incomplete queue file could be picked up by the queue manager before
it is completely written. So it is safer to rsync outside "incoming"
(in the same file-system) and then rename into "incoming".

The above said, rsync also uses temporary file-names while creating files,
and uses rename to finalize the file copy only once the contents are
all there, so Wietse's suggestion will likely work, provided rsync's
temp file names don't look like Postfix queue-ids (the queue manager
incoming directory scans skip filenames that don't look like queue-ids).

The code in question is src/global/mail_queue.c:mail_queue_id_ok()
which skips any filenames that are not alphanumeric (with '_').

So provided rsync's temp names include some other chars (I think
it uses ".tempname" to keep temp files "out of view" while they
are being created) there is no need for the intermediate copy...

--
Viktor.

From: Patrick Ben Koetter on
* Victor Duchovni <postfix-users(a)postfix.org>:
> On Thu, Jul 22, 2010 at 02:35:14PM +0200, Ralf Hildebrandt wrote:
>
> > > Consider using RSYNC to COPY the file from the hold queue to the
> > > incoming queue, using the same file name.
> >
> > Once it's there, will it take the same path as the initial mail (on
> > HOLD) would have taken?
>
> No, because only cleanup(8) and postsuper(1) put messages in the "hold"
> queue, if you place a mode 700 file in "incoming" it is in the first
> stage of output processing and can only be delivered, but not put on HOLD
> (except via postsuper).
>
> Note, if rsync propagates file permissions before it copies file contents,
> an incomplete queue file could be picked up by the queue manager before
> it is completely written. So it is safer to rsync outside "incoming"
> (in the same file-system) and then rename into "incoming".
>
> The above said, rsync also uses temporary file-names while creating files,
> and uses rename to finalize the file copy only once the contents are
> all there, so Wietse's suggestion will likely work, provided rsync's
> temp file names don't look like Postfix queue-ids (the queue manager
> incoming directory scans skip filenames that don't look like queue-ids).
>
> The code in question is src/global/mail_queue.c:mail_queue_id_ok()
> which skips any filenames that are not alphanumeric (with '_').
>
> So provided rsync's temp names include some other chars (I think
> it uses ".tempname" to keep temp files "out of view" while they
> are being created) there is no need for the intermediate copy...

Thanks for the great input. I'll take that into consideration when I build the
script.

p(a)rick

--
All technical questions asked privately will be automatically answered on the
list and archived for public access unless privacy is explicitely required and
justified.

saslfinger (debugging SMTP AUTH):
<http://postfix.state-of-mind.de/patrick.koetter/saslfinger/>

From: Ralf Hildebrandt on
* Victor Duchovni <Victor.Duchovni(a)morganstanley.com>:

> Note, if rsync propagates file permissions before it copies file contents,
> an incomplete queue file could be picked up by the queue manager before
> it is completely written. So it is safer to rsync outside "incoming"
> (in the same file-system) and then rename into "incoming".

Good point. rsycn it some place else, the mv it atomically.

> The above said, rsync also uses temporary file-names while creating files,

Yes.

> and uses rename to finalize the file copy only once the contents are
> all there, so Wietse's suggestion will likely work, provided rsync's
> temp file names don't look like Postfix queue-ids (the queue manager
> incoming directory scans skip filenames that don't look like queue-ids).
>
> The code in question is src/global/mail_queue.c:mail_queue_id_ok()
> which skips any filenames that are not alphanumeric (with '_').
>
> So provided rsync's temp names include some other chars (I think
> it uses ".tempname" to keep temp files "out of view" while they
> are being created) there is no need for the intermediate copy...

--
Ralf Hildebrandt
Geschäftsbereich IT | Abteilung Netzwerk
Charité - Universitätsmedizin Berlin
Campus Benjamin Franklin
Hindenburgdamm 30 | D-12203 Berlin
Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
ralf.hildebrandt(a)charite.de | http://www.charite.de


From: Victor Duchovni on
On Thu, Jul 22, 2010 at 09:24:52PM +0200, Ralf Hildebrandt wrote:

> * Victor Duchovni <Victor.Duchovni(a)morganstanley.com>:
>
> > Note, if rsync propagates file permissions before it copies file contents,
> > an incomplete queue file could be picked up by the queue manager before
> > it is completely written. So it is safer to rsync outside "incoming"
> > (in the same file-system) and then rename into "incoming".
>
> Good point. rsycn it some place else, the mv it atomically.

But not necessary if rsync temp file names are Postfix-safe (i.e.
not alnum + '_'), which is probably the case, so my point is likely
moot, but checking the validity of the assumption is sensible.

> > The above said, rsync also uses temporary file-names while creating files,
>
> Yes.
>
> > and uses rename to finalize the file copy only once the contents are
> > all there, so Wietse's suggestion will likely work, provided rsync's
> > temp file names don't look like Postfix queue-ids (the queue manager
> > incoming directory scans skip filenames that don't look like queue-ids).
> >
> > The code in question is src/global/mail_queue.c:mail_queue_id_ok()
> > which skips any filenames that are not alphanumeric (with '_').
> >
> > So provided rsync's temp names include some other chars (I think
> > it uses ".tempname" to keep temp files "out of view" while they
> > are being created) there is no need for the intermediate copy...

--
Viktor.

From: Wietse Venema on
Victor Duchovni:
> On Thu, Jul 22, 2010 at 09:24:52PM +0200, Ralf Hildebrandt wrote:
>
> > * Victor Duchovni <Victor.Duchovni(a)morganstanley.com>:
> >
> > > Note, if rsync propagates file permissions before it copies file contents,
> > > an incomplete queue file could be picked up by the queue manager before
> > > it is completely written. So it is safer to rsync outside "incoming"
> > > (in the same file-system) and then rename into "incoming".
> >
> > Good point. rsycn it some place else, the mv it atomically.
>
> But not necessary if rsync temp file names are Postfix-safe (i.e.
> not alnum + '_'), which is probably the case, so my point is likely
> moot, but checking the validity of the assumption is sensible.

rsync creates a temporary name ".mumble" and renames the file into place.

Wietse