<div dir="ltr">Hi systemd community.<br>Recently I've come accross one interesting problem with API of systemd.<br>The
problem is that, I'm not able to read commands comming to the AF_UNIX
socket, that was created by systemd and passed to my program using
sd_listen_fds(0) function.<br><br>What actually program requires, is AF_UNIX (AF_LOCAL) socket of type SOCK_STREAM.<br>In case if I create this socket manually, using socket(AF_LOCAL, SOCK_STREAM, 0) function, it works out as expected.<br><br>But, when I create a socket using systemd socket unit, reading fails with "-1" return value.<br><br>What
I actually do, is that I check if there are some sockets created for me
using sd_listen_fds(0), and in case it returns 1 (so 1 socket created),<br>program goes further and sets a file descriptor value to fd = SD_LISTEN_FDS_START + 0;<br>Since the SD_LISTEN_FDS_START is pre-defined to value '3', my file descriptor will always be '3'.<br><br>But when it comes to reading, with read() function, it fails with the errno EINVAL - Invalid argument.<br>It's not a matter of a other parameters than a file descriptor, since with manual creation of socket it works out as I said.<br><br>An initializing of the socket descriptor, when creating it by systemd passes as normal, so program starts.<br>But any further command received on fd fails with '-1' return value.<br><br>So my question is, where should I look into?<br><br><br>Socket unit file:<br>```<br>[Socket]<br>ListenStream=/var/run/foobar/foobar.sock<br>SocketUser=foouser<br>SocketGroup=foogroup<br>SocketMode=755<br><br>ExecStartPost=-/bin/chown foouser:foogroup /var/run/foobar<br><br>[Install]<br>WantedBy=sockets.target<br>```<br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><font style="background-color:rgb(255,255,255)" color="#0b5394">-- <br>BR, Donat Zenichev
<br><br></font></div></div></div></div></div></div></div>