Refusing to apply -chattr to non-dir, non-regular files
This commit is contained in:
parent
58fb826c1d
commit
c142b7b58f
@ -3033,7 +3033,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
|
||||
} else if(action == 61) { /* chattr */
|
||||
ret= Xorriso_set_lfa_flags(xorriso, node, show_path, "",
|
||||
chattr_flags, type, 1);
|
||||
chattr_flags, type, 1 | 4);
|
||||
|
||||
} else { /* includes : 15 in_iso */
|
||||
Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 0);
|
||||
@ -4717,6 +4717,12 @@ int Xorriso_decode_chattr_arg(struct XorrisO *xorriso, char *chattr_text,
|
||||
@param operator chattr operation mode 0='=', 1='+', 2='-'
|
||||
non-chattr modes: 3='.', 4="--remove-lfa-flags"
|
||||
@param flag bit0= use lfa_flags and operator rather than chattr_text
|
||||
bit1= do not refuse to set lfa_flags of files which
|
||||
are neither directory nor regular file
|
||||
bit2= if not bit1: refuse silently with return 2
|
||||
bit3= do not change flags but only test if it would be
|
||||
really attempted without bit3.
|
||||
return 1 if yes, <= 0 if not (with SORRY event).
|
||||
*/
|
||||
int Xorriso_set_lfa_flags(struct XorrisO *xorriso, void *in_node, char *path,
|
||||
char *chattr_text, uint64_t lfa_flags, int operator,
|
||||
@ -4739,6 +4745,19 @@ int Xorriso_set_lfa_flags(struct XorrisO *xorriso, void *in_node, char *path,
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
}
|
||||
if(!(flag & 2)) {
|
||||
if(!(LIBISO_ISREG(node) || LIBISO_ISDIR(node) || operator == 4)) {
|
||||
if(flag & 4)
|
||||
return(2);
|
||||
Xorriso_report_iso_error(xorriso, path, 0,
|
||||
"File type unsuitable for -chattr",
|
||||
0, "SORRY", 4);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(flag & 8)
|
||||
return(1);
|
||||
|
||||
if(operator == 4) {
|
||||
ret= Xorriso_path_setfattr(xorriso, (void *) node, path,
|
||||
|
@ -441,7 +441,7 @@ int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
|
||||
int iso_error_code, char msg_text[], int os_errno,
|
||||
char min_severity[], int flag)
|
||||
{
|
||||
int error_code, iso_sev, min_sev, ret;
|
||||
int error_code, iso_sev, min_sev, ret, origin= 1;
|
||||
char *sev_text_pt, *msg_text_pt= NULL;
|
||||
char *sfe= NULL;
|
||||
static int sorry_sev= -1;
|
||||
@ -454,6 +454,7 @@ int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
|
||||
Xorriso__text_to_sev("SORRY", &sorry_sev, 0);
|
||||
|
||||
if(flag&4) {
|
||||
origin= 0;
|
||||
error_code= 0x00050000;
|
||||
Xorriso__text_to_sev(min_severity, &iso_sev, 0);
|
||||
} else {
|
||||
@ -478,7 +479,8 @@ int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
|
||||
strcat(sfe, ": ");
|
||||
Text_shellsafe(victim, sfe+strlen(sfe), 0);
|
||||
}
|
||||
ret= Xorriso_msgs_submit(xorriso, error_code, sfe, os_errno, sev_text_pt, 4);
|
||||
ret= Xorriso_msgs_submit(xorriso, error_code, sfe, os_errno, sev_text_pt,
|
||||
origin << 2);
|
||||
ex:;
|
||||
Xorriso_free_meM(sfe);
|
||||
return(ret);
|
||||
|
@ -1832,6 +1832,11 @@ int Xorriso_option_chattri(struct XorrisO *xorriso, char *chattr_text,
|
||||
|
||||
for(i= 0; i<optc; i++) {
|
||||
if(flag&1) {
|
||||
/* Try out whether this file is suitable for chattr */
|
||||
ret= Xorriso_set_lfa_flags(xorriso, NULL, optv[i], chattr_text,
|
||||
lfa_flags, operator, 1 | 8);
|
||||
if(ret <= 0 || ret == 2)
|
||||
goto partial_failure;
|
||||
ret= Findjob_new(&job, optv[i], 0);
|
||||
if(ret<=0) {
|
||||
Xorriso_no_findjob(xorriso, "-chattr_r", 0);
|
||||
@ -1847,6 +1852,7 @@ int Xorriso_option_chattri(struct XorrisO *xorriso, char *chattr_text,
|
||||
}
|
||||
if(ret>0 && !xorriso->request_to_abort)
|
||||
continue; /* regular bottom of loop */
|
||||
partial_failure:;
|
||||
was_failure= 1;
|
||||
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
|
||||
if(fret>=0)
|
||||
|
@ -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 06, 2024"
|
||||
.TH XORRISO 1 "Version 1.5.7, Aug 07, 2024"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
@ -2018,7 +2018,8 @@ Use code \\000 for 0\-bytes.
|
||||
.TP
|
||||
\fB\-chattr\fR mode iso_rr_path [***]
|
||||
Set or unset Linux file attributes like program chattr(1) would do to disk
|
||||
files.
|
||||
files. Applying this command to files which are neither directory nor regular
|
||||
data file will yield a SORRY event, unless the mode is "\-\-remove\-lfa\-flags".
|
||||
.br
|
||||
The first letter of the mode string determines what to do. The other letters
|
||||
are symbolic attribute flag letters out of the set "aAcCdDeEFhiIjNmPsStTuVxZ"
|
||||
@ -2047,7 +2048,11 @@ but \-find test \-has_lfa_flags "\-" will match the file afterwards.
|
||||
Example: \-chattr +sDu /my/file /my/other_file \-\-
|
||||
.TP
|
||||
\fB\-chattr_r\fR mode iso_rr_path [***]
|
||||
Like \-chattr but affecting all files below given directories.
|
||||
Like \-chattr but affecting also all suitable files below the given directories.
|
||||
Except with mode "\-\-remove\-lfa\-flags", the given iso_rr_path parameters need
|
||||
to be directories or regular data files or else a SORRY event will happen.
|
||||
Files below the given directories will be skipped silently if their type is
|
||||
not suitable for \-chattr.
|
||||
.TP
|
||||
\fB\-alter_date\fR type timestring iso_rr_path [***]
|
||||
Alter the date entries of files in the ISO image. type may be one of
|
||||
@ -2251,10 +2256,9 @@ E.g. look for files with both flags 'i' (immutable) and 'd' (no dump) set:
|
||||
.br
|
||||
\fB\-has_some_lfa_flags_of\fR flag_letters :
|
||||
.br
|
||||
Similar to \-has_lfa_flags but matching files which have Linux file attributes
|
||||
attached and have at least one of the flags set which correspond to the
|
||||
characters in the string flag_letters. The flag_letters string "\-" never
|
||||
matches any file.
|
||||
Similar to \-has_lfa_flags but matching files which have at least one of the
|
||||
flags set which correspond to the characters in the string flag_letters.
|
||||
The flag_letters string "\-" never matches any file.
|
||||
E.g. look for files which have 'i' or 'a' or both of them set:
|
||||
.br
|
||||
\-has_some_lfa_flags_of ia
|
||||
@ -2495,7 +2499,8 @@ Command \-backslash_codes does not affect the output.
|
||||
shows the Linux file attribute flags like command \-lsattrd does.
|
||||
.br
|
||||
\fBchattr\fR
|
||||
applies \-chattr with the given mode.
|
||||
applies \-chattr with the given mode. Other than command \-chattr this silently
|
||||
skips any file which are not \-type "dir" or "file".
|
||||
.br
|
||||
E.g.: \-exec chattr +sDu \-\-
|
||||
.br
|
||||
|
@ -1743,7 +1743,9 @@ whether they stem from the loaded image or were newly inserted.
|
||||
\000 for 0-bytes.
|
||||
-chattr mode iso_rr_path [***]
|
||||
Set or unset Linux file attributes like program chattr(1) would do
|
||||
to disk files.
|
||||
to disk files. Applying this command to files which are neither
|
||||
directory nor regular data file will yield a SORRY event, unless
|
||||
the mode is "-remove-lfa-flags".
|
||||
The first letter of the mode string determines what to do. The
|
||||
other letters are symbolic attribute flag letters out of the set
|
||||
"aAcCdDeEFhiIjNmPsStTuVxZ" as described in man 1 chattr. There is
|
||||
@ -1767,7 +1769,12 @@ whether they stem from the loaded image or were newly inserted.
|
||||
afterwards.
|
||||
Example: -chattr +sDu /my/file /my/other_file -
|
||||
-chattr_r mode iso_rr_path [***]
|
||||
Like -chattr but affecting all files below given directories.
|
||||
Like -chattr but affecting also all suitable files below the given
|
||||
directories. Except with mode "-remove-lfa-flags", the given
|
||||
iso_rr_path parameters need to be directories or regular data files
|
||||
or else a SORRY event will happen. Files below the given
|
||||
directories will be skipped silently if their type is not suitable
|
||||
for -chattr.
|
||||
-alter_date type timestring iso_rr_path [***]
|
||||
Alter the date entries of files in the ISO image. type may be one
|
||||
of the following:
|
||||
@ -1928,12 +1935,11 @@ File: xorriso.info, Node: CmdFind, Next: Filter, Prev: Manip, Up: Commands
|
||||
-has_lfa_flags di
|
||||
-has_some_lfa_flags_of flag_letters :
|
||||
|
||||
Similar to -has_lfa_flags but matching files which have Linux
|
||||
file attributes attached and have at least one of the flags
|
||||
set which correspond to the characters in the string
|
||||
flag_letters. The flag_letters string "-" never matches any
|
||||
file. E.g. look for files which have 'i' or 'a' or both of
|
||||
them set:
|
||||
Similar to -has_lfa_flags but matching files which have at
|
||||
least one of the flags set which correspond to the characters
|
||||
in the string flag_letters. The flag_letters string "-" never
|
||||
matches any file. E.g. look for files which have 'i' or 'a'
|
||||
or both of them set:
|
||||
-has_some_lfa_flags_of ia
|
||||
-has_any_xattr :
|
||||
Matches files which have any xattr other than ACL.
|
||||
@ -2135,7 +2141,9 @@ File: xorriso.info, Node: CmdFind, Next: Filter, Prev: Manip, Up: Commands
|
||||
shows the Linux file attribute flags like command -lsattrd
|
||||
does.
|
||||
chattr
|
||||
applies -chattr with the given mode.
|
||||
applies -chattr with the given mode. Other than command
|
||||
-chattr this silently skips any file which are not -type "dir"
|
||||
or "file".
|
||||
E.g.: -exec chattr +sDu -
|
||||
get_md5
|
||||
prints the MD5 sum, if recorded, together with file path.
|
||||
@ -5930,8 +5938,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
* -acl controls handling of ACLs: Loading. (line 189)
|
||||
* -add inserts one or more paths: Insert. (line 44)
|
||||
* -add_plainly inserts one or more paths: Insert. (line 68)
|
||||
* -alter_date sets timestamps in ISO image: Manip. (line 166)
|
||||
* -alter_date_r sets timestamps in ISO image: Manip. (line 201)
|
||||
* -alter_date sets timestamps in ISO image: Manip. (line 173)
|
||||
* -alter_date_r sets timestamps in ISO image: Manip. (line 208)
|
||||
* -append_partition adds arbitrary file after image end: Bootable.
|
||||
(line 470)
|
||||
* -application_id sets application id: SetWrite. (line 218)
|
||||
@ -5951,7 +5959,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
* -changes_pending overrides change status: Writing. (line 12)
|
||||
* -charset sets input/output character set: Charset. (line 54)
|
||||
* -chattr sets Linux file attributes in ISO image: Manip. (line 139)
|
||||
* -chattr_r sets Linux file attributes in ISO image: Manip. (line 164)
|
||||
* -chattr_r sets Linux file attributes in ISO image: Manip. (line 166)
|
||||
* -check_md5 verifies file checksum: Verify. (line 184)
|
||||
* -check_md5_r verifies file tree checksums: Verify. (line 198)
|
||||
* -check_media reads media block by block: Verify. (line 21)
|
||||
@ -6029,7 +6037,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
* -hardlinks controls handling of hard links: Loading. (line 152)
|
||||
* -help prints help text: Scripting. (line 19)
|
||||
* -hfsplus enables production of HFS+ partition: SetWrite. (line 14)
|
||||
* -hide excludes file names from directory trees: Manip. (line 204)
|
||||
* -hide excludes file names from directory trees: Manip. (line 211)
|
||||
* -history brings text into readline history: Scripting. (line 44)
|
||||
* -indev acquires a drive for input: AqDrive. (line 23)
|
||||
* -in_charset sets input character set: Loading. (line 136)
|
||||
@ -6292,7 +6300,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
|
||||
* Hard links, control handling, -hardlinks: Loading. (line 152)
|
||||
* HFS+ allocation block size: Bootable. (line 458)
|
||||
* HFS+ serial number: Bootable. (line 455)
|
||||
* hidden, set in ISO image, -hide: Manip. (line 204)
|
||||
* hidden, set in ISO image, -hide: Manip. (line 211)
|
||||
* HP-PA boot sector, production: Bootable. (line 430)
|
||||
* Image reading, cache size, -data_cache_size: Loading. (line 444)
|
||||
* Image, demand volume ID, -assert_volid: Loading. (line 129)
|
||||
@ -6351,7 +6359,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
|
||||
* Linux file attributes, control handling, -lfa_flags: Loading.
|
||||
(line 207)
|
||||
* Linux file attributes, set in ISO image, -chattr: Manip. (line 139)
|
||||
* Linux file attributes, set in ISO image, -chattr_r: Manip. (line 164)
|
||||
* Linux file attributes, set in ISO image, -chattr_r: Manip. (line 166)
|
||||
* Linux file attributes, show in ISO image, -lsattr: Navigate.
|
||||
(line 78)
|
||||
* Linux file attributes, _definition: Extras. (line 84)
|
||||
@ -6472,8 +6480,8 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
|
||||
* Table-of-content, search sessions, -rom_toc_scan: Loading. (line 390)
|
||||
* Table-of-content, show parts of, -toc_of: Inquiry. (line 41)
|
||||
* Table-of-content, show, -toc: Inquiry. (line 27)
|
||||
* Timestamps, set in ISO image, -alter_date: Manip. (line 166)
|
||||
* Timestamps, set in ISO image, -alter_date_r: Manip. (line 201)
|
||||
* Timestamps, set in ISO image, -alter_date: Manip. (line 173)
|
||||
* Timestamps, set in ISO image, -alter_date_r: Manip. (line 208)
|
||||
* Tree, disk, traverse, -findx: Navigate. (line 99)
|
||||
* Tree, ISO, traverse and alter, -find: CmdFind. (line 7)
|
||||
* Unsuitable media states, _definition: Media. (line 25)
|
||||
@ -6532,45 +6540,45 @@ Node: Loading36962
|
||||
Node: Insert63843
|
||||
Node: SetInsert76038
|
||||
Node: Manip86212
|
||||
Node: CmdFind97876
|
||||
Node: Filter119126
|
||||
Node: Writing123748
|
||||
Node: SetWrite136242
|
||||
Node: Bootable167517
|
||||
Node: Jigdo198799
|
||||
Node: Charset203802
|
||||
Node: Exception207131
|
||||
Node: DialogCtl213260
|
||||
Node: Inquiry215862
|
||||
Node: Navigate228427
|
||||
Node: Verify237582
|
||||
Node: Restore248731
|
||||
Node: Emulation260938
|
||||
Node: Scripting271394
|
||||
Node: Frontend279288
|
||||
Node: Examples288914
|
||||
Node: ExDevices290092
|
||||
Node: ExCreate290753
|
||||
Node: ExDialog292053
|
||||
Node: ExGrowing293324
|
||||
Node: ExModifying294133
|
||||
Node: ExBootable294643
|
||||
Node: ExCharset295198
|
||||
Node: ExPseudo296094
|
||||
Node: ExCdrecord297021
|
||||
Node: ExMkisofs297341
|
||||
Node: ExGrowisofs299238
|
||||
Node: ExException300391
|
||||
Node: ExTime300849
|
||||
Node: ExIncBackup301307
|
||||
Node: ExRestore305333
|
||||
Node: ExRecovery306279
|
||||
Node: Files306851
|
||||
Node: Environ308185
|
||||
Node: Seealso308933
|
||||
Node: Bugreport309697
|
||||
Node: Legal310288
|
||||
Node: CommandIdx311300
|
||||
Node: ConceptIdx329629
|
||||
Node: CmdFind98332
|
||||
Node: Filter119646
|
||||
Node: Writing124268
|
||||
Node: SetWrite136762
|
||||
Node: Bootable168037
|
||||
Node: Jigdo199319
|
||||
Node: Charset204322
|
||||
Node: Exception207651
|
||||
Node: DialogCtl213780
|
||||
Node: Inquiry216382
|
||||
Node: Navigate228947
|
||||
Node: Verify238102
|
||||
Node: Restore249251
|
||||
Node: Emulation261458
|
||||
Node: Scripting271914
|
||||
Node: Frontend279808
|
||||
Node: Examples289434
|
||||
Node: ExDevices290612
|
||||
Node: ExCreate291273
|
||||
Node: ExDialog292573
|
||||
Node: ExGrowing293844
|
||||
Node: ExModifying294653
|
||||
Node: ExBootable295163
|
||||
Node: ExCharset295718
|
||||
Node: ExPseudo296614
|
||||
Node: ExCdrecord297541
|
||||
Node: ExMkisofs297861
|
||||
Node: ExGrowisofs299758
|
||||
Node: ExException300911
|
||||
Node: ExTime301369
|
||||
Node: ExIncBackup301827
|
||||
Node: ExRestore305853
|
||||
Node: ExRecovery306799
|
||||
Node: Files307371
|
||||
Node: Environ308705
|
||||
Node: Seealso309453
|
||||
Node: Bugreport310217
|
||||
Node: Legal310808
|
||||
Node: CommandIdx311820
|
||||
Node: ConceptIdx330149
|
||||
|
||||
End Tag Table
|
||||
|
@ -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 06, 2024"
|
||||
@c man .TH XORRISO 1 "Version 1.5.7, Aug 07, 2024"
|
||||
@c man .\" Please adjust this date whenever revising the manpage.
|
||||
@c man .\"
|
||||
@c man .\" Some roff macros, for reference:
|
||||
@ -2412,7 +2412,8 @@ Use code \000 for 0-bytes.
|
||||
@kindex -chattr sets Linux file attributes in ISO image
|
||||
@cindex Linux file attributes, set in ISO image, -chattr
|
||||
Set or unset Linux file attributes like program chattr(1) would do to disk
|
||||
files.
|
||||
files. Applying this command to files which are neither directory nor regular
|
||||
data file will yield a SORRY event, unless the mode is "--remove-lfa-flags".
|
||||
@*
|
||||
The first letter of the mode string determines what to do. The other letters
|
||||
are symbolic attribute flag letters out of the set "aAcCdDeEFhiIjNmPsStTuVxZ"
|
||||
@ -2443,7 +2444,11 @@ Example: -chattr +sDu /my/file /my/other_file --
|
||||
@item -chattr_r mode iso_rr_path [***]
|
||||
@kindex -chattr_r sets Linux file attributes in ISO image
|
||||
@cindex Linux file attributes, set in ISO image, -chattr_r
|
||||
Like -chattr but affecting all files below given directories.
|
||||
Like -chattr but affecting also all suitable files below the given directories.
|
||||
Except with mode "--remove-lfa-flags", the given iso_rr_path parameters need
|
||||
to be directories or regular data files or else a SORRY event will happen.
|
||||
Files below the given directories will be skipped silently if their type is
|
||||
not suitable for -chattr.
|
||||
@c man .TP
|
||||
@item -alter_date type timestring iso_rr_path [***]
|
||||
@kindex -alter_date sets timestamps in ISO image
|
||||
@ -2661,10 +2666,9 @@ E.g. look for files with both flags 'i' (immutable) and 'd' (no dump) set:
|
||||
@*
|
||||
@item -has_some_lfa_flags_of flag_letters :
|
||||
@*
|
||||
Similar to -has_lfa_flags but matching files which have Linux file attributes
|
||||
attached and have at least one of the flags set which correspond to the
|
||||
characters in the string flag_letters. The flag_letters string "-" never
|
||||
matches any file.
|
||||
Similar to -has_lfa_flags but matching files which have at least one of the
|
||||
flags set which correspond to the characters in the string flag_letters.
|
||||
The flag_letters string "-" never matches any file.
|
||||
E.g. look for files which have 'i' or 'a' or both of them set:
|
||||
@*
|
||||
-has_some_lfa_flags_of ia
|
||||
@ -2925,7 +2929,8 @@ Command -backslash_codes does not affect the output.
|
||||
shows the Linux file attribute flags like command -lsattrd does.
|
||||
@*
|
||||
@item chattr
|
||||
applies -chattr with the given mode.
|
||||
applies -chattr with the given mode. Other than command -chattr this silently
|
||||
skips any file which are not -type "dir" or "file".
|
||||
@*
|
||||
E.g.: -exec chattr +sDu --
|
||||
@*
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2024.08.06.202116"
|
||||
#define Xorriso_timestamP "2024.08.07.132513"
|
||||
|
Loading…
Reference in New Issue
Block a user