Took into respect ACL and xattr with -compare and -update

This commit is contained in:
Thomas Schmitt 2009-02-16 08:26:53 +00:00
parent ef8333effe
commit 1251c6e135
5 changed files with 486 additions and 111 deletions

View File

@ -53,14 +53,14 @@ Updates ISO subtrees incrementally to match given disk subtrees.
Writes result either as completely new image or as add-on session Writes result either as completely new image or as add-on session
to optical media or filesystem objects. to optical media or filesystem objects.
.br .br
Can record and restore ACL of disk files.
.br
Can activate ISOLINUX boot images via El Torito. Can activate ISOLINUX boot images via El Torito.
.br .br
Can perform multi-session tasks as emulation of mkisofs and cdrecord. Can perform multi-session tasks as emulation of mkisofs and cdrecord.
.br .br
Can restore files from ISO image to disk filesystem (see osirrox). Can restore files from ISO image to disk filesystem (see osirrox).
.br .br
Can record and restore ACL of disk files.
.br
Can issue commands to mount older sessions on Linux or FreeBSD. Can issue commands to mount older sessions on Linux or FreeBSD.
.br .br
Can check media for damages and copy readable blocks to disk. Can check media for damages and copy readable blocks to disk.
@ -386,7 +386,8 @@ The MBR of a follow-up session can get in effect only on overwriteable media.
are an advanced way of controlling access permissions to file objects. Neither are an advanced way of controlling access permissions to file objects. Neither
ISO 9660 nor Rock Ridge specify a way to record ACLs. So libisofs has ISO 9660 nor Rock Ridge specify a way to record ACLs. So libisofs has
introduced a standard conformant extension named AAIP for that purpose. introduced a standard conformant extension named AAIP for that purpose.
It uses this extension if enabled by option -acl. It uses this extension if enabled by option
.B -acl.
.br .br
AAIP enhanced images are supposed to be mountable normally, but one cannot AAIP enhanced images are supposed to be mountable normally, but one cannot
expect that the mounted filesystem will show and respect the eventual ACLs. expect that the mounted filesystem will show and respect the eventual ACLs.
@ -403,9 +404,10 @@ eventually removing the ACL from a file.
are pairs of name and value which can be attached to file objects. AAIP is are pairs of name and value which can be attached to file objects. AAIP is
able to represent them and xorriso allows to record and restore pairs which able to represent them and xorriso allows to record and restore pairs which
have names out of the user namespace. I.e. those which begin with "user.", have names out of the user namespace. I.e. those which begin with "user.",
like "user.x" or "user.whatever". Value can be any string which does like "user.x" or "user.whatever". Name has to be a 0 terminated string.
not exceed the size of 4095 characters. xattr processing happens only if Value may be any array of bytes which does not exceed the size of 4095 bytes.
it is enabled by option -xattr. xattr processing happens only if it is enabled by option
.B -xattr.
.br .br
As with ACL, currently only xorriso is able to retrieve xattr from AAIP As with ACL, currently only xorriso is able to retrieve xattr from AAIP
enhanced images and to restore them to xattr capable file systems. enhanced images and to restore them to xattr capable file systems.
@ -656,15 +658,14 @@ will be copied to -in_charset.
Enable or disable processing of ACLs. 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, 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 load AAIP data from ISO images, test ACL during file comparison,
extracting them from ISO images. See also options -getfacl, -setfacl. and restore ACLs to disk files when extracting them from ISO images.
See also options -getfacl, -setfacl.
.TP .TP
\fB\-xattr\fR "on"|"off" \fB\-xattr\fR "on"|"off"
Enable or disable processing of XFS style Extended Attributes. These are Enable or disable processing of xattr attributes in user namespace.
pairs of name and value. The names are 0-terminated strings. Values can If enabled, then xorriso will handle xattr similar to ACL.
be arbitrary binary data. See also options -getfattr, -setfattr and above paragraph about xattr.
If enabled, then xorriso will import and export xattr similar to ACL.
See also options -getfattr, -setfattr.
.TP .TP
\fB\-rom_toc_scan\fR "on"|"off"[:"emul_on"|"emul_off"] \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 Read-only drives do not tell the actual media type but show any media as
@ -1021,7 +1022,8 @@ Only names from the user namespace are allowed. I.e. a name has to begin with
"user.", like "user.x" or "user.whatever". "user.", like "user.x" or "user.whatever".
.br .br
Values and names undergo the normal input processing of xorriso. Values and names undergo the normal input processing of xorriso.
See also option -backslash_codes. Byte value 0 cannot be expressed. See also option -backslash_codes. Other than with option -setfattr_list,
the byte value 0 cannot be expressed via -setfattr.
.TP .TP
\fB\-setfattr_r\fR [-]name value iso_rr_path [***] \fB\-setfattr_r\fR [-]name value iso_rr_path [***]
Like -setfattr but affecting all files below eventual directories. Like -setfattr but affecting all files below eventual directories.
@ -1041,11 +1043,12 @@ pending iso_rr_path. Other input lines must have the form
.br .br
name="value" name="value"
.br .br
Name should be of the form user.xyz with only printable characters in Name must be from user namespace. I.e. user.xyz where xyz should consist of
xyz. The separator "=" is not allowed in names. Value may contain any kind printable characters only. The separator "=" is not allowed in names.
of bytes. It must be in quotes. Trailing whitespace after the end quote will Value may contain any kind of bytes. It must be in quotes. Trailing
be ignored. Non-printables bytes and quotes must be represented as \\XYZ by whitespace after the end quote will be ignored. Non-printables bytes and quotes
their octal ASCII code XYZ. Use code \\000 for 0-bytes. must be represented as \\XYZ by their octal ASCII code XYZ.
Use code \\000 for 0-bytes.
.TP .TP
\fB\-alter_date\fR type timestring iso_rr_path [***] \fB\-alter_date\fR type timestring iso_rr_path [***]
Alter the date entries of a file in the ISO image. type is Alter the date entries of a file in the ISO image. type is
@ -2152,8 +2155,8 @@ Like -gefacl but listing recursively the whole file trees underneath eventual
directories. directories.
.TP .TP
\fB\-getfattr\fR iso_rr_pattern [***] \fB\-getfattr\fR iso_rr_pattern [***]
Print the XFS style Extended Attributes of the given files in the ISO image. Print the xattr of the given files in the ISO image.
If ia file has no such xattr then noting is printed for it. If a file has no such xattr then noting is printed for it.
.TP .TP
\fB\-getfattr_r\fR iso_rr_pattern [***] \fB\-getfattr_r\fR iso_rr_pattern [***]
Like -gefattr but listing recursively the whole file trees underneath eventual Like -gefattr but listing recursively the whole file trees underneath eventual

View File

@ -1013,6 +1013,132 @@ int Sort_argv(int argc, char **argv, int flag)
} }
static int Text_to_argv(char *text, int *argc, char ***argv, int flag)
{
char *npt, *cpt;
int pass;
*argv= NULL;
*argc= 0;
for(pass= 0; pass < 2; pass++) {
if(pass) {
if(*argc == 0)
return(1);
(*argv)= calloc(*argc, sizeof(char *));
if(*argv == NULL) {
*argc= 0;
return(-1);
}
*argc= 0;
}
for(npt= cpt= text; npt != NULL; cpt= npt + 1) {
npt= strchr(cpt, '\n');
if(pass) {
if(npt != NULL)
*npt= 0;
(*argv)[*argc]= cpt;
}
(*argc)++;
}
}
return(1);
}
static int Count_diffs(int argc1, char **argv1, int argc2, char **argv2,
int flag)
{
int count= 0, i1= 0, i2= 0, cmp, end_corr= 0;
Sort_argv(argc1, argv1, 0);
Sort_argv(argc2, argv2, 0);
while(1) {
if(i1 >= argc1) {
count+= argc2 - i2 - end_corr;
break;
}
if(i2 >= argc2) {
count+= argc1 - i1 - end_corr;
break;
}
cmp= strcmp(argv1[i1], argv2[i2]);
if(cmp == 0) {
end_corr= 0;
i1++;
i2++;
} else if(cmp > 0) {
count++;
end_corr= 1;
i2++;
if(i2 < argc2 && i1 < argc1 - 1)
if(strcmp(argv1[i1 + 1], argv2[i2]) == 0) {
i1++;
end_corr= 0;
}
} else {
count++;
end_corr= 1;
i1++;
if(i1 < argc1 && i2 < argc2 - 1)
if(strcmp(argv2[i2 + 1], argv1[i1]) == 0) {
i2++;
end_corr= 0;
}
}
}
return(count);
}
/*
@flag bit0= do not initialize *diff_count
@return <0 error , 0 = mismatch , 1 = match
*/
static int Compare_text_lines(char *text1, char *text2, int *diff_count,
int flag)
{
int ret, argc1= 0, argc2= 0;
char **argv1= NULL, **argv2= NULL, *copy1= NULL, *copy2= NULL;
if(!(flag & 1))
*diff_count= 0;
if(text1 == NULL && text2 == NULL)
return(1);
if(text1 != NULL) {
copy1= strdup(text1);
if(copy1 == NULL)
{ret= -1; goto ex;}
ret= Text_to_argv(copy1, &argc1, &argv1, 0);
if(ret <= 0)
{ret= -1; goto ex;}
}
if(text2 != NULL) {
copy2= strdup(text2);
if(copy2 == NULL)
{ret= -1; goto ex;}
ret= Text_to_argv(copy2, &argc2, &argv2, 0);
if(ret <= 0)
{ret= -1; goto ex;}
}
ret= Count_diffs(argc1, argv1, argc2, argv2, 1);
if(ret < 0)
goto ex;
*diff_count+= ret;
ret= (*diff_count == 0);
ex:;
if(argv1 != NULL)
free(argv1);
if(argv2 != NULL)
free(argv2);
if(copy1 != NULL)
free(copy1);
if(copy2 != NULL)
free(copy2);
return ret;
}
/** Convert a text into a number of type double and multiply it by unit code /** Convert a text into a number of type double and multiply it by unit code
[kmgtpe] (2^10 to 2^60) or [s] (2048). (Also accepts capital letters.) [kmgtpe] (2^10 to 2^60) or [s] (2048). (Also accepts capital letters.)
@param text Input like "42", "2k", "3.14m" or "-1g" @param text Input like "42", "2k", "3.14m" or "-1g"
@ -6570,6 +6696,9 @@ cannot_address:;
bit16= symbolic link on disk pointing to dir, dir in iso bit16= symbolic link on disk pointing to dir, dir in iso
bit17= file chunks detected and compared bit17= file chunks detected and compared
bit18= incomplete chunk collection encountered bit18= incomplete chunk collection encountered
bit19= ACL differs (this condition sets also bit2)
bit20= xattr differ
>>> bit21= mismatch of recorded dev,inode
@param flag bit0= compare atime @param flag bit0= compare atime
bit1= compare ctime bit1= compare ctime
bit2= check only existence of both file objects bit2= check only existence of both file objects
@ -6586,10 +6715,12 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
int *result, int flag) int *result, int flag)
{ {
struct stat s1, s2, stbuf; struct stat s1, s2, stbuf;
int ret, missing= 0, is_split= 0, i, was_error= 0; int ret, missing= 0, is_split= 0, i, was_error= 0, diff_count= 0;
char *respt; char *respt;
char a[5*SfileadrL], sfe[5*SfileadrL]; char a[5*SfileadrL], sfe[5*SfileadrL];
char ttx1[40], ttx2[40]; char ttx1[40], ttx2[40];
char *a1_acl= NULL, *a2_acl= NULL, *d1_acl= NULL, *d2_acl= NULL;
char *attrlist1= NULL, *attrlist2= NULL;
struct SplitparT *split_parts= NULL; struct SplitparT *split_parts= NULL;
int split_count= 0; int split_count= 0;
@ -6677,6 +6808,7 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
Xorriso_result(xorriso,0); Xorriso_result(xorriso,0);
(*result)|= 4; (*result)|= 4;
} }
if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) { if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) {
sprintf(respt, "%s type : %s <> %s\n", sprintf(respt, "%s type : %s <> %s\n",
a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0)); a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0));
@ -6692,6 +6824,60 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
} }
} }
} }
/* ACL */
if(xorriso->do_aaip & 3) {
Xorriso_local_getfacl(xorriso, disk_adr, &a1_acl,
16 | ((flag & (1 << 28)) >> 23));
if(S_ISDIR(s1.st_mode))
Xorriso_local_getfacl(xorriso, disk_adr, &d1_acl, 1);
ret= Xorriso_getfacl(xorriso, NULL, iso_adr, &a2_acl, 1 | 4 | 16);
if(ret < 0)
goto ex;
if(S_ISDIR(s1.st_mode)) {
ret= Xorriso_getfacl(xorriso, NULL, iso_adr, &d2_acl, 1 | 8);
if(ret < 0)
goto ex;
}
ret= Compare_text_lines(a1_acl, a2_acl, &diff_count, 0);
if(ret < 0)
goto ex;
if(ret == 0)
(*result)|= 4 | (1 << 19);
ret= Compare_text_lines(d1_acl, d2_acl, &diff_count, 1);
if(ret < 0)
goto ex;
if(ret == 0)
(*result)|= 4 | (1 << 19);
if((*result) & (1 << 19)) {
sprintf(respt, "%s ACL : %d difference%s\n",
a, diff_count, diff_count == 1 ? "" : "s");
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
}
}
/* xattr */
if(xorriso->do_aaip & 12) {
ret= Xorriso_getfattr(xorriso, NULL, disk_adr, &attrlist1,
1 | 2 | ((flag & (1 << 28)) >> 23));
if(ret < 0)
goto ex;
ret= Xorriso_getfattr(xorriso, NULL, iso_adr, &attrlist2, 1);
if(ret < 0)
goto ex;
ret= Compare_text_lines(attrlist1, attrlist2, &diff_count, 0);
if(ret < 0)
goto ex;
if(ret == 0) {
(*result)|= (1 << 20);
sprintf(respt, "%s xattr : %d difference%s\n",
a, diff_count, diff_count == 1 ? "" : "s");
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
}
}
if(s1.st_uid != s2.st_uid) { if(s1.st_uid != s2.st_uid) {
sprintf(respt, "%s st_uid : %d <> %d\n", a, s1.st_uid, s2.st_uid); sprintf(respt, "%s st_uid : %d <> %d\n", a, s1.st_uid, s2.st_uid);
if(!(flag&(1<<31))) if(!(flag&(1<<31)))
@ -6754,6 +6940,11 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
(*result)|= 1024; (*result)|= 1024;
} }
} }
/* >>> dev,inode comparison. Eventually skip content comparison */
if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)) { if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)) {
/* Content */ /* Content */
if(is_split) { if(is_split) {
@ -6801,6 +6992,12 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
ex:; ex:;
if(split_parts!=NULL) if(split_parts!=NULL)
Splitparts_destroy(&split_parts, split_count, 0); Splitparts_destroy(&split_parts, split_count, 0);
Xorriso_local_getfacl(xorriso, disk_adr, &a1_acl, 1 << 15);
Xorriso_local_getfacl(xorriso, disk_adr, &d1_acl, 1 << 15);
if(a2_acl != NULL)
free(a2_acl);
if(d2_acl != NULL)
free(d2_acl);
return(ret); return(ret);
} }
@ -10166,8 +10363,8 @@ delete:;
} }
sprintf(xorriso->info_text, "Added/overwrote "); sprintf(xorriso->info_text, "Added/overwrote ");
} else if(compare_result&(4|16|32|256|512|1024)) { } else if(compare_result&(4|16|32|256|512|1024|(1<<19)|(1<<20))) {
/* access permissions, user id, group id, mtime, atime, ctime */ /* access permissions, user id, group id, mtime, atime, ctime, ACL, xattr */
if(is_split) { if(is_split) {
ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL, ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL,
@ -13539,7 +13736,7 @@ int Xorriso_option_getfacli(struct XorrisO *xorriso,
Findjob_destroy(&job, 0); Findjob_destroy(&job, 0);
} else { } else {
if(flag & 2) if(flag & 2)
ret= Xorriso_getfattr(xorriso, NULL, optv[i], 0); ret= Xorriso_getfattr(xorriso, NULL, optv[i], NULL, 0);
else else
ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0); ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.02.14.133013" #define Xorriso_timestamP "2009.02.16.082645"

View File

@ -6506,7 +6506,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
if(target == NULL || target[0] || text_2 == NULL || text_2[0]) if(target == NULL || target[0] || text_2 == NULL || text_2[0])
ret= Xorriso_setfacl(xorriso, (void *) node, show_path, target, text_2,0); ret= Xorriso_setfacl(xorriso, (void *) node, show_path, target, text_2,0);
} else if(action == 26) { } else if(action == 26) {
ret= Xorriso_getfattr(xorriso, (void *) node, show_path, 0); ret= Xorriso_getfattr(xorriso, (void *) node, show_path, NULL, 0);
} else if(action == 27) { } else if(action == 27) {
ret= Xorriso_path_setfattr(xorriso, (void *) node, show_path, ret= Xorriso_path_setfattr(xorriso, (void *) node, show_path,
target, strlen(text_2), text_2, 0); target, strlen(text_2), text_2, 0);
@ -6581,7 +6581,7 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
} }
Findjob_get_xattr_filter(job, &a_filter, 0); Findjob_get_xattr_filter(job, &a_filter, 0);
if(a_filter) { if(a_filter) {
ret = Xorriso_getfattr(xorriso, (void *) node, "", 2); ret = Xorriso_getfattr(xorriso, (void *) node, "", NULL, 64);
if(ret < 0) { if(ret < 0) {
Xorriso_process_msg_queues(xorriso, 0); Xorriso_process_msg_queues(xorriso, 0);
goto ex; goto ex;
@ -8841,6 +8841,11 @@ int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag)
@param flag bit0= do not report to result but only retrieve ACL text @param flag bit0= do not report to result but only retrieve ACL text
bit1= check for existence of true ACL (not fabricated), bit1= check for existence of true ACL (not fabricated),
do not allocate and set acl_text but return 1 or 2 do not allocate and set acl_text but return 1 or 2
bit2-3: what ALC to retrieve:
0= "access" and "default", mark "default:"
1= "access" only
2= "default" only, do not mark "default:"
bit4= get "access" ACL only if not trivial
@return 2 ok, no ACL available, eventual *acl_text will be NULL @return 2 ok, no ACL available, eventual *acl_text will be NULL
1 ok, ACL available, eventual *acl_text stems from malloc() 1 ok, ACL available, eventual *acl_text stems from malloc()
<=0 error <=0 error
@ -8848,7 +8853,7 @@ int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag)
int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
char **acl_text, int flag) char **acl_text, int flag)
{ {
int ret, d_ret, result_len= 0, pass; int ret, d_ret, result_len= 0, pass, what;
IsoNode *node; IsoNode *node;
char *text= NULL, *d_text= NULL, *cpt, *npt; char *text= NULL, *d_text= NULL, *cpt, *npt;
uid_t uid; uid_t uid;
@ -8856,6 +8861,10 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
struct passwd *pwd; struct passwd *pwd;
struct group *grp; struct group *grp;
what= (flag >> 2) & 3;
if(acl_text != NULL)
*acl_text= NULL;
node= (IsoNode *) in_node; node= (IsoNode *) in_node;
if(node == NULL) { if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
@ -8864,7 +8873,7 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
} }
#ifdef Xorriso_with_aaiP #ifdef Xorriso_with_aaiP
ret= iso_node_get_acl_text(node, &text, &d_text, 0); ret= iso_node_get_acl_text(node, &text, &d_text, flag & 16);
d_ret= (d_text != NULL); d_ret= (d_text != NULL);
#else #else
ret= d_ret= 0; ret= d_ret= 0;
@ -8927,33 +8936,45 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
ret= -1; goto ex; ret= -1; goto ex;
} }
} }
for(npt= cpt= text; npt != NULL; cpt= npt + 1) { if(text != NULL && what <= 1) {
npt= strchr(cpt, '\n'); for(npt= cpt= text; npt != NULL; cpt= npt + 1) {
if(npt != NULL) npt= strchr(cpt, '\n');
*npt= 0; if(npt != NULL)
if(*cpt == 0) { *npt= 0;
if(d_text != NULL || pass) if(*cpt == 0) {
continue; if(d_text != NULL || pass) {
} else if(npt != NULL)
result_len+= strlen(cpt) + 1; *npt= '\n';
if(pass) { continue;
sprintf(*acl_text + strlen(*acl_text), "%s\n", cpt); }
} else if(!(flag & 1)) { } else
Sfile_str(xorriso->result_line, cpt, 0); result_len+= strlen(cpt) + 1;
strcat(xorriso->result_line, "\n"); if(pass) {
Xorriso_result(xorriso, 0); sprintf(*acl_text + strlen(*acl_text), "%s\n", cpt);
} else if(!(flag & 1)) {
Sfile_str(xorriso->result_line, cpt, 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
}
if(npt != NULL)
*npt= '\n';
} }
} }
if(d_text != NULL) { if(d_text != NULL && (what == 0 || what == 2)) {
for(npt= cpt= d_text; npt != NULL; cpt= npt + 1) { for(npt= cpt= d_text; npt != NULL; cpt= npt + 1) {
npt= strchr(cpt, '\n'); npt= strchr(cpt, '\n');
if(npt != NULL) if(npt != NULL)
*npt= 0; *npt= 0;
if(*cpt != 0) { if(*cpt != 0) {
if(pass) { if(pass) {
sprintf(*acl_text + strlen(*acl_text), "default:%s\n", cpt); if(what == 0)
sprintf(*acl_text + strlen(*acl_text), "default:%s\n", cpt);
else
sprintf(*acl_text + strlen(*acl_text), "%s\n", cpt);
} else { } else {
Sfile_str(xorriso->result_line, "default:", 0); xorriso->result_line[0]= 0;
if(what == 0)
Sfile_str(xorriso->result_line, "default:", 0);
Sfile_str(xorriso->result_line, cpt, 1); Sfile_str(xorriso->result_line, cpt, 1);
result_len+= strlen(cpt) + 9; result_len+= strlen(cpt) + 9;
} }
@ -8963,6 +8984,8 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
strcat(xorriso->result_line, "\n"); strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
} }
if(npt != NULL)
*npt= '\n';
} }
} }
} }
@ -9029,78 +9052,91 @@ ex:;
return(ret); return(ret);
} }
/* /*
@param flag @param flag bit0= do not report to result but only retrieve attr text
bit1= check for existence of non-ACL xattr, bit1= path is disk_path
bit5= in case of symbolic link on disk: inquire link target
bit6= check for existence of non-ACL xattr,
return 0 or 1 return 0 or 1
*/ */
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
int flag) char **attr_text, int flag)
{ {
int ret= 1, i, bsl_mem; int ret= 1, i, bsl_mem, result_len= 0, pass;
size_t num_attrs= 0, *value_lengths= NULL; size_t num_attrs= 0, *value_lengths= NULL;
char **names= NULL, **values= NULL, *bsl; char **names= NULL, **values= NULL, *bsl;
IsoNode *node;
node= (IsoNode *) in_node; if(attr_text != NULL)
if(node == NULL) { *attr_text= NULL;
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); ret= Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names,
if(ret<=0) &value_lengths, &values, flag & (2 | 32));
goto ex; if(ret <= 0)
} goto ex;
if(flag & 64) {
#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); ret= (num_attrs > 0);
goto ex; goto ex;
} }
if(num_attrs == 0) if(num_attrs == 0)
{ret= 2; goto ex;} {ret= 2; goto ex;}
ret= Xorriso_getfname(xorriso, path, 0); if(!(flag & 1)) {
if(ret <= 0) ret= Xorriso_getfname(xorriso, path, 0);
goto ex; if(ret <= 0)
goto ex;
for(i= 0; i < num_attrs; i++) { }
if(strlen(names[i]) + value_lengths[i] >= SfileadrL) { for(pass= 0; pass < 1 + (attr_text != NULL); pass++) {
sprintf(xorriso->result_line, "# oversized: name %d , value %d bytes\n", if(pass) {
(int) strlen(names[i]), (int) value_lengths[i]); *attr_text= calloc(result_len + 1, 1);
} else { if(*attr_text == NULL) {
ret= Sfile_bsl_encoder(&bsl, names[i], strlen(names[i]), 8); Xorriso_no_malloc_memory(xorriso, NULL, 0);
if(ret <= 0) ret= -1; goto ex;
{ret= -1; goto ex;} }
strcpy(xorriso->result_line, bsl); }
free(bsl); for(i= 0; i < num_attrs; i++) {
ret= Sfile_bsl_encoder(&bsl, values[i], value_lengths[i], 8); if(strlen(names[i]) + value_lengths[i] >= SfileadrL) {
if(ret <= 0) sprintf(xorriso->result_line, "# oversized: name %d , value %d bytes\n",
{ret= -1; goto ex;} (int) strlen(names[i]), (int) value_lengths[i]);
sprintf(xorriso->result_line + strlen(xorriso->result_line), } else {
"=\"%s\"\n", bsl); ret= Sfile_bsl_encoder(&bsl, names[i], strlen(names[i]), 8);
free(bsl); if(ret <= 0)
} {ret= -1; goto ex;}
/* temporarily disable -backslash_codes with result output */ strcpy(xorriso->result_line, bsl);
bsl_mem= xorriso->bsl_interpretation; free(bsl);
xorriso->bsl_interpretation= 0; ret= Sfile_bsl_encoder(&bsl, values[i], value_lengths[i], 8);
Xorriso_result(xorriso, 0); if(ret <= 0)
xorriso->bsl_interpretation= bsl_mem; {ret= -1; goto ex;}
sprintf(xorriso->result_line + strlen(xorriso->result_line),
"=\"%s\"\n", bsl);
free(bsl);
}
/* temporarily disable -backslash_codes with result output */
result_len+= strlen(xorriso->result_line);
if(pass) {
strcat(*attr_text, xorriso->result_line);
} else if(!(flag & 1)) {
bsl_mem= xorriso->bsl_interpretation;
xorriso->bsl_interpretation= 0;
Xorriso_result(xorriso, 0);
xorriso->bsl_interpretation= bsl_mem;
}
}
}
if(!(flag & 1)) {
strcpy(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
} }
strcpy(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
ret= 1; ret= 1;
ex:; ex:;
#ifndef NIX
Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names,
&value_lengths, &values, 1 << 15);
#else /* NIX */
iso_node_get_attrs(node, &num_attrs, &names, &value_lengths, iso_node_get_attrs(node, &num_attrs, &names, &value_lengths,
&values, 1 << 15); /* free memory */ &values, 1 << 15); /* free memory */
#endif /* NIX */
return(ret); return(ret);
} }
@ -9177,17 +9213,151 @@ ex:;
int Xorriso_local_getfacl(struct XorrisO *xorriso, char *disk_path, int Xorriso_local_getfacl(struct XorrisO *xorriso, char *disk_path,
char **text, int flag) char **text, int flag)
{ {
int ret;
#ifdef Xorriso_with_aaiP #ifdef Xorriso_with_aaiP
ret= iso_local_get_acl_text(disk_path, text,
flag & (1 | 16 | 32 | (1 << 15)));
Xorriso_process_msg_queues(xorriso,0);
#else
ret= 0;
#endif
return(ret); int ret, skip= 0, colons= 0, countdown= 0;
char *acl= NULL, *cpt, *wpt;
if(flag & (1 << 15)) {
if(*text != NULL)
free(*text);
*text= NULL;
return(1);
}
*text= NULL;
ret= iso_local_get_acl_text(disk_path, &acl, flag & (1 | 16 | 32));
Xorriso_process_msg_queues(xorriso,0);
if(ret < 0 || ret == 2)
return(ret);
if(acl == NULL)
return(0);
*text= strdup(acl);
iso_local_get_acl_text(disk_path, &acl, 1 << 15);
if(*text == NULL) {
Xorriso_no_malloc_memory(xorriso, NULL, 0);
return(-1);
}
/* Garbage collection about trailing remarks after 3 permission chars */
wpt= *text;
for(cpt= *text; *cpt; cpt++) {
if(skip) {
if(*cpt == '\n')
skip= 0;
else
continue;
}
if(*cpt == ':' && !countdown) {
colons++;
if(colons == 2) {
countdown= 4;
colons= 0;
}
}
if(countdown > 0) {
countdown--;
if(countdown == 0)
skip= 1;
}
*wpt= *cpt;
wpt++;
}
*wpt= 0;
return(1);
#else
*text= NULL;
return(0);
#endif /* ! Xorriso_with_aaiP */
} }
/*
@param flag
bit1= path is disk_path
bit5= in case of symbolic link on disk: inquire link target
bit15= free memory
*/
int Xorriso_get_attrs(struct XorrisO *xorriso, void *in_node, char *path,
size_t *num_attrs, char ***names,
size_t **value_lengths, char ***values, int flag)
{
int ret, i, widx;
IsoNode *node;
if(flag & (1 << 15)) {
#ifdef Xorriso_with_aaiP
if(flag & 2) {
iso_local_get_attrs(NULL, num_attrs, names, value_lengths, values,
1 << 15);
} else {
iso_node_get_attrs(NULL, num_attrs, names, value_lengths, values,
1 << 15);
}
#endif /* Xorriso_with_aaiP */
return(1);
}
*num_attrs= 0;
if(flag & 2) {
#ifdef Xorriso_with_aaiP
ret= iso_local_get_attrs(path, num_attrs, names, value_lengths, values,
flag & 32);
if(ret < 0) {
strcpy(xorriso->info_text, "Error with reading xattr of disk file ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
}
#endif /* Xorriso_with_aaiP */
;
} else {
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);
if(ret < 0) {
Xorriso_report_iso_error(xorriso, "", ret,
"Error when obtaining xattr of ISO node", 0, "FAILURE", 1);
goto ex;
}
#endif /* Xorriso_with_aaiP */
/* Filter away any non-userspace xattr */;
widx= 0;
for(i= 0; i < *num_attrs; i++) {
if(strncmp((*names)[i], "user.", 5) != 0) {
free((*names)[i]);
(*names)[i]= NULL;
if((*values)[i] != NULL) {
free((*values)[i]);
(*values)[i]= NULL;
}
} else {
if(widx != i) {
(*names)[widx]= (*names)[i];
(*value_lengths)[widx]= (*value_lengths)[i];
(*values)[widx]= (*values)[i];
(*names)[i]= NULL;
(*value_lengths)[i]= 0;
(*values)[i]= NULL;
}
widx++;
}
}
*num_attrs= widx;
}
ret= 1;
ex:;
Xorriso_process_msg_queues(xorriso,0);
return(ret);
}

View File

@ -399,7 +399,7 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *node,
char *path, char **acl_text, int flag); char *path, char **acl_text, int flag);
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
int flag); char **attr_text, int flag);
/* Calls iso_image_set_ignore_aclea() according to xorriso->do_aaip */ /* Calls iso_image_set_ignore_aclea() according to xorriso->do_aaip */
int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag); int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag);
@ -416,10 +416,15 @@ int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag);
int Xorriso_setfacl(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_setfacl(struct XorrisO *xorriso, void *in_node, char *path,
char *access_text, char *default_text, int flag); char *access_text, char *default_text, int flag);
int Xorriso_get_attrs(struct XorrisO *xorriso, void *in_node, char *path,
size_t *num_attrs, char ***names,
size_t **value_lengths, char ***values, int flag);
int Xorriso_setfattr(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_setfattr(struct XorrisO *xorriso, void *in_node, char *path,
size_t num_attrs, char **names, size_t num_attrs, char **names,
size_t *value_lengths, char **values, int flag); size_t *value_lengths, char **values, int flag);
int Xorriso_local_getfacl(struct XorrisO *xorriso, char *disk_path, int Xorriso_local_getfacl(struct XorrisO *xorriso, char *disk_path,
char **text, int flag); char **text, int flag);