[PVFS-developers] Symlink Bug

Porter Don PorterDE@mercury.hendrix.edu
Thu, 20 Nov 2003 17:14:40 -0600


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C3AFBC.133A5BD0
Content-Type: text/plain


I started testing 1.6.1 and I found that if you delete a symlink, the file
is actually deleted from the iod.  Clearly this is not the desired
behaviour.  Attached is a patch that fixes this.  

Basically, in md_unlink there is some permission checking, but then the file
is not actually unlinked nor does the function return.  Instead, it defaults
to the case where the file isn't a symlink and the file is deleted, both
from manager and iod.  With this patch, after the permission checking if one
has write access then the file is actually unlinked and the function returns
in either case.

Thanks,
Don


------_=_NextPart_000_01C3AFBC.133A5BD0
Content-Type: application/octet-stream;
	name="symlink-unlink.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="symlink-unlink.patch"

diff -ur pvfs-1.6.1/mgr/meta/md_unlink.c =
pvfs-1.6.1-dev/mgr/meta/md_unlink.c=0A=
--- pvfs-1.6.1/mgr/meta/md_unlink.c	Wed Nov 12 08:09:20 2003=0A=
+++ pvfs-1.6.1-dev/mgr/meta/md_unlink.c	Thu Nov 20 16:52:45 2003=0A=
@@ -58,18 +58,19 @@=0A=
 =0A=
 		if (length >=3D 0) {=0A=
 			/* check for permissions to write to directory */=0A=
-			daccess_ok =3D meta_access(0, temp, request->uid, request->gid, =
W_OK);=0A=
-		}=0A=
-		else {=0A=
-			/*=0A=
-			 * if length<0, CWD is being used and directory permissions will =
=0A=
-			 * not be checked pursuant to the UNIX method =0A=
-			 *=0A=
-			 * just remove the link.=0A=
-			 */=0A=
-			return unlink(fname);=0A=
+			if((daccess_ok =3D meta_access(0, temp, request->uid, request->gid, =
W_OK)) < 0){=0A=
+				return daccess_ok;=0A=
+			}=0A=
 		}=0A=
+		/*=0A=
+		 * if length<0, CWD is being used and directory permissions will =0A=
+		 * not be checked pursuant to the UNIX method =0A=
+		 *=0A=
+		 * if we have access, we will also remove the link.=0A=
+		 */=0A=
+		return unlink(fname);=0A=
 	}=0A=
+=0A=
 	if (is_link) *is_link =3D 0;=0A=
 =0A=
    if ((fd =3D meta_open(fname, O_RDONLY )) < 0) {=0A=
Only in pvfs-1.6.1-dev/mgr/meta: md_unlink.c~=0A=
Only in pvfs-1.6.1-dev/mgr: mgr.c~=0A=
diff -ur pvfs-1.6.1/mgr/mgr.h pvfs-1.6.1-dev/mgr/mgr.h=0A=
--- pvfs-1.6.1/mgr/mgr.h	Wed Oct 22 06:17:46 2003=0A=
+++ pvfs-1.6.1-dev/mgr/mgr.h	Thu Nov 20 14:51:05 2003=0A=
@@ -70,7 +70,7 @@=0A=
 int md_open(char *name, mreq_p request, fmeta_p metar_p);=0A=
 int md_rmdir(mreq_p req_p, char *fname);=0A=
 int md_mkdir(char *dirpath, dmeta_p dir);=0A=
-int md_islink(char *link_name);=0A=
+int md_islink(char *link_name, struct stat *statbuf);=0A=
 char* md_readlink(char *link_name);=0A=
 int md_link(char *link_name, char *target_name, mreq_p request);=0A=
 int md_symlink(char *link_name, char *target_name, mreq_p request);=0A=

------_=_NextPart_000_01C3AFBC.133A5BD0--