Date: Tue, 14 May 2013 14:13:18 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Mike Ma <mikemandarine@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: How to get ucred/xucred in user space? Message-ID: <20130514111318.GP3047@kib.kiev.ua> In-Reply-To: <CA%2BcqwfdohLfzeJXx-2wPwMjZDq3zX-BnDcOpyz_MU4PS9Ur6DA@mail.gmail.com> References: <CA%2BcqwfdohLfzeJXx-2wPwMjZDq3zX-BnDcOpyz_MU4PS9Ur6DA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--gl32Q9cg1UYx5OVO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 14, 2013 at 10:00:21AM +0200, Mike Ma wrote: > Hi folks, >=20 > Can I ask if there's any way to get ucred/xucred of a process in user spa= ce? > As I'm trying to port glustertfs and it's a userland filesystem, I need to > get secondary groups of a process. >=20 > AFAIK, Linux gets them in /proc and NetBSD gets them in this way: > int name[] =3D { CTL_KERN, KERN_PROC, KERN_PROC_PID, frame->root-= >pid > }; > size_t namelen =3D sizeof name / sizeof name[0]; > struct kinfo_proc kp; > size_t kplen =3D sizeof(kp); > int i, ngroups; > if (sysctl(name, namelen, &kp, &kplen, NULL, 0) !=3D 0) > return; > ngroups =3D MIN(kp.kp_eproc.e_ucred.cr_ngroups, GF_REQUEST_MAXGRO= UPS); >=20 > I realized none of them would work in FreeBSD. > I'm wondering if there's any alternative way to get group information? The sysctl to retrieve the list of the groups the process belongs to is CTL_KERN/KERN_PROC/KERN_PROC_GROUPS. On HEAD, the libprocstat(3) contains the helper procstat_getgroups() which would be more conventient to use, or you could borrow a code from it. --gl32Q9cg1UYx5OVO Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQIcBAEBAgAGBQJRkhxOAAoJEJDCuSvBvK1BizsP/2dpRVnQkTE9iydzPVc7oydc chirm8uggZ2+5hPh/Yahy04fmqSYo7UHZPAYYjCXnI8y6M2ObQJAshtJkAHDfQ5A AasUhCcR9XITIOqo4YQWIbHrMhRndYW+U4Ou8uGE68pbd9S7CWW/5GtE8e0zGRoj S8ONbgwDnsZn44sDuzzxssKLqT2qMZM/q/l4K4F8I39rZwRk0PsonvvUeBqIl5Wt IgeOaYIddNOhZ+1FKJu9L4NEAZeCgVR2DLqVnmwBQYudskalECRtu9izFtkMoQuU QwUVDFNhi3B4TiWvjSi2GDdMExkTBGJZIK0DgmPHG6PrPxHA4RGGsxkFMhxkUAVk 332JJ4Cd9CkA9bf68uHJWklwK1uD2EI9KPrQzJdSus4KOJEZb2+2wGL2QrMoxGZd HYUFpMKRiaktd0BHxa47OcLZk6kiVQLliwbnYiCa167bKlm2le5Ae/RHNaoaGsU7 0soJrkutixWh4qqpZIspK1lGpGWdnf2ROTYnkpdjQBHp9AZAABoNyUtOI7y8b3CN BbPQUjlWVeF5AqAdLW4ybVtle2YZBa16AyWceCHTBMC9Fu3sRB9gMHvUrlGygtxH wNERwJCxhyDYBGG7dIbVH1QTHO9ZtXD3d3WZbgkfOrLCdDvbnZ8ygotZjMKRLrMh SMPnPfepcJmt4J5MFYVV =qQox -----END PGP SIGNATURE----- --gl32Q9cg1UYx5OVO--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130514111318.GP3047>