patch to libnautilus-private/nautilus-file.c




hi gals and dudes : )

i'm new to this list, but i want to type here that i made a patch for libnautilus-private/nautilus-file.c that solves bug #40644. it's a gnome-vfs based bug, but it's got heavy repercussions on nautilus, too. i was advised to post the patch to this list as well as in bugzilla, and since it hasn't been reviewed yet there might be mistakes in it, and i wanted you to have a look at it.

let me know what you think of it! : )

ciao! : )

edoardo
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.6435
diff -u -p -r1.6435 ChangeLog
--- ChangeLog	12 Mar 2005 11:45:12 -0000	1.6435
+++ ChangeLog	14 Mar 2005 02:18:46 -0000
@@ -1,3 +1,8 @@
+2005-03-13  thetroublemaker <thetroublemaker inventati org>
+
+	* libnautilus-private/nautilus-file.c:
+	fixed bug #40644, so that now the uid and gid fields are checked.
+
 2005-03-12  Martin Wehner  <martin wehner gmail com>
 
 	* src/file-manager/fm-directory-view.c:
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	14 Mar 2005 02:18:52 -0000
@@ -708,21 +708,26 @@ nautilus_file_denies_access_permission (
 		return FALSE;
 	}
 
+	/* check whether the uid is valid. */
+
+	if !(file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_UID) {
+		return TRUE;
+	}
+
 	/* 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 gid is valid */
+
+	if !(file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_GID) {
+		return TRUE;
+	}
 
 	/* 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;
@@ -3730,11 +3735,7 @@ gboolean
 nautilus_file_can_get_owner (NautilusFile *file)
 {
 	/* Before we have info on a file, the owner is unknown. */
-	/* 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?
-	 */
-	return !nautilus_file_info_missing (file, 0 /* FIXME bugzilla.gnome.org 40644: GNOME_VFS_FILE_INFO_FIELDS_UID */);
+	return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_UID);
 }
 
 /**
@@ -3953,11 +3954,7 @@ gboolean
 nautilus_file_can_get_group (NautilusFile *file)
 {
 	/* Before we have info on a file, the group is unknown. */
-	/* 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?
-	 */
-	return !nautilus_file_info_missing (file, 0 /* FIXME bugzilla.gnome.org 40644: GNOME_VFS_FILE_INFO_FIELDS_GID */);
+	return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_GID);
 }
 
 /**
@@ -3977,14 +3974,15 @@ nautilus_file_get_group_name (NautilusFi
 	struct group *group_info;
 
 	/* Before we have info on a file, the owner is unknown. */
-	if (nautilus_file_info_missing (file, 0 /* FIXME bugzilla.gnome.org 40644: GNOME_VFS_FILE_INFO_FIELDS_GID */)) {
+	if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_GID)) {
 		return NULL;
 	}
 
-	/* 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?
-	 */
+	/* check whether gid is valid */
+	if !(file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_GID) {
+		return NULL;
+	}
+	
 	/* No need to free result of getgrgid */
 	group_info = getgrgid ((gid_t) file->details->info->gid);
 
@@ -4284,11 +4282,7 @@ nautilus_file_get_owner_as_string (Nauti
 	char *user_name;
 
 	/* Before we have info on a file, the owner is unknown. */
-	/* 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 (nautilus_file_info_missing (file, 0 /* FIXME bugzilla.gnome.org 40644: GNOME_VFS_FILE_INFO_FIELDS_UID */)) {
+	if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_UID)) {
 		return NULL;
 	}
 


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