c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef ACL_BACKEND_VFILE_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define ACL_BACKEND_VFILE_H
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "acl-api-private.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#define ACL_FILENAME "dovecot-acl"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#define ACLLIST_FILENAME "dovecot-acl-list"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
71966291d5f91a87394ad2e321250e1d02670a84Timo Sirainen#define ACL_VFILE_VALIDITY_MTIME_NOTFOUND 0
71966291d5f91a87394ad2e321250e1d02670a84Timo Sirainen#define ACL_VFILE_VALIDITY_MTIME_NOACCESS -1
cc287b822b175619a853686b738ba673e370117bTimo Sirainen
cc287b822b175619a853686b738ba673e370117bTimo Sirainenstruct acl_vfile_validity {
cc287b822b175619a853686b738ba673e370117bTimo Sirainen time_t last_check;
cc287b822b175619a853686b738ba673e370117bTimo Sirainen
cc287b822b175619a853686b738ba673e370117bTimo Sirainen time_t last_read_time;
cc287b822b175619a853686b738ba673e370117bTimo Sirainen time_t last_mtime;
cc287b822b175619a853686b738ba673e370117bTimo Sirainen off_t last_size;
cc287b822b175619a853686b738ba673e370117bTimo Sirainen};
cc287b822b175619a853686b738ba673e370117bTimo Sirainen
cc287b822b175619a853686b738ba673e370117bTimo Sirainenstruct acl_backend_vfile_validity {
cc287b822b175619a853686b738ba673e370117bTimo Sirainen struct acl_vfile_validity global_validity, local_validity;
cc287b822b175619a853686b738ba673e370117bTimo Sirainen struct acl_vfile_validity mailbox_validity;
cc287b822b175619a853686b738ba673e370117bTimo Sirainen};
cc287b822b175619a853686b738ba673e370117bTimo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstruct acl_object_vfile {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_object aclobj;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
4c158400b046fefefce0194603951a6587f51867Timo Sirainen /* if backend->global_file is NULL, assume legacy separate global
4c158400b046fefefce0194603951a6587f51867Timo Sirainen ACL file per mailbox */
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen char *global_path, *local_path;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen};
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstruct acl_backend_vfile_acllist {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen time_t mtime;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const char *name;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen};
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstruct acl_backend_vfile {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_backend backend;
4c158400b046fefefce0194603951a6587f51867Timo Sirainen const char *global_path;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen pool_t acllist_pool;
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen ARRAY(struct acl_backend_vfile_acllist) acllist;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen time_t acllist_last_check;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen time_t acllist_mtime;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen unsigned int acllist_change_counter;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen unsigned int cache_secs;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool rebuilding_acllist:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool iterating_acllist:1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen};
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
cc287b822b175619a853686b738ba673e370117bTimo Sirainenvoid acl_vfile_write_rights_list(string_t *dest, const char *const *rights);
cc287b822b175619a853686b738ba673e370117bTimo Sirainenint acl_backend_vfile_object_update(struct acl_object *aclobj,
cc287b822b175619a853686b738ba673e370117bTimo Sirainen const struct acl_rights_update *update);
cc287b822b175619a853686b738ba673e370117bTimo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenvoid acl_backend_vfile_acllist_refresh(struct acl_backend_vfile *backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenint acl_backend_vfile_acllist_rebuild(struct acl_backend_vfile *backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenvoid acl_backend_vfile_acllist_verify(struct acl_backend_vfile *backend,
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const char *name, time_t mtime);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstruct acl_mailbox_list_context *
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacl_backend_vfile_nonowner_iter_init(struct acl_backend *backend);
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomibool acl_backend_vfile_nonowner_iter_next(struct acl_mailbox_list_context *ctx,
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const char **name_r);
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomiint
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacl_backend_vfile_nonowner_iter_deinit(struct acl_mailbox_list_context *ctx);
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainenint acl_backend_vfile_nonowner_lookups_rebuild(struct acl_backend *backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenint acl_backend_vfile_object_get_mtime(struct acl_object *aclobj,
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen time_t *mtime_r);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#endif