subscription-file.c revision a8c5a86d183db25a57bf193c06b41e092ec2e151
/* Copyright (c) 2002-2014 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream.h"
#include "ostream.h"
#include "nfs-workarounds.h"
#include "mkdir-parents.h"
#include "file-dotlock.h"
#include "mailbox-list-private.h"
#include "subscription-file.h"
#include <unistd.h>
#include <fcntl.h>
#define SUBSCRIPTION_FILE_LOCK_TIMEOUT 120
#define SUBSCRIPTION_FILE_CHANGE_TIMEOUT 30
struct subsfile_list_context {
struct mailbox_list *list;
char *path;
bool failed;
};
{
"No permission to read subscriptions");
} else {
"%s failed with subscription file %s: %m",
}
}
{
"No permission to modify subscriptions");
} else {
"%s failed with subscription file %s: %m",
}
}
bool ignore_estale)
{
const char *line;
switch (i_stream_read(input)) {
case -1:
if (input->stream_errno != 0 &&
"read()", path);
}
return NULL;
case -2:
/* mailbox name too large */
"Subscription file %s contains lines longer "
"than %u characters", path,
(unsigned int)list->mailbox_name_max_length);
return NULL;
}
}
return line;
}
{
struct dotlock_settings dotlock_set;
struct mailbox_permissions perm;
enum mailbox_list_path_type type;
name = "INBOX";
/* directory hasn't been created yet. */
return -1;
}
&dotlock);
}
if (fd_out == -1) {
"Timeout waiting for subscription file lock");
} else {
path);
}
return -1;
}
return -1;
}
if (fd_in != -1) {
TRUE);
if (!set) {
continue;
}
}
}
}
/* append subscription */
}
if (o_stream_nfinish(output) < 0) {
path);
}
}
} else {
}
if (file_dotlock_delete(&dotlock) < 0) {
"file_dotlock_delete()", path);
}
} else {
enum dotlock_replace_flags flags =
"file_dotlock_replace()", path);
}
}
}
struct subsfile_list_context *
{
struct subsfile_list_context *ctx;
int fd;
if (fd == -1) {
}
} else {
}
return ctx;
}
{
return ret;
}
{
return -1;
return -1;
}
return 0;
}
{
const char *line;
unsigned int i;
int fd;
return NULL;
for (i = 0;; i++) {
break;
/* Reopen the subscription file and re-send everything.
this isn't the optimal behavior, but it's allowed by
IMAP and this way we don't have to read everything into
memory or try to play any guessing games. */
if (fd == -1) {
/* In case of ENOENT all the subscriptions got lost.
Just return end of subscriptions list in that
case. */
}
return NULL;
}
TRUE);
}
return line;
}