~emersion/basu

f12a4efd8cb7268e67cc8929083a2d81e4cba051 — Kenny Levinsen 2 years ago 928a746
freebsd: Do not use cr_pid from LOCAL_PEERCRED

LOCAL_PEERCRED is used as substitute for SO_PEERCRED on FreeBSD. One of
the fields needed from there is the PID of the peer process. However,
while SO_PEERCRED returns the PID at the time of connect(2),
LOCAL_PEERCRED returns the PID at the time of listen(2). If the dbus
daemon fork(2)'d after listen(2) to daemonize, then the PID returned
will no longer exist, which breaks basu.

Remove the use of cr_pid for now, as it cannot be used.
1 files changed, 0 insertions(+), 4 deletions(-)

M src/basic/socket-util.c
M src/basic/socket-util.c => src/basic/socket-util.c +0 -4
@@ 41,11 41,7 @@ int getpeercred(int fd, struct ucred *ucred) {
        }

        struct ucred u = {
#if __FreeBSD_version >= 1300030 || (__FreeBSD_version >= 1202506 && __FreeBSD_version < 1300000)
                .pid = cred.cr_pid,
#else
                .pid = -1,
#endif
                .uid = cred.cr_uid,
                .gid = cred.cr_ngroups > 0 ? cred.cr_groups[0] : (gid_t)-1,
        };