emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111312: Don't fail in acl_set_file o


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111312: Don't fail in acl_set_file on MS-Windows if the operation is a no-op.
Date: Sun, 23 Dec 2012 19:16:33 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111312
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sun 2012-12-23 19:16:33 +0200
message:
  Don't fail in acl_set_file on MS-Windows if the operation is a no-op.
  
   src/w32.c (acl_set_file): If setting the file security descriptor
   fails, and the new DACL is identical to the existing one, silently
   return success.  This fixes problems for users backing up their
   own files without having the necessary privileges for setting
   security descriptors.
modified:
  src/ChangeLog
  src/w32.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-12-23 17:06:58 +0000
+++ b/src/ChangeLog     2012-12-23 17:16:33 +0000
@@ -1,5 +1,11 @@
 2012-12-23  Eli Zaretskii  <address@hidden>
 
+       * w32.c (acl_set_file): If setting the file security descriptor
+       fails, and the new DACL is identical to the existing one, silently
+       return success.  This fixes problems for users backing up their
+       own files without having the necessary privileges for setting
+       security descriptors.
+
        * w32proc.c (reader_thread): Do not index fd_info[] with negative
        values.
        (reader_thread): Exit when cp->status becomes STATUS_READ_ERROR

=== modified file 'src/w32.c'
--- a/src/w32.c 2012-12-23 17:06:58 +0000
+++ b/src/w32.c 2012-12-23 17:16:33 +0000
@@ -4876,8 +4876,31 @@
       retval = 0;
       errno = e;
     }
-  else if (err == ERROR_INVALID_OWNER)
-    errno = EPERM;
+  else if (err == ERROR_INVALID_OWNER || err == ERROR_NOT_ALL_ASSIGNED)
+    {
+      /* Maybe the requested ACL and the one the file already has are
+        identical, in which case we can silently ignore the
+        failure.  (And no, Windows doesn't.)  */
+      acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS);
+
+      errno = EPERM;
+      if (current_acl)
+       {
+         char *acl_from = acl_to_text (current_acl, NULL);
+         char *acl_to = acl_to_text (acl, NULL);
+
+         if (acl_from && acl_to && xstrcasecmp (acl_from, acl_to) == 0)
+           {
+             retval = 0;
+             errno = e;
+           }
+         if (acl_from)
+           acl_free (acl_from);
+         if (acl_to)
+           acl_free (acl_to);
+         acl_free (current_acl);
+       }
+    }
   else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
     errno = ENOENT;
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]