[issue25541] Wrong usage of sockaddr_un struct for abstract namespace unix sockets

PrzemeK report at bugs.python.org
Tue May 7 02:49:15 EDT 2019


PrzemeK <soutys at o2.pl> added the comment:

Yep, it was 3.4 then... but I think problem still exists

tl;dr: For abstract sockets (only?) filling struct with zeros is 
meaningful.

long:
* Python (cli) -> Python (srv) = works
* C (cli) -> C (srv) = works
* C (cli) -> Python (srv) = does NOT work
* Python (cli) -> C (srv) = does NOT work (strace dumps below)

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

$ uname -a
Linux ajzus 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ python3.7 --version
Python 3.7.1


// 1st console
$ gcc -g -Wall -Wextra -pedantic -o abs_srv abs_srv.c

$ strace ./abs_srv
...
socket(AF_UNIX, SOCK_STREAM, 0)         = 3
bind(3, {sa_family=AF_UNIX, sun_path=@"/var/tmp/sock.tmp\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 110) = 0
listen(3, 5)                            = 0
accept(3, NULL, NULL
// waiting


// 2nd console
$ ls /var/tmp/*.sock
ls: cannot access '/var/tmp/*.sock': No such file or directory

$ strace python3.7 abs_cli.py
...
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path=@"/var/tmp/sock.tmp"}, 20) = -1 ECONNREFUSED (Connection refused)

----------
versions: +Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25541>
_______________________________________


More information about the Python-bugs-list mailing list