PM: clean up endpoint info API/ABI
This commit is contained in:
parent
403764c538
commit
4c263d6002
@ -97,7 +97,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
#define FREEMEM 106 /* to PM, not used, not implemented */
|
#define FREEMEM 106 /* to PM, not used, not implemented */
|
||||||
#endif
|
#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
|
#define ADDDMA 108 /* to PM: inform PM about a region of memory
|
||||||
* that is used for bus-master DMA
|
* that is used for bus-master DMA
|
||||||
*/
|
*/
|
||||||
|
@ -121,9 +121,6 @@ _PROTOTYPE( int getgroups, (int _gidsetsize, gid_t _grouplist[]) );
|
|||||||
_PROTOTYPE( char *getlogin, (void) );
|
_PROTOTYPE( char *getlogin, (void) );
|
||||||
_PROTOTYPE( pid_t getpgrp, (void) );
|
_PROTOTYPE( pid_t getpgrp, (void) );
|
||||||
_PROTOTYPE( pid_t getpid, (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( pid_t getppid, (void) );
|
||||||
_PROTOTYPE( uid_t getuid, (void) );
|
_PROTOTYPE( uid_t getuid, (void) );
|
||||||
_PROTOTYPE( int isatty, (int _fd) );
|
_PROTOTYPE( int isatty, (int _fd) );
|
||||||
@ -201,7 +198,6 @@ _PROTOTYPE( int devctl, (int ctl_req, int driver, int device, int style,
|
|||||||
int force) );
|
int force) );
|
||||||
_PROTOTYPE( int mapdriver5, (char *label, size_t len, int major,
|
_PROTOTYPE( int mapdriver5, (char *label, size_t len, int major,
|
||||||
int style, int force) );
|
int style, int force) );
|
||||||
_PROTOTYPE( uid_t getpeuid, (endpoint_t ep) );
|
|
||||||
_PROTOTYPE(int adddma, (endpoint_t proc_e,
|
_PROTOTYPE(int adddma, (endpoint_t proc_e,
|
||||||
phys_bytes start, phys_bytes size) );
|
phys_bytes start, phys_bytes size) );
|
||||||
_PROTOTYPE(int deldma, (endpoint_t proc_e,
|
_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,
|
_PROTOTYPE(int getdma, (endpoint_t *procp, phys_bytes *basep,
|
||||||
phys_bytes *sizep) );
|
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 */
|
/* For compatibility with other Unix systems */
|
||||||
_PROTOTYPE( int getpagesize, (void) );
|
_PROTOTYPE( int getpagesize, (void) );
|
||||||
_PROTOTYPE( int setgroups, (int ngroups, const gid_t *gidset) );
|
_PROTOTYPE( int setgroups, (int ngroups, const gid_t *gidset) );
|
||||||
|
@ -54,7 +54,6 @@ libc_FILES=" \
|
|||||||
getlogin.c \
|
getlogin.c \
|
||||||
getpagesize.c \
|
getpagesize.c \
|
||||||
getpass.c \
|
getpass.c \
|
||||||
getpeuid.c \
|
|
||||||
getpwent.c \
|
getpwent.c \
|
||||||
getttyent.c \
|
getttyent.c \
|
||||||
getw.c \
|
getw.c \
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#define getngid _getngid
|
#define getngid _getngid
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
PUBLIC gid_t getngid(int proc_nr)
|
PUBLIC gid_t getngid(endpoint_t proc_ep)
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
m.m1_i1 = proc_nr; /* search gid for this process */
|
m.m1_i1 = proc_ep; /* search gid for this process */
|
||||||
if (_syscall(MM, GETGID, &m) < 0) return ( (gid_t) -1);
|
if (_syscall(MM, GETEPINFO, &m) < 0) return ( (gid_t) -1);
|
||||||
return( (gid_t) m.m2_i2); /* return search result */
|
return( (gid_t) m.m2_i2); /* return search result */
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
#define getnpid _getnpid
|
#define getnpid _getnpid
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
PUBLIC pid_t getnpid(int proc_nr)
|
PUBLIC pid_t getnpid(endpoint_t proc_ep)
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
m.m1_i1 = proc_nr; /* search pid for this process */
|
m.m1_i1 = proc_ep; /* search pid for this process */
|
||||||
if (_syscall(MM, MINIX_GETPID, &m) < 0) return ( (pid_t) -1);
|
return _syscall(MM, GETEPINFO, &m);
|
||||||
return( (pid_t) m.m2_i2); /* return search result */
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#define getnuid _getnuid
|
#define getnuid _getnuid
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
PUBLIC uid_t getnuid(int proc_nr)
|
PUBLIC uid_t getnuid(endpoint_t proc_ep)
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
m.m1_i1 = proc_nr; /* search uid for this process */
|
m.m1_i1 = proc_ep; /* search uid for this process */
|
||||||
if (_syscall(MM, GETUID, &m) < 0) return ( (uid_t) -1);
|
if (_syscall(MM, GETEPINFO, &m) < 0) return ( (uid_t) -1);
|
||||||
return( (uid_t) m.m2_i2); /* return search result */
|
return( (uid_t) m.m2_i1); /* return search result */
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -27,22 +27,16 @@ PUBLIC int do_get()
|
|||||||
case GETUID:
|
case GETUID:
|
||||||
r = rmp->mp_realuid;
|
r = rmp->mp_realuid;
|
||||||
rmp->mp_reply.reply_res2 = rmp->mp_effuid;
|
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;
|
break;
|
||||||
|
|
||||||
case GETGID:
|
case GETGID:
|
||||||
r = rmp->mp_realgid;
|
r = rmp->mp_realgid;
|
||||||
rmp->mp_reply.reply_res2 = rmp->mp_effgid;
|
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;
|
break;
|
||||||
|
|
||||||
case MINIX_GETPID:
|
case MINIX_GETPID:
|
||||||
r = mproc[who_p].mp_pid;
|
r = mproc[who_p].mp_pid;
|
||||||
rmp->mp_reply.reply_res2 = mproc[rmp->mp_parent].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;
|
break;
|
||||||
|
|
||||||
case GETPGRP:
|
case GETPGRP:
|
||||||
|
@ -128,8 +128,8 @@ PUBLIC int main()
|
|||||||
case GETPROCNR:
|
case GETPROCNR:
|
||||||
result= do_getprocnr();
|
result= do_getprocnr();
|
||||||
break;
|
break;
|
||||||
case GETPUID:
|
case GETEPINFO:
|
||||||
result= do_getpuid();
|
result= do_getepinfo();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Else, if the system call number is valid, perform the
|
/* Else, if the system call number is valid, perform the
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* do_procstat: request process status (Jorrit N. Herder)
|
* do_procstat: request process status (Jorrit N. Herder)
|
||||||
* do_getsysinfo: request copy of PM data structure (Jorrit N. Herder)
|
* do_getsysinfo: request copy of PM data structure (Jorrit N. Herder)
|
||||||
* do_getprocnr: lookup process slot number (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_allocmem: allocate a chunk of memory (Jorrit N. Herder)
|
||||||
* do_freemem: deallocate a chunk of memory (Jorrit N. Herder)
|
* do_freemem: deallocate a chunk of memory (Jorrit N. Herder)
|
||||||
* do_getsetpriority: get/set process priority
|
* 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;
|
register struct mproc *rmp;
|
||||||
endpoint_t ep;
|
endpoint_t ep;
|
||||||
@ -370,7 +370,7 @@ PUBLIC int do_getpuid()
|
|||||||
/* This call should be moved to DS. */
|
/* This call should be moved to DS. */
|
||||||
if (mp->mp_effuid != 0)
|
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);
|
mp->mp_endpoint);
|
||||||
sys_sysctl_stacktrace(mp->mp_endpoint);
|
sys_sysctl_stacktrace(mp->mp_endpoint);
|
||||||
return EPERM;
|
return EPERM;
|
||||||
@ -381,7 +381,8 @@ PUBLIC int do_getpuid()
|
|||||||
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
||||||
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
|
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
|
||||||
mp->mp_reply.reply_res2 = rmp->mp_effuid;
|
mp->mp_reply.reply_res2 = rmp->mp_effuid;
|
||||||
return(rmp->mp_realuid);
|
mp->mp_reply.reply_res3 = rmp->mp_effgid;
|
||||||
|
return(rmp->mp_pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ _PROTOTYPE( int do_sysuname, (void) );
|
|||||||
_PROTOTYPE( int do_getsysinfo, (void) );
|
_PROTOTYPE( int do_getsysinfo, (void) );
|
||||||
_PROTOTYPE( int do_getsysinfo_up, (void) );
|
_PROTOTYPE( int do_getsysinfo_up, (void) );
|
||||||
_PROTOTYPE( int do_getprocnr, (void) );
|
_PROTOTYPE( int do_getprocnr, (void) );
|
||||||
_PROTOTYPE( int do_getpuid, (void) );
|
_PROTOTYPE( int do_getepinfo, (void) );
|
||||||
_PROTOTYPE( int do_svrctl, (void) );
|
_PROTOTYPE( int do_svrctl, (void) );
|
||||||
_PROTOTYPE( int do_allocmem, (void) );
|
_PROTOTYPE( int do_allocmem, (void) );
|
||||||
_PROTOTYPE( int do_freemem, (void) );
|
_PROTOTYPE( int do_freemem, (void) );
|
||||||
|
@ -92,7 +92,7 @@ PUBLIC int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Only root can make calls to rs. unless it's RS_LOOKUP. */
|
/* 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)
|
if (euid != 0 && call_nr != RS_LOOKUP)
|
||||||
{
|
{
|
||||||
printf("RS: got unauthorized request %d from endpoint %d\n",
|
printf("RS: got unauthorized request %d from endpoint %d\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user