PERFORCE change 168397 for review

Marko Zec zec at FreeBSD.org
Thu Sep 10 11:09:36 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=168397

Change 168397 by zec at zec_nxlab on 2009/09/10 11:08:39

	When expading '@' to jail names in symlinks, substitute '.'
	with '/' in case of hierarchichal jails / vimages.
	
	This change is unlikely to ever get commited to svn.

Affected files ...

.. //depot/projects/vimage/src/sys/kern/vfs_lookup.c#30 edit

Differences ...

==== //depot/projects/vimage/src/sys/kern/vfs_lookup.c#30 (text+ko) ====

@@ -349,12 +349,24 @@
 			break;
 		}
 #ifdef IMUNES_SYMLINK_HACK
+		/*
+		 * If the symbolic link includes a special character '@',
+		 * and V_morphing_symlinks is set, substitute the first
+		 * occurence of '@' with full path to jail / vimage name.
+		 * If the full path includes subhierarchies, s/./\// when
+		 * expanding '@' to jail / vimage name.
+		 *
+		 * XXX revisit buffer length checking.
+		 */
 		CURVNET_SET(TD_TO_VNET(curthread));
 		if (V_morphing_symlinks) {
 			char *sp = strchr(cp, '@');
-			int vnamelen = strlen(td->td_ucred->cr_prison->pr_name);
 
 			if (sp) {
+				char *vname = td->td_ucred->cr_prison->pr_name;
+				int vnamelen = strlen(vname);
+				int i;
+
 				if (vnamelen >= auio.uio_resid) {
 					if (ndp->ni_pathlen > 1)
 						uma_zfree(namei_zone, cp);
@@ -367,6 +379,9 @@
 				bcopy(td->td_ucred->cr_prison->pr_name,
 				    sp, vnamelen);
 				linklen += (vnamelen - 1);
+				for (i = 0; i < vnamelen; i++)
+					if (sp[i] == '.')
+						sp[i] = '/';
 			}
 		}
 		CURVNET_RESTORE();


More information about the p4-projects mailing list