verma wrote:
> Hi all,
> 
> I am trying to call some function from my application of libsec(3SEC).
> I am able to call some function calls but unable the following call
> acl_fromtext(),acl_check(),acltomode() etc.
> Could any one help me to make the above call.
> I have not funded any document related to above function aprt from man page.
> following are my acl_fromtext() call from my application:
> 
> #include <sys/acl.h>
> int
> main()
> {
>         int convert;
>         char *acltextp = "user:bhushan:rw_";
>         acl_t **aclp;
> 
>         convert = acl_fromtext(acltextp, &aclp);
>         if(convert == 0)
>                 printf("converted\n");
>         else
>                 printf("error\n");
> 
> return 0;
> }

The above code has quite a few problems, and doesn't actually compile 
without warnings.  First rule of writing code with new (to you) 
interfaces pay attention to the compiler warnings and fix the issue 
before testing.

When I tried to compile the above I got:

cc foo.c -o foo
"foo.c", line 9: warning: argument #2 is incompatible with prototype:
         prototype: pointer to pointer to struct acl_info {enum acl_type 
{ACE_T(1), ACLENT_T(0)} acl_type, int acl_cnt, int acl_entry_size, int 
acl_flags, pointer to void acl_aclp} : "/usr/include/sys/acl.h", line 267
         argument : pointer to pointer to pointer to struct acl_info 
{enum acl_type {ACE_T(1), ACLENT_T(0)} acl_type, int acl_cnt, int 
acl_entry_size, int acl_flags, pointer to void acl_aclp}
"foo.c", line 11: warning: implicit function declaration: printf


Look at that carefully and you will see that your declaration of aclp is 
wrong it should be:
        acl_t   *aclp;

The other thing that would really help is if you actually printed out 
the return code of acl_fromtext().  The user has to actually exist 
locally so I had to change your username from mine.  In doing that I got 
  a return value of "11" which is EACL_PERM_MASK_ERROR.  You have an '_' 
char instead of a '-' as the last part of the text version of the ACL.

BTW I didn't actually have to compile or run this to see the errors in 
the code.  The '_' vs '-' I spotted before I even compiled the code and 
the error in the aclp declaration was obvious from the compiler warning 
message and confirmed by checking with the man page.

The point of what I did above though was to show you how to work this 
out using what the compiler and man page tells you.

How this helps you.

-- 
Darren J Moffat

Reply via email to