On Tue, Oct 31, 2023 at 03:46:01PM +0100, Anthony Harivel wrote: > The function qio_channel_get_peercred() returns a pointer to the > credentials of the peer process connected to this socket. > > This credentials structure is defined in <sys/socket.h> as follows: > > struct ucred { > pid_t pid; /* Process ID of the sending process */ > uid_t uid; /* User ID of the sending process */ > gid_t gid; /* Group ID of the sending process */ > }; > > The use of this function is possible only for connected AF_UNIX stream > sockets and for AF_UNIX stream and datagram socket pairs. > > Signed-off-by: Anthony Harivel <ahari...@redhat.com> > --- > include/io/channel.h | 20 ++++++++++++++++++++ > io/channel-socket.c | 17 +++++++++++++++++ > io/channel.c | 12 ++++++++++++ > 3 files changed, 49 insertions(+) > > diff --git a/include/io/channel.h b/include/io/channel.h > index 5f9dbaab65b0..99c02d61c3d9 100644 > --- a/include/io/channel.h > +++ b/include/io/channel.h > @@ -149,6 +149,9 @@ struct QIOChannelClass { > void *opaque); > int (*io_flush)(QIOChannel *ioc, > Error **errp); > + void (*io_peercred)(QIOChannel *ioc, > + struct ucred *cred, > + Error **errp);
This isn't going to fly. 'struct ucred' is Linux specific, so this won't compile on macOS, Windows, *BSD, and we don't really want a huge #ifdef ladder in these APIs. This will need to explode the struct and return the individual fields that are present instead, and the impl side must compile on other OS, even if its just stubbed out to return an error. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|