DAOS API (v2.1 - dev)
Loading...
Searching...
No Matches
daos_security.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2019-2023 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#include <daos_prop.h>
25
29#define DAOS_ACL_VERSION (1)
30
35#define DAOS_ACL_MAX_PRINCIPAL_LEN (255)
37#define DAOS_ACL_MAX_PRINCIPAL_BUF_LEN (DAOS_ACL_MAX_PRINCIPAL_LEN + 1)
38
40#define DAOS_ACL_PRINCIPAL_OWNER "OWNER@"
42#define DAOS_ACL_PRINCIPAL_OWNER_GRP "GROUP@"
44#define DAOS_ACL_PRINCIPAL_EVERYONE "EVERYONE@"
45
49#define DAOS_ACL_MAX_ACE_LEN (65536)
50
55#define DAOS_ACL_MAX_ACE_STR_LEN (DAOS_ACL_MAX_PRINCIPAL_LEN + 64)
56
63struct daos_acl {
65 uint16_t dal_ver;
67 uint16_t dal_reserv;
69 uint32_t dal_len;
71 uint8_t dal_ace[];
72};
73
88
93 DAOS_ACL_ACCESS_ALLOW = (1U << 0),
95 DAOS_ACL_ACCESS_ALARM = (1U << 2)
96};
97
101#define DAOS_ACL_ACCESS_ALL (DAOS_ACL_ACCESS_ALLOW | \
102 DAOS_ACL_ACCESS_AUDIT | \
103 DAOS_ACL_ACCESS_ALARM)
104
118
122#define DAOS_ACL_FLAG_ALL (DAOS_ACL_FLAG_GROUP | \
123 DAOS_ACL_FLAG_POOL_INHERIT | \
124 DAOS_ACL_FLAG_ACCESS_FAIL | \
125 DAOS_ACL_FLAG_ACCESS_SUCCESS)
126
131 DAOS_ACL_PERM_READ = (1U << 0),
132 DAOS_ACL_PERM_WRITE = (1U << 1),
133 DAOS_ACL_PERM_CREATE_CONT = (1U << 2),
134 DAOS_ACL_PERM_DEL_CONT = (1U << 3),
135 DAOS_ACL_PERM_GET_PROP = (1U << 4),
136 DAOS_ACL_PERM_SET_PROP = (1U << 5),
137 DAOS_ACL_PERM_GET_ACL = (1U << 6),
138 DAOS_ACL_PERM_SET_ACL = (1U << 7),
139 DAOS_ACL_PERM_SET_OWNER = (1U << 8),
140};
141
145#define DAOS_ACL_PERM_POOL_ALL (DAOS_ACL_PERM_READ | \
146 DAOS_ACL_PERM_GET_PROP | \
147 DAOS_ACL_PERM_WRITE | \
148 DAOS_ACL_PERM_CREATE_CONT | \
149 DAOS_ACL_PERM_DEL_CONT)
150
154#define DAOS_ACL_PERM_CONT_ALL (DAOS_ACL_PERM_READ | \
155 DAOS_ACL_PERM_WRITE | \
156 DAOS_ACL_PERM_DEL_CONT | \
157 DAOS_ACL_PERM_GET_PROP | \
158 DAOS_ACL_PERM_SET_PROP | \
159 DAOS_ACL_PERM_GET_ACL | \
160 DAOS_ACL_PERM_SET_ACL | \
161 DAOS_ACL_PERM_SET_OWNER)
162
166#define DAOS_ACL_PERM_ALL (DAOS_ACL_PERM_POOL_ALL | \
167 DAOS_ACL_PERM_CONT_ALL)
168
199
208struct daos_acl *
209daos_acl_create(struct daos_ace *aces[], uint16_t num_aces);
210
219struct daos_acl *
221
227void
229
239ssize_t
241
252struct daos_ace *
253daos_acl_get_next_ace(struct daos_acl *acl, struct daos_ace *current_ace);
254
269int
271 enum daos_acl_principal_type type,
272 const char *principal, struct daos_ace **ace);
273
291int
292daos_acl_add_ace(struct daos_acl **acl, struct daos_ace *new_ace);
293
310int
312 enum daos_acl_principal_type type,
313 const char *principal_name);
314
321void
323
334int
336
351struct daos_ace *
352daos_ace_create(enum daos_acl_principal_type type, const char *principal_name);
353
359void
361
371ssize_t
373
380void
381daos_ace_dump(struct daos_ace *ace, uint32_t tabs);
382
391bool
393
407bool
409
423int
424daos_acl_uid_to_principal(uid_t uid, char **name);
425
439int
440daos_acl_gid_to_principal(gid_t gid, char **name);
441
454int
455daos_acl_principal_to_uid(const char *principal, uid_t *uid);
456
469int
470daos_acl_principal_to_gid(const char *principal, gid_t *gid);
471
480const char *
482
494int
495daos_ace_from_str(const char *str, struct daos_ace **ace);
496
511int
512daos_ace_to_str(struct daos_ace *ace, char *buf, size_t buf_len);
513
525int
526daos_ace_str_get_verbose(const char *ace_str, char *buf, size_t buf_len);
527
540int
541daos_acl_from_strs(const char **ace_strs, size_t ace_nr, struct daos_acl **acl);
542
558int
559daos_acl_to_strs(struct daos_acl *acl, char ***ace_strs, size_t *ace_nr);
560
581int
582daos_acl_principal_from_str(const char *principal_str,
583 enum daos_acl_principal_type *type,
584 char **name);
585
598int
599daos_acl_to_stream(FILE *stream, struct daos_acl *acl, bool verbose);
600
601#if defined(__cplusplus)
602}
603#endif
604#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