1.5.20: acltotext32 - fix of error when handling default ACL types

Silvio Laguzzi slaguzzi@data-al.de
Tue Jul 18 12:31:00 GMT 2006


Hi, all

when I tested Joerg Schily's star under cygwin the acltotext() call
failed with an >Invalid Argument< error under Win2k.

Here's a sample code that reproduces this error:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/acl.h>


int main(void)
{
    int aclcount;
    aclent_t *aclp;
    char *fname = "/home/slaguzzi/src/star-1.5";

    if( (aclcount = acl(fname, GETACLCNT, 0, NULL)) < 0 ) {
      perror("Error getting ACL info for ~/src/star-1.5/");
    }
    if (aclcount <= MIN_ACL_ENTRIES) {
      /* Only traditional UNIX access list */
      printf( "Only traditional UNIX access lists\n" );
    }
    printf( "ACL count: %d\n", aclcount );
    if ( (aclp = (aclent_t *)calloc(aclcount, sizeof( aclent_t ) )) ==
NULL ) {
      perror( "Error allocating memory for ACL struct" );
    }
    if( acl(fname, GETACL, aclcount, aclp) < 0 ) {
      perror( "Cannot get ACL entries" );
    }
    errno = 0;
    int idx = 0;
    if( aclcheck( aclp, aclcount, &idx ) ) {
      perror( "Invalid aclp" );
      printf( "Invalid entry number: %d\n", idx );
    }
    char *acltext = acltotext(aclp, aclcount);

    free(aclp);
    if( !acltext ) {
      perror( "Error converting ACL to text" );
    }
    printf( "acltotext: %s", acltext );

    return( 0 );
}

I tracked down the problem to the implementation of
acltotext32 (__aclent32_t *aclbufp, int aclcnt) in
src/winsup/cygwin/sec_acl.cc.

The prefix "default" was correctly added to the output string in buf for
a default ACL entry type.
But the following switch(aclbuf[pos].a_type) statement did not handle
these default ACL entry types and stopped with EINVAL.

I changed line 731 in sec_acl.cc to

switch(aclbuf[pos].a_type & ~ACL_DEFAULT)

and everything went fine.

An unified diff for the code, the output of the 'cygcheck -s -v -r'
command and the corresponding ChangeLog is included in this message.

I hope that this fix may contribute to improve Win32 ACL handling under
Cygwin.


Best regards
Silvio Laguzzi

---
Silvio Laguzzi
Zimmer-AL GmbH
Junkersstr. 9
89231 Neu-Ulm (Germany)
Internet: http://www.data-al.de

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sec_acl.patch
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20060718/c1f00f76/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ChangeLog
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20060718/c1f00f76/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.txt
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20060718/c1f00f76/attachment.txt>


More information about the Cygwin-patches mailing list