DAOS API (v2.1 - dev)
Loading...
Searching...
No Matches
daos_security.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2019-2022 Intel Corporation.
3 *
4 * SPDX-License-Identifier: BSD-2-Clause-Patent
5 */
6
13#ifndef __DAOS_SECURITY_H__
14#define __DAOS_SECURITY_H__
15
16#if defined(__cplusplus)
17extern "C" {
18#endif
19
20#include <stdio.h>
21#include <stdint.h>
22#include <stdbool.h>
23#include <sys/types.h>
24
28#define DAOS_ACL_VERSION (1)
29
34#define DAOS_ACL_MAX_PRINCIPAL_LEN (255)
36#define DAOS_ACL_MAX_PRINCIPAL_BUF_LEN (DAOS_ACL_MAX_PRINCIPAL_LEN + 1)
37
39#define DAOS_ACL_PRINCIPAL_OWNER "OWNER@"
41#define DAOS_ACL_PRINCIPAL_OWNER_GRP "GROUP@"
43#define DAOS_ACL_PRINCIPAL_EVERYONE "EVERYONE@"
44
48#define DAOS_ACL_MAX_ACE_LEN (65536)
49
54#define DAOS_ACL_MAX_ACE_STR_LEN (DAOS_ACL_MAX_PRINCIPAL_LEN + 64)
55
62struct daos_acl {
64 uint16_t dal_ver;
66 uint16_t dal_reserv;
68 uint32_t dal_len;
70 uint8_t dal_ace[];
71};
72
87
92 DAOS_ACL_ACCESS_ALLOW = (1U << 0),
94 DAOS_ACL_ACCESS_ALARM = (1U << 2)
95};
96
100#define DAOS_ACL_ACCESS_ALL (DAOS_ACL_ACCESS_ALLOW | \
101 DAOS_ACL_ACCESS_AUDIT | \
102 DAOS_ACL_ACCESS_ALARM)
103
117
121#define DAOS_ACL_FLAG_ALL (DAOS_ACL_FLAG_GROUP | \
122 DAOS_ACL_FLAG_POOL_INHERIT | \
123 DAOS_ACL_FLAG_ACCESS_FAIL | \
124 DAOS_ACL_FLAG_ACCESS_SUCCESS)
125
130 DAOS_ACL_PERM_READ = (1U << 0),
131 DAOS_ACL_PERM_WRITE = (1U << 1),
132 DAOS_ACL_PERM_CREATE_CONT = (1U << 2),
133 DAOS_ACL_PERM_DEL_CONT = (1U << 3),
134 DAOS_ACL_PERM_GET_PROP = (1U << 4),
135 DAOS_ACL_PERM_SET_PROP = (1U << 5),
136 DAOS_ACL_PERM_GET_ACL = (1U << 6),
137 DAOS_ACL_PERM_SET_ACL = (1U << 7),
138 DAOS_ACL_PERM_SET_OWNER = (1U << 8),
139};
140
144#define DAOS_ACL_PERM_POOL_ALL (DAOS_ACL_PERM_READ | \
145 DAOS_ACL_PERM_GET_PROP | \
146 DAOS_ACL_PERM_WRITE | \
147 DAOS_ACL_PERM_CREATE_CONT | \
148 DAOS_ACL_PERM_DEL_CONT)
149
153#define DAOS_ACL_PERM_CONT_ALL (DAOS_ACL_PERM_READ | \
154 DAOS_ACL_PERM_WRITE | \
155 DAOS_ACL_PERM_DEL_CONT | \
156 DAOS_ACL_PERM_GET_PROP | \
157 DAOS_ACL_PERM_SET_PROP | \
158 DAOS_ACL_PERM_GET_ACL | \
159 DAOS_ACL_PERM_SET_ACL | \
160 DAOS_ACL_PERM_SET_OWNER)
161
165#define DAOS_ACL_PERM_ALL (DAOS_ACL_PERM_POOL_ALL | \
166 DAOS_ACL_PERM_CONT_ALL)
167
198
207struct daos_acl *
208daos_acl_create(struct daos_ace *aces[], uint16_t num_aces);
209
218struct daos_acl *
220
226void
228
238ssize_t
240
251struct daos_ace *
252daos_acl_get_next_ace(struct daos_acl *acl, struct daos_ace *current_ace);
253
268int
270 enum daos_acl_principal_type type,
271 const char *principal, struct daos_ace **ace);
272
290int
291daos_acl_add_ace(struct daos_acl **acl, struct daos_ace *new_ace);
292
309int
311 enum daos_acl_principal_type type,
312 const char *principal_name);
313
320void
322
333int
335
350struct daos_ace *
351daos_ace_create(enum daos_acl_principal_type type, const char *principal_name);
352
358void
360
370ssize_t
372
379void
380daos_ace_dump(struct daos_ace *ace, uint32_t tabs);
381
390bool
392
406bool
408
422int
423daos_acl_uid_to_principal(uid_t uid, char **name);
424
438int
439daos_acl_gid_to_principal(gid_t gid, char **name);
440
453int
454daos_acl_principal_to_uid(const char *principal, uid_t *uid);
455
468int
469daos_acl_principal_to_gid(const char *principal, gid_t *gid);
470
479const char *
481
493int
494daos_ace_from_str(const char *str, struct daos_ace **ace);
495
510int
511daos_ace_to_str(struct daos_ace *ace, char *buf, size_t buf_len);
512
524int
525daos_ace_str_get_verbose(const char *ace_str, char *buf, size_t buf_len);
526
539int
540daos_acl_from_strs(const char **ace_strs, size_t ace_nr, struct daos_acl **acl);
541
557int
558daos_acl_to_strs(struct daos_acl *acl, char ***ace_strs, size_t *ace_nr);
559
580int
581daos_acl_principal_from_str(const char *principal_str,
582 enum daos_acl_principal_type *type,
583 char **name);
584
597int
598daos_acl_to_stream(FILE *stream, struct daos_acl *acl, bool verbose);
599
600#if defined(__cplusplus)
601}
602#endif
603#endif /* __DAOS_SECURITY_H__ */
int daos_acl_from_strs(const char **ace_strs, size_t ace_nr, struct daos_acl **acl)
daos_acl_flags
@ DAOS_ACL_FLAG_ACCESS_SUCCESS
@ DAOS_ACL_FLAG_POOL_INHERIT
@ DAOS_ACL_FLAG_GROUP
@ DAOS_ACL_FLAG_ACCESS_FAIL
struct daos_acl * daos_acl_create(struct daos_ace *aces[], uint16_t num_aces)
int daos_acl_principal_to_gid(const char *principal, gid_t *gid)
int daos_acl_principal_to_uid(const char *principal, uid_t *uid)
daos_acl_access_type
@ DAOS_ACL_ACCESS_AUDIT
@ DAOS_ACL_ACCESS_ALARM
int daos_ace_to_str(struct daos_ace *ace, char *buf, size_t buf_len)
ssize_t daos_acl_get_size(struct daos_acl *acl)
const char * daos_ace_get_principal_str(struct daos_ace *ace)
struct daos_ace * daos_ace_create(enum daos_acl_principal_type type, const char *principal_name)
void daos_acl_free(struct daos_acl *acl)
int daos_ace_str_get_verbose(const char *ace_str, char *buf, size_t buf_len)
int daos_acl_to_stream(FILE *stream, struct daos_acl *acl, bool verbose)
void daos_acl_dump(struct daos_acl *acl)
int daos_acl_add_ace(struct daos_acl **acl, struct daos_ace *new_ace)
int daos_acl_principal_from_str(const char *principal_str, enum daos_acl_principal_type *type, char **name)
ssize_t daos_ace_get_size(struct daos_ace *ace)
struct daos_ace * daos_acl_get_next_ace(struct daos_acl *acl, struct daos_ace *current_ace)
int daos_acl_get_ace_for_principal(struct daos_acl *acl, enum daos_acl_principal_type type, const char *principal, struct daos_ace **ace)
void daos_ace_dump(struct daos_ace *ace, uint32_t tabs)
bool daos_acl_principal_is_valid(const char *name)
daos_acl_perm
bool daos_ace_is_valid(struct daos_ace *ace)
int daos_acl_validate(struct daos_acl *acl)
int daos_acl_uid_to_principal(uid_t uid, char **name)
struct daos_acl * daos_acl_dup(struct daos_acl *acl)
int daos_acl_to_strs(struct daos_acl *acl, char ***ace_strs, size_t *ace_nr)
int daos_acl_gid_to_principal(gid_t gid, char **name)
daos_acl_principal_type
@ DAOS_ACL_EVERYONE
@ NUM_DAOS_ACL_TYPES
@ DAOS_ACL_GROUP
@ DAOS_ACL_USER
@ DAOS_ACL_OWNER_GROUP
int daos_acl_remove_ace(struct daos_acl **acl, enum daos_acl_principal_type type, const char *principal_name)
int daos_ace_from_str(const char *str, struct daos_ace **ace)
void daos_ace_free(struct daos_ace *ace)
uint16_t dae_access_flags
uint64_t dae_allow_perms
uint16_t dae_reserv
uint8_t dae_access_types
uint64_t dae_audit_perms
uint64_t dae_alarm_perms
char dae_principal[]
uint16_t dae_principal_len
uint8_t dae_principal_type
uint32_t dal_len
uint16_t dal_reserv
uint8_t dal_ace[]
uint16_t dal_ver