[patch] Honor the setgid bit on directories



Hi,

  When copying a file gnome-vfs sets the owner and group to the same owner and
  group as the original file. If the destination dir has the setgid bit set,
  this results in the unexpected behaviour that the group isn't the same as the
  dirs group.

  This can be solved in two ways, remove the forced setting of owner and group
  from the copying code. But that's probably there for i reason that i'm
  currently missing. Or specifically set the right group if the destination dir
  is setgid.

  Attached patched implements the second solution. It's based on a patch from
  egeetha novell com with some small improvements.

  Sjoerd
-- 
The more you complain, the longer God lets you live.
--- libgnomevfs/gnome-vfs-xfer.c.orig	2005-01-23 21:21:32.000000000 +0100
+++ libgnomevfs/gnome-vfs-xfer.c	2005-01-23 22:15:26.000000000 +0100
@@ -1565,6 +1565,16 @@
 
 	if (call_progress_with_uris_often (progress, source_dir_uri, target_dir_uri, 
 					   GNOME_VFS_XFER_PHASE_OPENTARGET) != 0) {
+		GnomeVFSFileInfo *targetinfo;
+
+		/* get target_dir URI and file info to take care of SGID */
+		targetinfo = gnome_vfs_file_info_new ();
+		result = gnome_vfs_get_file_info_uri (target_dir_uri, targetinfo,
+			GNOME_VFS_FILE_INFO_DEFAULT);
+		if (result == GNOME_VFS_OK && GNOME_VFS_FILE_INFO_SGID(targetinfo)) {
+				targetinfo->gid = targetinfo->gid;
+		}
+		gnome_vfs_file_info_unref (targetinfo);
 
 		progress->progress_info->total_bytes_copied += DEFAULT_SIZE_OVERHEAD;
 		progress->progress_info->top_level_item = FALSE;
@@ -1713,6 +1723,20 @@
 			((GnomeVFSURI *)target_item->data);
 
 		if (result == GNOME_VFS_OK) {
+			GnomeVFSFileInfo *targetinfo;
+
+     /* get target_dir URI and file info to take care of SGID */
+			targetinfo = gnome_vfs_file_info_new ();
+			result = gnome_vfs_get_file_info_uri (target_dir_uri, targetinfo,
+					GNOME_VFS_FILE_INFO_DEFAULT);
+
+			if (result == GNOME_VFS_OK && GNOME_VFS_FILE_INFO_SGID(targetinfo)) {
+				targetinfo->gid = targetinfo->gid;
+			}
+			gnome_vfs_file_info_unref (targetinfo);
+			/* ignore errors from getting targetdir info */
+			result = GNOME_VFS_OK;
+
 			/* optionally keep trying until we hit a unique target name */
 			for (count = 1; ; count++) {
 				GnomeVFSXferOverwriteMode overwrite_mode_abort;


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