Enabled more actions for -findx: getfacl, getfattr, get_any_xattr

This commit is contained in:
Thomas Schmitt 2024-08-28 16:31:16 +02:00
parent c68d4f2ec6
commit ffe18475a4
7 changed files with 209 additions and 80 deletions

View File

@ -1156,17 +1156,20 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
char *abs_path, char *show_path, int depth, int flag)
{
int ret= 0, type, action= 0, dpl= 0, compare_result, uret, max_bit;
int follow_links;
uid_t user= 0;
gid_t group= 0;
time_t date= 0;
mode_t mode_or= 0, mode_and= ~1;
uint64_t chattr_flags, lfa_flags;
char *target, *text_2, *wdi_mem= NULL, *disk_prefix, *iso_path= NULL;
char *basename, *lfa_text= NULL;
char *basename, *lfa_text= NULL, *acl_text= NULL, *attrlist= NULL;
char *leafname= NULL;
struct FindjoB *subjob;
struct stat stbuf;
Xorriso_alloc_meM(iso_path, char, SfileadrL);
Xorriso_alloc_meM(leafname, char, SfileadrL);
action= Findjob_get_action_parms(job, &target, &text_2, &user, &group,
&mode_and, &mode_or, &type, &date, &subjob,
@ -1250,6 +1253,36 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
Xorriso_result(xorriso,0);
}
{ret= 1; goto ex;}
} else if(action == 24) { /* getfacl */
follow_links= (xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag & 1))) << 5;
ret= Xorriso_local_getfacl(xorriso, abs_path, &acl_text, follow_links);
if(ret == 1) {
ret= lstat(abs_path, &stbuf);
if(ret == -1)
{ret= 0; goto ex;}
ret= Xorriso_report_acl_header(xorriso, show_path,
stbuf.st_uid, stbuf.st_gid, 0);
if(ret > 0) {
strcpy(xorriso->result_line, acl_text);
Xorriso_result(xorriso, 0);
}
}
if(acl_text != NULL)
Xorriso_local_getfacl(xorriso, "", &acl_text, 1 << 15);
} else if(action == 26) { /* getfattr */
follow_links= (xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag & 1))) << 5;
ret= Xorriso_getfattr(xorriso, NULL, abs_path, &attrlist, 2 | follow_links);
} else if(action == 33) { /* get_any_xattr */
follow_links= (xorriso->do_follow_links ||
(xorriso->do_follow_param && !(flag & 1))) << 5;
ret= Xorriso_getfattr(xorriso, NULL, abs_path, &attrlist,
2 | 8 | follow_links);
} else if(action == 40) { /* estimate_size */
basename= strrchr(abs_path, '/');
if(basename != NULL)
@ -1263,6 +1296,14 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action == 44) { /* list_extattr */
ret= Xorriso_list_extattr(xorriso, NULL, abs_path, show_path, target, 2);
} else if(action == 50) { /* print_outname */
ret= Sfile_leafname(abs_path, leafname, 0);
if(ret <= 0)
goto ex;
ret= Xorriso_test_outchar(xorriso, NULL, leafname, type, 1);
if(ret <= 0)
goto ex;
} else if(action == 60) { /* lsattrd */
ret= Xorriso_get_lfa_flags(xorriso, NULL, show_path, &lfa_flags, &max_bit,
2);
@ -1294,6 +1335,7 @@ ex:;
xorriso->request_to_abort= 1; /* Need an image. No use to try again. */
if(wdi_mem != NULL)
free(wdi_mem);
Xorriso_free_meM(leafname);
Xorriso_free_meM(iso_path);
return(ret);
}

View File

@ -648,6 +648,35 @@ int Xorriso_is_split(struct XorrisO *xorriso, char *path, void *node,
}
int Xorriso_report_acl_header(struct XorrisO *xorriso, char *path,
uid_t uid, gid_t gid, int flag)
{
int ret;
struct passwd *pwd;
struct group *grp;
ret= Xorriso_getfname(xorriso, path, 0);
if(ret <= 0)
goto ex;
pwd= getpwuid(uid);
if(pwd == NULL)
sprintf(xorriso->result_line, "# owner: %.f\n", (double) uid);
else
sprintf(xorriso->result_line, "# owner: %s\n", pwd->pw_name);
Xorriso_result(xorriso, 0);
grp= getgrgid(gid);
if(grp == NULL)
sprintf(xorriso->result_line, "# group: %.f\n", (double) gid);
else
sprintf(xorriso->result_line, "# group: %s\n", grp->gr_name);
Xorriso_result(xorriso, 0);
ret= 1;
ex:
return(ret);
}
/* @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
@ -673,8 +702,6 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
char *text= NULL, *d_text= NULL, *cpt, *npt;
uid_t uid;
gid_t gid;
struct passwd *pwd;
struct group *grp;
what= (flag >> 2) & 3;
if(acl_text != NULL)
@ -713,23 +740,11 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
}
if(!(flag & 1)) {
ret= Xorriso_getfname(xorriso, path, 0);
uid= iso_node_get_uid(node);
gid= iso_node_get_gid(node);
ret= Xorriso_report_acl_header(xorriso, path, uid, gid, 0);
if(ret <= 0)
goto ex;
uid= iso_node_get_uid(node);
pwd= getpwuid(uid);
if(pwd == NULL)
sprintf(xorriso->result_line, "# owner: %.f\n", (double) uid);
else
sprintf(xorriso->result_line, "# owner: %s\n", pwd->pw_name);
Xorriso_result(xorriso, 0);
gid= iso_node_get_gid(node);
grp= getgrgid(gid);
if(grp == NULL)
sprintf(xorriso->result_line, "# group: %.f\n", (double) gid);
else
sprintf(xorriso->result_line, "# group: %s\n", grp->gr_name);
Xorriso_result(xorriso, 0);
}
for(pass= 0; pass < 1 + (acl_text != NULL && !(flag & 2)); pass++) {

View File

@ -9,7 +9,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 "Version 1.5.7, Aug 27, 2024"
.TH XORRISO 1 "Version 1.5.7, Aug 28, 2024"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -2492,8 +2492,8 @@ E.g.: \-exec setfacl u:lisa:rw,u::rw,g::r,o::\-,m::rw \-\-
.br
\fBgetfattr\fR
prints xattr name\-value pairs to the result channel. The choice of namespaces
depends on the setting of command \-xattr: "on" or "user" restricts it to the
namespace "user", "any" only omits namespace "isofs".
depends on the setting of command \-xattr: "off", "on", or "user" restricts
it to the namespace "user", "any" only omits namespace "isofs".
.br
\fBget_any_xattr\fR
prints xattr name\-value pairs from any namespace
@ -5115,7 +5115,7 @@ Similar to shell command du \-sk.
.TP
\fB\-findx\fR disk_path [test [op] [test ...]] [-exec action [params]] --
Like \-find but operating on local filesystem and not on the ISO image.
This is subject to the settings of \-follow.
The \-findx command is subject to the settings of \-follow.
.br
\-findx accepts the same tests as \-find, but only the following ones work
like described with \-find:
@ -5168,12 +5168,35 @@ contains files. To be used with \-type "m" to report mount points.
deletes all files from the counterpart
in the ISO image. To be used with \-type "m" to truncate mount points.
.br
\fBprint_outname\fR
prints in the first line the filename as found on disk,
and in the second line the filename after conversion forth and back between
local character set and one of the namespaces "rockridge", "joliet", "ecma119",
or "hfsplus". The third output line is "\-\-" .
.br
The name conversion does not take into respect the possibility of name
collisions in the target namespace. Such collisions are most likely in "joliet"
and "ecma119", where they get resolved by automatic file name changes.
.br
\fBestimate_size\fR
prints a lower and an upper estimation of the number of blocks which the
found files together will occupy in the emerging ISO image.
This does not account for the superblock,
for the directories in the \-findx path, or for image padding.
.br
\fBgetfacl\fR
prints access permissions in ACL text form to the result channel.
.br
\fBgetfattr\fR
prints xattr name\-value pairs to the result channel.
The choice of namespaces depends on the setting of command \-xattr:
"off", "on", or "user" restricts it to the namespace "user", "any" causes all
namespaces to be shown.
.br
\fBget_any_xattr\fR
prints xattr name\-value pairs to the result channel. All namespaces are shown
regardless of the setting of command \-xattr.
.br
\fBlist_extattr\fR mode
prints a script to the result channel, which would use FreeBSD command
setextattr to set the file's xattr name\-value pairs of user namespace.

View File

@ -2135,8 +2135,8 @@ File: xorriso.info, Node: CmdFind, Next: Filter, Prev: Manip, Up: Commands
getfattr
prints xattr name-value pairs to the result channel. The
choice of namespaces depends on the setting of command -xattr:
"on" or "user" restricts it to the namespace "user", "any"
only omits namespace "isofs".
"off", "on", or "user" restricts it to the namespace "user",
"any" only omits namespace "isofs".
get_any_xattr
prints xattr name-value pairs from any namespace except ACL to
the result channel. This is mostly for debugging of namespace
@ -4296,7 +4296,7 @@ File: xorriso.info, Node: Navigate, Next: Verify, Prev: Inquiry, Up: Command
match one of the patterns. Similar to shell command du -sk.
-findx disk_path [test [op] [test ...]] [-exec action [params]] --
Like -find but operating on local filesystem and not on the ISO
image. This is subject to the settings of -follow.
image. The -findx command is subject to the settings of -follow.
-findx accepts the same tests as -find, but only the following ones
work like described with -find:
-bad_outname, -decision, -disk_name, -disk_path, -has_acl,
@ -4336,11 +4336,33 @@ File: xorriso.info, Node: Navigate, Next: Verify, Prev: Inquiry, Up: Command
empty_iso_dir
deletes all files from the counterpart in the ISO image. To
be used with -type "m" to truncate mount points.
print_outname
prints in the first line the filename as found on disk, and in
the second line the filename after conversion forth and back
between local character set and one of the namespaces
"rockridge", "joliet", "ecma119", or "hfsplus". The third
output line is "-" .
The name conversion does not take into respect the possibility
of name collisions in the target namespace. Such collisions
are most likely in "joliet" and "ecma119", where they get
resolved by automatic file name changes.
estimate_size
prints a lower and an upper estimation of the number of blocks
which the found files together will occupy in the emerging ISO
image. This does not account for the superblock, for the
directories in the -findx path, or for image padding.
getfacl
prints access permissions in ACL text form to the result
channel.
getfattr
prints xattr name-value pairs to the result channel. The
choice of namespaces depends on the setting of command -xattr:
"off", "on", or "user" restricts it to the namespace "user",
"any" causes all namespaces to be shown.
get_any_xattr
prints xattr name-value pairs to the result channel. All
namespaces are shown regardless of the setting of command
-xattr.
list_extattr mode
prints a script to the result channel, which would use FreeBSD
command setextattr to set the file's xattr name-value pairs of
@ -6012,9 +6034,9 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -close_filter_list bans filter registration: Filter. (line 50)
* -commit writes pending ISO image: Writing. (line 27)
* -commit_eject writes and ejects: Writing. (line 53)
* -compare reports ISO/disk differences: Navigate. (line 156)
* -compare_l reports ISO/disk differences: Navigate. (line 172)
* -compare_r reports ISO/disk differences: Navigate. (line 168)
* -compare reports ISO/disk differences: Navigate. (line 178)
* -compare_l reports ISO/disk differences: Navigate. (line 194)
* -compare_r reports ISO/disk differences: Navigate. (line 190)
* -compliance controls standard compliance: SetWrite. (line 62)
* -concat copies ISO file content: Restore. (line 148)
* -copyright_file sets copyright file name: SetWrite. (line 266)
@ -6182,8 +6204,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -setfattr_r sets xattr in ISO image: Manip. (line 118)
* -set_filter applies filter to file: Filter. (line 58)
* -set_filter_r applies filter to file tree: Filter. (line 84)
* -show_stream shows data source and filters: Navigate. (line 176)
* -show_stream_r shows data source and filters: Navigate. (line 194)
* -show_stream shows data source and filters: Navigate. (line 198)
* -show_stream_r shows data source and filters: Navigate. (line 216)
* -sh_style_result makes results look more like shell: Scripting.
(line 63)
* -signal_handling controls handling of system signals: Exception.
@ -6318,8 +6340,8 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Filter, apply to file, -set_filter: Filter. (line 58)
* Filter, ban registration, -close_filter_list: Filter. (line 50)
* Filter, register, -external_filter: Filter. (line 20)
* Filter, show chain, -show_stream: Navigate. (line 176)
* Filter, show chains of tree, -show_stream_r: Navigate. (line 194)
* Filter, show chain, -show_stream: Navigate. (line 198)
* Filter, show chains of tree, -show_stream_r: Navigate. (line 216)
* Filter, unregister, -unregister_filter: Filter. (line 47)
* Filter, zisofs parameters, -zisofs: SetWrite. (line 317)
* Filter, _definition: Filter. (line 6)
@ -6523,9 +6545,9 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Unsuitable media states, _definition: Media. (line 25)
* UTF-16, for Joliet paths, -compliance: SetWrite. (line 114)
* Verify, check blocks, -check_media: Verify. (line 21)
* Verify, compare ISO and disk file, -compare: Navigate. (line 156)
* Verify, compare ISO and disk tree, -compare_r: Navigate. (line 168)
* Verify, compare ISO and disk, -compare_l: Navigate. (line 172)
* Verify, compare ISO and disk file, -compare: Navigate. (line 178)
* Verify, compare ISO and disk tree, -compare_r: Navigate. (line 190)
* Verify, compare ISO and disk, -compare_l: Navigate. (line 194)
* Verify, file checksum, -check_md5: Verify. (line 184)
* Verify, file tree checksums, -check_md5_r: Verify. (line 198)
* Verify, preset -check_media, -check_media_defaults: Verify. (line 40)
@ -6577,44 +6599,44 @@ Node: Insert64966
Node: SetInsert77161
Node: Manip87397
Node: CmdFind99517
Node: Filter120831
Node: Writing125453
Node: SetWrite137947
Node: Bootable169222
Node: Jigdo200504
Node: Charset205507
Node: Exception208836
Node: DialogCtl215025
Node: Inquiry217627
Node: Navigate230192
Node: Verify240256
Node: Restore251405
Node: Emulation263612
Node: Scripting274068
Node: Frontend281962
Node: Examples291588
Node: ExDevices292766
Node: ExCreate293427
Node: ExDialog294727
Node: ExGrowing295998
Node: ExModifying296807
Node: ExBootable297317
Node: ExCharset297872
Node: ExPseudo298768
Node: ExCdrecord299695
Node: ExMkisofs300015
Node: ExGrowisofs301912
Node: ExException303065
Node: ExTime303523
Node: ExIncBackup303981
Node: ExRestore308007
Node: ExRecovery308953
Node: Files309525
Node: Environ310859
Node: Seealso311607
Node: Bugreport312371
Node: Legal312962
Node: CommandIdx313974
Node: ConceptIdx332303
Node: Filter120839
Node: Writing125461
Node: SetWrite137955
Node: Bootable169230
Node: Jigdo200512
Node: Charset205515
Node: Exception208844
Node: DialogCtl215033
Node: Inquiry217635
Node: Navigate230200
Node: Verify241417
Node: Restore252566
Node: Emulation264773
Node: Scripting275229
Node: Frontend283123
Node: Examples292749
Node: ExDevices293927
Node: ExCreate294588
Node: ExDialog295888
Node: ExGrowing297159
Node: ExModifying297968
Node: ExBootable298478
Node: ExCharset299033
Node: ExPseudo299929
Node: ExCdrecord300856
Node: ExMkisofs301176
Node: ExGrowisofs303073
Node: ExException304226
Node: ExTime304684
Node: ExIncBackup305142
Node: ExRestore309168
Node: ExRecovery310114
Node: Files310686
Node: Environ312020
Node: Seealso312768
Node: Bugreport313532
Node: Legal314123
Node: CommandIdx315135
Node: ConceptIdx333464

End Tag Table

View File

@ -50,7 +50,7 @@
@c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISO 1 "Version 1.5.7, Aug 27, 2024"
@c man .TH XORRISO 1 "Version 1.5.7, Aug 28, 2024"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -2922,8 +2922,8 @@ E.g.: -exec setfacl u:lisa:rw,u::rw,g::r,o::@minus{},m::rw @minus{}@minus{}
@*
@item getfattr
prints xattr name-value pairs to the result channel. The choice of namespaces
depends on the setting of command -xattr: "on" or "user" restricts it to the
namespace "user", "any" only omits namespace "isofs".
depends on the setting of command -xattr: "off", "on", or "user" restricts
it to the namespace "user", "any" only omits namespace "isofs".
@*
@item get_any_xattr
prints xattr name-value pairs from any namespace
@ -5836,7 +5836,7 @@ Similar to shell command du -sk.
@kindex -findx traverses disk tree
@cindex Tree, disk, traverse, -findx
Like -find but operating on local filesystem and not on the ISO image.
This is subject to the settings of -follow.
The -findx command is subject to the settings of -follow.
@*
-findx accepts the same tests as -find, but only the following ones work
like described with -find:
@ -5891,12 +5891,35 @@ contains files. To be used with -type "m" to report mount points.
deletes all files from the counterpart
in the ISO image. To be used with -type "m" to truncate mount points.
@*
@item print_outname
prints in the first line the filename as found on disk,
and in the second line the filename after conversion forth and back between
local character set and one of the namespaces "rockridge", "joliet", "ecma119",
or "hfsplus". The third output line is "--" .
@*
The name conversion does not take into respect the possibility of name
collisions in the target namespace. Such collisions are most likely in "joliet"
and "ecma119", where they get resolved by automatic file name changes.
@*
@item estimate_size
prints a lower and an upper estimation of the number of blocks which the
found files together will occupy in the emerging ISO image.
This does not account for the superblock,
for the directories in the -findx path, or for image padding.
@*
@item getfacl
prints access permissions in ACL text form to the result channel.
@*
@item getfattr
prints xattr name-value pairs to the result channel.
The choice of namespaces depends on the setting of command -xattr:
"off", "on", or "user" restricts it to the namespace "user", "any" causes all
namespaces to be shown.
@*
@item get_any_xattr
prints xattr name-value pairs to the result channel. All namespaces are shown
regardless of the setting of command -xattr.
@*
@item list_extattr mode
prints a script to the result channel, which would use FreeBSD command
setextattr to set the file's xattr name-value pairs of user namespace.

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.08.27.205212"
#define Xorriso_timestamP "2024.08.28.143041"

View File

@ -422,6 +422,9 @@ 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_report_acl_header(struct XorrisO *xorriso, char *path,
uid_t uid, gid_t gid, int flag);
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
char **attr_text, int flag);
@ -601,10 +604,11 @@ int Xorriso_preparer_string(struct XorrisO *xorriso, char xorriso_id[129],
int Xorriso_jigdo_interpreter(struct XorrisO *xorriso, char *aspect, char *arg,
int flag);
int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job,
char *basename, mode_t st_mode, off_t st_size, int flag);
int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt, char *in_name,
int name_space, int flag);
int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
char *origin, char *dest, int flag);