/* ARISA - user privileges defines */ /* Copyright (C) 2003, 2004 Carl Ritson */ #define _ARISA_USER_H /* all the user privileges */ enum { PRIV_PACK_ADD = 0, PRIV_PACK_DEL = 1, PRIV_PACK_MOD = 2, // change labels, bandwidth limits PRIV_SEND_ADD = 3, // this includes queue'ing (force send) PRIV_SEND_DEL = 4, PRIV_SEND_MOD = 5, // shuffling queues and such PRIV_PACKLIST_SEND = 6, // send xdcc list / plists PRIV_PACKLIST_SCAN = 7, PRIV_PACKLIST_MOD = 8, // modify settings of packlists, not packs PRIV_ALL_PACKLISTS = 9, // privileges apply to all packlists PRIV_PACKLISTS = 10, // can create not just access packlists PRIV_QUEUES = 11, PRIV_POOLS = 12, PRIV_INTERFACES = 13, PRIV_FILES = 14, PRIV_FILE_MOVE = 16, PRIV_FILE_DEL = 17, PRIV_DIR_ADD = 18, PRIV_DIR_DEL = 19, PRIV_SELF_MOD = 20, // can change own password and hosts PRIV_USERS = 21, // user modification functions PRIV_UPLOAD = 22, PRIV_DOWNLOAD = 23, PRIV_LOG = 24, // can view,listen and add to log PRIV_PARTY_LINE = 25, // can listen and send to party line PRIV_MESSAGE = 26, // can send messages to IRC PRIV_NETWORKS = 27, // add,del,mod networks and defaults PRIV_SETTINGS = 28, PRIV_SHUTDOWN = 29, PRIV_SOCKET = 30, // can access via admin socket PRIV_MAX = 31 }; /* size of the character buffer for priviledges */ #define USER_PRIVS_SIZE (sizeof(char)*12) /* macros to manipulate the privileges */ #define PRIVS_EMPTY (0) #define PRIVS_FULL (~0) #define PRIV_TO_MASK(x) (1 << ((uint32_t)x)) #define PRIV_M_ISSET(u,m) (((u) & (m)) == (m)) #define PRIV_U_ISSET(u,p) PRIV_M_ISSET(u,PRIV_TO_MASK(p)) #define PRIV_ISSET(u,p) PRIV_U_ISSET((u)->uprivs,p) static inline void user_set_privs(user_t *u, uint32_t privs) { u->uprivs = privs; if(u->privs == NULL) u->privs = xalloc(USER_PRIVS_SIZE); snprintf(u->privs,USER_PRIVS_SIZE,"%08lx",(unsigned long)htonl(privs)); } static inline void user_reload_privs(user_t *u) { if(u->privs != NULL) u->uprivs = ntohl(strtoul(u->privs,NULL,16)); else u->uprivs = PRIVS_EMPTY; } #define PRIV_SET(u,p) \ do { user_set_privs((u),(u)->uprivs | PRIV_TO_MASK(p)); } while(0) #define PRIV_UNSET(u,p) \ do { user_set_privs((u),(u)->uprivs & ~PRIV_TO_MASK(p)); } while(0) typedef struct { int priv; char *text; } priv_text_t; extern priv_text_t priv_text[];