Subject: magic symlinks: uid keyword translation
To: None <tech-kern@NetBSD.org>
From: Elad Efrat <elad@NetBSD.org>
List: tech-kern
Date: 10/30/2006 14:50:14
This is a multi-part message in MIME format.
--Boundary_(ID_XvgXoxKWxDWWG3j3UYg6Rw)
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
hi,
attached diff adds a "uid" keyword translation for magic symlinks.
any objections?
-e.
--
Elad Efrat
--Boundary_(ID_XvgXoxKWxDWWG3j3UYg6Rw)
Content-type: text/plain; name=vfs_lookup.c.diff
Content-transfer-encoding: 7BIT
Content-disposition: inline; filename=vfs_lookup.c.diff
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)
--Boundary_(ID_XvgXoxKWxDWWG3j3UYg6Rw)--