[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c,1.34,1.35
cras at procontrol.fi
cras at procontrol.fi
Sat Feb 8 15:13:15 EET 2003
Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory danu:/tmp/cvs-serv14273/lib-storage/index/mbox
Modified Files:
mbox-storage.c
Log Message:
Autodetect /var/mail/%u and /var/spool/mail/%u INBOXes.
Index: mbox-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- mbox-storage.c 22 Jan 2003 19:23:28 -0000 1.34
+++ mbox-storage.c 8 Feb 2003 13:13:12 -0000 1.35
@@ -98,6 +98,26 @@
return NULL;
}
+static const char *get_inbox_file(const char *root_dir, int only_root)
+{
+ const char *user, *path;
+
+ if (!only_root) {
+ user = getenv("USER");
+ if (user != NULL) {
+ path = t_strconcat("/var/mail/", user, NULL);
+ if (access(path, R_OK|W_OK) == 0)
+ return path;
+
+ path = t_strconcat("/var/spool/mail/", user, NULL);
+ if (access(path, R_OK|W_OK) == 0)
+ return path;
+ }
+ }
+
+ return t_strconcat(root_dir, "/inbox", NULL);
+}
+
static const char *create_root_dir(void)
{
const char *home, *path;
@@ -123,10 +143,12 @@
struct mail_storage *storage;
const char *root_dir, *inbox_file, *index_dir, *p;
struct stat st;
+ int autodetect;
root_dir = inbox_file = index_dir = NULL;
- if (data == NULL || *data == '\0') {
+ autodetect = data == NULL || *data == '\0';
+ if (autodetect) {
/* we'll need to figure out the mail location ourself.
it's root dir if we've already chroot()ed, otherwise
either $HOME/mail or $HOME/Mail */
@@ -167,7 +189,7 @@
}
if (inbox_file == NULL)
- inbox_file = t_strconcat(root_dir, "/inbox", NULL);
+ inbox_file = get_inbox_file(root_dir, !autodetect);
if (index_dir == NULL)
index_dir = root_dir;
More information about the dovecot-cvs
mailing list