On 04/15/08 10:34, verma wrote: > Hi All, > > I build and run the following program that is using aclcheck() API of > libsec.so.1. > When I run this program gives the following error > aclcheck() error:: Invalid argument > ACL Checking is invalid > > Can any one help me, what I am missing here.
Well, for starters, *what* are you trying to do? You define an incomplete aclent_t (it contains only a USER_OBJ, no GROUP_OBJ, no OTHER_OBJ). I'd suggest you read the manpage of aclcheck(3SEC) since it's pretty clear on what constitutes a valid aclent_t. In that manpage, you'll also see that you should check for the return value of aclcheck(), not errno, to see if something's wrong and what the problem is. Lastly, don't cast malloc() values and exit() if malloc() returns a failure. For instance: #include <stdio.h> #include <stdlib.h> #include <sys/acl.h> #include <errno.h> int main(void) { int check; aclent_t *aclbufp; int which = 0; int aclcnt = 1; char *errors[] = { "NOERROR", "GRP_ERROR", "USER_ERROR", "OTHER_ERROR", "CLASS_ERROR", "DUPLICATE_ERROR", "MISS_ERROR", "MEM_ERROR", "ENTRY_ERROR" }; aclbufp = malloc((sizeof (aclent_t)) * aclcnt); if(aclbufp == NULL) { printf("malloc failed to allocate the memory\n"); exit(1); } aclbufp->a_type = 1; aclbufp->a_id = 105; aclbufp->a_perm = 0655; if ((check = aclcheck(aclbufp, aclcnt, &which)) != 0) { printf("aclcheck failed: %s, which = %d\n", errors[check], which); } else { printf("ACL Checking is valid\n"); } return 0; }