Why not remove UNIX domain socket before bind

Datong Sun datong at cloudflare.com
Thu Dec 1 09:16:37 UTC 2016


Hi Maxim,

Thanks for the explanation. Regarding a), what about checking and making
sure the type of file is actually a socket before removing? Obviously it
does not prevent NGINX from deleting sockets created by other processes but
it's a much smaller issue compared to deleting arbitrary file.

Thanks,

On Wed, Nov 30, 2016 at 6:57 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Tue, Nov 29, 2016 at 01:30:25PM -0800, Shuxin Yang wrote:
>
> >      Is there any reason not to delete UNIX domain socket before bind?
>
> To name a few, deleting a socket implies that:
>
> a) any file can be accidentally deleted due to a typo in the
>    listen directive;
>
> b) attempts to do duplicate listen are not detected and silently
>    break service, e.g., if you start duplicate instance of nginx.
>
> Instead we delete the socket after closing it.
>
> --
> Maxim Dounin
> http://nginx.org/
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>



-- 

*Datong Sun*  |  Systems Engineer
datong at cloudflare.com
<https://www.cloudflare.com/>

1 888 99 FLARE  |  www.cloudflare.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20161201/9601a527/attachment.html>


More information about the nginx-devel mailing list