New flag bit5 for iso_file_source_get_aa_string() and iso_image_set_ignore_aclea(), new flag bit7 for iso_local_get_lfa_flags()

This commit is contained in:
Thomas Schmitt 2024-08-27 10:51:36 +02:00
parent 622b5645f0
commit efaab52265
6 changed files with 52 additions and 5 deletions

View File

@ -281,6 +281,8 @@ static int get_single_attr(char *path, char *name, size_t *value_length,
bit5= in case of symbolic link: inquire link target bit5= in case of symbolic link: inquire link target
bit6= do not obtain Linux style file attribute flags bit6= do not obtain Linux style file attribute flags
(chattr) (chattr)
bit7= With bit6: Ignore non-settable flags and do
not record "isofs.fa" if all flags are zero
bit15= free memory of names, value_lengths, values bit15= free memory of names, value_lengths, values
@return 1 ok @return 1 ok
(reserved for FreeBSD: 2 ok, no permission to inspect (reserved for FreeBSD: 2 ok, no permission to inspect
@ -454,7 +456,12 @@ try_lfa_flags:;
if(!(flag & 64)) { if(!(flag & 64)) {
/* ( aaip_get_lfa_flags() does not gracefully handle dead symbolic links) */ /* ( aaip_get_lfa_flags() does not gracefully handle dead symbolic links) */
ret= iso_local_get_lfa_flags(path, &lfa_flags, &max_bit, &os_errno, 0); ret= iso_local_get_lfa_flags(path, &lfa_flags, &max_bit, &os_errno,
flag & (1 << 7));
if((flag & (1 << 7)) && lfa_flags == (uint64_t) 0) {
/* virtually no lfa_flags because no settable ones */
ret= 4;
}
if(ret == 1 || ret == 2) { if(ret == 1 || ret == 2) {
ret= aaip_encode_lfa_flags(lfa_flags, lfa_value, &lfa_length, 0); ret= aaip_encode_lfa_flags(lfa_flags, lfa_value, &lfa_length, 0);
if(ret > 0) { if(ret > 0) {
@ -528,6 +535,7 @@ ex:;
(else return 4 on ENOTTY) (else return 4 on ENOTTY)
bit2= do not issue own error messages with operating bit2= do not issue own error messages with operating
system errors system errors
bit7= Ignore non-settable flags
@return 1= ok, all local attribute flags are in lfa_flags @return 1= ok, all local attribute flags are in lfa_flags
2= ok, but some local flags could not be mapped to 2= ok, but some local flags could not be mapped to
the FS_*_FL bits the FS_*_FL bits
@ -539,6 +547,7 @@ int aaip_get_lfa_flags(char *path, uint64_t *lfa_flags, int *max_bit,
int *os_errno, int flag) int *os_errno, int flag)
{ {
int ret= 0; int ret= 0;
static uint64_t user_settable= 0, su_settable= 0, non_settable= 0, unknown= 0;
#ifdef Libisofs_with_aaip_lfa_flagS #ifdef Libisofs_with_aaip_lfa_flagS
int fd; int fd;
@ -549,6 +558,10 @@ int aaip_get_lfa_flags(char *path, uint64_t *lfa_flags, int *max_bit,
*max_bit= -1; *max_bit= -1;
*os_errno= 0; *os_errno= 0;
if(non_settable == (uint64_t) 0)
iso_util_get_lfa_masks(&user_settable, &su_settable, &non_settable,
&unknown);
#ifdef Libisofs_with_aaip_lfa_flagS #ifdef Libisofs_with_aaip_lfa_flagS
#ifdef FS_IOC_GETFLAGS #ifdef FS_IOC_GETFLAGS
fd= open(path, O_RDONLY | O_NDELAY); fd= open(path, O_RDONLY | O_NDELAY);
@ -579,6 +592,9 @@ int aaip_get_lfa_flags(char *path, uint64_t *lfa_flags, int *max_bit,
else else
*max_bit= sizeof(long) * 8 - 1; *max_bit= sizeof(long) * 8 - 1;
if(flag & (1 << 7))
*lfa_flags&= ~non_settable;
ret= 1; ret= 1;
#endif /* FS_IOC_GETFLAGS */ #endif /* FS_IOC_GETFLAGS */

View File

@ -254,7 +254,8 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
1 | (image->builder_ignore_acl << 1) | 1 | (image->builder_ignore_acl << 1) |
(image->builder_ignore_ea << 2) | (image->builder_ignore_ea << 2) |
(image->builder_take_all_ea << 3) | (image->builder_take_all_ea << 3) |
((!image->builder_ignore_lfa_flags) << 4)); ((!image->builder_ignore_lfa_flags) << 4) |
(image->builder_ignore_ro_lfa_flags << 5) );
if(ret == 2) if(ret == 2)
image->blind_on_local_get_attrs = 1; image->blind_on_local_get_attrs = 1;
if (ret > 0 && aa_string != NULL) { if (ret > 0 && aa_string != NULL) {

View File

@ -524,7 +524,7 @@ int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
ret = aaip_get_attr_list(path, &num_attrs, &names, ret = aaip_get_attr_list(path, &num_attrs, &names,
&value_lengths, &values, &value_lengths, &values,
(!(flag & 2)) | 2 | (flag & 4) | (flag & 8) | 16 | (!(flag & 2)) | 2 | (flag & 4) | (flag & 8) | 16 |
((!(flag & 16)) << 6)); ((!(flag & 16)) << 6) | ((!!(flag & 32)) << 7));
if (ret <= 0) { if (ret <= 0) {
if (ret == -2) if (ret == -2)
ret = ISO_AAIP_NO_GET_LOCAL; ret = ISO_AAIP_NO_GET_LOCAL;
@ -950,6 +950,7 @@ int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag)
* Bitfield for control purposes * Bitfield for control purposes
* bit2= do not issue own error messages with operating system errors * bit2= do not issue own error messages with operating system errors
* bit5= in case of symbolic link: inquire link target * bit5= in case of symbolic link: inquire link target
* bit7= Ignore non-settable Linux-like file attribute flags
* @return * @return
* 1= ok, lfa_flags is valid * 1= ok, lfa_flags is valid
* 2= ok, but some local flags could not be mapped to the FS_*_FL bits * 2= ok, but some local flags could not be mapped to the FS_*_FL bits
@ -980,7 +981,7 @@ int iso_local_get_lfa_flags(char *disk_path, uint64_t *lfa_flags, int *max_bit,
if ((stbuf.st_mode & S_IFMT) == S_IFLNK && !(flag & 32)) if ((stbuf.st_mode & S_IFMT) == S_IFLNK && !(flag & 32))
return 3; return 3;
ret = aaip_get_lfa_flags(disk_path, lfa_flags, max_bit, os_errno, ret = aaip_get_lfa_flags(disk_path, lfa_flags, max_bit, os_errno,
flag & 4); flag & (4 | (1 << 7)));
if(ret == 0) if(ret == 0)
return ISO_LFA_NOT_ENABLED; return ISO_LFA_NOT_ENABLED;
if(ret < 0) if(ret < 0)

View File

@ -201,6 +201,7 @@ int iso_image_new(const char *name, IsoImage **image)
img->builder_ignore_acl = 1; img->builder_ignore_acl = 1;
img->builder_ignore_ea = 1; img->builder_ignore_ea = 1;
img->builder_ignore_lfa_flags = 1; img->builder_ignore_lfa_flags = 1;
img->builder_ignore_ro_lfa_flags = 0;
img->truncate_mode = 1; img->truncate_mode = 1;
img->truncate_length = LIBISOFS_NODE_NAME_MAX; img->truncate_length = LIBISOFS_NODE_NAME_MAX;
img->truncate_buffer[0] = 0; img->truncate_buffer[0] = 0;
@ -632,6 +633,7 @@ void iso_image_set_ignore_aclea(IsoImage *image, int what)
image->builder_ignore_ea = !!(what & 2); image->builder_ignore_ea = !!(what & 2);
image->builder_ignore_lfa_flags= !(what & 4); image->builder_ignore_lfa_flags= !(what & 4);
image->builder_take_all_ea = !!(what & 8); image->builder_take_all_ea = !!(what & 8);
image->builder_ignore_ro_lfa_flags = !!(what & 32);
} }
@ -640,7 +642,8 @@ int iso_image_get_ignore_aclea(IsoImage *image)
return image->builder_ignore_acl | return image->builder_ignore_acl |
(image->builder_ignore_ea << 1) | (image->builder_ignore_ea << 1) |
((!image->builder_ignore_lfa_flags) << 2) | ((!image->builder_ignore_lfa_flags) << 2) |
(image->builder_take_all_ea << 3); (image->builder_take_all_ea << 3) |
(image->builder_ignore_ro_lfa_flags << 5);
} }

View File

@ -152,6 +152,14 @@ struct Iso_Image
*/ */
unsigned int builder_ignore_lfa_flags : 1; unsigned int builder_ignore_lfa_flags : 1;
/**
* Whether to ignore Linux style file attribute flags (chattr) which are
* only readable but non-settable ("ZEIheVN").
* Not in effect with loading a complete ISO image but only with image
* manipulation.
*/
unsigned int builder_ignore_ro_lfa_flags : 1;
/** /**
* If not builder_ignore_ea : import all xattr namespaces from local * If not builder_ignore_ea : import all xattr namespaces from local
* filesystem, not only "user. * filesystem, not only "user.

View File

@ -862,6 +862,15 @@ struct IsoFileSource_Iface
* not be able to produce it again. * not be able to produce it again.
* bit1= No need to get ACL (no guarantee of exclusion) * bit1= No need to get ACL (no guarantee of exclusion)
* bit2= No need to get xattr (no guarantee of exclusion) * bit2= No need to get xattr (no guarantee of exclusion)
* bit3= if not bit2: import all xattr namespaces from
* local filesystem, not only "user."
* bit4= Try to get Linux-like file attribute flags
* (chattr) as "isofs.fa"
* @since 1.5.8
* bit5= With bit4: Ignore non-settable Linux-like file
* attribute flags and do not record "isofs.fa"
* if the other flags are all zero
* @since 1.5.8
* @param aa_string Returns a pointer to the AAIP string data. If no AAIP * @param aa_string Returns a pointer to the AAIP string data. If no AAIP
* string is available, *aa_string becomes NULL. * string is available, *aa_string becomes NULL.
* (See doc/susp_aaip_*_*.txt for the meaning of AAIP and * (See doc/susp_aaip_*_*.txt for the meaning of AAIP and
@ -1313,6 +1322,9 @@ int iso_image_new(const char *name, IsoImage **image);
* @since 1.5.8 * @since 1.5.8
* bit3= if not bit1: import all xattr namespaces, not only "user." * bit3= if not bit1: import all xattr namespaces, not only "user."
* @since 1.5.0 * @since 1.5.0
* bit5= with bit2: Ignore non-settable Linux-like file attribute flags
* and do not record "isofs.fa" if the other flags are all zero
* @since 1.5.8
* all other bits are reserved * all other bits are reserved
* *
* @since 0.6.14 * @since 0.6.14
@ -7270,6 +7282,10 @@ int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz);
* bit4= Try to get Linux-like file attribute flags (chattr) * bit4= Try to get Linux-like file attribute flags (chattr)
* as "isofs.fa" * as "isofs.fa"
* @since 1.5.8 * @since 1.5.8
* bit5= With bit4: Ignore non-settable Linux-like file
* attribute flags and do not record "isofs.fa"
* if the other flags are all zero
* @since 1.5.8
* @return 1 means success (*aa_string == NULL is possible) * @return 1 means success (*aa_string == NULL is possible)
* <0 means failure and must b a valid libisofs error code * <0 means failure and must b a valid libisofs error code
* (e.g. ISO_FILE_ERROR if no better one can be found). * (e.g. ISO_FILE_ERROR if no better one can be found).
@ -8059,6 +8075,8 @@ int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names,
* Bitfield for control purposes * Bitfield for control purposes
* bit2= do not issue own error messages with system call errors * bit2= do not issue own error messages with system call errors
* bit5= in case of symbolic link: inquire link target * bit5= in case of symbolic link: inquire link target
* bit7= Ignore non-settable Linux-like file attribute flags
* @since 1.5.8
* @return * @return
* 1 = ok, lfa_flags is valid * 1 = ok, lfa_flags is valid
* 2 = ok, but some local flags could not be mapped to the FS_*_FL bits * 2 = ok, but some local flags could not be mapped to the FS_*_FL bits