PM: clean up endpoint info API/ABI

This commit is contained in:
David van Moolenbroek 2009-10-31 14:09:28 +00:00
parent 403764c538
commit 4c263d6002
12 changed files with 26 additions and 45 deletions

View file

@ -97,7 +97,7 @@
#if 0
#define FREEMEM 106 /* to PM, not used, not implemented */
#endif
#define GETPUID 107 /* to PM: get the uid of a process (endpoint) */
#define GETEPINFO 107 /* to PM: get pid/uid/gid of an endpoint */
#define ADDDMA 108 /* to PM: inform PM about a region of memory
* that is used for bus-master DMA
*/

View file

@ -121,9 +121,6 @@ _PROTOTYPE( int getgroups, (int _gidsetsize, gid_t _grouplist[]) );
_PROTOTYPE( char *getlogin, (void) );
_PROTOTYPE( pid_t getpgrp, (void) );
_PROTOTYPE( pid_t getpid, (void) );
_PROTOTYPE( pid_t getnpid, (int proc_nr) );
_PROTOTYPE( uid_t getnuid, (int proc_nr) );
_PROTOTYPE( gid_t getngid, (int proc_nr) );
_PROTOTYPE( pid_t getppid, (void) );
_PROTOTYPE( uid_t getuid, (void) );
_PROTOTYPE( int isatty, (int _fd) );
@ -201,7 +198,6 @@ _PROTOTYPE( int devctl, (int ctl_req, int driver, int device, int style,
int force) );
_PROTOTYPE( int mapdriver5, (char *label, size_t len, int major,
int style, int force) );
_PROTOTYPE( uid_t getpeuid, (endpoint_t ep) );
_PROTOTYPE(int adddma, (endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE(int deldma, (endpoint_t proc_e,
@ -209,6 +205,10 @@ _PROTOTYPE(int deldma, (endpoint_t proc_e,
_PROTOTYPE(int getdma, (endpoint_t *procp, phys_bytes *basep,
phys_bytes *sizep) );
_PROTOTYPE( pid_t getnpid, (endpoint_t proc_ep) );
_PROTOTYPE( uid_t getnuid, (endpoint_t proc_ep) );
_PROTOTYPE( gid_t getngid, (endpoint_t proc_ep) );
/* For compatibility with other Unix systems */
_PROTOTYPE( int getpagesize, (void) );
_PROTOTYPE( int setgroups, (int ngroups, const gid_t *gidset) );

View file

@ -54,7 +54,6 @@ libc_FILES=" \
getlogin.c \
getpagesize.c \
getpass.c \
getpeuid.c \
getpwent.c \
getttyent.c \
getw.c \

View file

@ -2,10 +2,10 @@
#define getngid _getngid
#include <unistd.h>
PUBLIC gid_t getngid(int proc_nr)
PUBLIC gid_t getngid(endpoint_t proc_ep)
{
message m;
m.m1_i1 = proc_nr; /* search gid for this process */
if (_syscall(MM, GETGID, &m) < 0) return ( (gid_t) -1);
m.m1_i1 = proc_ep; /* search gid for this process */
if (_syscall(MM, GETEPINFO, &m) < 0) return ( (gid_t) -1);
return( (gid_t) m.m2_i2); /* return search result */
}

View file

@ -2,10 +2,9 @@
#define getnpid _getnpid
#include <unistd.h>
PUBLIC pid_t getnpid(int proc_nr)
PUBLIC pid_t getnpid(endpoint_t proc_ep)
{
message m;
m.m1_i1 = proc_nr; /* search pid for this process */
if (_syscall(MM, MINIX_GETPID, &m) < 0) return ( (pid_t) -1);
return( (pid_t) m.m2_i2); /* return search result */
m.m1_i1 = proc_ep; /* search pid for this process */
return _syscall(MM, GETEPINFO, &m);
}

View file

@ -2,10 +2,10 @@
#define getnuid _getnuid
#include <unistd.h>
PUBLIC uid_t getnuid(int proc_nr)
PUBLIC uid_t getnuid(endpoint_t proc_ep)
{
message m;
m.m1_i1 = proc_nr; /* search uid for this process */
if (_syscall(MM, GETUID, &m) < 0) return ( (uid_t) -1);
return( (uid_t) m.m2_i2); /* return search result */
m.m1_i1 = proc_ep; /* search uid for this process */
if (_syscall(MM, GETEPINFO, &m) < 0) return ( (uid_t) -1);
return( (uid_t) m.m2_i1); /* return search result */
}

View file

@ -1,12 +0,0 @@
#include <lib.h>
#include <unistd.h>
PUBLIC uid_t getpeuid(ep)
endpoint_t ep;
{
message m;
m.m1_i1= ep;
if (_syscall(MM, GETPUID, &m) < 0) return ( (uid_t) -1);
return( (uid_t) m.m2_i1);
}

View file

@ -27,22 +27,16 @@ PUBLIC int do_get()
case GETUID:
r = rmp->mp_realuid;
rmp->mp_reply.reply_res2 = rmp->mp_effuid;
if (pm_isokendpt(m_in.PM_ENDPT, &proc) == OK && proc >= 0)
rmp->mp_reply.reply_res3 = mproc[proc].mp_effuid;
break;
case GETGID:
r = rmp->mp_realgid;
rmp->mp_reply.reply_res2 = rmp->mp_effgid;
if (pm_isokendpt(m_in.PM_ENDPT, &proc) == OK && proc >= 0)
rmp->mp_reply.reply_res3 = mproc[proc].mp_effgid;
break;
case MINIX_GETPID:
r = mproc[who_p].mp_pid;
rmp->mp_reply.reply_res2 = mproc[rmp->mp_parent].mp_pid;
if(pm_isokendpt(m_in.PM_ENDPT, &proc) == OK && proc >= 0)
rmp->mp_reply.reply_res3 = mproc[proc].mp_pid;
break;
case GETPGRP:

View file

@ -128,8 +128,8 @@ PUBLIC int main()
case GETPROCNR:
result= do_getprocnr();
break;
case GETPUID:
result= do_getpuid();
case GETEPINFO:
result= do_getepinfo();
break;
default:
/* Else, if the system call number is valid, perform the

View file

@ -5,7 +5,7 @@
* do_procstat: request process status (Jorrit N. Herder)
* do_getsysinfo: request copy of PM data structure (Jorrit N. Herder)
* do_getprocnr: lookup process slot number (Jorrit N. Herder)
* do_getpuid: get the uid/euid of a process given its endpoint
* do_getepinfo: get the pid/uid/gid of a process given its endpoint
* do_allocmem: allocate a chunk of memory (Jorrit N. Herder)
* do_freemem: deallocate a chunk of memory (Jorrit N. Herder)
* do_getsetpriority: get/set process priority
@ -360,9 +360,9 @@ PUBLIC int do_getprocnr()
}
/*===========================================================================*
* do_getpuid *
* do_getepinfo *
*===========================================================================*/
PUBLIC int do_getpuid()
PUBLIC int do_getepinfo()
{
register struct mproc *rmp;
endpoint_t ep;
@ -370,7 +370,7 @@ PUBLIC int do_getpuid()
/* This call should be moved to DS. */
if (mp->mp_effuid != 0)
{
printf("PM: unauthorized call of do_getpuid by proc %d\n",
printf("PM: unauthorized call of do_getepinfo by proc %d\n",
mp->mp_endpoint);
sys_sysctl_stacktrace(mp->mp_endpoint);
return EPERM;
@ -381,12 +381,13 @@ PUBLIC int do_getpuid()
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
mp->mp_reply.reply_res2 = rmp->mp_effuid;
return(rmp->mp_realuid);
mp->mp_reply.reply_res3 = rmp->mp_effgid;
return(rmp->mp_pid);
}
}
/* Process not found */
return(ESRCH);
return(ESRCH);
}
/*===========================================================================*

View file

@ -52,7 +52,7 @@ _PROTOTYPE( int do_sysuname, (void) );
_PROTOTYPE( int do_getsysinfo, (void) );
_PROTOTYPE( int do_getsysinfo_up, (void) );
_PROTOTYPE( int do_getprocnr, (void) );
_PROTOTYPE( int do_getpuid, (void) );
_PROTOTYPE( int do_getepinfo, (void) );
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_allocmem, (void) );
_PROTOTYPE( int do_freemem, (void) );

View file

@ -92,7 +92,7 @@ PUBLIC int main(void)
}
/* Only root can make calls to rs. unless it's RS_LOOKUP. */
euid= getpeuid(m.m_source);
euid= getnuid(m.m_source);
if (euid != 0 && call_nr != RS_LOOKUP)
{
printf("RS: got unauthorized request %d from endpoint %d\n",