#ifndef WS_ACL_H
#define WS_ACL_H
#include "nsapi.h"
#include "auth.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ACLListElm ACLListElm;
typedef struct ACLList ACLList;
typedef struct WSAcl WSAcl;
typedef struct WSAce WSAce;
struct ACLListHandle {
AuthDB *defaultauthdb;
ACLListElm *listhead;
ACLListElm *listtail;
};
struct ACLListElm {
ACLList *acl;
ACLListElm *next;
};
typedef int(*acl_check_f)(ACLList*, User*,
int);
struct ACLList {
AuthDB *authdb;
char *authprompt;
int isextern;
int(*check)(ACLList *acl, User *user,
int access_mask);
};
struct WSAcl {
ACLList acl;
WSAce **ace;
WSAce **ece;
int acenum;
int ecenum;
};
struct WSAce {
char *who;
uint32_t access_mask;
uint16_t flags;
uint16_t type;
};
#define ACL_READ_DATA 0x0001
#define ACL_WRITE_DATA 0x0002
#define ACL_APPEND 0x0002
#define ACL_ADD_FILE 0x0004
#define ACL_ADD_SUBDIRECTORY 0x0004
#define ACL_READ_XATTR 0x0008
#define ACL_WRITE_XATTR 0x0010
#define ACL_EXECUTE 0x0020
#define ACL_DELETE_CHILD 0x0040
#define ACL_DELETE 0x0040
#define ACL_READ_ATTRIBUTES 0x0080
#define ACL_WRITE_ATTRIBUTES 0x0100
#define ACL_LIST 0x0200
#define ACL_READ_ACL 0x0400
#define ACL_WRITE_ACL 0x0800
#define ACL_WRITE_OWNER 0x1000
#define ACL_SYNCHRONIZE 0x2000
#define ACL_READ \
(
ACL_READ_DATA|
ACL_READ_XATTR|
ACL_READ_ATTRIBUTES)
#define ACL_WRITE \
(
ACL_WRITE_DATA|
ACL_WRITE_XATTR|
ACL_WRITE_ATTRIBUTES)
#define ACL_FILE_INHERIT 0x0001
#define ACL_DIR_INHERIT 0x0002
#define ACL_NO_PROPAGATE 0x0004
#define ACL_INHERIT_ONLY 0x0008
#define ACL_SUCCESSFUL_ACCESS_FLAG 0x0010
#define ACL_FAILED_ACCESS_ACE_FLAG 0x0020
#define ACL_IDENTIFIER_GROUP 0x0040
#define ACL_OWNER 0x1000
#define ACL_GROUP 0x2000
#define ACL_EVERYONE 0x4000
#define ACL_TYPE_ALLOWED 0x01
#define ACL_TYPE_DENIED 0x02
#define ACL_TYPE_AUDIT 0x03
#define ACL_TYPE_ALARM 0x04
void acllist_append(Session *sn, Request *rq, ACLList *acl);
void acllist_prepend(Session *sn, Request *rq, ACLList *acl);
uint32_t acl_oflag2mask(
int oflags);
User* acllist_getuser(Session *sn, Request *rq, ACLListHandle *list);
void acl_set_error_status(Session *sn, Request *rq, ACLList *acl, User *user);
int acl_evaluate(Session *sn, Request *rq,
int access_mask);
ACLList* acl_evallist(
ACLListHandle *acllist,
User *user,
int access_mask,
ACLList **externacl);
#ifdef __cplusplus
}
#endif
#endif