New options -xattr, -getfattr, find -has_xattr, -has_aaip, -exec getfattr

master
Thomas Schmitt 14 years ago
parent 4ceee394f7
commit f861321c45
  1. 25
      xorriso/xorriso.1
  2. 187
      xorriso/xorriso.c
  3. 6
      xorriso/xorriso_private.h
  4. 2
      xorriso/xorriso_timestamp.h
  5. 314
      xorriso/xorrisoburn.c
  6. 2
      xorriso/xorrisoburn.h

@ -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 28, 2008"
.TH XORRISO 1 "Feb 02, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -624,10 +624,17 @@ will be copied to -in_charset.
.TP
\fB\-acl\fR "on"|"off"
Enable or disable processing of ACLs.
If enabled then xorriso will obtain ACLs from disk file objects,
If enabled, then xorriso will obtain ACLs from disk file objects,
store ACLs in the ISO image using the libisofs specific AAIP format,
load AAIP data from ISO images, and restore ACLs to disk files when
extracting them from ISO images.
extracting them from ISO images. See also options -getfacl, -setfacl.
.TP
\fB\-xattr\fR "on"|"off"
Enable or disable processing of XFS style Extended Attributes. These are
pairs of name and value. The names are 0-terminated strings. Values can
be arbitrary binary data.
If enabled, then xorriso will import and export xattr similar to ACL.
See also option -getfattr.
.TP
\fB\-rom_toc_scan\fR "on"|"off"[:"emul_on"|"emul_off"]
Read-only drives do not tell the actual media type but show any media as
@ -2013,11 +2020,11 @@ This resembles shell command ls -d.
.TP
\fB\-lsl\fR iso_rr_pattern [***]
Like -ls but also list some of the file attributes.
Output format resembles shell command ls -ln.
The output format resembles shell command ls -ln.
.TP
\fB\-lsdl\fR iso_rr_pattern [***]
Like -lsd but also list some of the file attributes.
Output format resembles shell command ls -dln.
The output format resembles shell command ls -dln.
.TP
\fB\-lsx\fR disk_pattern [***]
List files on local filesystem which match shell patterns. Patterns which do
@ -2050,6 +2057,14 @@ the ISO image while option -acl was set to "on".
Like -gefacl but listing recursively the whole file trees underneath eventual
directories.
.TP
\fB\-getfattr\fR iso_rr_pattern [***]
Print the XFS style Extended Attributes of the given files in the ISO image.
If the file has no such xattr then noting is printed.
.TP
\fB\-getfattr_r\fR iso_rr_pattern [***]
Like -gefattr 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.

@ -634,13 +634,13 @@ ex:;
bit3= encode in any case shellsafe:
<=42 , 59, 60, 62, 63, 92, 94, 96, >=123
*/
int Sfile_bsl_encoder(char **result, char *text, int flag)
int Sfile_bsl_encoder(char **result, char *text, size_t text_len, int flag)
{
char *rpt, *wpt;
int count, sq_open= 0, dq_open= 0;
count= 0;
for(rpt= text; *rpt != 0; rpt++) {
for(rpt= text; rpt - text < text_len; rpt++) {
count++;
if(flag & 8) {
if(!(*rpt <= 42 || *rpt == 59 || *rpt == 60 || *rpt == 62 ||
@ -657,7 +657,7 @@ int Sfile_bsl_encoder(char **result, char *text, int flag)
(*result)= wpt= calloc(count + 1, 1);
if(wpt == NULL)
return(-1);
for(rpt= text; *rpt != 0; rpt++) {
for(rpt= text; rpt - text < text_len; rpt++) {
if(*rpt == '\'')
sq_open= !(sq_open || dq_open);
if(*rpt == '"')
@ -2323,6 +2323,8 @@ struct FindjoB {
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 */
int xattr_filter; /* -1=only without xattr , 0=all , 1=only with xattr */
int aaip_filter; /* -1=only without AA string, 0=all , 1=only with AA */
void *wanted_node; /* if not NULL, then only this node address matches */
@ -2352,6 +2354,7 @@ struct FindjoB {
23= internal:memorize path of last matching node in found_path
24= getfacl
25= setfacl access_acl default_acl
26= getfattr
*/
int action;
@ -2383,6 +2386,8 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
m->damage_filter= 0;
m->commit_filter= 0;
m->acl_filter= 0;
m->xattr_filter= 0;
m->aaip_filter= 0;
m->wanted_node= NULL;
m->action= 0; /* print */
m->target= NULL; /* a mere pointer, not managed memory */
@ -2540,6 +2545,34 @@ int Findjob_set_acl_filter(struct FindjoB *o, int value, int flag)
}
/* @param value -1= files without xattr, 0= all files, 1= only files with xattr
*/
int Findjob_set_xattr_filter(struct FindjoB *o, int value, int flag)
{
if(value < 0)
o->xattr_filter= -1;
else if(value > 0)
o->xattr_filter= 1;
else
o->xattr_filter= 0;
return(1);
}
/* @param value -1= files without aaip, 0= all files, 1= only files with aaip
*/
int Findjob_set_aaip_filter(struct FindjoB *o, int value, int flag)
{
if(value < 0)
o->aaip_filter= -1;
else if(value > 0)
o->aaip_filter= 1;
else
o->aaip_filter= 0;
return(1);
}
int Findjob_get_acl_filter(struct FindjoB *o, int *acl_filter, int flag)
{
*acl_filter= o->acl_filter;
@ -2547,6 +2580,20 @@ int Findjob_get_acl_filter(struct FindjoB *o, int *acl_filter, int flag)
}
int Findjob_get_xattr_filter(struct FindjoB *o, int *xattr_filter, int flag)
{
*xattr_filter= o->xattr_filter;
return(1);
}
int Findjob_get_aaip_filter(struct FindjoB *o, int *aaip_filter, int flag)
{
*aaip_filter= o->aaip_filter;
return(1);
}
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
{
o->wanted_node= wanted_node;
@ -4612,7 +4659,7 @@ bit15= with bit1 or bit2: close depicted log file
/* Eventually perform backslash encoding of non-printable characters */
if(((xorriso->bsl_interpretation & 32) && channel_no == 1) ||
((xorriso->bsl_interpretation & 64) && channel_no == 2)) {
ret= Sfile_bsl_encoder(&text, text, 1 | 2 | 4);
ret= Sfile_bsl_encoder(&text, text, strlen(text), 1 | 2 | 4);
if(ret <= 0)
{ret= -1; goto ex;}
}
@ -6177,6 +6224,9 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
is_default= (xorriso->do_aaip==0);
sprintf(line,"-acl %s\n", (xorriso->do_aaip & 1 ? "on" : "off"));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
sprintf(line,"-xattr %s\n", (xorriso->do_aaip & 4 ? "on" : "off"));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
@ -6207,7 +6257,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
for(s= xorriso->drive_greylist; s != NULL; s= Xorriso_lst_get_next(s, 0)) {
sprintf(line, "-drive_class 'caution' %s\n",
sprintf(line, "-drive_class 'caution' %s\n",
Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0));
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
@ -13017,6 +13067,14 @@ not_enough_arguments:;
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], "-has_xattr")==0) {
Findjob_set_xattr_filter(job, 1, 0);
} else if(strcmp(argv[i], "-has_no_xattr")==0) {
Findjob_set_xattr_filter(job, -1, 0);
} else if(strcmp(argv[i], "-has_aaip")==0) {
Findjob_set_aaip_filter(job, 1, 0);
} else if(strcmp(argv[i], "-has_no_aaip")==0) {
Findjob_set_aaip_filter(job, -1, 0);
} else if(strcmp(argv[i], "-exec")==0) {
if(i+1>=end_idx)
goto not_enough_arguments;
@ -13169,6 +13227,8 @@ not_enough_arguments:;
goto ex;
Findjob_set_action_text_2(job, 25, access_acl_text, default_acl_text,
0);
} else if(strcmp(cpt, "getfattr")==0) {
Findjob_set_action_target(job, 26, NULL, 0);
} else {
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
Text_shellsafe(argv[i], sfe, 0));
@ -13299,8 +13359,11 @@ int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag)
}
/* Option -getfacl alias -getfacli, -getfacl_r alias -getfacl_ri */
/* @param flag bit0=recursive -getfacl_r
/* Optionis -getfacl alias -getfacli, -getfacl_r alias -getfacl_ri
-getfattr alias getfattri
*/
/* @param flag bit0= recursive -getfacl_r
bit1= getfattr rather than getfacl
*/
int Xorriso_option_getfacli(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag)
@ -13322,12 +13385,18 @@ int Xorriso_option_getfacli(struct XorrisO *xorriso,
Xorriso_no_findjob(xorriso, "-getfacl_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_target(job, 24, NULL, 0);
if(flag & 2) {
Findjob_set_action_target(job, 26, NULL, 0);
} else
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, NULL, optv[i], NULL, 0);
if(flag & 2)
ret= Xorriso_getfattr(xorriso, NULL, optv[i], 0);
else
ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0);
}
if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */
@ -13432,6 +13501,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Override system assumption of the local character set name.",
" -acl \"on\"|\"off\"",
" Enable resp. disable reading and writing of ACLs.",
" -xattr \"on\"|\"off\"",
" Enable resp. disable reading and writing of xattr.",
" -ban_stdio_write",
" Allow for writing only the usage of optical drives.",
" -blank \"fast\"|\"all\"|\"deformat\"|\"deformat_quickest\"",
@ -13569,11 +13640,12 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" If -type is given then only files with matching type are",
" processed. Types: block,char,dir,pipe,file,link,socket.",
" Further tests: -damaged, -undamaged, -lba_range start count,",
" -pending_data, -has_acl, -has_no_acl.",
" -pending_data, -has_acl, -has_no_acl, -has_xattr,",
" -has_no_xattr, -has_aaip, -has_no_aaip.",
" Action may be one of: echo, chown, chown_r, chgrp, chgrp_r",
" chmod, chmod_r, alter_date, alter_date_r, lsdl, compare,",
" rm, rm_r, compare, update, report_damage, report_lba,",
" getfacl, setfacl, find.",
" getfacl, setfacl, getfattr, find.",
" params are their arguments except iso_rr_path.",
" echo, lsdl, rm, rm_r, report_damage have no params at all.",
" -mkdir iso_rr_path [...]",
@ -13666,6 +13738,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -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.",
" -getfattr pattern [***] list eventual xattr of the given files.",
" -getfxattr_r pattern [***] like -getfxattr 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.",
@ -13977,57 +14051,11 @@ int Xorriso_option_load(struct XorrisO *xorriso, char *adr_mode,
ret= Xorriso_reassure(xorriso, "-load", "loads an alternative image", 0);
if(ret<=0)
return(2);
#ifndef NIX
ret= Xorriso_decode_load_adr(xorriso, "-load", adr_mode, adr_value,
&(xorriso->image_start_mode),
xorriso->image_start_value, 0);
if(ret <= 0)
return(ret);
#else
double num;
int l;
if(strcmp(adr_mode, "auto")==0)
xorriso->image_start_mode= 0;
else if(strcmp(adr_mode, "session")==0)
xorriso->image_start_mode= 1;
else if(strcmp(adr_mode, "track")==0)
xorriso->image_start_mode= 2;
else if(strcmp(adr_mode, "lba")==0 || strcmp(adr_mode, "sbsector")==0)
xorriso->image_start_mode= 3 | ((flag&1) << 16);
else if(strcmp(adr_mode, "volid")==0)
xorriso->image_start_mode= 4;
else {
sprintf(xorriso->info_text, "-load: unknown address mode '%s'", adr_mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
l= strlen(adr_value);
if(l==0)
xorriso->image_start_mode= 0;
if(xorriso->image_start_mode>=1 && xorriso->image_start_mode<= 3) {
num= Scanf_io_size(adr_value, 0);
if(xorriso->image_start_mode==3 &&
(adr_value[l-1]<'0' || adr_value[l-1]>'9'))
num/= 2048.0;
sprintf(xorriso->image_start_value, "%.f", num);
} else {
if(strlen(adr_value)>80) {
sprintf(xorriso->info_text, "-load: address value too long (80 < %d)",
(int) strlen(adr_value));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
strcpy(xorriso->image_start_value, adr_value);
}
#endif /* NIX */
xorriso->image_start_mode|= (1<<30); /* enable non-default msc1 processing */
if(strlen(xorriso->indev)>0) {
ret= Xorriso_option_rollback(xorriso, 1); /* Load image, no -reassure */
@ -15181,10 +15209,6 @@ int Xorriso_option_prompt(struct XorrisO *xorriso, char *text, int flag)
/* Option -publisher */
int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag)
{
#ifdef NIX
int ret;
#endif
if(strlen(name)>=sizeof(xorriso->publisher)) {
sprintf(xorriso->info_text,
"Name too long with option -publisher (%d > %d)",
@ -15192,13 +15216,6 @@ int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
#ifdef NIX
ret= Xorriso_set_publisher(xorriso, name, 0);
if(ret<=0)
return(ret);
#endif /* NIX */
if(Sfile_str(xorriso->publisher,name,0)<=0)
return(-1);
return(1);
@ -16059,6 +16076,27 @@ int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag)
}
/* Option -xattr "on"|"off" */
int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag)
{
int ret;
if(strcmp(mode, "off")==0)
xorriso->do_aaip&= ~12;
else if(strcmp(mode, "on")==0)
xorriso->do_aaip|= (4 | 8);
else {
sprintf(xorriso->info_text, "-xattr: unknown mode '%s'", mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
ret= Xorriso_set_ignore_aclea(xorriso, 0);
if(ret <= 0)
return(ret);
return(1);
}
/* ---------------------------- End Options API ------------------------ */
@ -16124,7 +16162,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"prog","prog_help","publisher","quoted_not_list","quoted_path_list",
"reassure","report_about","rom_toc_scan",
"session_log","speed","split_size","status","status_history_max",
"stream_recording","temp_mem_limit","uid","volid","use_readline",
"stream_recording","temp_mem_limit","uid","use_readline","volid","xattr",
""
};
static char arg2_commands[][40]= {
@ -16147,6 +16185,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"du","dui","dus","dusi","dux","dusx","extract_l",
"file_size_limit","find","findi","findx",
"getfacl","getfacli","getfacl_r","getfacl_ri",
"getfattr","getfattri","getfattr_r","getfattr_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",
@ -16503,6 +16542,12 @@ next_command:;
} else if(strcmp(cmd,"getfacl_r")==0 || strcmp(cmd,"getfacl_ri")==0) {
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 1);
} else if(strcmp(cmd,"getfattr")==0 || strcmp(cmd,"getfattri")==0) {
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 2);
} else if(strcmp(cmd,"getfattr_r")==0 || strcmp(cmd,"getfattr_ri")==0) {
ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 1 | 2);
} else if(strcmp(cmd,"gid")==0) {
(*idx)++;
ret= Xorriso_option_gid(xorriso,arg1,0);
@ -16854,6 +16899,10 @@ next_command:;
(*idx)++;
ret= Xorriso_option_volid(xorriso,arg1,0);
} else if(strcmp(cmd,"xattr")==0) {
(*idx)++;
ret= Xorriso_option_xattr(xorriso, arg1, 0);
} else if(strcmp(cmd, xorriso->list_delimiter)==0){
/* tis ok */;

@ -660,7 +660,7 @@ int Sfile_type(char *filename, int flag);
bit3= encode in any case shellsafe:
<=42 , 59, 60, 62, 63, 92, 94, 96, >=123
*/
int Sfile_bsl_encoder(char **result, char *text, int flag);
int Sfile_bsl_encoder(char **result, char *text, size_t text_len, int flag);
char *Text_shellsafe(char *in_text, char *out_text, int flag);
@ -751,6 +751,10 @@ 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_get_xattr_filter(struct FindjoB *o, int *xattr_filter, int flag);
int Findjob_get_aaip_filter(struct FindjoB *o, int *aaip_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);

@ -1 +1 @@
#define Xorriso_timestamP "2009.01.30.145624"
#define Xorriso_timestamP "2009.02.02.134346"

@ -173,11 +173,6 @@ LIBISOBURN_MISCONFIGURATION_ = 0;
/* End of ugly compile time test (scroll up for explanation) */
#ifdef NIX
sprintf(xorriso->info_text, "Starting up libraries ...\n");
Xorriso_info(xorriso, 0);
#endif
handler_prefix= calloc(strlen(xorriso->progname)+3+1, 1);
if(handler_prefix==NULL) {
sprintf(xorriso->info_text,
@ -236,12 +231,6 @@ LIBISOBURN_MISCONFIGURATION_ = 0;
sprintf(xorriso->info_text, "%s", reason);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
}
#ifdef NIX
sprintf(xorriso->info_text, "Library startup done.\n");
Xorriso_info(xorriso, 0);
#endif
free(handler_prefix);
return(1);
}
@ -1151,11 +1140,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
Xorriso_process_msg_queues(xorriso, 0);
return(ret);
}
#ifdef NIX
relax= isoburn_igopt_allow_deep_paths;
#else
relax= xorriso->relax_compliance;
#endif
xorriso->alignment= 0;
image= isoburn_get_attached_image(source_drive);
@ -1202,19 +1187,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
#ifdef NIX
#ifdef Xorriso_with_make_isohybrid_mbR
/* ??? must the boot image have a low LBA to boot from MBR ? */
/* A81110: Does not look so. The proplems were caused by wrong
self-LBA in isolinux.bin at byte 12 to 15 */
isoburn_igopt_set_sort_files(sopts, isoburn_igopt_sort_files_by_weight);
iso_node_set_sort_weight(node, 0x7fffffff);
#endif
#endif /* NIX */
ret= Xorriso_node_from_path(xorriso, image, xorriso->boot_image_cat_path,
&node, 1);
if(ret > 0) {
@ -1458,17 +1430,8 @@ ex:;
Xorriso_set_abort_severity(xorriso, 0);
if(ret<=0) {
/* >>> ??? revive discarded boot image */;
#ifdef NIX
/* <<< this was probably not a good idea */
} else if(xorriso->boot_image_bin_path[0]) {
xorriso->keep_boot_image= 1;
xorriso->patch_isolinux_image= 1;
xorriso->boot_image_bin_path[0]= 0;
sprintf(xorriso->info_text, "Switched to -boot_image isolinux patch");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
#endif /* NIX */
/* >>> ??? revive discarded boot image */;
}
if(disc!=NULL)
@ -2014,15 +1977,15 @@ int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf,
/* @param flag bit0= give directory x-permission where is r-permission
bit1= do not transfer ACL
bit2= transfer ACL even if NULL
bit1= do not transfer ACL or xattr
*/
int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf,
char *disk_path, IsoNode *node, int flag)
{
mode_t mode;
int a_ret= 0, d_ret= 0;
char *default_text= NULL, *access_text= NULL;
int ret= 1;
size_t num_attrs= 0, *value_lengths= NULL;
char **names= NULL, **values= NULL;
mode= stbuf->st_mode;
if((flag&1) && S_ISDIR(mode)) {
@ -2040,18 +2003,34 @@ int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf,
iso_node_set_mtime(node, stbuf->st_mtime);
iso_node_set_ctime(node, stbuf->st_ctime);
if((xorriso->do_aaip & 1) && !(flag & 2)) {
a_ret= iso_local_get_acl_text(disk_path, &access_text, 16);
if(S_ISDIR(stbuf->st_mode) && a_ret >= 0)
d_ret= iso_local_get_acl_text(disk_path, &default_text, 1);
if(access_text != NULL || default_text != NULL || (flag & 4))
a_ret= iso_node_set_acl_text(node, access_text, default_text, 0);
if(access_text != NULL)
iso_local_get_acl_text(disk_path, &access_text, 1 << 15);
if(default_text != NULL)
iso_local_get_acl_text(disk_path, &default_text, 1 << 15);
}
return(a_ret >= 0 && d_ret >= 0);
if(flag & 2)
{ret= 1; goto ex;}
if(xorriso->do_aaip & 5) {
ret= iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths,
&values, ((xorriso->do_aaip & 1) && !(flag & 2))
| (!(xorriso->do_aaip & 4)) << 4);
if(ret < 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, disk_path, ret,
"Error when obtaining local ACL and xattr", 0,
"FAILURE", 1 | 2);
ret= 0; goto ex;
}
ret= iso_node_set_attrs(node, num_attrs, names, value_lengths, values, 0);
if(ret < 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, "", ret,
"Error when obtaining local ACL and xattr", 0,
"FAILURE", 1);
ret= 0; goto ex;
}
ret= 1;
}
ex:;
iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths,
&values, 1 << 15); /* free memory */
return(ret);
}
@ -2495,7 +2474,7 @@ int Xorriso_copy_properties(struct XorrisO *xorriso,
return(0);
}
Xorriso_transfer_properties(xorriso, &stbuf, disk_path, node,
4 | ((flag & 2) >> 1) | (((stbuf.st_mode & S_IFMT) == S_IFLNK) << 1));
((flag & 2) >> 1) | (((stbuf.st_mode & S_IFMT) == S_IFLNK) << 1));
xorriso->volset_change_pending= 1;
return(1);
}
@ -2924,6 +2903,9 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
#ifdef Xorriso_with_aaiP
if(xorriso->do_aaip & 2) {
/* >>> change to iso_node_get_attrs */;
ret= iso_node_get_acl_text(node, &access_text, &default_text, 16);
if(ret < 0) {
strcpy(xorriso->info_text, "Error with obtaining ACL for ");
@ -2931,6 +2913,9 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
/* >>> change to iso_node_set_attrs */;
if(access_text != NULL) {
ret= iso_local_set_acl_text(disk_path, access_text, 0);
if(ret == -1) {
@ -6499,6 +6484,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action == 25) {
if(target == NULL || target[0] || text_2 == NULL || text_2[0])
ret= Xorriso_setfacl(xorriso, (void *) node, show_path, target, text_2,0);
} else if(action == 26) {
ret= Xorriso_getfattr(xorriso, (void *) node, show_path, 0);
} else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
@ -6519,7 +6506,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, acl_filter;
int ret, start_lba, end_lba, damage_filter, commit_filter, lba, a_filter;
off_t damage_start, damage_end, size;
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i;
void *wanted_node;
@ -6556,18 +6543,49 @@ 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) {
Findjob_get_acl_filter(job, &a_filter, 0);
if(a_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)
if(a_filter < 0 && ret != 2)
{ret= 0; goto ex;}
if(acl_filter > 0 && ret == 2)
if(a_filter > 0 && ret == 2)
{ret= 0; goto ex;}
}
Findjob_get_xattr_filter(job, &a_filter, 0);
if(a_filter) {
ret = Xorriso_getfattr(xorriso, (void *) node, "", 2);
if(ret < 0) {
Xorriso_process_msg_queues(xorriso, 0);
goto ex;
}
if(a_filter < 0 && ret > 0)
{ret= 0; goto ex;}
if(a_filter > 0 && ret == 0)
{ret= 0; goto ex;}
}
Findjob_get_aaip_filter(job, &a_filter, 0);
if(a_filter) {
#ifdef Xorriso_with_aaiP
{ void *xinfo_dummy;
ret= iso_node_get_xinfo(node, aaip_xinfo_func, &xinfo_dummy);
}
#else
ret= 0;
#endif
if(ret < 0) {
Xorriso_process_msg_queues(xorriso, 0);
goto ex;
}
if(a_filter < 0 && ret == 1)
{ret= 0; goto ex;}
if(a_filter > 0 && ret != 1)
{ret= 0; goto ex;}
}
Findjob_get_wanted_node(job, &wanted_node, 0);
if(wanted_node != NULL && ((IsoNode *) wanted_node) != node)
{ret= 0; goto ex;}
@ -6851,56 +6869,6 @@ int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag)
}
#ifdef NIX
/* @param flag bit0= do not mark image as changed */
int Xorriso_set_publisher(struct XorrisO *xorriso, char *name, int flag)
{
int ret;
IsoImage *volume;
if(xorriso->in_volset_handle == NULL)
return(2);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
return(ret);
iso_image_set_publisher_id(volume, name);
if(!(flag&1))
xorriso->volset_change_pending= 1;
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,"Publisher: '%s'",
iso_image_get_publisher_id(volume));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
return(1);
}
/* @param flag bit0= do not mark image as changed */
int Xorriso_set_application_id(struct XorrisO *xorriso, char *name, int flag)
{
int ret;
IsoImage *volume;
if(xorriso->in_volset_handle == NULL)
return(2);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
return(ret);
iso_image_set_application_id(volume, name);
if(!(flag&1))
xorriso->volset_change_pending= 1;
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,"Application id: '%s'",
iso_image_get_application_id(volume));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
return(1);
}
#endif /* NIX */
/* @param flag bit0=prepare for a burn run */
int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag)
{
@ -8813,6 +8781,34 @@ ok:;
}
/*
@param flag bit0= do not remove leading slash
*/
int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag)
{
int ret, path_offset= 0, bsl_mem;
char *bsl_path= NULL;
if(path[0] == '/' && !(flag & 1))
path_offset= 1;
/* backslash escaped path rather than shellsafe path */
ret= Sfile_bsl_encoder(&bsl_path, path + path_offset,
strlen(path + path_offset), 8);
if(ret <= 0)
return(-1);
sprintf(xorriso->result_line, "# file: %s\n", bsl_path);
free(bsl_path);
bsl_path= NULL;
/* temporarily disable -backslash_codes with result output */
bsl_mem= xorriso->bsl_interpretation;
xorriso->bsl_interpretation= 0;
Xorriso_result(xorriso, 0);
xorriso->bsl_interpretation= bsl_mem;
return(1);
}
/* @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
@ -8828,15 +8824,14 @@ ok:;
int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
char **acl_text, int flag)
{
int ret, d_ret, path_offset= 0, result_len= 0, pass, bsl_mem;
int ret, d_ret, result_len= 0, pass;
IsoNode *node;
char *text= NULL, *d_text= NULL, *cpt, *npt, *bsl_path= NULL;
char *text= NULL, *d_text= NULL, *cpt, *npt;
uid_t uid;
gid_t gid;
struct passwd *pwd;
struct group *grp;
node= (IsoNode *) in_node;
if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
@ -8881,22 +8876,9 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
}
if(!(flag & 1)) {
if(path[0] == '/' && !(flag & 2))
path_offset= 1;
/* backslash escaped path rather than shellsafe path */
ret= Sfile_bsl_encoder(&bsl_path, path + path_offset, 8);
ret= Xorriso_getfname(xorriso, path, 0);
if(ret <= 0)
{ret= -1; goto ex;}
sprintf(xorriso->result_line, "# file: %s\n", bsl_path);
free(bsl_path);
bsl_path= NULL;
/* temporarily disable -backslash_codes with result output */
bsl_mem= xorriso->bsl_interpretation;
xorriso->bsl_interpretation= 0;
Xorriso_result(xorriso, 0);
xorriso->bsl_interpretation= bsl_mem;
goto ex;
uid= iso_node_get_uid(node);
pwd= getpwuid(uid);
if(pwd == NULL)
@ -8963,8 +8945,6 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
ret= 1;
ex:;
iso_node_get_acl_text(node, &text, &d_text, 1 << 15);
if(bsl_path != NULL)
free(bsl_path);
return(ret);
}
@ -9025,3 +9005,77 @@ ex:;
return(ret);
}
/*
@param flag
>>> bit1= check for existence of non-ACL xattr,
return 0 or 1
*/
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
int flag)
{
int ret= 1, i, bsl_mem;
size_t num_attrs= 0, *value_lengths= NULL;
char **names= NULL, **values= NULL, *bsl;
IsoNode *node;
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_attrs(node, &num_attrs, &names, &value_lengths,
&values, 0);
#else
ret= 1;
#endif
if(ret < 0) {
strcpy(xorriso->info_text, "Error with obtaining xattr of ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
}
if(flag & 2) {
ret= (num_attrs > 0);
goto ex;
}
if(num_attrs == 0)
{ret= 2; goto ex;}
ret= Xorriso_getfname(xorriso, path, 0);
if(ret <= 0)
goto ex;
for(i= 0; i < num_attrs; i++) {
if(strlen(names[i]) + value_lengths[i] >= SfileadrL) {
sprintf(xorriso->result_line, "# oversized: name %d , value %d bytes\n",
(int) strlen(names[i]), (int) value_lengths[i]);
} else {
ret= Sfile_bsl_encoder(&bsl, names[i], strlen(names[i]), 8);
if(ret <= 0)
{ret= -1; goto ex;}
strcpy(xorriso->result_line, bsl);
free(bsl);
ret= Sfile_bsl_encoder(&bsl, values[i], value_lengths[i], 8);
if(ret <= 0)
{ret= -1; goto ex;}
sprintf(xorriso->result_line + strlen(xorriso->result_line),
"=\"%s\"\n", bsl);
free(bsl);
}
/* temporarily disable -backslash_codes with result output */
bsl_mem= xorriso->bsl_interpretation;
xorriso->bsl_interpretation= 0;
Xorriso_result(xorriso, 0);
xorriso->bsl_interpretation= bsl_mem;
}
strcpy(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
ret= 1;
ex:;
iso_node_get_attrs(node, &num_attrs, &names, &value_lengths,
&values, 1 << 15); /* free memory */
return(ret);
}

@ -398,6 +398,8 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result,
int Xorriso_getfacl(struct XorrisO *xorriso, void *node,
char *path, char **acl_text, int flag);
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
int flag);
/* Calls iso_image_set_ignore_aclea() according to xorriso->do_aaip */
int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag);

Loading…
Cancel
Save