#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
*/
_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) );
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,
_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) );
getlogin.c \
getpagesize.c \
getpass.c \
- getpeuid.c \
getpwent.c \
getttyent.c \
getw.c \
#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 */
}
#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);
}
#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 */
}
+++ /dev/null
-#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);
-}
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:
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
* 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
}
/*===========================================================================*
- * do_getpuid *
+ * do_getepinfo *
*===========================================================================*/
-PUBLIC int do_getpuid()
+PUBLIC int do_getepinfo()
{
register struct mproc *rmp;
endpoint_t ep;
/* 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;
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);
}
/*===========================================================================*
_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) );
}
/* 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",