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

This commit is contained in:
Thomas Schmitt 2009-01-23 14:08:31 +00:00
parent 2ab9541683
commit 8555af6e7f
6 changed files with 101 additions and 23 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Jan 22, 2008"
.TH XORRISO 1 "Jan 23, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1990,6 +1990,10 @@ format of shell command getfacl. If a file has no ACL then it gets fabricated
from the -chmod settings. A file may have a real ACL if it was introduced into
the ISO image while option -acl was set to "on".
.TP
\fB\-getfacl_r\fR iso_rr_pattern [***]
Like -gefacl but listing recursively the whole file trees underneath eventual
directories.
.TP
\fB\-du\fR iso_rr_pattern [***]
Recursively list size of directories and files in the ISO image
which match one of the patterns.
@ -2959,7 +2963,7 @@ the newly written session (here for mount point /mnt):
Options -mount_cmd and -mount are also able to produce the mount commands for
older sessions in the table-of-content. E.g. as superuser:
.br
\fB$\fR osirrox -mount /dev/sr0 "volid" '*2008_12_05*' /mnt
\fB#\fR osirrox -mount /dev/sr0 "volid" '*2008_12_05*' /mnt
.br
Sessions on multi-session media are separated by several MB of unused blocks.
So with small sessions the payload capacity can become substantially lower

View File

@ -2308,6 +2308,7 @@ struct FindjoB {
int end_lba;
int damage_filter; /* -1=only undamaged , 0=all , 1=only damaged */
int commit_filter; /* bit0= test -pending_data : uncommitted regular files */
int acl_filter; /* -1=only without ACL , 0=all , 1=only with ACL */
void *wanted_node; /* if not NULL, then only this node address matches */
@ -2335,6 +2336,7 @@ struct FindjoB {
21= report_damage
22= report_lba
23= internal:memorize path of last matching node in found_path
24= getfacl
*/
int action;
char *target;
@ -2362,6 +2364,7 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
m->end_lba= -1;
m->damage_filter= 0;
m->commit_filter= 0;
m->acl_filter= 0;
m->wanted_node= NULL;
m->action= 0; /* print */
m->target= NULL; /* a mere pointer, not managed memory */
@ -2504,6 +2507,27 @@ int Findjob_get_commit_filter(struct FindjoB *o, int *commit_filter, int flag)
}
/* @param value -1= files without ACL, 0= all files, 1= only files with ACL
*/
int Findjob_set_acl_filter(struct FindjoB *o, int value, int flag)
{
if(value < 0)
o->acl_filter= -1;
else if(value > 0)
o->acl_filter= 1;
else
o->acl_filter= 0;
return(1);
}
int Findjob_get_acl_filter(struct FindjoB *o, int *acl_filter, int flag)
{
*acl_filter= o->acl_filter;
return(1);
}
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
{
o->wanted_node= wanted_node;
@ -12742,6 +12766,10 @@ not_enough_arguments:;
Findjob_set_lba_range(job, start_lba, count, 0);
} else if(strcmp(argv[i], "-pending_data")==0) {
Findjob_set_commit_filter(job, 1, 1, 0);
} else if(strcmp(argv[i], "-has_acl")==0) {
Findjob_set_acl_filter(job, 1, 0);
} else if(strcmp(argv[i], "-has_no_acl")==0) {
Findjob_set_acl_filter(job, -1, 0);
} else if(strcmp(argv[i], "-exec")==0) {
if(i+1>=end_idx)
goto not_enough_arguments;
@ -12882,6 +12910,8 @@ not_enough_arguments:;
Findjob_set_action_target(job, 21, NULL, 0);
} else if(strcmp(cpt, "report_lba")==0) {
Findjob_set_action_target(job, 22, NULL, 0);
} else if(strcmp(cpt, "getfacl")==0) {
Findjob_set_action_target(job, 24, NULL, 0);
} else {
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
Text_shellsafe(argv[i], sfe, 0));
@ -13008,8 +13038,8 @@ int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag)
}
/* Option -getfacl */
/* @param flag >>> ??? bit0=recursive (-getfacl_r)
/* Option -getfacl , -getfacl_r */
/* @param flag bit0=recursive -getfacl_r
*/
int Xorriso_option_getfacl(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag)
@ -13018,6 +13048,7 @@ int Xorriso_option_getfacl(struct XorrisO *xorriso,
int optc= 0;
char **optv= NULL;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
ret= Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, &optc,
&optv, 0);
@ -13025,11 +13056,17 @@ int Xorriso_option_getfacl(struct XorrisO *xorriso,
goto ex;
for(i= 0; i<optc; i++) {
if(flag&1) {
/* >>> set up findjob and run it */;
ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) {
Xorriso_no_findjob(xorriso, "-getfacl_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_target(job, 24, NULL, 0);
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
NULL, optv[i], &dir_stbuf, 0, 0);
Findjob_destroy(&job, 0);
} else {
ret= Xorriso_getfacl(xorriso, optv[i], NULL, 0);
ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0);
}
if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */
@ -13357,6 +13394,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -lslx pattern [***] like -lsx but also telling some file attributes.",
" -lsdlx pattern [***] like -lsdx but also telling some file attributes.",
" -getfacl pattern [***] list eventual ACLs of the given files.",
" -getfacl_r pattern [***] like -getfacl but listing whole file trees.",
"",
" -du pattern [***] recursively lists sizes of files or directories in the",
" ISO image which match one of the shell parser patterns.",
@ -15642,7 +15680,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"compare_l","cpr","cpri","cp_rax","cp_rx","cpax","cpx",
"du","dui","dus","dusi","dux","dusx","extract_l",
"file_size_limit","find","findi","findx",
"getfacl","getfacli",
"getfacl","getfacli","getfacl_r","getfacl_ri",
"ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli",
"lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri",
"not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l",
@ -15994,6 +16032,9 @@ next_command:;
} else if(strcmp(cmd,"getfacl")==0 || strcmp(cmd,"getfacli")==0) {
ret= Xorriso_option_getfacl(xorriso, argc, argv, idx, 0);
} else if(strcmp(cmd,"getfacl_r")==0 || strcmp(cmd,"getfacl_ri")==0) {
ret= Xorriso_option_getfacl(xorriso, argc, argv, idx, 1);
} else if(strcmp(cmd,"gid")==0) {
(*idx)++;
ret= Xorriso_option_gid(xorriso,arg1,0);

View File

@ -736,6 +736,8 @@ int Findjob_get_lba_damage_filter(struct FindjoB *o, int *start_lba,
int Findjob_get_commit_filter(struct FindjoB *o, int *commit_filter, int flag);
int Findjob_get_acl_filter(struct FindjoB *o, int *acl_filter, int flag);
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag);
int Findjob_get_wanted_node(struct FindjoB *o, void **wanted_node, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.01.23.102843"
#define Xorriso_timestamP "2009.01.23.140824"

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;
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);

View File

@ -382,16 +382,21 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result,
int flag);
/* @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= just check for existence of ACL, 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 *node,
char *path, char **acl_text, int flag);
/* Calls iso_image_set_ignore_aclea() according to xorriso->do_aaip */