Subject: Re: magic symlinks: uid keyword translation
To: Quentin Garnier <cube@cubidou.net>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 10/30/2006 14:54:38
On Oct 30, 2006, at 6:22 AM, 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?
>
> s/16/LOGIN_NAME_MAX/
Why? We're talking about the ASCII representation of a number,
here... not a login name.
>
>> 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));
>> + SUBSTITUTE("uid", uidtmp, strlen(uidtmp));
>> } else {
>> tmp[newlen++] = '@';
>> if (termchar == VC)
>
>
> --
> 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.
-- thorpej