1 /* 2 Copyright (C) 2004 IC & S dbmail@ic-s.nl 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later 8 version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 /** 21 * \file acl.h 22 * 23 * \brief header file for ACL (access control list) functions of DBMail. 24 * see RFC 2086 for details on IMAP ACL 25 * 26 * \author (c) 2004 IC&S 27 */ 28 29 /** 30 * different rights a user can have on a mailbox 31 */ 32 33 #ifndef DM_ACL_H 34 #define DM_ACL_H 35 36 #include "dbmailtypes.h" 37 #include "dm_mailboxstate.h" 38 39 /** 40 * \brief sets new rights to a mailbox for a user. 41 * \param userid id of user 42 * \param mboxid id of mailbox 43 * \param rightsstring string of righs 44 * \return 45 * - -1 on error 46 * - 1 on success 47 */ 48 int acl_set_rights(uint64_t userid, uint64_t mboxid, const char *rightsstring); 49 50 /** 51 * \brief delete identifier, rights pair for selected user for mailbox 52 * \param userid id of user 53 * \param mboxid id of mailbox 54 * \return 55 * - -1 on error 56 * - 0 if nothing removed (i.e. no acl was found) 57 * - 1 if acl removed 58 */ 59 //int acl_delete_acl(uint64_t userid, uint64_t mboxid); 60 #define acl_delete_acl(a,b) db_acl_delete_acl((a),(b)) 61 62 /** 63 * \brief checks if a user has a certain right to a mailbox 64 * \param userid id of user 65 * \param mboxid id of mailbox 66 * \param right the right to check for 67 * \return 68 * - -1 on db error 69 * - 0 if no right 70 * - 1 if user has this right 71 */ 72 int acl_has_right(MailboxState_T S, uint64_t userid, ACLRight right); 73 74 /** 75 * \brief get complete acl for a mailbox 76 * \param mboxid id of mailbox 77 * \return 78 * - NULL on error 79 * - acl string (list of identifier-rights pairs, might by empty) 80 * \note string should be freed by caller 81 */ 82 char *acl_get_acl(uint64_t mboxid); 83 84 /** 85 * \brief list rights that may be granted to a user on a mailbox 86 * \param userid id of user 87 * \param mboxid id of mailbox 88 * \return 89 * - NULL on error 90 * - string of rights otherwise (SEE RFC for details) 91 * \note string should be freed by caller 92 */ 93 const char *acl_listrights(uint64_t userid, uint64_t mboxid); 94 95 /** 96 * \brief list rights that a user has on a mailbox 97 * \param userid id of user 98 * \param mboxid id of mailbox 99 * \return 100 * - NULL on error 101 * - string of rights otherwise (SEE RFC) 102 * \note string should be freed by caller 103 */ 104 /*@null@*/ char *acl_myrights(uint64_t userid, uint64_t mboxid); 105 106 #endif 107