From c8495481ca5a13f8a91b89d2ad1fd26952148d8e Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 23 Jan 2009 09:32:32 +0100 Subject: [PATCH] Controlling import and export of ACL, EA, AAIP --- doc/susp_aaip_0_2.txt | 9 ++++++ libisofs/builder.c | 7 ++++- libisofs/ecma119.c | 13 +++++++++ libisofs/ecma119.h | 6 ++++ libisofs/fs_image.c | 4 +-- libisofs/fs_local.c | 12 +++++++- libisofs/image.c | 10 +++++++ libisofs/image.h | 14 +++++++++ libisofs/libisofs.h | 66 +++++++++++++++++++++++++++++++++++++++---- libisofs/rockridge.c | 23 ++++----------- 10 files changed, 138 insertions(+), 26 deletions(-) diff --git a/doc/susp_aaip_0_2.txt b/doc/susp_aaip_0_2.txt index 673d7ab..e482627 100644 --- a/doc/susp_aaip_0_2.txt +++ b/doc/susp_aaip_0_2.txt @@ -32,6 +32,13 @@ address enough storage if needed. The SUSP field and the ER entry of AAIP shall only be present if the ER entry of RRIP is present. +This extension is supposed not to disturb any reader system which complies +to this SUSP demand: +"6.2 Requirements for a Receiving System + [...] + Any System Use Field which the receiving system does not recognize + is to be ignored and skipped." + ------------------------------------------------------------------------------- System Entries Provided by this Specification @@ -337,4 +344,6 @@ Pending considerations: - shall "AA" be fixely defined as signature ? +- shall the tag types ACL_USER and ACL_GROUP with non-numeric qualifier be + revoked ? diff --git a/libisofs/builder.c b/libisofs/builder.c index e617be8..232b7ca 100644 --- a/libisofs/builder.c +++ b/libisofs/builder.c @@ -13,6 +13,9 @@ #include "node.h" #include "fsource.h" +/* ts A90121 : needed for image->builder_ignore_acl */ +#include "image.h" + #include #include #include @@ -187,7 +190,9 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image, /* ts A90115 */ /* obtain ownership of eventual AA string */ - ret = iso_file_source_get_aa_string(src, &aa_string, 1); + ret = iso_file_source_get_aa_string(src, &aa_string, + 1 | (image->builder_ignore_acl << 1) | + (image->builder_ignore_ea << 2 )); if (ret == 1 && aa_string != NULL) { /* >>> change field signatures to eventual libisofs non-"AA" setting */; diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index c670896..91e0c6b 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -883,6 +883,10 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) target->rockridge = opts->rockridge; target->joliet = opts->joliet; target->iso1999 = opts->iso1999; + + /* ts A90122 */ + target->aaip = opts->aaip; + target->always_gmt = opts->always_gmt; target->ino = 0; target->omit_version_numbers = opts->omit_version_numbers @@ -1412,6 +1416,15 @@ int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable) return ISO_SUCCESS; } +int iso_write_opts_set_aaip(IsoWriteOpts *opts, int enable) +{ + if (opts == NULL) { + return ISO_NULL_POINTER; + } + opts->aaip = enable ? 1 : 0; + return ISO_SUCCESS; +} + int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit) { if (opts == NULL) { diff --git a/libisofs/ecma119.h b/libisofs/ecma119.h index 6f885e3..d0d8f47 100644 --- a/libisofs/ecma119.h +++ b/libisofs/ecma119.h @@ -42,6 +42,9 @@ struct iso_write_opts { unsigned int joliet :1; unsigned int iso1999 :1; + /* ts A90122 */ + unsigned int aaip :1; /* whether to write eventual ACL and EAs */ + /* allways write timestamps in GMT */ unsigned int always_gmt :1; @@ -245,6 +248,9 @@ struct ecma119_image unsigned int eltorito :1; unsigned int iso1999 :1; + /* ts A90122 */ + unsigned int aaip :1; /* whether to write eventual ACLs and EAs */ + /* allways write timestamps in GMT */ unsigned int always_gmt :1; diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 0289193..0c2d65e 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -295,8 +295,8 @@ struct image_fs_data /** * malloc() storage for the string of AA fields which represent - * POSIX Extended Attributes and ACLs. (Not to be confused with - * ECMA-119 Extended Attributes.) + * ACLs and XFS-style Extended Attributes. (Not to be confused with + * ECMA-119 Extended Attributes.) */ unsigned char *aa_string; diff --git a/libisofs/fs_local.c b/libisofs/fs_local.c index 3e13815..dad77ef 100644 --- a/libisofs/fs_local.c +++ b/libisofs/fs_local.c @@ -39,6 +39,7 @@ int iso_file_source_new_lfs(IsoFileSource *parent, const char *name, */ IsoFilesystem *lfs= NULL; + typedef struct { /** reference to the parent (if root it points to itself) */ @@ -485,8 +486,16 @@ int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag) size_t num_attrs = 0, *value_lengths = NULL, result_len, sret; char *path = NULL, **names = NULL, **values = NULL; unsigned char *result = NULL; + _LocalFsFileSource *data; + + data = src->data; *aa_string = NULL; + + if ((flag & 3 ) == 3) { + ret = 1; + goto ex; + } /* Obtain EAs and ACLs ("access" and "default"). ACLs encoded according to AAIP ACL representation. Clean out st_mode ACL entries. */ @@ -494,7 +503,8 @@ int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag) /* >>> make adjustable: bit4 = ignoring of st_mode ACL entries */ ret = aaip_get_attr_list(path, &num_attrs, &names, - &value_lengths, &values, 1 | 2 | 16); + &value_lengths, &values, + (!(flag & 2)) | 2 | (flag & 4) | 16); if (ret <= 0) { ret = ISO_FILE_ERROR; goto ex; diff --git a/libisofs/image.c b/libisofs/image.c index b2fff23..693e8cf 100644 --- a/libisofs/image.c +++ b/libisofs/image.c @@ -71,6 +71,8 @@ int iso_image_new(const char *name, IsoImage **image) img->volset_id = strdup(name); img->volume_id = strdup(name); } + img->builder_ignore_acl = 1; + img->builder_ignore_ea = 1; *image = img; return ISO_SUCCESS; } @@ -308,3 +310,11 @@ int iso_image_update_sizes(IsoImage *image) return dir_update_size(image, image->root); } + + +void iso_image_set_ignore_aclea(IsoImage *image, int what) +{ + image->builder_ignore_acl = (what & 1); + image->builder_ignore_ea = !!(what & 2); +} + diff --git a/libisofs/image.h b/libisofs/image.h index b86aca1..eac3e9e 100644 --- a/libisofs/image.h +++ b/libisofs/image.h @@ -76,6 +76,20 @@ struct Iso_Image */ int ignore_special; + /** + * Whether to ignore ACL when inserting nodes into the image. + * Not in effect with loading a complete ISO image but only with image + * manipulation. + */ + unsigned int builder_ignore_acl : 1; + + /** + * Whether to ignore EAs when inserting nodes into the image. + * Not in effect with loading a complete ISO image but only with image + * manipulation. ACL does not count as EA. + */ + unsigned int builder_ignore_ea : 1; + /** * Files to exclude. Wildcard support is included. */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 3e377ca..2670b58 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -673,12 +673,20 @@ struct IsoFileSource_Iface /* ts A90114 */ /** * Valid only if .version is > 0. See above. - * Get the AA string with encoded ACL and/or POSIX Extended Attributes. + * Get the AA string with encoded ACL and/or XFS-style Extended Attributes. * (Not to be confused with ECMA-119 Extended Attributes). + * + * bit1 and bit2 of flag should be implemented so that freshly fetched + * info does not include the undesired ACL or EAs. Nevertheless if the + * aa_string is cached, then it is permissible that ACL and EA are still + * delivered. + * * @param flag Bitfield for control purposes * bit0= Transfer ownership of AA string data. * src will free the eventual cached data and might * not be able to produce it again. + * bit1= No need to get ACL (no guarantee of exclusion) + * bit2= No need to get EA (no guarantee of exclusion) * @param aa_string Returns a pointer to the AA string data. If no AA * string is available, *aa_string becomes NULL. * Field signature will be "AA". @@ -915,6 +923,30 @@ char *iso_get_local_charset(int flag); int iso_image_new(const char *name, IsoImage **image); +/* ts A90121 */ +/** + * Control whether ACL and XFS-style Extended Attributes will be imported from + * external filesystems (typically the local POSIX filesystem) when new + * nodes get inserted. If enabled by iso_write_opts_set_aaip() they will later + * be written into the image as AAIP extension fields. + * + * A change of this setting does neither affect existing IsoNode objects + * nor the way how ACL and EA are handled when loading an ISO image. + * The latter is controlled by iso_read_opts_set_no_aaip(). + * + * @param image + * The image of which the behavior is to be controlled + * @param what + * A bit field which sets the behavior: + * bit0= ignore ACLs if the external file object bears some + * bit1= ignore EAs if the external file object bears some + * all other bits are reserved + * + * @since 0.6.14 + */ +void iso_image_set_ignore_aclea(IsoImage *image, int what); + + /** * The following two functions three macros are utilities to help ensuring * version match of application, compile time header, and runtime library. @@ -1017,6 +1049,9 @@ int iso_lib_is_compatible(int major, int minor, int micro); * ---> 1 [BACKUP] * POSIX compatibility for backup. Simple settings, ISO level is set to * 3 and RR extensions are enabled. Useful for backup purposes. + * Note that ACL and XFS-style EA are not enabled by default. + * If you enable them, expect them not to show up in the mounted image. + * They will have to be retrieved by libisofs applications like xorriso. * ---> 2 [DISTRIBUTION] * Setting for information distribution. Both RR and Joliet are enabled * to maximize compatibility with most systems. Permissions are set to @@ -1098,6 +1133,21 @@ int iso_write_opts_set_joliet(IsoWriteOpts *opts, int enable); */ int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable); +/* ts A90122 */ +/** + * Control writing of AAIP informations for ACL and XFS-style Extended + * Attributes. + * For importing ACL and EA when inserting nodes from external filesystems + * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea(). + * For loading of this information from images see iso_read_opts_set_no_aaip(). + * + * @param enable 1 = do not read AAIP information + * 0 = read AAIP information if available + * All other values are reserved. + * @since 0.6.14 + */ +int iso_write_opts_set_aaip(IsoWriteOpts *opts, int enable); + /** * Omit the version number (";1") at the end of the ISO-9660 identifiers. * This breaks ECMA-119 specification, but version numbers are usually not @@ -1461,8 +1511,7 @@ int iso_image_update_sizes(IsoImage *image); * ---> 0 [STANDARD] * Suitable for most situations. Most extension are read. When both * Joliet and RR extension are present, RR is used. - * AAIP for ACL and POSIX Extended Attributes is not enabled by - * default. + * AAIP for ACL and Extended Attributes is not enabled by default. * @return * 1 success, < 0 error * @@ -1509,7 +1558,12 @@ int iso_read_opts_set_no_joliet(IsoReadOpts *opts, int nojoliet); int iso_read_opts_set_no_iso1999(IsoReadOpts *opts, int noiso1999); /** - * Control reading of AAIP informations for ACL and POSIX Extended Attributes. + * Control reading of AAIP informations about ACL and XFS-style Extended + * Attributes when loading existing images. + * For importing ACL and EA when inserting nodes from external filesystems + * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea(). + * For eventual writing of this information see iso_write_opts_set_aaip(). + * * @param noaaip 1 = do not read AAIP information * 0 = read AAIP information if available * All other values are reserved. @@ -3666,7 +3720,7 @@ int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz); /** - * Get the AA string with encoded ACL and/or POSIX Extended Attributes. + * Get the AA string with encoded ACL and/or XFS-style Extended Attributes. * (Not to be confused with ECMA-119 Extended Attributes). * @param src The file source object to be inquired. * @param aa_string Returns a pointer to the AA string data. If no AA @@ -3680,6 +3734,8 @@ int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz); * bit0= Transfer ownership of AA string data. * src will free the eventual cached data and might * not be able to produce it again. + * bit1= No need to get ACL (but no guarantee of exclusion) + * bit2= No need to get EA (but no guarantee of exclusion) * @return 1 means success (*aa_string == NULL is possible) * <0 means failure and must b a valid libisofs error code * (e.g. ISO_FILE_ERROR if no better one can be found). diff --git a/libisofs/rockridge.c b/libisofs/rockridge.c index b5d4476..0cab79b 100644 --- a/libisofs/rockridge.c +++ b/libisofs/rockridge.c @@ -880,9 +880,7 @@ int susp_calc_nm_sl_aa(Ecma119Image *t, Ecma119Node *n, size_t space, /* obtain num_aapt from node */ num_aapt = 0; - /* >>> if AAIP is enabled */ - if (1) { - + if (t->aaip) { ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt); if (ret == 1) { num_aapt = aaip_count_bytes((unsigned char *) xipt, 0); @@ -1127,10 +1125,7 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space, /* obtain num_aapt from node */ num_aapt = 0; - - /* >>> if AAIP is enabled */ - if (1) { - + if (t->aaip) { ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt); if (ret == 1) { num_aapt = aaip_count_bytes((unsigned char *) xipt, 0); @@ -1171,13 +1166,11 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space, if (1) { #else /* Libisofs_with_aaip_dummY */ - /* >>> if AAIP is enabled */ - if (1) { + if (t->aaip) { #endif /* ! Libisofs_with_aaip_dummY */ *ce += 160; /* ER of AAIP */ - } #endif /* Libisofs_with_aaiP */ @@ -1655,9 +1648,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type, ret = ISO_SUCCESS; num_aapt = 0; - /* >>> if AAIP is enabled */ - if (1) { - + if (t->aaip) { ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt); if (ret == 1) { num_aapt = aaip_count_bytes((unsigned char *) xipt, 0); @@ -1708,8 +1699,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type, #else /* Libisofs_with_aaip_dummY */ - /* >>> if AAIP is enabled */ - if (1) { + if (t->aaip) { #endif /* ! Libisofs_with_aaip_dummY */ @@ -1737,8 +1727,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type, #else /* Libisofs_with_aaip_dummY */ - /* >>> if AAIP is enabled */ - if (1) { + if (t->aaip) { #endif /* ! Libisofs_with_aaip_dummY */