[PATH] support for UNIX socket in abstract namespace

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATH] support for UNIX socket in abstract namespace

Roberto De Ioris
(Warning this is Linux only)

Hi all, the attached path adds support for unix socket in abstract namespace.
They are special sockets without filesystem correspondence (so you can use
them without thinking about permissions or in chroot). In netstat they are
reported with a '@' prefix.

For example (using uWSGI):

uwsgi -s @funnysock

netstat -l

unix  2      [ ACC ]     STREAM     LISTENING     23813    @funnysock

After applying the patch you can connect to it with

uwsgi_pass unix:@funnysock;

I hope it can be useful

--
Roberto De Ioris
http://unbit.it
_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx

unix_abstract.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Igor Sysoev-2
On Mon, May 23, 2011 at 04:18:30PM +0200, Roberto De Ioris wrote:

> (Warning this is Linux only)
>
> Hi all, the attached path adds support for unix socket in abstract namespace.
> They are special sockets without filesystem correspondence (so you can use
> them without thinking about permissions or in chroot). In netstat they are
> reported with a '@' prefix.
>
> For example (using uWSGI):
>
> uwsgi -s @funnysock
>
> netstat -l
>
> unix  2      [ ACC ]     STREAM     LISTENING     23813    @funnysock
>
> After applying the patch you can connect to it with
>
> uwsgi_pass unix:@funnysock;
>
> I hope it can be useful

Thank you for the feature. I think it's better to allow nginx configuration
parser to support "\0" as binary 0. Then this socket may be set as

uwsgi_pass   unix:\0funnysock;


--
Igor Sysoev

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Roberto De Ioris

> On Mon, May 23, 2011 at 04:18:30PM +0200, Roberto De Ioris wrote:
>> (Warning this is Linux only)
>>
>> Hi all, the attached path adds support for unix socket in abstract
>> namespace.
>> They are special sockets without filesystem correspondence (so you can
>> use
>> them without thinking about permissions or in chroot). In netstat they
>> are
>> reported with a '@' prefix.
>>
>> For example (using uWSGI):
>>
>> uwsgi -s @funnysock
>>
>> netstat -l
>>
>> unix  2      [ ACC ]     STREAM     LISTENING     23813    @funnysock
>>
>> After applying the patch you can connect to it with
>>
>> uwsgi_pass unix:@funnysock;
>>
>> I hope it can be useful
>
> Thank you for the feature. I think it's better to allow nginx
> configuration
> parser to support "\0" as binary 0. Then this socket may be set as
>
> uwsgi_pass   unix:\0funnysock;
>

I fear it will require changes changes as 0 being the token delimeter in
config parsing :(


--
Roberto De Ioris
http://unbit.it

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Roberto De Ioris

>>> I hope it can be useful
>>
>> Thank you for the feature. I think it's better to allow nginx
>> configuration
>> parser to support "\0" as binary 0. Then this socket may be set as
>>
>> uwsgi_pass   unix:\0funnysock;
>>
>
> I fear it will require changes changes



i mean "heavy changes"



--
Roberto De Ioris
http://unbit.it

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Igor Sysoev-2
In reply to this post by Roberto De Ioris
On Mon, May 23, 2011 at 07:42:02PM +0200, Roberto De Ioris wrote:

>
> > On Mon, May 23, 2011 at 04:18:30PM +0200, Roberto De Ioris wrote:
> >> (Warning this is Linux only)
> >>
> >> Hi all, the attached path adds support for unix socket in abstract
> >> namespace.
> >> They are special sockets without filesystem correspondence (so you can
> >> use
> >> them without thinking about permissions or in chroot). In netstat they
> >> are
> >> reported with a '@' prefix.
> >>
> >> For example (using uWSGI):
> >>
> >> uwsgi -s @funnysock
> >>
> >> netstat -l
> >>
> >> unix  2      [ ACC ]     STREAM     LISTENING     23813    @funnysock
> >>
> >> After applying the patch you can connect to it with
> >>
> >> uwsgi_pass unix:@funnysock;
> >>
> >> I hope it can be useful
> >
> > Thank you for the feature. I think it's better to allow nginx
> > configuration
> > parser to support "\0" as binary 0. Then this socket may be set as
> >
> > uwsgi_pass   unix:\0funnysock;
> >
>
> I fear it will require changes changes as 0 being the token delimeter in
> config parsing :(

No, nginx does not use zero-trailing strings.


--
Igor Sysoev

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Igor Sysoev-2
In reply to this post by Roberto De Ioris
On Mon, May 23, 2011 at 07:42:02PM +0200, Roberto De Ioris wrote:

>
> > On Mon, May 23, 2011 at 04:18:30PM +0200, Roberto De Ioris wrote:
> >> (Warning this is Linux only)
> >>
> >> Hi all, the attached path adds support for unix socket in abstract
> >> namespace.
> >> They are special sockets without filesystem correspondence (so you can
> >> use
> >> them without thinking about permissions or in chroot). In netstat they
> >> are
> >> reported with a '@' prefix.
> >>
> >> For example (using uWSGI):
> >>
> >> uwsgi -s @funnysock
> >>
> >> netstat -l
> >>
> >> unix  2      [ ACC ]     STREAM     LISTENING     23813    @funnysock
> >>
> >> After applying the patch you can connect to it with
> >>
> >> uwsgi_pass unix:@funnysock;
> >>
> >> I hope it can be useful
> >
> > Thank you for the feature. I think it's better to allow nginx
> > configuration
> > parser to support "\0" as binary 0. Then this socket may be set as
> >
> > uwsgi_pass   unix:\0funnysock;
> >
>
> I fear it will require changes changes as 0 being the token delimeter in
> config parsing :(
Could you test the attached patch ?


--
Igor Sysoev

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx

patch.zero (559 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Roberto De Ioris

> On Mon, May 23, 2011 at 07:42:02PM +0200, Roberto De Ioris wrote:
>>
>> > On Mon, May 23, 2011 at 04:18:30PM +0200, Roberto De Ioris wrote:
>> >> (Warning this is Linux only)
>> >>
>> >> Hi all, the attached path adds support for unix socket in abstract
>> >> namespace.
>> >> They are special sockets without filesystem correspondence (so you
>> can
>> >> use
>> >> them without thinking about permissions or in chroot). In netstat
>> they
>> >> are
>> >> reported with a '@' prefix.
>> >>
>> >> For example (using uWSGI):
>> >>
>> >> uwsgi -s @funnysock
>> >>
>> >> netstat -l
>> >>
>> >> unix  2      [ ACC ]     STREAM     LISTENING     23813    @funnysock
>> >>
>> >> After applying the patch you can connect to it with
>> >>
>> >> uwsgi_pass unix:@funnysock;
>> >>
>> >> I hope it can be useful
>> >
>> > Thank you for the feature. I think it's better to allow nginx
>> > configuration
>> > parser to support "\0" as binary 0. Then this socket may be set as
>> >
>> > uwsgi_pass   unix:\0funnysock;
>> >
>>
>> I fear it will require changes changes as 0 being the token delimeter in
>> config parsing :(
>
> Could you test the attached patch ?


This is the same code i made after you suggestion, but in the url parsing
code (ngx_parse_unix_domain_url), ngx_cpystrn() is used and it takes '\0'
in account.

Changing ngx_cpystrn to not use \0 fixes the problem. Probably
substituting it with ngx_memcpy is the way to go.

Another thing to do is "fixing"

u->addrs[0].socklen = sizeof(struct sockaddr_un);

to

u->addrs[0].socklen = sizeof(saun->sun_family)+len;



--
Roberto De Ioris
http://unbit.it

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Igor Sysoev-2
On Mon, May 23, 2011 at 08:17:46PM +0200, Roberto De Ioris wrote:

>
> > On Mon, May 23, 2011 at 07:42:02PM +0200, Roberto De Ioris wrote:
> >>
> >> > On Mon, May 23, 2011 at 04:18:30PM +0200, Roberto De Ioris wrote:
>
> This is the same code i made after you suggestion, but in the url parsing
> code (ngx_parse_unix_domain_url), ngx_cpystrn() is used and it takes '\0'
> in account.
>
> Changing ngx_cpystrn to not use \0 fixes the problem. Probably
> substituting it with ngx_memcpy is the way to go.
>
> Another thing to do is "fixing"
>
> u->addrs[0].socklen = sizeof(struct sockaddr_un);
>
> to
>
> u->addrs[0].socklen = sizeof(saun->sun_family)+len;

nxg_memcpy should work here.


--
Igor Sysoev

_______________________________________________
nginx mailing list
[hidden email]
http://nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

vedranf
In addition to this discussion, I found this:
http://forum.nginx.org/read.php?29,230660,230660

I wonder if this patch is included in the main code?
I could not use unix domain sockets in abstract namespace, like this:
unix:@socket_name
nor:
unix:\0socket_name

in nginx/1.3.6

What are the chances of include this patch, where is the problem?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,200086,230765#msg-230765

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
pva
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

pva
Is there any chance that abstract namespace support will be added for unix
sockets?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,200086,276278#msg-276278

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Maxim Dounin
Hello!

On Wed, Sep 06, 2017 at 05:20:11PM -0400, Pavel Murzakov wrote:

> Is there any chance that abstract namespace support will be added for unix
> sockets?

You may try the patch here, likely it still applies:

http://mailman.nginx.org/pipermail/nginx-devel/2016-October/008878.html

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
pva
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

pva
Thank you.
I knew that there was a patch. Just wondering whether it's going to be
merged or not cause it's more handy when you don't need to patch anything.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,200086,276296#msg-276296

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: [PATH] support for UNIX socket in abstract namespace

Maxim Dounin
Hello!

On Thu, Sep 07, 2017 at 10:03:51AM -0400, Pavel Murzakov wrote:

> Thank you.
> I knew that there was a patch. Just wondering whether it's going to be
> merged or not cause it's more handy when you don't need to patch anything.

Unlikely, unless there will be some positive feedback on the
patch.  You may help to make this happen by testing the patch and
providing some feedback.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx