Re: [patch] Honor the setgid bit on directories



On Sun, 2005-01-23 at 22:58 +0100, Sjoerd Simons wrote:
> 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.

I don't understand this patch:

+               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);
 
Get target directory info, if its SGID, set the "gid" member of the
target info struct to itself, then free the target info struct.

How can this possibly do anything at all?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a time-tossed flyboy househusband living undercover at Ringling Bros. 
Circus. She's a pregnant junkie socialite with the power to bend men's minds. 
They fight crime! 




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