* bug#23068: 25.1.50; unix socket address in abstract namespace
@ 2016-03-20 3:18 Mark Oteiza
2016-03-20 16:32 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Mark Oteiza @ 2016-03-20 3:18 UTC (permalink / raw
To: 23068
For the wishlist: teach emacs how to handle unix domain sockets with
an abstract address. For instance, connecting to an abstract address
might look like:
(make-network-process
:name "dog" :buffer " *woof*"
:service "\0sock" :family 'local)
the salient part being that the first element of the address is a null
byte. unix(7) has details.
In GNU Emacs 25.1.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
of 2016-03-19 built on duoteque
Repository revision: 326fff41fa9f674d80be00b5c97c44f8043bbace
Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --without-gconf --with-modules
--with-x-toolkit=lucid 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
-fstack-protector-strong --param=ssp-buffer-size=4 -g
-fvar-tracking-assignments -g -fvar-tracking-assignments'
CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
LUCID X11 MODULES
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 3:18 bug#23068: 25.1.50; unix socket address in abstract namespace Mark Oteiza
@ 2016-03-20 16:32 ` Eli Zaretskii
2016-03-20 17:02 ` Mark Oteiza
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2016-03-20 16:32 UTC (permalink / raw
To: Mark Oteiza; +Cc: 23068
> From: Mark Oteiza <mvoteiza@udel.edu>
> Date: Sat, 19 Mar 2016 23:18:35 -0400
>
> For the wishlist: teach emacs how to handle unix domain sockets with
> an abstract address. For instance, connecting to an abstract address
> might look like:
>
> (make-network-process
> :name "dog" :buffer " *woof*"
> :service "\0sock" :family 'local)
>
> the salient part being that the first element of the address is a null
> byte. unix(7) has details.
Which parts of this don't already work?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 16:32 ` Eli Zaretskii
@ 2016-03-20 17:02 ` Mark Oteiza
2016-03-20 17:11 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Mark Oteiza @ 2016-03-20 17:02 UTC (permalink / raw
To: Eli Zaretskii; +Cc: 23068
On 20/03/16 at 06:32pm, Eli Zaretskii wrote:
> > From: Mark Oteiza <mvoteiza@udel.edu>
> > Date: Sat, 19 Mar 2016 23:18:35 -0400
> >
> > For the wishlist: teach emacs how to handle unix domain sockets with
> > an abstract address. For instance, connecting to an abstract address
> > might look like:
> >
> > (make-network-process
> > :name "dog" :buffer " *woof*"
> > :service "\0sock" :family 'local)
> >
> > the salient part being that the first element of the address is a null
> > byte. unix(7) has details.
>
> Which parts of this don't already work?
For testing purposes, the socket is bound with
socat -vd abstract-listen:sock,fork TCP:host:port
and I'm able to connect to it otherwise. The above elisp does:
socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
connect(8, {sa_family=AF_LOCAL, sun_path=@""}, 110) = -1 ECONNREFUSED (Connection refused)
close(8)
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 17:02 ` Mark Oteiza
@ 2016-03-20 17:11 ` Lars Magne Ingebrigtsen
2016-03-20 17:25 ` Eli Zaretskii
2016-03-20 17:39 ` Andreas Schwab
0 siblings, 2 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2016-03-20 17:11 UTC (permalink / raw
To: Mark Oteiza; +Cc: 23068
Mark Oteiza <mvoteiza@udel.edu> writes:
> and I'm able to connect to it otherwise. The above elisp does:
>
> socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
> connect(8, {sa_family=AF_LOCAL, sun_path=@""}, 110) = -1
> ECONNREFUSED (Connection refused)
> close(8)
Yeah, this code in conv_lisp_to_sockaddr doesn't look very correct:
else if (STRINGP (address))
{
#ifdef HAVE_LOCAL_SOCKETS
if (family == AF_LOCAL)
{
struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
cp = SDATA (address);
for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
sockun->sun_path[i] = *cp++;
sa->sa_family = family;
}
#endif
return;
}
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 17:11 ` Lars Magne Ingebrigtsen
@ 2016-03-20 17:25 ` Eli Zaretskii
2016-03-20 17:39 ` Andreas Schwab
1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2016-03-20 17:25 UTC (permalink / raw
To: Lars Magne Ingebrigtsen; +Cc: mvoteiza, 23068
> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, 23068@debbugs.gnu.org
> Date: Sun, 20 Mar 2016 18:11:09 +0100
>
> Mark Oteiza <mvoteiza@udel.edu> writes:
>
> > and I'm able to connect to it otherwise. The above elisp does:
> >
> > socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
> > connect(8, {sa_family=AF_LOCAL, sun_path=@""}, 110) = -1
> > ECONNREFUSED (Connection refused)
> > close(8)
>
> Yeah, this code in conv_lisp_to_sockaddr doesn't look very correct:
>
> else if (STRINGP (address))
> {
> #ifdef HAVE_LOCAL_SOCKETS
> if (family == AF_LOCAL)
> {
> struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
> cp = SDATA (address);
> for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
> sockun->sun_path[i] = *cp++;
> sa->sa_family = family;
> }
> #endif
> return;
> }
That should be trivial to fix. Elsewhere, we specifically attempt to
support this feature:
#ifdef HAVE_LOCAL_SOCKETS
case AF_LOCAL:
{
struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
ptrdiff_t name_length = len - offsetof (struct sockaddr_un, sun_path);
/* If the first byte is NUL, the name is a Linux abstract
socket name, and the name can contain embedded NULs. If
it's not, we have a NUL-terminated string. Be careful not
to walk past the end of the object looking for the name
terminator, however. */
if (name_length > 0 && sockun->sun_path[0] != '\0')
{
const char *terminator
= memchr (sockun->sun_path, '\0', name_length);
if (terminator)
name_length = terminator - (const char *) sockun->sun_path;
}
return make_unibyte_string (sockun->sun_path, name_length);
}
IOW, this is not a wishlist feature request, but a routine bug report ;-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 17:11 ` Lars Magne Ingebrigtsen
2016-03-20 17:25 ` Eli Zaretskii
@ 2016-03-20 17:39 ` Andreas Schwab
2016-03-20 18:02 ` Eli Zaretskii
1 sibling, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2016-03-20 17:39 UTC (permalink / raw
To: Lars Magne Ingebrigtsen; +Cc: Mark Oteiza, 23068
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Mark Oteiza <mvoteiza@udel.edu> writes:
>
>> and I'm able to connect to it otherwise. The above elisp does:
>>
>> socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 8
>> connect(8, {sa_family=AF_LOCAL, sun_path=@""}, 110) = -1
>> ECONNREFUSED (Connection refused)
>> close(8)
>
> Yeah, this code in conv_lisp_to_sockaddr doesn't look very correct:
>
> else if (STRINGP (address))
> {
> #ifdef HAVE_LOCAL_SOCKETS
> if (family == AF_LOCAL)
> {
> struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
> cp = SDATA (address);
> for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
> sockun->sun_path[i] = *cp++;
This also needs to encode the string in one way.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 17:39 ` Andreas Schwab
@ 2016-03-20 18:02 ` Eli Zaretskii
2016-03-20 19:49 ` Andreas Schwab
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2016-03-20 18:02 UTC (permalink / raw
To: Andreas Schwab; +Cc: mvoteiza, larsi, 23068
> From: Andreas Schwab <schwab@linux-m68k.org>
> Date: Sun, 20 Mar 2016 18:39:02 +0100
> Cc: Mark Oteiza <mvoteiza@udel.edu>, 23068@debbugs.gnu.org
>
> This also needs to encode the string in one way.
The network-related functions in process.c generally don't bother
encoding the strings at all.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 18:02 ` Eli Zaretskii
@ 2016-03-20 19:49 ` Andreas Schwab
2016-03-20 19:51 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2016-03-20 19:49 UTC (permalink / raw
To: Eli Zaretskii; +Cc: mvoteiza, larsi, 23068
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Andreas Schwab <schwab@linux-m68k.org>
>> Date: Sun, 20 Mar 2016 18:39:02 +0100
>> Cc: Mark Oteiza <mvoteiza@udel.edu>, 23068@debbugs.gnu.org
>>
>> This also needs to encode the string in one way.
>
> The network-related functions in process.c generally don't bother
> encoding the strings at all.
That doesn't mean it is correct. A file name needs to be encoded.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#23068: 25.1.50; unix socket address in abstract namespace
2016-03-20 19:49 ` Andreas Schwab
@ 2016-03-20 19:51 ` Eli Zaretskii
0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2016-03-20 19:51 UTC (permalink / raw
To: Andreas Schwab; +Cc: mvoteiza, larsi, 23068
> From: Andreas Schwab <schwab@linux-m68k.org>
> Cc: mvoteiza@udel.edu, larsi@gnus.org, 23068@debbugs.gnu.org
> Date: Sun, 20 Mar 2016 20:49:31 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> From: Andreas Schwab <schwab@linux-m68k.org>
> >> Date: Sun, 20 Mar 2016 18:39:02 +0100
> >> Cc: Mark Oteiza <mvoteiza@udel.edu>, 23068@debbugs.gnu.org
> >>
> >> This also needs to encode the string in one way.
> >
> > The network-related functions in process.c generally don't bother
> > encoding the strings at all.
>
> That doesn't mean it is correct.
No, of course not. What it means is that many more places need to be
fixed in this regard.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-03-20 19:51 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-20 3:18 bug#23068: 25.1.50; unix socket address in abstract namespace Mark Oteiza
2016-03-20 16:32 ` Eli Zaretskii
2016-03-20 17:02 ` Mark Oteiza
2016-03-20 17:11 ` Lars Magne Ingebrigtsen
2016-03-20 17:25 ` Eli Zaretskii
2016-03-20 17:39 ` Andreas Schwab
2016-03-20 18:02 ` Eli Zaretskii
2016-03-20 19:49 ` Andreas Schwab
2016-03-20 19:51 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.