aio-libs / aiosmtpd

A reimplementation of the Python stdlib smtpd.py based on asyncio.
https://aiosmtpd.aio-libs.org
Apache License 2.0
319 stars 96 forks source link

Selectively intuitive setuid behavior #275

Open strongholdmedia opened 3 years ago

strongholdmedia commented 3 years ago

In my mediocre, pre-'90s universe, we use setuid to ascertain that we may drop privileges after binding the socket. This is necessary, as one does not simply bind a port below 1025 without doing so as root. In fact, that is the sole reason to run such stuff as root.

However, when set (left) as such, the software attempts to drop its privileges as soon as it evaluates the arguments.

To me, this makes somewhat limited sense.

Am I missing something? I would be glad to receive some pointers.

pepoluan commented 2 years ago

Hmm... you have a point. It seems we invoked the process the wrong way around, and the tests did not catch this because they overrode os.setuid.

I'll see how I can fix this. Probably simple #KnockWood