Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to see euid & ruid

185 views
Skip to first unread message

krish

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to
Hello ,


HP -UX 10.20

How can I come to know the euid and ruid of a given process.
Only one of them is reported by the ps command switches.


Thanks

vcard.vcf

Richard J. Rauenzahn

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to

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

lsp...@mindspring.com

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to

In article <350CE22D...@baan.com>,
krish <tkri...@baan.com> wrote:
>
> This is a multi-part message in MIME format.
> --------------8DBB8E222B9B7BEC1AABF892
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

>
> Hello ,
>
> HP -UX 10.20
>
> How can I come to know the euid and ruid of a given process.
> Only one of them is reported by the ps command switches.
>
> Thanks

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

0 new messages