From owner-freebsd-questions@FreeBSD.ORG Thu Mar 18 00:12:36 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B8B5016A4CE for ; Thu, 18 Mar 2004 00:12:36 -0800 (PST) Received: from priv-edtnes51.telusplanet.net (outbound04.telus.net [199.185.220.223]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6931043D41 for ; Thu, 18 Mar 2004 00:12:36 -0800 (PST) (envelope-from cpressey@catseye.mine.nu) Received: from catseye.biscuit.boo ([154.5.85.228]) by priv-edtnes51.telusplanet.netSMTP <20040318081236.KAA26906.priv-edtnes51.telusplanet.net@catseye.biscuit.boo>; Thu, 18 Mar 2004 01:12:36 -0700 Date: Thu, 18 Mar 2004 00:18:02 -0800 From: Chris Pressey To: Simon Timms Message-Id: <20040318001802.51ccb1bf.cpressey@catseye.mine.nu> In-Reply-To: <000401c40be6$705c5760$0c00a8c0@simmain> References: <000401c40be6$705c5760$0c00a8c0@simmain> Organization: Cat's Eye Technologies X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i386-portbld-freebsd4.9) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: KLD and UID X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2004 08:12:36 -0000 On Tue, 16 Mar 2004 23:09:36 -0700 Simon Timms wrote: > Hi there, I am playing around with kernel modules trying to learn > something and hopefully not destroy my computer too badly. Right now > my goal is to print out the user id from an open() call. I am basing > my work around that found at http://www.nux-acid.org/src/open.c. To > that basic code I added (in the new_open method) > > printf("uid %u\n", p->p_ucred->cr_uid); > > However this completely doesn't work and I end up crashing the kernel. > I notice in other places people do things like > > uid_t uid = p->p_cred->p_svuid; > > however I don't see a p_cred member in the proc structure. Is there > something obvious I am missing here? Complete code listing at > http://simon.ma.cx/module.c. Any additional comments/criticisms > always appreciated. > > Thanks, Simon What version of FreeBSD are you trying this on? You might want to look at this thread on hackers@, it's very similar to what you're trying to do, I think: http://docs.freebsd.org/cgi/mid.cgi?20040316163956.GD638 -Chris