summaryrefslogtreecommitdiff
path: root/acl.h
blob: 00e5dc348dfdeb4573072608979fa4633c80230c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef _DBMAIL_ACL_H
#define _DBMAIL_ACL_H
/*
 Copyright (C) 2004 IC & S  dbmail@ic-s.nl

 This program is free software; you can redistribute it and/or 
 modify it under the terms of the GNU General Public License 
 as published by the Free Software Foundation; either 
 version 2 of the License, or (at your option) any later 
 version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/**
 * \file acl.h
 *
 * \brief header file for ACL (access control list) functions of DBMail.
 *        see RFC 2086 for details on IMAP ACL
 *
 * \author (c) 2004 IC&S
 */

/** 
 * different rights a user can have on a mailbox 
 */
typedef enum {
	ACL_RIGHT_LOOKUP,
	ACL_RIGHT_READ,
	ACL_RIGHT_SEEN,
	ACL_RIGHT_WRITE,
	ACL_RIGHT_INSERT,
	ACL_RIGHT_POST,
	ACL_RIGHT_CREATE,
	ACL_RIGHT_DELETE,
	ACL_RIGHT_ADMINISTER,
	ACL_RIGHT_NONE
} ACLRight_t;


#include "dbmailtypes.h"

/**
 * \brief checks if a user has a certain right to a mailbox 
 * \param userid id of user
 * \param mboxid id of mailbox
 * \param right the right to check for
 * \return 
 *     - -1 on db error
 *     -  0 if no right
 *     -  1 if user has this right
 */
int acl_has_right(u64_t userid, u64_t mboxid, ACLRight_t right);

/**
 * \brief sets new rights to a mailbox for a user.
 * \param userid id of user
 * \param mboxid id of mailbox
 * \param rightsstring string of righs
 * \return 
 *     - -1 on error
 *     -  1 on success
 */
int acl_set_rights(u64_t userid, u64_t mboxid, const char *rightsstring);

/**
 * \brief delete identifier, rights pair for selected user for mailbox
 * \param userid id of user
 * \param mboxid id of mailbox
 * \return 
 *      - -1 on error
 *      -  0 if nothing removed (i.e. no acl was found)
 *      -  1 if acl removed
 */
int acl_delete_acl(u64_t userid, u64_t mboxid);

/**
 * \brief get complete acl for a mailbox
 * \param mboxid id of mailbox
 * \return
 *     - NULL on error
 *     - acl string (list of identifier-rights pairs, might by empty)
 * \note string should be freed by caller
 */
/*@null@*/ char *acl_get_acl(u64_t mboxid);

/**
 * \brief list rights that may be granted to a user on a mailbox
 * \param userid id of user
 * \param mboxid id of mailbox
 * \return
 *     - NULL on error
 *     - string of rights otherwise (SEE RFC for details)
 * \note string should be freed by caller
 */
/*@null@*/ /*@only@*/ char *acl_listrights(u64_t userid, u64_t mboxid);

/**
 * \brief list rights that a user has on a mailbox
 * \param userid id of user
 * \param mboxid id of mailbox
 * \return
 *     - NULL on error
 *     - string of rights otherwise (SEE RFC)
 * \note string should be freed by caller
 */
/*@null@*/ char *acl_myrights(u64_t userid, u64_t mboxid);

#endif