umlaut-patch

Corinna Vinschen corinna@vinschen.de
Sun Jan 9 16:14:00 GMT 2000


Hi,

I suddenly found out that the NT function GetFileSecurity() failes,
if the filename contains german umlauts. This will apparently happen
in other native NT versions as well. So I have patched get_file_owner()
and get_file_group() which historically use this function. they will
use the ReadSD() function from security.cc now.

Corinna


ChangeLog:
==========

Mon Jan 10 01:11:00 2000  Corinna Vinschen  <corinna@vinschen.de>

	* fhandler.cc (get_file_owner): Use of ReadSD() instead of
	GetFileSecurity().
	(get_file_group): Ditto.
Index: cygwin/fhandler.cc
===================================================================
RCS file: /src/cvsroot/winsup-000108/cygwin/fhandler.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fhandler.cc
--- cygwin/fhandler.cc	2000/01/09 10:50:51	1.1.1.1
+++ cygwin/fhandler.cc	2000/01/09 23:50:53
@@ -101,18 +101,18 @@ get_file_owner (int use_ntsec, const cha
 {
   if (use_ntsec && allow_ntsec)
     {
-      char psd_buffer[1024];
+      extern LONG ReadSD(const char *, PSECURITY_DESCRIPTOR, LPDWORD);
+      DWORD sd_size = 4096;
+      char psd_buffer[4096];
       PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) psd_buffer;
-      DWORD requested_length;
       PSID psid;
       BOOL bOwnerDefaulted = TRUE;
 
-      if (!GetFileSecurity (filename, OWNER_SECURITY_INFORMATION,
-			   psd, 1024, &requested_length))
-	return getuid();
+      if (ReadSD (filename, psd, &sd_size) <= 0)
+        return getuid();
 
       if (!GetSecurityDescriptorOwner (psd, &psid, &bOwnerDefaulted))
-	return getuid ();
+        return getuid ();
 
       return psid ? get_uid_from_sid (psid) : getuid ();
     }
@@ -125,20 +125,18 @@ get_file_group (int use_ntsec, const cha
 {
   if (use_ntsec && allow_ntsec)
     {
-      char psd_buffer[1024];
+      extern LONG ReadSD(const char *, PSECURITY_DESCRIPTOR, LPDWORD);
+      DWORD sd_size = 4096;
+      char psd_buffer[4096];
       PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) psd_buffer;
-      DWORD requested_length;
       PSID psid;
       BOOL bGroupDefaulted = TRUE;
 
-      /* obtain the file's group information */
-      if (!GetFileSecurity (filename, GROUP_SECURITY_INFORMATION, psd,
-			    1024, &requested_length))
-	return getgid();
-
-      /* extract the group sid from the security descriptor */
-      if(!GetSecurityDescriptorGroup (psd, &psid, &bGroupDefaulted))
-	return getgid ();
+      if (ReadSD (filename, psd, &sd_size) <= 0)
+        return getgid();
+
+      if (!GetSecurityDescriptorGroup (psd, &psid, &bGroupDefaulted))
+        return getgid ();
 
       return psid ? get_gid_from_sid (psid) : getuid ();
     }


More information about the Cygwin-developers mailing list