More graceful reaction on filesystems where ACL are not enabled.

This commit is contained in:
Thomas Schmitt 2010-01-11 09:57:00 +01:00
parent c874a159e2
commit 819e3218f6
4 changed files with 32 additions and 9 deletions

View File

@ -290,7 +290,7 @@ described here. This feature allows scdbackup to omit its own checksum filter
if using xorriso as ISO 9660 formatter program. if using xorriso as ISO 9660 formatter program.
Such a tag makes only sense if the session begins at LBA 0. Such a tag makes only sense if the session begins at LBA 0.
See scdbackup-*/README, appendix VERIFY for a specification See scdbackup-*/README, appendix VERIFY for a specification.
Example of a scdbackup checksum tag: Example of a scdbackup checksum tag:
scdbackup_checksum_tag_v0.1 2456606865 61 2_2 B00109.143415 2456606865 485bbef110870c45754d7adcc844a72c c2355d5ea3c94d792ff5893dfe0d6d7b scdbackup_checksum_tag_v0.1 2456606865 61 2_2 B00109.143415 2456606865 485bbef110870c45754d7adcc844a72c c2355d5ea3c94d792ff5893dfe0d6d7b

View File

@ -18,6 +18,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
#ifndef Libisofs_with_aaip_acL #ifndef Libisofs_with_aaip_acL
/* It seems ACL is fixely integrated in FreeBSD libc. There is no libacl. */ /* It seems ACL is fixely integrated in FreeBSD libc. There is no libacl. */
@ -37,13 +38,14 @@
finally has to be freed by a call to this function finally has to be freed by a call to this function
with bit15 of flag. with bit15 of flag.
@param flag Bitfield for control purposes @param flag Bitfield for control purposes
bit0= obtain default ACL rather than access ACL (bit0= obtain default ACL rather than access ACL)
bit4= set *text = NULL and return 2 bit4= set *text = NULL and return 2
if the ACL matches st_mode permissions. if the ACL matches st_mode permissions.
bit5= in case of symbolic link: inquire link target bit5= in case of symbolic link: inquire link target
bit15= free text and return 1 bit15= free text and return 1
@return > 0 ok @return > 0 ok
0 ACL support not enabled at compile time 0 ACL support not enabled at compile time
or filesystem does not support ACL
-1 failure of system ACL service (see errno) -1 failure of system ACL service (see errno)
-2 attempt to inquire ACL of a symbolic -2 attempt to inquire ACL of a symbolic
link without bit4 or bit5 link without bit4 or bit5
@ -88,8 +90,18 @@ int aaip_get_acl_text(char *path, char **text, int flag)
acl= acl_get_file(path, ACL_TYPE_ACCESS); acl= acl_get_file(path, ACL_TYPE_ACCESS);
if(acl == NULL) if(acl == NULL) {
if(errno == EOPNOTSUPP) {
/* filesystem does not support ACL */
if(flag & 16)
return(2);
/* >>> ??? fake ACL from POSIX permissions ? */;
return(0);
}
return(-1); return(-1);
}
*text= acl_to_text(acl, NULL); *text= acl_to_text(acl, NULL);
acl_free(acl); acl_free(acl);
@ -181,10 +193,8 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
if(flag & 1) { /* Obtain ACL */ if(flag & 1) { /* Obtain ACL */
/* access-ACL */ /* access-ACL */
ret= aaip_get_acl_text(path, &acl_text, flag & (16 | 32)); aaip_get_acl_text(path, &acl_text, flag & (16 | 32));
if(ret <= 0) if(acl_text == NULL)
goto ex;
if(ret == 2)
{ret= 1; goto ex;} /* empty ACL / only st_mode info was found in ACL */ {ret= 1; goto ex;} /* empty ACL / only st_mode info was found in ACL */
ret= aaip_encode_acl(acl_text, (mode_t) 0, &a_acl_len, &a_acl, flag & 2); ret= aaip_encode_acl(acl_text, (mode_t) 0, &a_acl_len, &a_acl, flag & 2);
if(ret <= 0) if(ret <= 0)

View File

@ -18,6 +18,8 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
#ifdef Libisofs_with_aaip_acL #ifdef Libisofs_with_aaip_acL
#include <sys/acl.h> #include <sys/acl.h>
@ -46,6 +48,7 @@
2 only st_mode permissions exist and bit 4 is set 2 only st_mode permissions exist and bit 4 is set
or empty ACL and bit0 is set or empty ACL and bit0 is set
0 ACL support not enabled at compile time 0 ACL support not enabled at compile time
or filesystem does not support ACL
-1 failure of system ACL service (see errno) -1 failure of system ACL service (see errno)
-2 attempt to inquire ACL of a symbolic link without -2 attempt to inquire ACL of a symbolic link without
bit4 or bit5 resp. with no suitable link target bit4 or bit5 resp. with no suitable link target
@ -79,8 +82,18 @@ int aaip_get_acl_text(char *path, char **text, int flag)
} }
acl= acl_get_file(path, (flag & 1) ? ACL_TYPE_DEFAULT : ACL_TYPE_ACCESS); acl= acl_get_file(path, (flag & 1) ? ACL_TYPE_DEFAULT : ACL_TYPE_ACCESS);
if(acl == NULL) if(acl == NULL) {
if(errno == ENOTSUP) {
/* filesystem does not support ACL */
if(flag & 16)
return(2);
/* >>> ??? fake ACL from POSIX permissions ? */;
return(0);
}
return(-1); return(-1);
}
*text= acl_to_text(acl, NULL); *text= acl_to_text(acl, NULL);
acl_free(acl); acl_free(acl);

View File

@ -4566,7 +4566,7 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
* @return * @return
* 1 ok * 1 ok
* 2 ok, trivial ACL found while bit4 is set, *text is NULL * 2 ok, trivial ACL found while bit4 is set, *text is NULL
* 0 no ACL manipulation adapter available * 0 no ACL manipulation adapter available / ACL not supported on fs
* -1 failure of system ACL service (see errno) * -1 failure of system ACL service (see errno)
* -2 attempt to inquire ACL of a symbolic link without bit4 or bit5 * -2 attempt to inquire ACL of a symbolic link without bit4 or bit5
* resp. with no suitable link target * resp. with no suitable link target