Lines Matching refs:file

1 /* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
10 #include "acl-global-file.h"
40 struct acl_global_file *file;
42 file = i_new(struct acl_global_file, 1);
43 file->path = i_strdup(path);
44 file->refresh_interval_secs = refresh_interval_secs;
45 file->debug = debug;
46 i_array_init(&file->rights, 32);
47 file->rights_pool = pool_alloconly_create("acl global file rights", 1024);
48 return file;
53 struct acl_global_file *file = *_file;
57 array_free(&file->rights);
58 pool_unref(&file->rights_pool);
59 i_free(file->path);
60 i_free(file);
70 struct acl_global_file *file;
107 pright->vpattern = p_strdup(ctx->file->rights_pool, vpattern);
108 if (acl_rights_parse_line(line, ctx->file->rights_pool,
115 static int acl_global_file_read(struct acl_global_file *file)
125 array_clear(&file->rights);
126 p_clear(file->rights_pool);
129 ctx.file = file;
132 input = i_stream_create_file(file->path, (size_t)-1);
140 i_error("Global ACL file %s line %u: %s",
141 file->path, linenum, error);
148 i_error("Couldn't read global ACL file %s: %s",
149 file->path, i_stream_get_error(input));
156 i_error("Couldn't stat global ACL file %s: %s",
157 file->path, i_stream_get_error(input));
160 file->prev_st = *st;
172 right = array_append_space(&file->rights);
174 p_array_init(&right->rights, file->rights_pool, 4);
183 int acl_global_file_refresh(struct acl_global_file *file)
187 if (file->last_refresh_time + (time_t)file->refresh_interval_secs > ioloop_time)
189 if (file->last_refresh_time != 0) {
190 if (stat(file->path, &st) < 0) {
191 i_error("stat(%s) failed: %m", file->path);
194 if (st.st_ino == file->prev_st.st_ino &&
195 st.st_size == file->prev_st.st_size &&
196 CMP_ST_MTIME(&st, &file->prev_st)) {
197 /* no change to the file */
198 file->last_refresh_time = ioloop_time;
202 if (acl_global_file_read(file) < 0)
204 file->last_refresh_time = ioloop_time;
208 void acl_global_file_last_stat(struct acl_global_file *file, struct stat *st_r)
210 *st_r = file->prev_st;
213 void acl_global_file_get(struct acl_global_file *file, const char *vname,
220 array_foreach_modifiable(&file->rights, global_rights) {
223 if (file->debug) {
234 bool acl_global_file_have_any(struct acl_global_file *file, const char *vname)
238 i_assert(file->last_refresh_time != 0);
240 array_foreach_modifiable(&file->rights, rights) {