Hello,

September 16, 2026 at 12:42 AM, "Samuel Thibault" wrote:
> David Bidner, le mar. 15 sept. 2026 14:47:28 +0200, a ecrit:
> 
> > 
> > The accepted server-side socket is created with sock_clone(), which gives
> >  it pflocal's own uid/gid (normally root), so fstat() on the accepted
> >  AF_LOCAL socket reports root rather than the connecting user. Copy the
> >  connecting socket's uid/gid onto the clone, so the accepting side can
> >  learn the peer's credentials with fstat().
> > 
> This seems odd, Linux does not behave like that.

That's correct, I was avoiding changing glibc. I've seen SCM_CREDS
in <bits/socket.h>, but that's per message, not a connection property.
To implement the Linux way, we'd need to add the ucred struct and
define SO_PEERCRED (e.g. 0x1009) in sysdeps/mach/hurd/bits/socket.h.

> > 
> > * pflocal/socket.c (S_socket_connect): Copy sock->uid/gid to the server
> >  clone.
> >  ---
> >  pflocal/socket.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >  
> >  diff --git a/pflocal/socket.c b/pflocal/socket.c
> >  index d60bece..cad2a0c 100644
> >  --- a/pflocal/socket.c
> >  +++ b/pflocal/socket.c
> >  @@ -136,6 +136,8 @@ S_socket_connect (struct sock_user *user, struct addr 
> > *addr)
> >  err = sock_clone (peer, &server);
> >  if (!err)
> >  {
> >  + server->uid = sock->uid;
> >  + server->gid = sock->gid;
> >  err = sock_connect (sock, server);
> >  if (!err)
> >  {
> >  -- 
> >  2.47.3
> >
>


Reply via email to