getpeuid implementation. Get the uid of a process (by endpoint)

This commit is contained in:
Philip Homburg
2007-04-27 12:21:06 +00:00
parent 8eb09f6ddc
commit 69ca935251
7 changed files with 49 additions and 0 deletions
+3
View File
@@ -119,6 +119,9 @@ PUBLIC int main()
case GETPROCNR:
result= do_getprocnr();
break;
case GETPUID:
result= do_getpuid();
break;
default:
/* Else, if the system call number is valid, perform the
* call.
+30
View File
@@ -5,6 +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 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
@@ -358,6 +359,35 @@ PUBLIC int do_getprocnr()
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 *
*===========================================================================*/
+1
View File
@@ -68,6 +68,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_svrctl, (void) );
_PROTOTYPE( int do_allocmem, (void) );
_PROTOTYPE( int do_freemem, (void) );