]> sourceware.org Git - newlib-cygwin.git/commitdiff
* flock.cc (allow_others_to_sync): Use RtlGetDaclSecurityDescriptor
authorCorinna Vinschen <corinna@vinschen.de>
Fri, 2 Mar 2012 17:07:17 +0000 (17:07 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Fri, 2 Mar 2012 17:07:17 +0000 (17:07 +0000)
rather than accessing the SECURITY_DESCRIPTOR structure directly.
Take no DACL and NULL DACL into account.

winsup/cygwin/ChangeLog
winsup/cygwin/flock.cc

index 3e5a87b661f22aa6400379c6ae81933a65259f19..c6273aa339da4609c75b1fae38b053e06ecf76ca 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-02  Corinna Vinschen  <corinna@vinschen.de>
+
+       * flock.cc (allow_others_to_sync): Use RtlGetDaclSecurityDescriptor
+       rather than accessing the SECURITY_DESCRIPTOR structure directly.
+       Take no DACL and NULL DACL into account.
+
 2012-03-02  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler_console.cc (fhandler_console::input_tcsetattr): Revert
index a4d28e5f6260f3f5d5339666f04f9ff10b768c0c..c66891a354b623e1ec2566898fb692c82a7dfbc1 100644 (file)
@@ -176,8 +176,22 @@ allow_others_to_sync ()
   /* Create a valid dacl pointer and set its size to be as big as
      there's room in the temporary buffer.  Note that the descriptor
      is in self-relative format. */
-  dacl = (PACL) ((char *) sd + (uintptr_t) sd->Dacl);
-  dacl->AclSize = NT_MAX_PATH * sizeof (WCHAR) - ((char *) dacl - (char *) sd);
+  BOOLEAN present, defaulted;
+  RtlGetDaclSecurityDescriptor (sd, &present, &dacl, &defaulted);
+  if (dacl == NULL) /* Everyone has all access anyway */
+    {
+      done = true;
+      return;
+    }
+  else if (!present)
+    {
+      dacl = (PACL) (sd + 1);
+      RtlCreateAcl (dacl, MAX_PROCESS_SD_SIZE - sizeof *sd, ACL_REVISION);
+    }
+  else
+    {
+      dacl->AclSize = MAX_PROCESS_SD_SIZE - ((PBYTE) dacl - (PBYTE) sd);
+    }
   /* Allow everyone to SYNCHRONIZE with this process. */
   status = RtlAddAccessAllowedAce (dacl, ACL_REVISION, SYNCHRONIZE,
                                   well_known_world_sid);
This page took 0.034432 seconds and 5 git commands to generate.