This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dumb question


On Tue, 30 Jun 1998 16:17:39 +0200 (MET DST), Mark Kettenis wrote:

>   >Zack, for what do you need struct ucred ? Are you playing with
>   >__SCM_CREDENTIALS in the moment ? I have some big problems with it,
>   >which I couldn't solve. If I could see code which works, maybe
>   >I could find my mistake.
>
>   The code I'm looking at is Alexey Kuznetsov's TLI-over-sockets
>   library, which I was trying to package as a glibc addon.  It was
>   written to libc5 and assumes struct ucred is in sys/socket.h.  I have
>   no idea if the code actually works.
>
>   zw
>
>The BSD's have a sys/ucred.h header file, which defines a struct
>ucred.  Maybe we should add it to the Linux port of glibc.  However
>the defenition of the BSD struct ucred is different from the Linux
>struct ucred (more fields, different names, but no pid field), see  
>
>    http://minnie.cs.adfa.oz.au/FreeBSD-srctree/newsrc/sys/ucred.h.html

Since the context is the __SCM_CREDENTIALS sendmsg() option, the struct
to emulate is cmsgcred:

struct cmsgcred {
	pid_t	cmcred_pid;		/* PID of sending process */
	uid_t	cmcred_uid;		/* real UID of sending process */
	uid_t	cmcred_euid;		/* effective UID of sending process */
	gid_t	cmcred_gid;		/* real GID of sending process */
	short	cmcred_ngroups;		/* number or groups */
	gid_t	cmcred_groups[CMGROUP_MAX];	/* groups */
};

We need a wrapper to fix the type clash anyway, so I think I'll have
sendmsg() convert this structure to the one the kernel expects, and
promote __SCM_CREDENTIALS to SCM_CREDS which is what BSD calls this
option.  The fields Linux doesn't provide can be set to -1 or 0.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]