From the ps man page:
ruid The user ID number of the real process owner.
uid The user ID number of the effective process owner.
Note, to use some of the options, you have to set UNIX95=1 in your
environment.
Rich
krish <tkri...@baan.com> writes:
>-=-=-=-=-=-
>-=-=-=-=-=-
>
>begin: vcard
>fn: T Krishnanand
>n: Krishnanand;T
>org: Baan Info Systems India Pvt. Ltd.
>adr: 8-2-120/112 , Block A, Palace View Estate;;Road No.2 , Banajara Hills;Hyderabad;Andhra
>Pradesh;500033;India
>email;internet: tkri...@baan.com
>title: Junior DBA
>tel;work: +91-40-3600002
>tel;fax: +91-40-217366
>tel;home: +91-40-290903
>x-mozilla-cpt: www.ils.baan.com;2
>x-mozilla-html: TRUE
>version: 2.1
>end: vcard
>
>
>-=-=-=-=-=-
--
Rich Rauenzahn ----------...@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| not HP | MS 46TU2
IASD / Enterprise Systems Group +--------------+---- Cupertino, CA 95014
Well, being the hacker I am here is one method. This is the method
that comes to mind most quickly, but there is probably an easy command
line way somehow-- I am just not thinking of it right now. I am more
familiar with the system header files, etc. than I am with all the little
command line args to obscure commands. Anyway, I find that this way is more
interesting. :-)
Enjoy!
============================================================================
/*
** Use pstat to determine the effective & real UID
** as well as the effective GID for a process.
** This program does _no_ error checking, but it is
** a good example of the pstat interface (hopefully!).
**
** L. Spells, 3/17/98
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/pstat.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
struct pst_status pst;
pid_t pid=0;
int count=0;
/* Assume pid to check is passed in as first arg...*/
pid=(pid_t) atoi(argv[1]);
/* Get information about a particular pid-- this is a bit
** strange, but you can set the third parameter (elemcount)
** to 0 and set the last parameter (index) to the pid you
** want information about and it will fill in info for that
** process only. This same call, with different parms can
** get you the info for all executing processes on the system.
*/
count = pstat_getproc(&pst, sizeof(struct pst_status), 0, pid);
switch (count)
{
case -1: perror("pstat_getproc()");
break;
case 0 : fprintf(stderr,"No such pid: %d\n",pid);
break;
default: /* Now that you have the uid values, you could use
** a call to getpwuid to get the password structure
** so that you could print out the user name here,
** but I am not going into that in this example.
*/
fprintf(stdout,"EUID = %ld RUID = %ld EGID = %ld\n",
pst.pst_euid, pst.pst_uid, pst.pst_egid);
break;
}
return(0);
}
============================================================================
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading