diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 0c2d65e..5e086f8 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -2010,12 +2010,12 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block) data->aaip_version = 2; if (!data->aaip_load) - iso_msg_submit(data->msgid, ISO_DATA_AAIP_IGNORED, 0, + iso_msg_submit(data->msgid, ISO_AAIP_IGNORED, 0, "Identifier for extension AAIP 0.2 found, but loading is not enabled."); #else /* Libisofs_with_aaiP */ - iso_msg_submit(data->msgid, ISO_DATA_AAIP_IGNORED, 0, + iso_msg_submit(data->msgid, ISO_AAIP_IGNORED, 0, "Identifier for future extension AAIP 0.2 found and ignored."); #endif /* ! Libisofs_with_aaiP */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 3ed9b14..832dce7 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -4207,7 +4207,23 @@ void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, /* ts A90121 */ /** AAIP info is present in ISO image but will be ignored (NOTE, HIGH, -336) */ -#define ISO_DATA_AAIP_IGNORED 0xB030FEB1 +#define ISO_AAIP_IGNORED 0xB030FEB0 + +/* ts A90130 */ +/** Error with decoding ACL from AAIP info (FAILURE, HIGH, -337) */ +#define ISO_AAIP_BAD_ACL 0xE830FEAF + +/* ts A90130 */ +/** Error with encoding ACL for AAIP (FAILURE, HIGH, -338) */ +#define ISO_AAIP_BAD_ACL_TEXT 0xE830FEAE + +/* ts A90130 */ +/** No AAIP processing enabled at compile time (FAILURE, HIGH, -339) */ +#define ISO_AAIP_NOT_ENABLED 0xE830FEAD + +/* ts A90130 */ +/** Error with decoding attribute list AAIP info (FAILURE, HIGH, -340) */ +#define ISO_AAIP_BAD_AASTRING 0xE830FEAC /* --------------------------------- AAIP --------------------------------- */ @@ -4239,64 +4255,72 @@ void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, int aaip_xinfo_func(void *data, int flag); -/* ts A90116 */ +/* ts A90130 */ /** - * Get an eventual ACL which is associated with the node. + * Get the eventual ACLs which are associated with the node. * The result will be in "long" text form as of man acl resp. acl_to_text(). * * @param node * The node that is to be inquired. - * @param text - * Will return a pointer to the eventual ACL text or NULL if the desired - * ACL is not available. Call this funtion with flag bit15 to finally - * release the memory occupied an ACL inquiry. + * @param access_text + * Will return a pointer to the eventual "access" ACL text or NULL if it + * is not available and flag bit 4 is set. + * Call this function with flag bit15 to finally release the memory + * occupied by an ACL inquiry. + * @param default_text + * Will return a pointer to the eventual "default" ACL or NULL if it + * is not available. + * (Linux directories can have a "default" ACL which influences + * the permissions of newly created files.) * @param flag * Bitfield for control purposes - * bit0= obtain "default" ACL rather than "access" ACL - * (Linux directories can have a "default" ACL which influences - * the permissions of newly created files.) - * bit4= if no ACL is available: return *text == NULL - * else: produce ACL from POSIX permissions + * bit4= if no "access" ACL is available: return *access_text == NULL + * else: produce ACL from stat(2) permissions * bit15= free memory and return 1 * @return - * 2 ACL produced from POSIX permissions - * 1 ACL was read from node - * 0 if the desired ACL type is not available + * 2 *access_text was produced from stat(2) permissions + * 1 *access_text was produced from ACL of node + * 0 if flag bit4 is set and no ACL is available * < 0 on error * * @since 0.6.14 */ -int iso_node_get_acl_text(IsoNode *node, char **text, int flag); +int iso_node_get_acl_text(IsoNode *node, + char **access_text, char **default_text, int flag); -/* ts A90119 */ +/* ts A90130 */ /** - * Set the ACL of the given node to the list in parameter text or delete it. + * Set the ACLs of the given node to the lists in parameters access_text and + * default_text or delete them. * - * The POSIX permission bits get updated according to the new ACL if neither - * bit0 nor bit1 of parameter flag are set nor parameter text is NULL. + * The POSIX permission bits get updated according to the new "access" ACL if + * neither bit1 of parameter flag is set nor parameter access_text is NULL. * Note that S_IRWXG permission bits correspond to ACL mask permissions * if a "mask::" entry exists in the ACL. Only if there is no "mask::" then * the "group::" entry corresponds to to S_IRWXG. * * @param node * The node that is to be manipulated. - * @param text - * The ACL text to be set into effect. NULL will delete an eventually - * existing ACL of the node. + * @param access_text + * The text to be set into effect as "access" ACL. NULL will delete an + * eventually existing "access" ACL of the node. + * @param default_text + * The text to be set into effect as "default" ACL. NULL will delete an + * eventually existing "default" ACL of the node. + * (Linux directories can have a "default" ACL which influences + * the permissions of newly created files.) * @param flag * Bitfield for control purposes - * bit0= set "default" ACL rather than "access" ACL - * (Linux directories can have a "default" ACL which influences - * the permissions of newly created files.) - * bit1= ignore text but rather update eventual "access" ACL to the POSIX - * permissions of node. If no ACL exists, then do nothing and - * return success. + * bit1= ignore text parameters but rather update eventual "access" ACL + * to the stat(2) permissions of node. If no "access" ACL exists, + * then do nothing and return success. * @return * > 0 success * < 0 failure */ -int iso_node_set_acl_text(IsoNode *node, char *text, int flag); +int iso_node_set_acl_text(IsoNode *node, + char *access_text, char *default_text, int flag); /* -------- This is an interface to the ACL of the local filesystem -------- */ diff --git a/libisofs/messages.c b/libisofs/messages.c index 38801d8..8c19967 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -210,6 +210,10 @@ const char *iso_error_to_msg(int errcode) case ISO_DATA_SOURCE_FAILURE: case ISO_DATA_SOURCE_FATAL: return "Read error occured with IsoDataSource"; + case ISO_AAIP_IGNORED: + return "AAIP info is present in ISO image but will be ignored"; + case ISO_AAIP_BAD_ACL: + return "Error with decoding ACL from AAIP info"; default: return "Unknown error"; } diff --git a/libisofs/node.c b/libisofs/node.c index 17ab4ef..51ffb04 100644 --- a/libisofs/node.c +++ b/libisofs/node.c @@ -297,7 +297,7 @@ int iso_node_set_perms_internal(IsoNode *node, mode_t mode, int flag) /* If the node has ACL info : update ACL */ ret = 1; if (!(flag & 1)) - ret = iso_node_set_acl_text(node, "", 2); + ret = iso_node_set_acl_text(node, "", "", 2); return ret; #endif @@ -1390,11 +1390,8 @@ int iso_node_get_attrs(IsoNode *node, size_t *num_attrs, if (todo > 2048) todo = 2048; if (todo == 0) { - - /* >>> Out of data while still prompted to submit */; - - /* >>> invent better error code */ - return ISO_ERROR; + /* Out of data while still prompted to submit */ + return ISO_AAIP_BAD_AASTRING; } /* Allow 1 million bytes of memory consumption, 100,000 attributes */ ret = aaip_decode_attrs(&aaip, "AA", (size_t) 1000000, (size_t) 100000, @@ -1406,27 +1403,20 @@ int iso_node_get_attrs(IsoNode *node, size_t *num_attrs, if (ret == 2) break; - /* >>> "aaip_decode_attrs() reports error */; - - /* >>> invent better error code */ - return ISO_ERROR; + /* aaip_decode_attrs() reports error */ + return ISO_AAIP_BAD_AASTRING; } if(rpt - aa_string != len) { - - /* >>> "aaip_decode_attrs() returns 2 but still bytes are left" */ - - /* >>> invent better error code */ - return ISO_ERROR; + /* aaip_decode_attrs() returns 2 but still bytes are left */ + return ISO_AAIP_BAD_AASTRING; } ret = aaip_get_decoded_attrs(&aaip, num_attrs, names, value_lengths, values, 0); if(ret != 1) { - - /* >>> aaip_get_decoded_attrs() failed */; - - return ISO_OUT_OF_MEM; + /* aaip_get_decoded_attrs() failed */ + return ISO_AAIP_BAD_AASTRING; } #else /* Libisofs_with_aaiP */ @@ -1480,9 +1470,7 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names, #else /* Libisofs_with_aaiP */ - /* >>> no support for attributes */ - - return ISO_ERROR; + return ISO_AAIP_NOT_ENABLED; #endif /* ! Libisofs_with_aaiP */ @@ -1520,8 +1508,9 @@ int iso_decode_acl(unsigned char *v_data, size_t v_len, size_t *consumed, #endif /* ! Libisofs_with_aaiP */ -/* ts A90116 */ -int iso_node_get_acl_text(IsoNode *node, char **text, int flag) +/* ts A90130 */ +int iso_node_get_acl_text(IsoNode *node, + char **access_text, char **default_text, int flag) { #ifdef Libisofs_with_aaiP @@ -1534,13 +1523,16 @@ int iso_node_get_acl_text(IsoNode *node, char **text, int flag) mode_t st_mode; if (flag & (1 << 15)) { - if (*text != NULL) - free(*text); - *text = NULL; + if (*access_text != NULL) + free(*access_text); + *access_text = NULL; + if (*default_text != NULL) + free(*default_text); + *default_text = NULL; return 1; } - *text = NULL; + *access_text = *default_text = NULL; ret = iso_node_get_attrs(node, &num_attrs, &names, &value_lengths, &values, 0); @@ -1554,39 +1546,33 @@ int iso_node_get_acl_text(IsoNode *node, char **text, int flag) v_data = (unsigned char *) values[i]; v_len = value_lengths[i]; - if (flag & 1) { - /* Skip "access" ACL and address "default" ACL instead */ - ret = aaip_decode_acl(v_data, v_len, - &consumed, NULL, (size_t) 0, &text_fill, 1); - if (ret <= 0) - goto bad_decode; - if (ret != 2) { - ret = 0; - goto ex; - } + /* "access" ACL */ + ret = iso_decode_acl(v_data, v_len, + &consumed, access_text, &text_fill, 0); + if (ret <= 0) + goto bad_decode; + if (ret == 2) { v_data += consumed; v_len -= consumed; + ret = iso_decode_acl(v_data, v_len, + &consumed, default_text, &text_fill, 0); + if (ret == 0) + goto bad_decode; } - - ret = iso_decode_acl(v_data, v_len, &consumed, text, &text_fill, 0); - if (ret == 0) - goto bad_decode; - if (ret < 0) - goto ex; break; } - if (*text == NULL && !(flag & 16)) { + if (*access_text == NULL && !(flag & 16)) { from_posix = 1; - *text = calloc(42, 1); /* 42 for aaip_update_acl_st_mode */ + *access_text = calloc(42, 1); /* 42 for aaip_update_acl_st_mode */ } - if (*text != NULL) { + if (*access_text != NULL) { st_mode = iso_node_get_permissions(node); - aaip_add_acl_st_mode(*text, st_mode, 0); - text_fill = strlen(*text); + aaip_add_acl_st_mode(*access_text, st_mode, 0); + text_fill = strlen(*access_text); } - if (text == NULL) + if (*access_text == NULL && *default_text == NULL) ret = 0; else ret = 1 + from_posix; @@ -1596,25 +1582,22 @@ ex:; return ret; bad_decode:; - - /* >>> something is wrong with the attribute value */; - - /* >>> invent better error code */ - ret = ISO_ERROR; + ret = ISO_AAIP_BAD_ACL; goto ex; #else /* Libisofs_with_aaiP */ - *text = NULL; - return 0; + *access_text = *default_text = NULL; + return ISO_AAIP_NOT_ENABLED; #endif /* ! Libisofs_with_aaiP */ } -/* ts A90119 */ -int iso_node_set_acl_text(IsoNode *node, char *acl_text, int flag) +/* ts A90130 */ +int iso_node_set_acl_text(IsoNode *node, char *access_text, char *default_text, + int flag) { #ifdef Libisofs_with_aaiP @@ -1625,7 +1608,6 @@ int iso_node_set_acl_text(IsoNode *node, char *acl_text, int flag) char **names = NULL, **values = NULL, *a_text = NULL, *d_text = NULL; char **new_names, **new_values; size_t *new_value_lengths; - char **tpt; unsigned char *v_data, *acl= NULL; int ret; mode_t st_mode; @@ -1647,57 +1629,45 @@ int iso_node_set_acl_text(IsoNode *node, char *acl_text, int flag) continue; v_data = (unsigned char *) values[i]; v_len = value_lengths[i]; - /* "access" ACL */; - ret = iso_decode_acl(v_data, v_len, &consumed, &a_text, &a_text_fill, - 0); - if (ret == 0) - goto bad_decode; - if (ret < 0) - goto ex; - if (ret == 2) { - /* "default" ACL */; - v_data += consumed; - v_len -= consumed; - ret = iso_decode_acl(v_data, v_len, &consumed, &d_text, - &d_text_fill, 0); + if (flag & 2) { /* update "access" ACL by st_mode */ + /* read "access" ACL */ + ret = iso_decode_acl(v_data, v_len, &consumed, + &a_text, &a_text_fill, 0); if (ret == 0) goto bad_decode; if (ret < 0) goto ex; - } - - if (flag & 2) { + if (ret == 2) { + /* read "default" ACL */ + v_data += consumed; + v_len -= consumed; + ret = iso_decode_acl(v_data, v_len, &consumed, &d_text, + &d_text_fill, 0); + if (ret == 0) + goto bad_decode; + if (ret < 0) + goto ex; + } /* Update "access" ACL by st_mode */ if (a_text == NULL) { ret = 1; goto ex; } ret = aaip_cleanout_st_mode(a_text, &st_mode, 8); - if (ret < 0) - goto bad_decode; - } else { - if (flag & 1) - tpt = &d_text; - else - tpt = &a_text; - if (*tpt != NULL) { - free(*tpt); - *tpt = NULL; + if (ret < 0) { + ret = ISO_AAIP_BAD_ACL_TEXT; + goto ex; } - if (acl_text != NULL) { - *tpt = calloc(strlen(acl_text) + 1, 1); - if (*tpt == NULL) { - ret = ISO_OUT_OF_MEM; - goto ex; - } - memcpy(*tpt, acl_text, strlen(acl_text)); - } - } - if (a_text != NULL || d_text != NULL) - ret = aaip_encode_both_acl(a_text, d_text, st_mode, &acl_len, &acl, - 2 | 8); - else ret = 1; + if (a_text != NULL || d_text != NULL) + ret = aaip_encode_both_acl(a_text, d_text, st_mode, + &acl_len, &acl, 2 | 8); + } else { + ret = 1; + if (access_text != NULL || default_text != NULL) + ret = aaip_encode_both_acl(access_text, default_text, st_mode, + &acl_len, &acl, 2 | 8); + } if (ret <= 0) { ret = ISO_OUT_OF_MEM; goto ex; @@ -1728,22 +1698,15 @@ int iso_node_set_acl_text(IsoNode *node, char *acl_text, int flag) } /* There is no ACL yet */ - if ((flag & 2) || acl_text == NULL) { + if ((flag & 2) || (access_text == NULL && default_text == NULL)) { /* thus no need to update ACL by st_mode or to delete ACL */ ret = 1; goto ex; } - if (flag & 1) - ret = aaip_encode_both_acl(NULL, acl_text, - st_mode, &acl_len, &acl, 2 | 8); - else - ret = aaip_encode_both_acl(acl_text, NULL, - st_mode, &acl_len, &acl, 2 | 8); + ret = aaip_encode_both_acl(access_text, default_text, + st_mode, &acl_len, &acl, 2 | 8); if (ret <= 0) { - - /* >>> cannot encode */; - - ret = ISO_ERROR; + ret = ISO_AAIP_BAD_ACL_TEXT; goto ex; } @@ -1785,12 +1748,14 @@ int iso_node_set_acl_text(IsoNode *node, char *acl_text, int flag) goto ex; update_perms:; - if(acl_text != NULL && !(flag & (1 | 2))) { + if(access_text != NULL && !(flag & (1 | 2))) { /* Update node permissions by acl_text */ st_mode = iso_node_get_permissions(node); - ret = aaip_cleanout_st_mode(acl_text, &st_mode, 4); - if (ret < 0) - goto bad_decode; + ret = aaip_cleanout_st_mode(access_text, &st_mode, 4); + if (ret < 0) { + ret = ISO_AAIP_BAD_ACL_TEXT; + goto ex; + } iso_node_set_perms_internal(node, st_mode, 1); } @@ -1807,22 +1772,14 @@ ex:; return ret; bad_decode:; - - /* >>> something is wrong with the attribute value */; - - /* >>> invent better error code */ - ret = ISO_ERROR; + ret = ISO_AAIP_BAD_ACL; goto ex; #else /* Libisofs_with_aaiP */ - if (acl_text != NULL) { - - /* >>> No ACL enabled in program code */; - - return(0); - } - return (1); + if (access_text != NULL || default_text != NULL) + return ISO_AAIP_NOT_ENABLED; + return 1; #endif /* ! Libisofs_with_aaiP */ diff --git a/libisofs/rockridge_read.c b/libisofs/rockridge_read.c index 564e86d..7dcc668 100644 --- a/libisofs/rockridge_read.c +++ b/libisofs/rockridge_read.c @@ -416,8 +416,8 @@ int read_rr_PN(struct susp_sys_user_entry *pn, struct stat *st) } /* ts A90129 */ - /* (dev_t << 32) causes compiler warnings on FreeBSD. - RRIP 1.10 4.1.2 prescribes PN "Dev_t High" to be 0 on 32 bit dev_t. + /* (dev_t << 32) causes compiler warnings on FreeBSD + because sizeof(dev_t) is 4. */ st->st_rdev = (dev_t)iso_read_bb(pn->data.PN.low, 4, NULL); if (sizeof(st->st_rdev) > 4) {