Vote count:
0
I'm writing a program that sets acl permissions for a given user/group. Very similar to the "setfacl" command. According to a given user/group I search first if the entry already exists. If I get a NULL then I call acl_create_entry. When I check the ACL via acl_check, I get an ACL_ENTRY_ERROR. The function is something similar to this:
/*ar_pobj=Path or file name, ar_tagType=ACL_USER or ACL_GROUP, ar_ptagQual=User name or group name, ar_pperms=string with permissions "rwx-"*/
int addPermissions(char *ar_pobj, acl_tag_t ar_tagType, char *ar_ptagQual, char *ar_pperms)
{
acl_t la_acl;
id_t la_qual;
acl_entry_t la_entry;
int la_error;
la_acl=acl_get_file(par_obj,ACL_TYPE_ACCESS);
if (la_acl == NULL)
{
return -1;
}
switch(ar_tagType)
{
case ACL_USER:
la_qual=userIdFromName(ar_ptagQual);/*This function works fine*/
if(-1==la_qual)
{
acl_free(la_acl);
return -1;
}
break;
case ACL_GROUP:
la_qual=groupIdFromName(ar_ptagQual);/*This function works fine*/
if(-1==la_qual)
{
acl_free(la_acl);
return -1;
}
break;
default:
acl_free(la_acl);
return -1;
}
la_entry = findEntry(la_acl,ar_tagType,la_qual);/*This function returns NULL as the entry was not found*/
if(NULL==la_entry)
{
if (acl_create_entry(&la_acl, &la_entry) == -1)/*Returns OK*/
{
acl_free(la_acl);
return -1;
}
la_error=acl_check(la_acl,NULL);/*HERE IS WHERW I GET THE ERROR*/
...
}
...
}
Any clues? Thank you in advance.
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire