Re: SO_PASSCRED and SCM_CREDENTIALS | error: use of undeclared identifier

From: Michael Grimm <trashcan_at_ellael.org>
Date: Thu, 21 Mar 2024 17:22:11 UTC
Gleb Popov <arrowd@freebsd.org> wrote:
> 
> On Wed, Mar 20, 2024 at 11:16 PM Michael Grimm <trashcan@ellael.org> wrote:

>> Compilation fails:
>> 
>> cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I/usr/local/include/python3.9 -c knot_resolver_manager/kresd_controller/supervisord/plugin/notifymodule.c -o build/temp.freebsd-14.0-STABLE-amd64-cpython-39/knot_resolver_manager/kresd_controller/supervisord/plugin/notifymodule.o
>> knot_resolver_manager/kresd_controller/supervisord/plugin/notifymodule.c:52:42: error: use of undeclared identifier 'SO_PASSCRED'
>>   52 |         res = setsockopt(controlfd, SOL_SOCKET, SO_PASSCRED, &data,
> 
> This might help you:
> https://github.com/CollaboraOnline/online/commit/8c6cbedd583e80e3c0f93a3e42b3579492da2087

Thanks, that helped a lot! I patched that file as follows:

#) included sys/ucred.h
#) used LOCAL_PEERCRED instead of SO_PASSCRED
#) used 'struct xucred' instead of 'struct ucred'
#) used SCM_CREDS instead of SCM_CREDENTIALS
#) used cred.cr_pid instead of cred.pid as returned value

The file compiles without error, now. But I don't know yet if the socket will work as expected (some more porting and testing needed).

Thanks and regards,
Michael