From owner-freebsd-ports Mon Jul 1 08:02:38 1996 Return-Path: owner-ports Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id IAA02706 for ports-outgoing; Mon, 1 Jul 1996 08:02:38 -0700 (PDT) Received: from pumpkin.min.ntt.jp (root@pumpkin.min.ntt.jp [163.138.54.71]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id IAA02690 for ; Mon, 1 Jul 1996 08:02:33 -0700 (PDT) Received: from pumpkin.min.ntt.jp (ishizuka@localhost [127.0.0.1]) by pumpkin.min.ntt.jp (8.7.5/8.6.12) with ESMTP id AAA01326 for ; Tue, 2 Jul 1996 00:02:06 +0900 (JST) Message-Id: <199607011502.AAA01326@pumpkin.min.ntt.jp> To: ports@freebsd.org Subject: pidentd-2.7b3 Date: Tue, 02 Jul 1996 00:02:06 +0900 From: Masachika ISHIZUKA Sender: owner-ports@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi. The pident-2.7b3 (and early versions) for FreeBSD does not show a real ID. It shows an effective ID. I was fixed it. ---------------------------------------------------- % diff freebsd.c.orig freebsd.c 2c2 < ** kernel/other.c Low level kernel access functions for FreeBSD 2.x --- > ** kernel/freebsd.c Low level kernel access functions for FreeBSD 7c7,9 < ** Last update: 11 April 1995 - torstenb@FreeBSD.ORG --- > ** Last update: 18 Nov 1995 > ** > ** Please send bug fixes/bug reports to: Peter Eriksson 9a12 > #include 10a14,15 > #include > #include 11a17,18 > #include > #include 15a23,24 > #include > #include 16a26 > #include 20a31,32 > #include > 25,26d36 < #include < 29,30c39,47 < #include < #include --- > #ifndef BSD4_4 > # include > #else > # include > # define KINFO_PROC_ALL KERN_PROC_ALL > #endif > > #include > 31a49 > 33a52,58 > #include > #include > > #ifndef BSD4_4 > # include > #endif > 40c65 < --- > 45,47d69 < < #include < 52a75,76 > #include > 56,58d79 < #ifdef INPLOOKUP_SETLOCAL < #define _HAVE_OLD_INPCB < #endif 66c87 < #define N_FILE 0 --- > #define N_FILE 0 69c90 < --- > 76d96 < static kvm_t *kd; 79d98 < 82d100 < #ifdef _HAVE_OLD_INPCB 84,86c102 < #else < static struct inpcbhead tcb; < #endif --- > static kvm_t *kd = NULL; 93c109 < if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL))) --- > if ((kd = (kvm_t *)kvm_openfiles(path_unix, path_kmem, NULL, O_RDONLY, NULL)) == NULL) 99c115 < if (kvm_nlist(kd, nl) != 0) --- > if (kvm_nlist(kd, nl) < 0) 102d117 < 112,115c127,130 < long addr; < char *buf; < int len; < char *what; --- > long addr; > char *buf; > int len; > char *what; 117d131 < 119,122c133,139 < { < if (syslog_flag) < syslog(LOG_DEBUG,"getbuf: kvm_read(%08x, %d) - %s : %m", < addr, len, what); --- > { > if (syslog_flag) > syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m", > addr, len, what); > > return 0; > } 124,126d140 < return 0; < } < 130,131d143 < < 169c181 < { --- > { 172,174c184,186 < pcbp->inp_laddr.s_addr == laddr->s_addr && < pcbp->inp_fport == fport && < pcbp->inp_lport == lport ) --- > pcbp->inp_laddr.s_addr == laddr->s_addr && > pcbp->inp_fport == fport && > pcbp->inp_lport == lport ) 177,180c189,192 < getbuf((long) pcbp->inp_next, < pcbp, < sizeof(struct inpcb), < "tcblist")); --- > getbuf((long) pcbp->inp_next, > pcbp, > sizeof(struct inpcb), > "tcblist")); 185,187c197,199 < pcbp.inp_fport == fport && < pcbp.inp_lport == lport ) < return(pcbp.inp_socket); --- > pcbp.inp_fport == fport && > pcbp.inp_lport == lport ) > return(pcbp.inp_socket); 189c201 < } while (head != NULL); --- > } while (head != NULL); 195,196d206 < < 210,212c220,221 < struct ucred ucb; < < /* -------------------- FILE DESCRIPTOR TABLE -------------------- */ --- > struct kinfo_proc *kp; > int nentries; 214,218c223,227 < char *filebuf; < filebuf=kvm_getfiles(kd,KERN_FILE,0,&nfile); < if(filebuf==0) < ERROR("k_getuid: out of memory (file table)"); < xfile = (struct file *)(filebuf + sizeof (struct file *)); --- > if ((kp = kvm_getprocs(kd, KINFO_PROC_ALL, 0, &nentries)) == NULL) > { > ERROR("k_getuid: kvm_getprocs"); > return -1; > } 223c232 < --- > 228c237 < --- > 236c245 < for (i = 0; i < nfile; i++) --- > for (i = 0; i < nentries; i++) 238,242c247 < if (xfile[i].f_count == 0) < continue; < < if (xfile[i].f_type == DTYPE_SOCKET && < (struct socket *) xfile[i].f_data == sockp) --- > if(kp[i].kp_proc.p_fd != NULL) 244,247c249,289 < if (!getbuf(xfile[i].f_cred, &ucb, sizeof(ucb), "ucb")) < return -1; < < *uid = ucb.cr_uid; --- > int j; > struct filedesc pfd; > struct file **ofiles; > struct file ofile; > > if(!getbuf(kp[i].kp_proc.p_fd, &pfd, sizeof(pfd), "pfd")) > return(-1); > > ofiles = (struct file **) malloc(pfd.fd_nfiles * sizeof(struct file *)); > > if(!getbuf(pfd.fd_ofiles, ofiles, > pfd.fd_nfiles * sizeof(struct file *), "ofiles")) > { > free(ofiles); > return(-1); > } > > for(j = 0; j < pfd.fd_nfiles; j ++) > { > if(!getbuf(ofiles[j], &ofile, sizeof(struct file), "ofile")) > { > free(ofiles); > return(-1); > } > > if(ofile.f_count == 0) > continue; > > if(ofile.f_type == DTYPE_SOCKET && > (struct socket *) ofile.f_data == sockp) > { > struct pcred pc; > > if(!getbuf(kp[i].kp_proc.p_cred, &pc, sizeof(pc), "pcred")) > return(-1); > > *uid = pc.p_ruid; > free(ofiles); > return 0; > } > } 249c291 < return 0; --- > free(ofiles); 252c294 < --- >