New find tests -has_acl, -has_no_acl, new action getfacl, new option getfacl_r

This commit is contained in:
2009-01-23 14:08:31 +00:00
parent 41619c2763
commit e7036f90dc
6 changed files with 101 additions and 23 deletions

View File

@ -6451,6 +6451,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
ret= Xorriso_report_lba(xorriso, show_path, node, 0);
} else if(action == 23) {
ret= Findjob_set_found_path(job, show_path, 0);
} else if(action == 24) {
ret = Xorriso_getfacl(xorriso, (void *) node, show_path, NULL, 0);
} else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
@ -6471,7 +6473,7 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
struct stat *boss_stbuf, struct stat *stbuf,
int depth, int flag)
{
int ret, start_lba, end_lba, damage_filter, commit_filter, lba;
int ret, start_lba, end_lba, damage_filter, commit_filter, lba, acl_filter;
off_t damage_start, damage_end, size;
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i;
void *wanted_node;
@ -6508,6 +6510,18 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
if(ret > 0 && lba >= 0)
{ret= 0; goto ex;}
}
Findjob_get_acl_filter(job, &acl_filter, 0);
if(acl_filter) {
ret = Xorriso_getfacl(xorriso, (void *) node, "", NULL, 2);
if(ret <= 0) {
Xorriso_process_msg_queues(xorriso, 0);
goto ex;
}
if(acl_filter < 0 && ret != 2)
{ret= 0; goto ex;}
if(acl_filter > 0 && ret == 2)
{ret= 0; goto ex;}
}
Findjob_get_wanted_node(job, &wanted_node, 0);
if(wanted_node != NULL && ((IsoNode *) wanted_node) != node)
{ret= 0; goto ex;}
@ -8745,17 +8759,20 @@ ok:;
}
/* @param acl_text if acl_text is not NULL, then *acl_text will be set to the
/* @param node Opaque handle to IsoNode which is to be inquired instead of path if it is not NULL.
@param path is used as address if node is NULL.
@param acl_text if acl_text is not NULL, then *acl_text will be set to the
ACL text (without comments) of the file object. In this
case it finally has to be freed by the caller.
@param flag bit0= do not report to result but only retrieve ACL text
bit1= do not strip leading '/' from "# file:"
bit1= check for existence of true ACL (not fabricated),
do not allocate and set acl_text but return 1 or 2
@return 2 ok, no ACL available, eventual *acl_text will be NULL
1 ok, ACL available, eventual *acl_text stems from malloc()
<=0 error
*/
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, char **acl_text,
int flag)
int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
char **acl_text, int flag)
{
int ret, path_offset= 0;
IsoNode *node;
@ -8765,9 +8782,13 @@ int Xorriso_getfacl(struct XorrisO *xorriso, char *path, char **acl_text,
struct passwd *pwd;
struct group *grp;
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
if(ret<=0)
goto ex;
node= (IsoNode *) in_node;
if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
if(ret<=0)
goto ex;
}
#ifdef Xorriso_with_aaiP
ret= iso_node_get_acl_text(node, &text, 0);
@ -8775,12 +8796,17 @@ int Xorriso_getfacl(struct XorrisO *xorriso, char *path, char **acl_text,
ret= 0;
#endif
if(ret < 0) {
strcpy(xorriso->info_text, "Error with obtaining ACL of ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
if(flag & 2) {
ret= 1 + (ret != 1);
goto ex;
}
if(flag & 1) {
ret= 1 + (ret == 0);
goto ex;
@ -8832,7 +8858,7 @@ int Xorriso_getfacl(struct XorrisO *xorriso, char *path, char **acl_text,
ret= 1;
ex:;
if(acl_text != NULL)
if(acl_text != NULL && !(flag & 2))
*acl_text= text;
else if(text != NULL)
free(text);