Re: request: qmail-qfilter to use mkdtemp()

"Amitai Schleier" <[email protected]> 26 Oct 2017 01:59:33 -0400
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
--=_MailMate_491DDC97-526A-40D1-A707-55AAC989258A_=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On 25 Oct 2017, at 19:19, Bruce Guenter wrote:

> On Tue, Oct 24, 2017 at 02:51:10PM -0400, Amitai Schleier wrote:
>> This works beautifully -- iff I chmod qmail-qfilter's TMPDIR wide open=
,
>> which is obviously terrible.
>
> Why is it obviously terrible? qmail-qfilter uses mkstemp to create
> temporary file names, which is designed to do so securely. In fact, the=

> default for qmail-qfilter is to create its temporary files in /tmp,
> which is generally world writeable.

That makes sense. Maybe I've long misunderstood this part of the README:

> - Check the definitions at the top of qmail-qfilter.c, especially the
>   value of TMPDIR.  This should be set to a temporary directory that
>   only the executor of qmail-qfilter has write access to.

As a packager of qmail-qfilter, I've always taken this to mean I ought to=
 create a subdirectory like /tmp/qmail-qfilter, owned by qmaild:root, mod=
e 700-ish. If you're saying plain old /tmp is just fine (as we'd expect w=
ith mkstemp()), then my new understanding is that I created my own proble=
m and can fix it simply by removing some cruft from my packaging.

If my new understanding is correct, awesome. I'm happy that my SMTP AUTH =
code will interact nicely with qmail-qfilter without needing any code cha=
nges. :-)

If you've been thinking about a new release at some point, there is still=
 one tiny patch I'd love to see integrated. It exports qmail-qfilter's pa=
rent's PID to the environment, so filters can log the PID of the (e.g.) q=
mail-smtpd session that invoked them: https://github.com/bruceg/qmail-qfi=
lter/pull/1/commits/b7acc42a19b4f66a29e9faa0b0c52dd44e64a7bf Needs to be =
added to the man page as well (sorry, just noticed the omission).

Thank you for qmail-qfilter, and for helping me spot my mistake!

- Amitai
--=_MailMate_491DDC97-526A-40D1-A707-55AAC989258A_=
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename=signature.asc
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQFIBAEBAgAyFiEEtg90xLGZAmNNAEq19cMgCiOcY4QFAlnxecUUHHNjaG1vbnpA
c2NobW9uei5jb20ACgkQ9cMgCiOcY4R89wgAtDgsDdwvOsJ7bSdEUaeJsC+MPE9A
5r1l2OkaeEQwQ4TWXBSDSIpgsrvxUJFrUiq1B6VPrexQIsEUDz2CYV3f4YnEPk0W
7b1X2InDxg2DBy57Fw70TKHy3jvMK0chPSW0e4AFAPs6s71ymBeVMDbuoG5lUFe4
qx6vrNqwWGceHBAHSQTT8MGqGeYgW400fksAqUxvfB9F5VfY+19HShuSaBejE80m
Pj/cVyliYGGSeWOjVKgqWliDo4sdtEweZ81awkp3ZJxDFAHAj8ZrlxrjX2M1+/5u
ztJgEg6pxWWyP+AbllpcwXFVPy9+T9a78nccJxMSHCE5Zm5a2HMKbfTDoQ==
=7Kww
-----END PGP SIGNATURE-----

--=_MailMate_491DDC97-526A-40D1-A707-55AAC989258A_=--