Subject: Re: magic symlinks: uid keyword translation
To: Elad Efrat <elad@NetBSD.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 10/30/2006 15:22:27
--ny1v8xcV31BR+sbv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Oct 30, 2006 at 02:50:14PM +0200, Elad Efrat wrote:
> hi,
>=20
> attached diff adds a "uid" keyword translation for magic symlinks.
>=20
> any objections?

s/16/LOGIN_NAME_MAX/

> Index: vfs_lookup.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> 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,=20
>  		} 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));
> +			SUBSTITUTE("uid", uidtmp, strlen(uidtmp));
>  		} else {
>  			tmp[newlen++] =3D '@';
>  			if (termchar =3D=3D VC)


--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"You could have made it, spitting out benchmarks
Owe it to yourself not to fail"
Amplifico, Spitting Out Benchmarks, Hometakes Vol. 2, 2005.

--ny1v8xcV31BR+sbv
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (NetBSD)

iQEVAwUBRUYKo9goQloHrPnoAQIASAgAhNz1Y27RNNVHrXT5tduqYEX16Z7LlAq+
pVLN/zf8QcXqn4rej38bINK6sgTfL5rfmAXhHeyrhrM/e6cYoCkTGXeBfyeW0SVR
vgefef7k/Eb3MAhR0PTRI1KxqW0bTtFvHJxAkYm/ZrIkr21SIKcxpVhDvypxu4eq
GVTgX2iivD5DJeBrfLTjM8r2ZeYr4tI9QnzfCC47KL9yf/dJB8SwUxLzMVhjnSWq
oXSLXC4YzmsDo1YFsVKpeRtS6aOAGTpI7d5KFFaGn64smxbKNwGM04b5e1z0ts4d
/ObLoWghLidCDbUP8cvVYhXUjEV2mTlJDmuWXLA2z8MWVtYEkW0WOg==
=Zx2W
-----END PGP SIGNATURE-----

--ny1v8xcV31BR+sbv--