]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/filed/xacl_freebsd.h
b3e1d653beca9a1750e1e70d3342640522342a9d
[bacula/bacula] / bacula / src / filed / xacl_freebsd.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18  */
19 /**
20  * Major refactoring of ACL and XATTR code written by:
21  *
22  *  RadosÅ‚aw Korzeniewski, MMXVI
23  *  radoslaw@korzeniewski.net, radekk@inteos.pl
24  *  Inteos Sp. z o.o. http://www.inteos.pl/
25  *
26  */
27
28 #ifndef __XACL_FreeBSD_H_
29 #define __XACL_FreeBSD_H_
30
31 #if defined(HAVE_FREEBSD_OS)
32 #include <sys/types.h>
33
34 #ifdef HAVE_SYS_ACL_H
35 #include <sys/acl.h>
36 #else
37 #error "configure failed to detect availability of sys/acl.h"
38 #endif
39
40 #if (!defined(HAVE_EXTATTR_GET_LINK) && !defined(HAVE_EXTATTR_GET_FILE)) || \
41     (!defined(HAVE_EXTATTR_SET_LINK) && !defined(HAVE_EXTATTR_SET_FILE)) || \
42     (!defined(HAVE_EXTATTR_LIST_LINK) && !defined(HAVE_EXTATTR_LIST_FILE)) || \
43     !defined(HAVE_EXTATTR_NAMESPACE_TO_STRING) || \
44     !defined(HAVE_EXTATTR_STRING_TO_NAMESPACE)
45 #error "Missing full support for the extattr functions."
46 #endif
47
48 #ifdef HAVE_SYS_EXTATTR_H
49 #include <sys/types.h>
50 #include <sys/extattr.h>
51 #else
52 #error "Missing sys/extattr.h header file"
53 #endif
54
55 #ifdef HAVE_LIBUTIL_H
56 #include <libutil.h>
57 #endif
58
59 #if !defined(HAVE_EXTATTR_GET_LINK) && defined(HAVE_EXTATTR_GET_FILE)
60 #define extattr_get_link extattr_get_file
61 #endif
62 #if !defined(HAVE_EXTATTR_SET_LINK) && defined(HAVE_EXTATTR_SET_FILE)
63 #define extattr_set_link extattr_set_file
64 #endif
65 #if !defined(HAVE_EXTATTR_LIST_LINK) && defined(HAVE_EXTATTR_LIST_FILE)
66 #define extattr_list_link extattr_list_file
67 #endif
68
69 /*
70  *
71  *
72  */
73 class XACL_FreeBSD : public XACL {
74 private:
75    bRC_XACL os_backup_acl (JCR *jcr, FF_PKT *ff_pkt);
76    bRC_XACL os_restore_acl (JCR *jcr, int stream, char *content, uint32_t length);
77    bRC_XACL os_backup_xattr (JCR *jcr, FF_PKT *ff_pkt);
78    bRC_XACL os_restore_xattr (JCR *jcr, int stream, char *content, uint32_t length);
79    bRC_XACL os_get_acl(JCR *jcr, XACL_type xacltype);
80    bRC_XACL os_set_acl(JCR *jcr, XACL_type xacltype, char *content, uint32_t length);
81    bRC_XACL os_get_xattr_names (JCR *jcr, const int ns, POOLMEM **list, uint32_t *length);
82    bRC_XACL os_get_xattr_value (JCR *jcr, const int ns, char * name, char ** pvalue, uint32_t * plen);
83    bRC_XACL os_set_xattr (JCR *jcr, XACL_xattr *xattr);
84    /* requires acl.h available */
85    bool acl_issimple(acl_t acl);
86    acl_type_t get_acltype(XACL_type xacltype);
87    int acl_nrentries(acl_t acl);
88    bRC_XACL check_xacltype (JCR *jcr, int name);
89 public:
90    XACL_FreeBSD ();
91 };
92
93 #endif /* HAVE_FREEBSD_OS */
94
95 #endif /* __XACL_FreeBSD_H_ */