
The getnucred() function was used by UDS to obtain credentials of user processes in a form used in the UDS API, namely the ucred structure. Since the NetBSD merge, this structure has changed drastically (aside from being renamed to "uucred"), and it is no longer in UDS's best interest to use this structure internally. Therefore, getnucred() is no longer a useful API either, and instead we directly use the previously private getepinfo() function to obtain credentials. Change-Id: I80bc809de716ec0a9b7497cb109d2f2708a629d5
55 lines
795 B
C
55 lines
795 B
C
#include "syslib.h"
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include <sys/ucred.h>
|
|
|
|
pid_t
|
|
getepinfo(endpoint_t proc_ep, uid_t *uid, gid_t *gid)
|
|
{
|
|
message m;
|
|
int r;
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
m.m_lsys_pm_getepinfo.endpt = proc_ep;
|
|
|
|
if ((r = _taskcall(PM_PROC_NR, PM_GETEPINFO, &m)) < 0)
|
|
return r;
|
|
|
|
if (uid != NULL)
|
|
*uid = m.m_pm_lsys_getepinfo.uid;
|
|
if (gid != NULL)
|
|
*gid = m.m_pm_lsys_getepinfo.gid;
|
|
return (pid_t) r;
|
|
}
|
|
|
|
pid_t
|
|
getnpid(endpoint_t proc_ep)
|
|
{
|
|
return getepinfo(proc_ep, NULL, NULL);
|
|
}
|
|
|
|
uid_t
|
|
getnuid(endpoint_t proc_ep)
|
|
{
|
|
uid_t uid;
|
|
int r;
|
|
|
|
if ((r = getepinfo(proc_ep, &uid, NULL)) < 0)
|
|
return (uid_t) r;
|
|
|
|
return uid;
|
|
}
|
|
|
|
gid_t
|
|
getngid(endpoint_t proc_ep)
|
|
{
|
|
gid_t gid;
|
|
int r;
|
|
|
|
if ((r = getepinfo(proc_ep, NULL, &gid)) < 0)
|
|
return (gid_t) r;
|
|
|
|
return gid;
|
|
}
|