#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 DEVCTL 120 /* to FS, map or unmap a device */
#define TASK_REPLY 121 /* to FS: reply code from drivers, not
#define unmapdriver(device) devctl(DEV_UNMAP, 0, device, 0)
_PROTOTYPE( int devctl, (int ctl_req, int driver, int device, int style,
int force) );
+_PROTOTYPE( uid_t getpeuid, (endpoint_t ep) );
/* For compatibility with other Unix systems */
_PROTOTYPE( int getpagesize, (void) );
getlogin.c \
getpagesize.c \
getpass.c \
+ getpeuid.c \
getpwent.c \
getttyent.c \
getw.c \
--- /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 GETPROCNR:
result= do_getprocnr();
break;
+ case GETPUID:
+ result= do_getpuid();
+ break;
default:
/* Else, if the system call number is valid, perform the
* call.
* 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 it's 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
return(OK);
}
+/*===========================================================================*
+ * do_getpuid *
+ *===========================================================================*/
+PUBLIC int do_getpuid()
+{
+ 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",
+ mp->mp_endpoint);
+ return EPERM;
+ }
+
+ ep= m_in.endpt;
+
+ 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);
+ }
+ }
+
+ /* Process not found */
+ return(ESRCH);
+}
+
/*===========================================================================*
* do_reboot *
*===========================================================================*/
_PROTOTYPE( int do_getsysinfo, (void) );
_PROTOTYPE( int do_getsysinfo_up, (void) );
_PROTOTYPE( int do_getprocnr, (void) );
+_PROTOTYPE( int do_getpuid, (void) );
_PROTOTYPE( int do_svrctl, (void) );
_PROTOTYPE( int do_allocmem, (void) );
_PROTOTYPE( int do_freemem, (void) );