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 16:07:48
--sPkBZsy7C+1fV4MN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Oct 30, 2006 at 04:57:51PM +0200, Elad Efrat wrote:
> Quentin Garnier wrote:
> > On Mon, Oct 30, 2006 at 02:50:14PM +0200, Elad Efrat wrote:
> >> hi,
> >>
> >> attached diff adds a "uid" keyword translation for magic symlinks.
> >>
> >> any objections?
> >=20
> > s/16/LOGIN_NAME_MAX/
>=20
> why?

1. raw numbers like this are wrong.
2. the best example of 1. is that LOGIN_NAME_MAX is 17.
3. someone might wish to run a system with a different LOGIN_NAME_MAX,
   for whatever reason (although it's not recommended, and not made
   easy either).

> >=20
> >> 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
> >=20
>=20
>=20
> --=20
> Elad Efrat

--=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.

--sPkBZsy7C+1fV4MN
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iQEVAwUBRUYVRNgoQloHrPnoAQK3lQf/bwUdi30SmBv+tpzGxMvd3P+kXmpfvpa4
zkQ0n52Fmh6OAFZtfz9ztvtu5MTVSuWDmHFyIq/MoJsDjjWyqytQ0mTZyaCWoavH
3Y2BCZLDXzpxll9lW5YQBK/0D/yyQH6EwL87MOA/W8lhGLx3YMtmCinHUkfkOqIB
xoyWZ2wfOZGTlIP9LDbqgzijJAn3PxM1fil8CllEyXeOHcPG2Q64MS4G/OOWz9wu
/NZJKBldyD69qYvVHSkyZ09sfU2csoXXGZ9IFYwPLVuROEgUzSVOTpiyMAV+8O2g
PO/wkiJxQHqgcAox0OvZ3Cn7MP+SUA0pdhzMC0zX78dyPNPYagiWyg==
=VQ/I
-----END PGP SIGNATURE-----

--sPkBZsy7C+1fV4MN--