Re: patch to libnautilus-private/nautilus-file.c




hi everyone : )

this is a modification to the patch i had previously submitted. i hope it's a step in the right direction. please review it and type what you think.

ciao! : )

edoardo
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.362
diff -u -p -r1.362 nautilus-file.c
--- libnautilus-private/nautilus-file.c	22 Feb 2005 10:41:46 -0000	1.362
+++ libnautilus-private/nautilus-file.c	20 Mar 2005 00:42:04 -0000
@@ -708,33 +708,47 @@ nautilus_file_denies_access_permission (
 		return FALSE;
 	}
 
-	/* File owner's access is governed by the owner bits. */
-	/* FIXME bugzilla.gnome.org 40644: 
-	 * Can we trust the uid in the file info? Might
-	 * there be garbage there? What will it do for non-local files?
-	 */
-	if (user_info->user_id == (uid_t) file->details->info->uid) {
-		return (file->details->info->permissions & owner_permission) == 0;
+	/* check whether the uid is valid. */
+	if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_UID) {
+		/* File owner's access is governed by the owner bits. */
+		if (user_info->user_id == (uid_t) file->details->info->uid) {
+			/* check whether access bits of the permissions field are valid */
+			if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) {
+				return (file->details->info->permissions & owner_permission) == 0;
+			}
+		}
 	}
 
-
-	/* Group member's access is governed by the group bits. */
-	/* FIXME bugzilla.gnome.org 40644: 
-	 * Can we trust the gid in the file info? Might
-	 * there be garbage there? What will it do for non-local files?
-	 */
-	if (user_info->has_primary_group
-	    && user_info->primary_group == (gid_t) file->details->info->gid) {
-		return (file->details->info->permissions & group_permission) == 0;
+	/* check whether the gid is valid. */
+	if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_GID) {
+		/* Group member's access is governed by the group bits. */
+		if (user_info->has_primary_group
+		    && user_info->primary_group == (gid_t) file->details->info->gid) {
+		    	/* check whether access bits of the permissions field are valid */
+			if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) {
+				return (file->details->info->permissions & group_permission) == 0;
+			}
+		}
 	}
+
 	/* Check supplementary groups */
 	for (i = 0; i < user_info->num_supplementary_groups; i++) {
-		if ((gid_t) file->details->info->gid == user_info->supplementary_groups[i]) {
-			return (file->details->info->permissions & group_permission) == 0;
+		/* check whether the gid is valid. */
+		if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_GID) {
+			if ((gid_t) file->details->info->gid == user_info->supplementary_groups[i]) {
+				/* check whether access bits of the permissions field are valid */
+				if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) {
+					return (file->details->info->permissions & group_permission) == 0;
+				}
+			}
 		}
 	}
-	/* Other users' access is governed by the other bits. */
-	return (file->details->info->permissions & other_permission) == 0;
+	
+	/* check whether access bits of the permissions field are valid */
+	if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) {
+		/* Other users' access is governed by the other bits. */
+		return (file->details->info->permissions & other_permission) == 0;
+	}
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]