Path: utzoo!utgpu!cunews!bnrgate!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request From: dupuy@cs.columbia.edu Newsgroups: comp.sys.sun Subject: How to find the real uid/gid of a process? Keywords: No Digest Subjects in Unmoderated Mode Message-ID: <3647@brchh104.bnr.ca> Date: 5 Jun 91 14:17:00 GMT Sender: news@brchh104.bnr.ca Organization: Sunspots, Pseudo-Unmoderated Lines: 24 Approved: sun-spots@rice.edu X-Original-Date: Wed, 29 May 91 23:13:17 EDT > I would like to determine the real uid and gid of each process, but can't > seem to access them from each struct proc returned by kvm_nextproc(); > > Assuming: > struct proc theproc; > > when I attempt to access theproc->p_cred I get a Memory Fault, and when I > access it as root I get a Segv. This is because theproc->p_cred is a pointer which is valid in the kernel's address space - not in your process's address space. You should use kvm_read to get the data: kvm_t kmem = kvm_open(NULL, NULL, NULL, O_RDONLY, argv[0]) struct proc *theproc = kvm_nextproc(kmem); struct ucred *cred = malloc (sizeof struct ucred); kvm_read(kmem, theproc->p_cred, cred, sizeof struct ucred); theproc->p_cred = cred; @alex -- inet: dupuy@cs.columbia.edu