/* * Add entries to a hpux ACL. * * Entries are directly added to the hpuxacl parameter. * if memory allocation fails, this may result in hpuxacl * being NULL. if the resulting acl is to be checked and is * not valid, it is kept in hpuxacl but False is returned. * * The type of ACEs (access/default) to be added to the ACL can * be selected via the type parameter. * I use the SMB_ACL_TYPE_T type here. Since SMB_ACL_TYPE_ACCESS * is defined as "0", this means that one can only add either * access or default ACEs from the given ACL, not both at the same * time. If it should become necessary to add all of an ACL, one * would have to replace this parameter by another type. */ static bool hpux_add_to_acl(HPUX_ACL_T *hpux_acl, int *count, HPUX_ACL_T add_acl, int add_count, SMB_ACL_TYPE_T type) { int i; if ((type != SMB_ACL_TYPE_ACCESS) && (type != SMB_ACL_TYPE_DEFAULT)) { DEBUG(10, ("invalid acl type given: %d\n", type)); errno = EINVAL; return False; } for (i = 0; i < add_count; i++) { if (!_IS_OF_TYPE(add_acl[i], type)) { continue; } ADD_TO_ARRAY(NULL, HPUX_ACE_T, add_acl[i], hpux_acl, count); if (hpux_acl == NULL) { DEBUG(10, ("error enlarging acl.\n")); errno = ENOMEM; return False; } } return True; }
/* * convert either the access or the default part of a * soaris acl to the SMB_ACL format. */ static SMB_ACL_T solaris_acl_to_smb_acl(SOLARIS_ACL_T solaris_acl, int count, SMB_ACL_TYPE_T type) { SMB_ACL_T result; int i; if ((result = sys_acl_init(0)) == NULL) { DEBUG(10, ("error allocating memory for SMB_ACL\n")); goto fail; } for (i = 0; i < count; i++) { SMB_ACL_ENTRY_T smb_entry; SMB_ACL_PERM_T smb_perm; if (!_IS_OF_TYPE(solaris_acl[i], type)) { continue; } result = SMB_REALLOC(result, sizeof(struct smb_acl_t) + (sizeof(struct smb_acl_entry) * (result->count + 1))); if (result == NULL) { DEBUG(10, ("error reallocating memory for SMB_ACL\n")); goto fail; } smb_entry = &result->acl[result->count]; if (sys_acl_set_tag_type(smb_entry, solaris_tag_to_smb_tag(solaris_acl[i].a_type)) != 0) { DEBUG(10, ("invalid tag type given: 0x%04x\n", solaris_acl[i].a_type)); goto fail; } /* intentionally not checking return code here: */ sys_acl_set_qualifier(smb_entry, (void *)&solaris_acl[i].a_id); smb_perm = solaris_perm_to_smb_perm(solaris_acl[i].a_perm); if (sys_acl_set_permset(smb_entry, &smb_perm) != 0) { DEBUG(10, ("invalid permset given: %d\n", solaris_acl[i].a_perm)); goto fail; } result->count += 1; } goto done; fail: SAFE_FREE(result); done: DEBUG(10, ("solaris_acl_to_smb_acl %s\n", ((result == NULL) ? "failed" : "succeeded"))); return result; }
/* * convert either the access or the default part of a * soaris acl to the SMB_ACL format. */ static SMB_ACL_T hpux_acl_to_smb_acl(HPUX_ACL_T hpux_acl, int count, SMB_ACL_TYPE_T type, TALLOC_CTX *mem_ctx) { SMB_ACL_T result; int i; if ((result = sys_acl_init(mem_ctx)) == NULL) { DEBUG(10, ("error allocating memory for SMB_ACL\n")); goto fail; } for (i = 0; i < count; i++) { SMB_ACL_ENTRY_T smb_entry; SMB_ACL_PERM_T smb_perm; if (!_IS_OF_TYPE(hpux_acl[i], type)) { continue; } result->acl = talloc_realloc(result, result->acl, struct smb_acl_entry, result->count + 1); if (result->acl == NULL) { DEBUG(10, ("error reallocating memory for SMB_ACL\n")); goto fail; } smb_entry = &result->acl[result->count]; if (sys_acl_set_tag_type(smb_entry, hpux_tag_to_smb_tag(hpux_acl[i].a_type)) != 0) { DEBUG(10, ("invalid tag type given: 0x%04x\n", hpux_acl[i].a_type)); goto fail; } /* intentionally not checking return code here: */ sys_acl_set_qualifier(smb_entry, (void *)&hpux_acl[i].a_id); smb_perm = hpux_perm_to_smb_perm(hpux_acl[i].a_perm); if (sys_acl_set_permset(smb_entry, &smb_perm) != 0) { DEBUG(10, ("invalid permset given: %d\n", hpux_acl[i].a_perm)); goto fail; } result->count += 1; } goto done; fail: TALLOC_FREE(result); done: DEBUG(10, ("hpux_acl_to_smb_acl %s\n", ((result == NULL) ? "failed" : "succeeded"))); return result; }