Subject: Re: magic symlinks: uid keyword translation
To: Elad Efrat <elad@NetBSD.org>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 10/30/2006 19:33:00
Hi,

On Mon, Oct 30, 2006 at 02:50:14PM +0200, Elad Efrat wrote:

> Index: vfs_lookup.c
> ===================================================================
> RCS file: /cvsroot/src/sys/kern/vfs_lookup.c,v
> retrieving revision 1.71
> diff -u -p -r1.71 vfs_lookup.c
> --- vfs_lookup.c	23 Jul 2006 22:06:12 -0000	1.71
> +++ vfs_lookup.c	30 Oct 2006 01:36:19 -0000
> @@ -163,6 +163,12 @@ symlink_magic(struct proc *p, char *cp, 
>  		} else if (MATCH("ostype")) {
>  			SUBSTITUTE("ostype", ostype,
>  			    strlen(ostype));
> +		} else if (MATCH("uid")) {
> +			char uidtmp[16];
> +
> +			(void)snprintf(uidtmp, sizeof(uidtmp) - 1, "%u",
> +			    kauth_cred_getuid(p->p_cred));

p->p_cred shouldn't be used in this context. You should use one of
cnp->cn_cred or kauth_cred_get(). I'm not sure which is appropriate
here.

Thanks,
Andrew