acl: Don't use GETACLCNT and similar ops, since they are unreliable.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 Feb 2012 00:12:06 +0000 (01:12 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 20 Feb 2012 03:17:22 +0000 (04:17 +0100)
commitc78091bebe80acf4b14d460999b2b2a9cea15b28
treeb62c38468d180a2b054718d9f74180d79f776729
parent1e5535ce0c17e7e605e71d7423789a3d5254d9f7
acl: Don't use GETACLCNT and similar ops, since they are unreliable.

 - There were several instances of this pattern:

     for (;;) {
       n = acl (f, GETACLCNT, 0, NULL);
       [ allocate an array A of size N ]
       if (acl (f, GETACL, n, a) == n)
 break;
     }

   This loop might never terminate if some other process is constantly
   manipulating the file's ACL.  The loop should be rewritten to
   terminate.

 - The acl (... GETACLNT ...) call is merely an optimization; its value
   is merely a hint as to how big to make the array.  A better
   optimization is to avoid the acl (... GETACLNT ...)  call entirely,
   and just guess a reasonably-big size, growing the size and trying
   again if it's not large enough.  This guarantees termination, and
   saves a system call.

* lib/acl-internal.h: Include <limits.h>.
(MIN, SIZE_MAX): New macros.
* lib/file-has-acl.c (file_has_acl) [Solaris]: Read the entries into
a stack-allocated buffer, and use malloc if it does not fit. Don't
use GETACLCNT.
* lib/set-mode-acl.c (qset_acl) [Solaris]: Likewise.
ChangeLog
lib/acl-internal.h
lib/file-has-acl.c
lib/set-mode-acl.c