New API call iso_local_get_acl_text()

and bug fixes about "default" ACL
release-1.5.4.branch
Thomas Schmitt 14 years ago
parent 0b4792bc0c
commit b53ef57ac6
  1. 36
      libisofs/aaip-os-linux.c
  2. 2
      libisofs/aaip_0_2.c
  3. 7
      libisofs/aaip_0_2.h
  4. 41
      libisofs/libisofs.h
  5. 19
      libisofs/node.c

@ -43,45 +43,31 @@
@return 1 ok
2 only st_mode permissions exist and bit 4 is set
or empty ACL and bit0 is set
0 ACL support not enabled at compile time
-1 failure of system ACL service (see errno)
-2 ACL support not enabled at compile time
*/
int aaip_get_acl_text(char *path, char **text, int flag)
{
#ifdef Libisofs_with_aaip_acL
acl_t acl= NULL;
#endif
struct stat stbuf;
int ret;
if(flag & (1 << 15)) {
if(*text != NULL)
#ifdef Libisofs_with_aaip_acL
acl_free(text);
#else
free(text);
#endif
*text= NULL;
return(1);
}
*text= NULL;
#ifdef Libisofs_with_aaip_acL
acl= acl_get_file(path, (flag & 1) ? ACL_TYPE_DEFAULT : ACL_TYPE_ACCESS);
if(acl == NULL)
return(-1);
*text= acl_to_text(acl, NULL);
acl_free(acl);
#else /* Libisofs_with_aaip_acL */
/* ??? >>> Fake ACL */;
return(-2);
#endif /* ! Libisofs_with_aaip_acL */
if(*text == NULL)
return(-1);
if(flag & 16) {
@ -94,16 +80,18 @@ int aaip_get_acl_text(char *path, char **text, int flag)
}
if(flag & (1 | 16)) {
if((*text)[0] == 0 || strcmp(*text, "\n") == 0) {
#ifdef Libisofs_with_aaip_acL
acl_free(text);
#else
free(text);
#endif
*text= NULL;
return(2);
}
}
return(1);
#else /* Libisofs_with_aaip_acL */
return(0);
#endif /* ! Libisofs_with_aaip_acL */
}
@ -288,9 +276,9 @@ ex:;
@param text The input text (0 terminated, ACL long text form)
@param flag Bitfield for control purposes
bit0= set default ACL rather than access ACL
@return > 0 ok
-1 failure of system ACL service (see errno)
-2 ACL support not enabled at compile time
@return >0 ok
0 ACL support not enabled at compile time
-1 failure of system ACL service (see errno)
*/
int aaip_set_acl_text(char *path, char *text, int flag)
{
@ -315,7 +303,7 @@ ex:
#else /* Libisofs_with_aaip_acL */
return(-2);
return(0);
#endif /* ! Libisofs_with_aaip_acL */

@ -2006,7 +2006,7 @@ int aaip_decode_acl(unsigned char *data, size_t num_data, size_t *consumed,
ret= aaip_write_acl_line(&wpt, &w_size, "other", "", perm_text, cnt);
} else if(type == Aaip_SWITCH_MARK) {
/* Indicate to caller: end of desired ACL type access/default */
if((!(perm & Aaip_EXEC)) ^ (!!(flag & 2)))
if((perm & Aaip_EXEC) ^ (!!(flag & 2)))
return(2);
} else if(type == Aaip_ACL_USER_N) {
/* determine username from uid */

@ -43,7 +43,7 @@ size_t aaip_encode(char aa_name[2], size_t num_attrs, char **names,
Attribute. According to AAIP 0.2 this value is to be stored together with
an empty name.
@param acl_text The ACL in long text form
@param st_mode The stat(2) permission bits to be used with flag bit2
@param st_mode The stat(2) permission bits to be used with flag bit3
@param result_len Number of bytes in the resulting value
@param result *result will point to the start of the result string.
This is malloc() memory which needs to be freed when
@ -68,7 +68,7 @@ int aaip_encode_acl(char *acl_text, mode_t st_mode,
Submit NULL if there is no such ACL to be encoded.
@param d_acl_text The "default" ACL in long text form.
Submit NULL if there is no such ACL to be encoded.
@param st_mode The stat(2) permission bits to be used with flag bit2
@param st_mode The stat(2) permission bits to be used with flag bit3
@param result_len Number of bytes in the resulting value
@param result *result will point to the start of the result string.
This is malloc() memory which needs to be freed when
@ -154,6 +154,7 @@ int aaip_add_acl_st_mode(char *acl_text, mode_t st_mode, int flag);
bit15= free text and return 1
@return 1 ok
2 only st_mode permissions exist and bit 4 is set
0 ACL support not enabled at compile time
-1 failure of system ACL service (see errno)
*/
int aaip_get_acl_text(char *path, char **text, int flag);
@ -458,7 +459,7 @@ int aaip_decode_acl(unsigned char *data, size_t num_data, size_t *consumed,
@param flag Bitfield for control purposes
bit0= set default ACL rather than access ACL
@return >0 ok
0 no ACL manipulation adapter available
0 ACL support not enabled at compile time
-1 failure of system ACL service (see errno)
*/
int aaip_set_acl_text(char *path, char *text, int flag);

@ -3169,6 +3169,9 @@ int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path,
IsoNode **node);
/**
* This is a more versatile form of iso_tree_add_node which allows to set
* the node name in ISO image already when it gets added.
*
* Add a new node to the image tree, from an existing file, and with the
* given name, that must not exist on dir.
*
@ -4250,7 +4253,7 @@ int aaip_xinfo_func(void *data, int flag);
* @return
* 2 ACL produced from POSIX permissions
* 1 ACL was read from node
* 0 if the desire ACL type is not available
* 0 if the desired ACL type is not available
* < 0 on error
*
* @since 0.6.14
@ -4283,13 +4286,43 @@ int iso_node_get_acl_text(IsoNode *node, char **text, int flag);
* return success.
* @return
* > 0 success
* <=0 failure
* < 0 failure
*/
int iso_node_set_acl_text(IsoNode *node, char *text, int flag);
/* -------- This is an interface to the ACL of the local filesystem -------- */
/* ts A90127 */
/**
* Get the ACL of the given file in the local filesystem in long text form.
*
* @param disk_path
* Path to the file
* @param text
* Will return a pointer to the ACL text. If not NULL the text will be
* 0 terminated and finally has to be disposed by a call to this function
* with bit15 set.
* @param flag
* Bitfield for control purposes
* bit0= get default ACL rather than access ACL
* bit4= set *text = NULL and return 2
* if the ACL matches st_mode permissions.
* bit15= free text and return 1
* @return
* 1 ok
* 2 ok, trivial ACL found while bit4 is set, *text is NULL
* 0 no ACL manipulation adapter available
* -1 failure of system ACL service (see errno)
*
* @since 0.6.14
*/
int iso_local_get_acl_text(char *disk_path, char **text, int flag);
/* ts A90118 */
/* Set the ACL of the given file in the local filesystem to a given list
/**
* Set the ACL of the given file in the local filesystem to a given list
* in long text form.
*
* @param disk_path
@ -4305,7 +4338,7 @@ int iso_node_set_acl_text(IsoNode *node, char *text, int flag);
* -1 failure of system ACL service (see errno)
*
* @since 0.6.14
*/
*/
int iso_local_set_acl_text(char *disk_path, char *text, int flag);

@ -1817,7 +1817,7 @@ int iso_local_set_acl_text(char *disk_path, char *text, int flag)
#ifdef Libisofs_with_aaiP
return aaip_set_acl_text(disk_path, text, flag);
return aaip_set_acl_text(disk_path, text, flag & 1);
#else /* Libisofs_with_aaiP */
@ -1827,3 +1827,20 @@ int iso_local_set_acl_text(char *disk_path, char *text, int flag)
}
/* ts A90127 */
int iso_local_get_acl_text(char *disk_path, char **text, int flag)
{
#ifdef Libisofs_with_aaiP
return aaip_get_acl_text(disk_path, text, flag & (1 | 16 | (1 << 15)));
#else /* Libisofs_with_aaiP */
return 0;
#endif /* ! Libisofs_with_aaiP */
}

Loading…
Cancel
Save