Projects
Kolab:3.4
cyrus-imapd
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 102
View file
cyrus-imapd.spec
Changed
@@ -38,13 +38,13 @@ Name: cyrus-imapd Summary: A high-performance mail server with IMAP, POP3, NNTP and SIEVE support Version: 2.5 -Release: 0.1.dev20141010.gitaf61c13a%{?dist} +Release: 0.1.dev20141017.git9704e5d4%{?dist} License: BSD Group: System Environment/Daemons URL: http://www.cyrusimap.org # Upstream sources -# From af61c13a4259959ef7a09e1d8d6f4743c011b7e9 +# From 9704e5d41981a18f46a63af78cf02c63fe3824a6 Source0: ftp://ftp.andrew.cmu.edu/pub/cyrus/%{_name}-%{real_version}%{?dot_snapshot_version}.tar.gz Source1: cyrus-imapd.imap-2.3.x-conf Source2: cyrus-imapd.cvt_cyrusdb_all
View file
cyrus-imapd-2.5.tar.gz/Makefile.am
Changed
@@ -54,17 +54,37 @@ BUILT_SOURCES = xversion.h \ imap/imap_err.c \ lib/imapopts.c -DISTCLEANFILES = imap/imap_err.c imap/imap_err.h imap/mupdate_err.c imap/mupdate_err.h imap/nntp_err.c imap/nntp_err.h \ +DISTCLEANFILES = imap/imap_err.c \ + imap/imap_err.h \ + imap/mupdate_err.c \ + imap/mupdate_err.h \ + imap/nntp_err.c \ + imap/nntp_err.h \ com_err/et/compile_et \ - perl/annotator/Makefile perl/annotator/Makefile.PL perl/imap/Makefile perl/imap/Makefile.PL perl/sieve/managesieve/Makefile perl/sieve/managesieve/Makefile.PL perl/sieve/scripts/installsieve perl/sieve/scripts/sieveshell \ - sieve/sieve_err.c sieve/sieve_err.h + perl/annotator/Makefile \ + perl/annotator/Makefile.PL \ + perl/imap/Makefile \ + perl/imap/Makefile.PL \ + perl/sieve/managesieve/Makefile \ + perl/sieve/managesieve/Makefile.PL \ + perl/sieve/scripts/installsieve \ + perl/sieve/scripts/sieveshell \ + sieve/sieve_err.c \ + sieve/sieve_err.h MAINTAINERCLEANFILES = \ - doc/murder.png doc/netnews.png \ - doc/man/cyradm.1.html man/imapd.conf.5 man/sieveshell.1 doc/man/sieveshell.1.html \ - imap/lmtpstats.h imap/pushstats.h \ - lib/chartable.c lib/imapopts.h \ - sieve/addr.h sieve/sieve.h + doc/murder.png \ + doc/netnews.png \ + doc/man/cyradm.1.html \ + man/imapd.conf.5 \ + man/sieveshell.1 \ + doc/man/sieveshell.1.html \ + imap/lmtpstats.h \ + imap/pushstats.h \ + lib/chartable.c \ + lib/imapopts.h \ + sieve/addr.h \ + sieve/sieve.h SUBDIRS = . DIST_SUBDIRS = . @@ -391,7 +411,6 @@ com_err/et/config_script \ imap/lmtpstats.snmp \ imap/pushstats.snmp \ - lib/imapoptions \ lib/mkchartable.pl \ lib/test/run \ perl/sieve/scripts/installsieve.pl \ @@ -689,9 +708,14 @@ imap/pushstats.h \ imap/proxy.c \ imap/proxy.h \ - master/service.c \ + master/service.c + +if AUTOCREATE +imap_imapd_SOURCES += \ imap/autocreate.h \ imap/autocreate.c +endif + imap_imapd_LDADD = if SIEVE imap_imapd_LDADD += sieve/libcyrus_sieve.la @@ -748,6 +772,8 @@ imap/mutex.h \ imap/notify.c \ imap/notify.h \ + imap/partlist.c \ + imap/partlist.h \ imap/proc.c \ imap/proc.h \ imap/protocol.h \ @@ -776,6 +802,8 @@ imap/telemetry.h \ imap/tls.c \ imap/tls.h \ + imap/tls_th-lock.c \ + imap/tls_th-lock.h \ imap/upgrade_index.c \ imap/upgrade_index.h \ imap/user.c \ @@ -792,8 +820,6 @@ endif imap_lmtpd_SOURCES = \ - imap/autocreate.c \ - imap/autocreate.h \ imap/lmtpd.c \ imap/lmtpd.h \ imap/lmtpengine.c \ @@ -804,6 +830,13 @@ imap/proxy.c \ imap/spool.c \ master/service.c + +if AUTOCREATE +imap_lmtpd_SOURCES += \ + imap/autocreate.c \ + imap/autocreate.h +endif + imap_lmtpd_LDADD = if SIEVE imap_lmtpd_SOURCES += imap/lmtp_sieve.c imap/lmtp_sieve.h imap/smtpclient.c @@ -831,6 +864,7 @@ imap/mupdate.h \ imap/mupdate-slave.c \ imap/mutex_pthread.c \ + imap/tls_th-lock.c \ master/service-thread.c imap_mupdate_LDADD = $(LD_SERVER_ADD) -lpthread @@ -849,12 +883,17 @@ imap_nntpd_LDADD = $(LD_SERVER_ADD) imap_pop3d_SOURCES = \ - imap/autocreate.c \ - imap/autocreate.h \ imap/mutex_fake.c \ imap/pop3d.c \ imap/proxy.c \ master/service.c + +if AUTOCREATE +imap_pop3d_SOURCES += \ + imap/autocreate.c \ + imap/autocreate.h +endif + imap_pop3d_LDADD = if SIEVE imap_pop3d_LDADD += sieve/libcyrus_sieve.la
View file
cyrus-imapd-2.5.tar.gz/configure.ac
Changed
@@ -1076,6 +1076,12 @@ AC_DEFINE_UNQUOTED(MASTER_PIDFILE, $MASTERPIDFILE,[Name of the pidfile for master]) dnl +dnl see if we're compiling with autocreate support +dnl +AC_ARG_ENABLE(autocreate, + [AS_HELP_STRING([--enable-autocreate], [enable autocreate support])],,[enable_autocreate="no";]) +AM_CONDITIONAL([AUTOCREATE], [test "$enable_autocreate" != "no"]) +dnl dnl see if we're compiling with IMAP idled support dnl AC_ARG_ENABLE(idled, @@ -1623,6 +1629,7 @@ event notification: $enable_event_notification gssapi: $gssapi + autocreate: $enable_autocreate idled: $enable_idled kerberos V4: $krb4 murder: $enable_murder
View file
cyrus-imapd-2.5.tar.gz/doc/install-configure.html
Changed
@@ -508,15 +508,15 @@ <li>Add the following to <tt>/etc/imapd.conf</tt> to tell the server where to find the certificate and key files (used for ALL services): -<pre>tls_cert_file: /var/imap/server.pem -tls_key_file: /var/imap/server.pem +<pre>server_cert_file: /var/imap/server.cert +server_key_file: /var/imap/server.key </pre> Optionally, you can use separate certificates and key files for each service: -<pre>[servicename]_tls_cert_file: /var/imap/imap-server.pem -[servicename]_tls_key_file: /var/imap/imap-server.pem +<pre>[servicename]_server_cert_file: /var/imap/imap-server.cert +[servicename]_server_key_file: /var/imap/imap-server.key </pre> "servicename" here refers to the name of the service as specified
View file
cyrus-imapd-2.5.tar.gz/imap/annotate.c
Changed
@@ -49,6 +49,11 @@ #include <unistd.h> #endif #include <errno.h> +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#elif defined(HAVE_STDINT_H) +# include <stdint.h> +#endif #include <sys/types.h> #include <sys/stat.h> #include <sys/uio.h> @@ -67,6 +72,7 @@ #include "times.h" #include "imap/imap_err.h" #include "mboxlist.h" +#include "partlist.h" #include "util.h" #include "xmalloc.h" #include "ptrarray.h" @@ -1424,11 +1430,37 @@ static void annotation_get_freespace(annotate_state_t *state, struct annotate_entry_list *entry) { - unsigned long tavail; + uint64_t tavail = 0; + struct buf value = BUF_INITIALIZER; + + (void) partlist_local_find_freespace_most(0, NULL, NULL, &tavail, NULL); + buf_printf(&value, "%" PRIuMAX, (uintmax_t)tavail); + output_entryatt(state, entry->name, "", &value); + buf_free(&value); +} + +static void annotation_get_freespace_total(annotate_state_t *state, + struct annotate_entry_list *entry) +{ + uint64_t tavail = 0; + uint64_t ttotal = 0; struct buf value = BUF_INITIALIZER; - (void) find_free_partition(&tavail); - buf_printf(&value, "%lu", tavail); + (void) partlist_local_find_freespace_most(0, NULL, NULL, &tavail, &ttotal); + buf_printf(&value, "%" PRIuMAX ";%" PRIuMAX, (uintmax_t)tavail, (uintmax_t)ttotal); + output_entryatt(state, entry->name, "", &value); + buf_free(&value); +} + +static void annotation_get_freespace_percent_most(annotate_state_t *state, + struct annotate_entry_list *entry) +{ + uint64_t avail = 0; + uint64_t total = 0; + struct buf value = BUF_INITIALIZER; + + (void) partlist_local_find_freespace_most(1, &avail, &total, NULL, NULL); + buf_printf(&value, "%" PRIuMAX ";%" PRIuMAX, (uintmax_t)avail, (uintmax_t)total); output_entryatt(state, entry->name, "", &value); buf_free(&value); } @@ -1961,6 +1993,24 @@ /*set*/NULL, NULL },{ + "/vendor/cmu/cyrus-imapd/freespace/total", + ATTRIB_TYPE_STRING, + BACKEND_ONLY, + ATTRIB_VALUE_SHARED, + 0, + annotation_get_freespace_total, + /*set*/NULL, + NULL + },{ + "/vendor/cmu/cyrus-imapd/freespace/percent/most", + ATTRIB_TYPE_STRING, + BACKEND_ONLY, + ATTRIB_VALUE_SHARED, + 0, + annotation_get_freespace_percent_most, + /*set*/NULL, + NULL + },{ "/vendor/cmu/cyrus-imapd/shutdown", ATTRIB_TYPE_STRING, PROXY_AND_BACKEND,
View file
cyrus-imapd-2.5.tar.gz/imap/autocreate.c
Changed
@@ -145,7 +145,7 @@ } /* Check if autocreate_sieve_compiledscript is defined in imapd.conf */ - if(!(compiled_source_script = config_getstring(IMAPOPT_AUTOCREATE_SIEVE_COMPILEDSCRIPT))) { + if(!(compiled_source_script = config_getstring(IMAPOPT_AUTOCREATE_SIEVE_SCRIPT_COMPILED))) { syslog(LOG_WARNING, "autocreate_sieve: autocreate_sieve_compiledscript option is not defined. Compiling it"); do_compile = 1; } @@ -361,7 +361,7 @@ * to generate the global script so that it is not compiled each time then we create it. */ if(do_compile && - config_getswitch(IMAPOPT_GENERATE_COMPILED_SIEVE_SCRIPT)) { + config_getswitch(IMAPOPT_AUTOCREATE_SIEVE_SCRIPT_COMPILE)) { if(!compiled_source_script) { syslog(LOG_WARNING, "autocreate_sieve: To save a compiled sieve script, autocreate_sieve_compiledscript must have been defined in imapd.conf"); @@ -588,7 +588,7 @@ * subscribe user to every shared folder one has the apropriate * permissions. */ - if (config_getswitch(IMAPOPT_AUTOSUBSCRIBE_ALL_SHAREDFOLDERS)) { + if (config_getswitch(IMAPOPT_AUTOCREATE_SUBSCRIBE_SHAREDFOLDERS_ALL)) { /* don't care about errors here, the sub will log them */ mboxlist_findall(namespace, "*", 0, userid, auth_state, autochangesub, &changesub_rock); @@ -597,7 +597,7 @@ /* otherwise, check if there are particular folders to subscribe */ - sub = config_getstring(IMAPOPT_AUTOSUBSCRIBESHAREDFOLDERS); + sub = config_getstring(IMAPOPT_AUTOCREATE_SUBSCRIBE_SHAREDFOLDERS); if (!sub) return; changesub_rock.was_explicit = 1; @@ -618,8 +618,8 @@ const char *userid) { int r = IMAP_MAILBOX_NONEXISTENT; /* default error if we break early */ - int autocreatequota = config_getint(IMAPOPT_AUTOCREATEQUOTA); - int autocreatequotamessage = config_getint(IMAPOPT_AUTOCREATEQUOTAMSG); + int autocreatequota = config_getint(IMAPOPT_AUTOCREATE_QUOTA); + int autocreatequotamessage = config_getint(IMAPOPT_AUTOCREATE_QUOTA_MESSAGES); int n; char *inboxname = mboxname_user_mbox(userid, NULL); struct auth_state *auth_state = NULL; @@ -719,8 +719,8 @@ syslog(LOG_NOTICE, "autocreateinbox: User %s, INBOX was successfully created", userid); - create = strarray_split(config_getstring(IMAPOPT_AUTOCREATEINBOXFOLDERS), SEP, STRARRAY_TRIM); - subscribe = strarray_split(config_getstring(IMAPOPT_AUTOSUBSCRIBEINBOXFOLDERS), SEP, STRARRAY_TRIM); + create = strarray_split(config_getstring(IMAPOPT_AUTOCREATE_INBOX_FOLDERS), SEP, STRARRAY_TRIM); + subscribe = strarray_split(config_getstring(IMAPOPT_AUTOCREATE_SUBSCRIBE_FOLDERS), SEP, STRARRAY_TRIM); /* need to convert all names to internal namespace first */ for (n = 0; n < create->count; n++)
View file
cyrus-imapd-2.5.tar.gz/imap/backend.c
Changed
@@ -472,7 +472,10 @@ #endif /* HAVE_ZLIB */ } -EXPORTED int backend_starttls(struct backend *s, struct tls_cmd_t *tls_cmd) +EXPORTED int backend_starttls( struct backend *s, + struct tls_cmd_t *tls_cmd, + const char *c_cert_file, + const char *c_key_file) { #ifndef HAVE_SSL return -1; @@ -493,7 +496,7 @@ return -1; } - r = tls_init_clientengine(5, "", ""); + r = tls_init_clientengine(5, c_cert_file, c_key_file); if (r == -1) return -1; /* SASL and openssl have different ideas about whether ssf is signed */ @@ -591,7 +594,6 @@ socklen_t addrsize; char buf[2048], optstr[128], *p; const char *mech_conf, *pass; - if (prot->type != TYPE_STD) return SASL_FAIL; /* set the IP addresses */ @@ -642,6 +644,30 @@ if (!mech_conf) mech_conf = config_getstring(IMAPOPT_FORCE_SASL_CLIENT_MECH); +#ifdef HAVE_SSL + strlcpy(optstr, s->hostname, sizeof(optstr)); + p = strchr(optstr, '.'); + if (p) *p = '\0'; + + strlcat(optstr, "_client_cert", sizeof(optstr)); + const char *c_cert_file = config_getoverflowstring(optstr, NULL); + + if (!c_cert_file) { + c_cert_file = config_getstring(IMAPOPT_TLS_CLIENT_CERT); + } + + strlcpy(optstr, s->hostname, sizeof(optstr)); + p = strchr(optstr, '.'); + if (p) *p = '\0'; + + strlcat(optstr, "_client_key", sizeof(optstr)); + + const char *c_key_file = config_getoverflowstring(optstr, NULL); + if (!c_key_file) { + c_key_file = config_getstring(IMAPOPT_TLS_CLIENT_KEY); + } +#endif + mechlist = backend_get_cap_params(s, CAPA_AUTH); do { @@ -673,7 +699,7 @@ /* If we don't have a usable mech, do TLS and try again */ } while (r == SASL_NOMECH && CAPA(s, CAPA_STARTTLS) && - backend_starttls(s, &prot->u.std.tls_cmd) != -1 && + backend_starttls(s, &prot->u.std.tls_cmd, c_cert_file, c_key_file) != -1 && (mechlist = backend_get_cap_params(s, CAPA_AUTH))); if (r == SASL_OK) { @@ -771,8 +797,9 @@ strcmp(new_mechlist, old_mechlist)) { syslog(LOG_ERR, "possible MITM attack:" "list of available SASL mechanisms changed"); - free(new_mechlist); - free(old_mechlist); + + if (new_mechlist) free(new_mechlist); + if (old_mechlist) free(old_mechlist); return -1; } free(new_mechlist); @@ -967,7 +994,7 @@ prot_setisclient(ret->out, 1); /* Start TLS if required */ - if (do_tls) r = backend_starttls(ret, NULL); + if (do_tls) r = backend_starttls(ret, NULL, NULL, NULL); /* Login to the server */ if (prot->type == TYPE_SPEC)
View file
cyrus-imapd-2.5.tar.gz/imap/backend.h
Changed
@@ -96,7 +96,11 @@ struct protocol_t *prot, const char *userid, sasl_callback_t *cb, const char **auth_status, int logfd); -int backend_starttls(struct backend *s, struct tls_cmd_t *tls_cmd); +int backend_starttls( struct backend *s, + struct tls_cmd_t *tls_cmd, + const char *c_cert_file, + const char *c_key_file); + int backend_ping(struct backend *s, const char *userid); void backend_disconnect(struct backend *s); char *intersect_mechlists(char *config, char *server);
View file
cyrus-imapd-2.5.tar.gz/imap/ctl_cyrusdb.c
Changed
@@ -95,7 +95,7 @@ { FNAME_QUOTADB, &config_quota_db, NULL, 1 }, { FNAME_GLOBALANNOTATIONS, &config_annotation_db, NULL, 1 }, { FNAME_DELIVERDB, &config_duplicate_db, NULL, 0 }, - { FNAME_TLSSESSIONS, &config_tlscache_db, NULL, 0 }, + { FNAME_TLSSESSIONS, &config_tls_sessions_db,NULL, 0 }, { FNAME_PTSDB, &config_ptscache_db, NULL, 0 }, { FNAME_STATUSCACHEDB, &config_statuscache_db, NULL, 0 }, { NULL, NULL, NULL, 0 }
View file
cyrus-imapd-2.5.tar.gz/imap/global.c
Changed
@@ -96,7 +96,7 @@ EXPORTED const char *config_seenstate_db; HIDDEN const char *config_mboxkey_db; EXPORTED const char *config_duplicate_db; -EXPORTED const char *config_tlscache_db; +EXPORTED const char *config_tls_sessions_db; EXPORTED const char *config_ptscache_db; EXPORTED const char *config_statuscache_db; HIDDEN const char *config_userdeny_db; @@ -255,7 +255,7 @@ config_seenstate_db = config_getstring(IMAPOPT_SEENSTATE_DB); config_mboxkey_db = config_getstring(IMAPOPT_MBOXKEY_DB); config_duplicate_db = config_getstring(IMAPOPT_DUPLICATE_DB); - config_tlscache_db = config_getstring(IMAPOPT_TLSCACHE_DB); + config_tls_sessions_db = config_getstring(IMAPOPT_TLS_SESSIONS_DB); config_ptscache_db = config_getstring(IMAPOPT_PTSCACHE_DB); config_statuscache_db = config_getstring(IMAPOPT_STATUSCACHE_DB); config_userdeny_db = config_getstring(IMAPOPT_USERDENY_DB); @@ -757,67 +757,6 @@ return 1; } -struct part_stats { - char name[MAX_PARTITION_LEN+1]; /* name of part with most space */ - unsigned long avail; /* 1k free blocks on freeest part */ - unsigned long tavail; /* total 1k free blocks on server */ - unsigned long fsid[512]; /* array of file system IDs */ - unsigned nfsid; /* number of file system IDs */ -}; - -/* - * config_foreachoverflowstring() callback which finds spool partition - * with the most available space and totals the space available on - * all partitions. - */ -static void get_part_stats(const char *key, const char *val, void *rock) -{ - struct part_stats *stats = (struct part_stats *) rock; - struct statvfs s; - unsigned long avail; - unsigned i; - - /* not a partition-* config option */ - if (strncmp("partition-", key, 10)) return; - - /* can't stat the given path */ - if (statvfs(val, &s)) return; - - /* eliminate duplicate filesystems */ - for (i = 0; i < stats->nfsid; i++) { - if (s.f_fsid == stats->fsid[i]) return; - } - stats->fsid[stats->nfsid++] = s.f_fsid; - - /* calculate avail space in 1k blocks */ - avail = (unsigned long) (s.f_bavail * (s.f_frsize / 1024.0)); - - /* add to total */ - stats->tavail += avail; - - if (avail > stats->avail) { - /* this part has the most avail space */ - stats->avail = avail; - strlcpy(stats->name, key+10, MAX_PARTITION_LEN); - } -} - -/* - * Returns the name of the spool partition with the most available space. - * Optionally returns the total amount of available space on the server - * (all partitions) in 1k blocks. - */ -HIDDEN char *find_free_partition(unsigned long *tavail) -{ - static struct part_stats stats; - - memset(&stats, 0, sizeof(struct part_stats)); - config_foreachoverflowstring(get_part_stats, &stats); - - if (tavail) *tavail = stats.tavail; - return stats.name; -} - /* Set up the Session ID Buffer */ EXPORTED void session_new_id(void) {
View file
cyrus-imapd-2.5.tar.gz/imap/global.h
Changed
@@ -155,13 +155,15 @@ int getint32(struct protstream *pin, int *num); int getsint32(struct protstream *pin, int *num); int getuint32(struct protstream *pin, unsigned int *num); +int getint64(struct protstream *pin, int64_t *num); +int getsint64(struct protstream *pin, int64_t *num); +int getuint64(struct protstream *pin, uint64_t *num); int getmodseq(struct protstream *pin, modseq_t *num); void eatline(struct protstream *pin, int c); /* Misc utils */ extern int shutdown_file(char *buf, int size); -extern char *find_free_partition(unsigned long *tavail); extern char *find_msgid(char *, char **); #define UNIX_SOCKET "[unix socket]" extern const char *get_clienthost(int s, @@ -179,7 +181,7 @@ extern const char *config_seenstate_db; extern const char *config_mboxkey_db; extern const char *config_duplicate_db; -extern const char *config_tlscache_db; +extern const char *config_tls_sessions_db; extern const char *config_ptscache_db; extern const char *config_statuscache_db; extern const char *config_userdeny_db;
View file
cyrus-imapd-2.5.tar.gz/imap/imap_proxy.c
Changed
@@ -59,6 +59,7 @@ #include "proxy.h" #include "mboxname.h" #include "mupdate-client.h" +#include "partlist.h" #include "prot.h" #include "util.h" #include "xmalloc.h" @@ -69,6 +70,10 @@ extern char *imapd_userid, *proxy_userid; extern struct namespace imapd_namespace; +static partlist_t *server_parts = NULL; + +static void proxy_part_filldata(partlist_t *part_list, int idx); + static void imap_postcapability(struct backend *s) { if (CAPA(s, CAPA_SASL_IR)) { @@ -1317,103 +1322,118 @@ char *find_free_server(void) { const char *servers = config_getstring(IMAPOPT_SERVERLIST); - unsigned long long int max_avail = 0; char *server = NULL; if (servers) { - char *tmpbuf, *cur_server, *next_server; - char mytag[128]; - struct backend *be; - - /* make a working copy of the list */ - cur_server = tmpbuf = xstrdup(servers); - - while (cur_server) { - /* eat any leading whitespace */ - while (Uisspace(*cur_server)) cur_server++; - - if (!*cur_server) break; - - /* find end of server */ - if ((next_server = strchr(cur_server, ' ')) || - (next_server = strchr(cur_server, '\t'))) - *next_server++ = '\0'; - - syslog(LOG_DEBUG, "checking free space on server '%s'", cur_server); - - /* connect to server */ - be = proxy_findserver(cur_server, &imap_protocol, - proxy_userid, &backend_cached, - &backend_current, &backend_inbox, imapd_in); - if (be) { - unsigned long long int avail = 0; - static struct buf avail_buf; - int c; - - /* fetch annotation from remote */ - proxy_gentag(mytag, sizeof(mytag)); - prot_printf(be->out, - "%s GETANNOTATION \"\" " - "\"/vendor/cmu/cyrus-imapd/freespace\" " - "\"value.shared\"\r\n", mytag); - prot_flush(be->out); - - for (/* each annotation response */;;) { - /* read a line */ - c = prot_getc(be->in); - if (c != '*') break; - c = prot_getc(be->in); - if (c != ' ') { /* protocol error */ c = EOF; break; } - - c = chomp(be->in, - "ANNOTATION \"\" " - "\"/vendor/cmu/cyrus-imapd/freespace\" " - "(\"value.shared\" "); - - if (c == EOF) { - /* we don't care about this response */ - eatline(be->in, c); - continue; - } - - /* read amount of free space */ - c = getastring(be->in, be->out, &avail_buf); + if (!server_parts) { + server_parts = xzmalloc(sizeof(partlist_t)); + + partlist_initialize( + server_parts, + proxy_part_filldata, + NULL, + servers, + NULL, + partlist_getmode(config_getstring(IMAPOPT_SERVERLIST_SELECT_MODE)), + config_getint(IMAPOPT_SERVERLIST_SELECT_SOFT_USAGE_LIMIT), + config_getint(IMAPOPT_SERVERLIST_SELECT_USAGE_REINIT) + ); - if (c != '"') { c = EOF; break; } - eatline(be->in, c); /* we don't care about the rest of the line */ - } - - if (c != EOF) { - prot_ungetc(c, be->in); + } - /* we should be looking at the tag now */ - eatline(be->in, c); - } + server = (char *)partlist_select_value(server_parts); + } - if (c == EOF) { - /* uh oh, we're not happy */ - fatal("Lost connection to backend", EC_UNAVAILABLE); - } + return server; +} - avail = strtoull(avail_buf.s, NULL, 10); - if (avail > max_avail) { - syslog(LOG_DEBUG, "freespace on %s (%llu) greater than current maximum on %s (%llu)", cur_server, avail, server, max_avail); - server = cur_server; - max_avail = avail; - } else { - syslog(LOG_DEBUG, "freespace on %s (%llu) still the current maximum (not %s (%llu))", server, max_avail, cur_server, avail); - } +static void proxy_part_filldata(partlist_t *part_list, int idx) +{ + char mytag[128]; + struct backend *be; + partitem_t *item = &part_list->items[idx]; + + item->id = 0; + item->available = 0; + item->total = 0; + item->quota = 0.; + + syslog(LOG_DEBUG, "checking free space on server '%s'", item->value); + + /* connect to server */ + be = proxy_findserver(item->value, &imap_protocol, + proxy_userid, &backend_cached, + &backend_current, &backend_inbox, imapd_in); + + if (be) { + uint64_t server_available = 0; + uint64_t server_total = 0; + int c; + + /* fetch annotation from remote */ + proxy_gentag(mytag, sizeof(mytag)); + if (part_list->mode == PART_SELECT_MODE_FREESPACE_MOST) { + prot_printf(be->out, + "%s GETANNOTATION \"\" " + "\"/vendor/cmu/cyrus-imapd/freespace/total\" " + "\"value.shared\"\r\n", mytag); + } + else { + prot_printf(be->out, + "%s GETANNOTATION \"\" " + "\"/vendor/cmu/cyrus-imapd/freespace/percent/most\" " + "\"value.shared\"\r\n", mytag); + } + prot_flush(be->out); + + for (/* each annotation response */;;) { + /* read a line */ + c = prot_getc(be->in); + if (c != '*') break; + c = prot_getc(be->in); + if (c != ' ') { /* protocol error */ c = EOF; break; } + + if (part_list->mode == PART_SELECT_MODE_FREESPACE_MOST) { + c = chomp(be->in, + "ANNOTATION \"\" " + "\"/vendor/cmu/cyrus-imapd/freespace/total\" " + "(\"value.shared\" "); + } else { + c = chomp(be->in, + "ANNOTATION \"\" " + "\"/vendor/cmu/cyrus-imapd/freespace/percent/most\" " + "(\"value.shared\" "); + } + if ((c == EOF) || (c != '\"')) { + /* we don't care about this response */ + eatline(be->in, c); + continue; } - /* move to next server */ - cur_server = next_server; + /* read available */ + c = getuint64(be->in, &server_available); + if (c != ';') { c = EOF; break; } + + /* read total */ + c = getuint64(be->in, &server_total); + if (c != '\"') { c = EOF; break; }
View file
cyrus-imapd-2.5.tar.gz/imap/imapd.c
Changed
@@ -70,7 +70,9 @@ #include "annotate.h" #include "append.h" #include "auth.h" +#ifdef USE_AUTOCREATE #include "autocreate.h" +#endif // USE_AUTOCREATE #include "assert.h" #include "backend.h" #include "bsearch.h" @@ -95,6 +97,7 @@ #include "mboxname.h" #include "mbdump.h" #include "mupdate-client.h" +#include "partlist.h" #include "proc.h" #include "quota.h" #include "seen.h" @@ -1082,6 +1085,8 @@ statuscache_done(); } + partlist_local_done(); + if (imapd_in) { /* Flush the incoming buffer */ prot_NONBLOCK(imapd_in); @@ -2245,6 +2250,7 @@ } } +#ifdef USE_AUTOCREATE /* * Autocreate Inbox and subfolders upon login */ @@ -2253,7 +2259,7 @@ if (imapd_userisadmin) return; if (imapd_userisproxyadmin) return; - if (config_getint(IMAPOPT_AUTOCREATEQUOTA)) { + if (config_getint(IMAPOPT_AUTOCREATE_QUOTA)) { char *inboxname = mboxname_user_mbox(imapd_userid, NULL); int r = mboxlist_lookup(inboxname, NULL, NULL); free(inboxname); @@ -2261,6 +2267,7 @@ autocreate_user(&imapd_namespace, imapd_userid); } } +#endif // USE_AUTOCREATE static void authentication_success(void) { @@ -2301,7 +2308,9 @@ mboxevent_free(&mboxevent); } +#ifdef USE_AUTOCREATE autocreate_inbox(); +#endif // USE_AUTOCREATE } static int checklimits(const char *tag) @@ -3027,7 +3036,7 @@ if (!imapd_compress_done && !imapd_tls_comp) { prot_printf(imapd_out, " COMPRESS=DEFLATE"); } -#endif +#endif // HAVE_ZLIB for (i = 0 ; i < QUOTA_NUMRESOURCES ; i++) prot_printf(imapd_out, " X-QUOTA=%s", quota_names[i]); @@ -5332,7 +5341,6 @@ { int r = 0; char mailboxname[MAX_MAILBOX_BUFFER]; - int autocreatequotastorage; int mbtype = 0; const char *partition = NULL; const char *server = NULL; @@ -5574,10 +5582,11 @@ NULL // struct mailbox mailboxptr ); +#ifdef USE_AUTOCREATE // Clausing autocreate for the INBOX if (r == IMAP_PERMISSION_DENIED) { if (strcasecmp(name, "INBOX")) { - if ((autocreatequotastorage = config_getint(IMAPOPT_AUTOCREATEQUOTA))) { + if ((int autocreatequotastorage = config_getint(IMAPOPT_AUTOCREATE_QUOTA))) { r = mboxlist_createmailbox( mailboxname, 0, @@ -5597,7 +5606,7 @@ goto done; } - int autocreatequotamessage = config_getint(IMAPOPT_AUTOCREATEQUOTAMSG); + int autocreatequotamessage = config_getint(IMAPOPT_AUTOCREATE_QUOTA_MESSAGES); if ((autocreatequotastorage > 0) || (autocreatequotamessage > 0)) { int newquotas[QUOTA_NUMRESOURCES]; @@ -5634,6 +5643,18 @@ } // (r == IMAP_PERMISSION_DENIED) +#else // USE_AUTOCREATE + if (r) { + prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); + goto done; + + } else { // (r) + prot_printf(imapd_out, "%s OK %s\r\n", tag, error_message(IMAP_OK_COMPLETED)); + goto done; + + } // (r) +#endif // USE_AUTOCREATE + if (specialuse.len) { r = annotatemore_write(mailboxname, "/specialuse", imapd_userid, &specialuse); if (r) { @@ -6541,7 +6562,9 @@ goto freeargs; } +#ifdef USE_AUTOCREATE autocreate_inbox(); +#endif // USE_AUTOCREATE return; @@ -7474,7 +7497,7 @@ fatal("cmd_starttls() executed, but starttls isn't implemented!", EC_SOFTWARE); } -#endif /* HAVE_SSL */ +#endif // (OPENSSL_VERSION_NUMBER >= 0x0090800fL) static int parse_statusitems(unsigned *statusitemsp, const char **errstr) { @@ -12328,7 +12351,7 @@ "%s NO [COMPRESSIONACTIVE] %s active via TLS\r\n", tag, SSL_COMP_get_name(imapd_tls_comp)); } -#endif +#endif defined(HAVE_SSL) && (OPENSSL_VERSION_NUMBER >= 0x0090800fL) else if (strcasecmp(alg, "DEFLATE")) { prot_printf(imapd_out, "%s NO Unknown COMPRESS algorithm: %s\r\n", tag, alg);
View file
cyrus-imapd-2.5.tar.gz/imap/imapparse.c
Changed
@@ -297,7 +297,80 @@ return c; } -/* This would be called getuint64() if +EXPORTED int getint64(struct protstream *pin, int64_t *num) +{ + int64_t result = 0; + char c; + int gotchar = 0; + + /* LLONG_MAX == 9223372036854775807LL */ + while ((c = prot_getc(pin)) != EOF && cyrus_isdigit(c)) { + if (result > 922337203685477580LL || (result == 922337203685477580LL && (c > '7'))) + fatal("num too big", EC_IOERR); + result = result * 10 + c - '0'; + gotchar = 1; + } + + if (!gotchar) + return EOF; + + *num = result; + + return c; +} + +/* Like getint64() but explicitly signed, i.e. negative numbers + * are accepted */ +EXPORTED int getsint64(struct protstream *pin, int64_t *num) +{ + int c; + int sgn = 1; + + c = prot_getc(pin); + if (c == EOF) + return EOF; + + if (c == '-') + sgn = -1; + else if (c == '+') + sgn = 1; + else + prot_ungetc(c, pin); + + c = getint64(pin, num); + if (c == EOF) + return EOF; + /* this is slightly buggy: the number LLONG_MIN == -9223372036854775808LL + * is a valid signed 64b int but is not accepted */ + if (sgn < 0) + *num = - (*num); + return c; +} + +/* can't flag with -1 if there is no number here, so return EOF */ +EXPORTED int getuint64(struct protstream *pin, uint64_t *num) +{ + uint64_t result = 0; + char c; + int gotchar = 0; + + /* ULLONG_MAX == 18446744073709551615ULL */ + while ((c = prot_getc(pin)) != EOF && cyrus_isdigit(c)) { + if (result > 1844674407370955161ULL || (result == 1844674407370955161ULL && (c > '5'))) + fatal("num too big", EC_IOERR); + result = result * 10 + c - '0'; + gotchar = 1; + } + + if (!gotchar) + return EOF; + + *num = result; + + return c; +} + +/* This would call getuint64() if * all were right with the world */ EXPORTED int getmodseq(struct protstream *pin, modseq_t *num) {
View file
cyrus-imapd-2.5.tar.gz/imap/lmtp_sieve.c
Changed
@@ -951,7 +951,7 @@ if (config_getswitch(IMAPOPT_ANYSIEVEFOLDER)) { createsievefolder = 1; } - else if ((subf = config_getstring(IMAPOPT_AUTOSIEVEFOLDERS)) != NULL) { + else if ((subf = config_getstring(IMAPOPT_AUTOCREATE_SIEVE_FOLDERS)) != NULL) { strarray_t *create = strarray_split(subf, SEP, STRARRAY_TRIM); for (n = 0; n < create->count; n++) {
View file
cyrus-imapd-2.5.tar.gz/imap/lmtpd.c
Changed
@@ -67,7 +67,9 @@ #include "append.h" #include "assert.h" #include "auth.h" +#ifdef USE_AUTOCREATE #include "autocreate.h" +#endif #include "backend.h" #include "duplicate.h" #include "exitcodes.h" @@ -119,7 +121,9 @@ static FILE *spoolfile(message_data_t *msgdata); static void removespool(message_data_t *msgdata); +#ifdef USE_AUTOCREATE static int autocreate_inbox(const char *user, const char *domain); +#endif /* current namespace */ static struct namespace lmtpd_namespace; @@ -1044,7 +1048,7 @@ exit(code); } - +#ifdef USE_AUTOCREATE /* * Autocreate Inbox and subfolders upon login */ @@ -1073,11 +1077,11 @@ /* * Check for autocreatequota and createonpost */ - if (!config_getint(IMAPOPT_AUTOCREATEQUOTA)) { + if (!config_getint(IMAPOPT_AUTOCREATE_QUOTA)) { free(username); return IMAP_MAILBOX_NONEXISTENT; } - if (!config_getswitch(IMAPOPT_CREATEONPOST)) { + if (!config_getswitch(IMAPOPT_AUTOCREATE_POST)) { free(username); return IMAP_MAILBOX_NONEXISTENT; } @@ -1088,6 +1092,7 @@ return r; } +#endif // USE_AUTOCREATE static int verify_user(const char *user, const char *domain, char *mailbox, quota_t quotastorage_check, quota_t quotamessage_check, @@ -1133,11 +1138,13 @@ */ r = mlookup(namebuf, &mbentry); +#ifdef USE_AUTOCREATE /* If user mailbox does not exist, then invoke autocreate inbox function */ if (r == IMAP_MAILBOX_NONEXISTENT) { r = autocreate_inbox(user, domain); if (!r) r = mlookup(namebuf, &mbentry); } +#endif // USE_AUTOCREATE if (r == IMAP_MAILBOX_NONEXISTENT && !user && config_getswitch(IMAPOPT_LMTP_FUZZY_MAILBOX_MATCH) &&
View file
cyrus-imapd-2.5.tar.gz/imap/mboxevent.c
Changed
@@ -55,6 +55,7 @@ #include "annotate.h" #include "assert.h" #include "exitcodes.h" +#include "global.h" #include "imapurl.h" #include "libconfig.h" #include "map.h"
View file
cyrus-imapd-2.5.tar.gz/imap/mboxlist.c
Changed
@@ -70,6 +70,7 @@ #include "imap/imap_err.h" #include "xmalloc.h" #include "xstrlcpy.h" +#include "partlist.h" #include "xstrlcat.h" #include "user.h" @@ -588,12 +589,12 @@ if (!part && config_defpartition) part = config_defpartition; - /* look for partition with free space */ + /* look for most fitting partition */ if (!part) - part = find_free_partition(NULL); + part = partlist_local_select(); /* Configuration error */ - if (strlen(part) > MAX_PARTITION_LEN) + if (!part || (strlen(part) > MAX_PARTITION_LEN)) goto err; if (!config_partitiondir(part))
View file
cyrus-imapd-2.5.tar.gz/imap/mupdate.c
Changed
@@ -84,6 +84,7 @@ #include "nonblock.h" #include "prot.h" #include "tls.h" +#include "tls_th-lock.h" #include "util.h" #include "version.h" #include "xmalloc.h" @@ -553,6 +554,10 @@ database_init(); +#ifdef HAVE_SSL + CRYPTO_thread_setup(); +#endif + if (!masterp) { r = pthread_create(&t, NULL, &mupdate_client_start, NULL); if (r == 0) { @@ -598,6 +603,9 @@ /* Called by service API to shut down the service */ void service_abort(int error) { +#ifdef HAVE_SSL + CRYPTO_thread_cleanup(); +#endif shut_down(error); }
View file
cyrus-imapd-2.5.tar.gz/imap/nntpd.c
Changed
@@ -92,6 +92,7 @@ #include "mkgmtime.h" #include "mupdate-client.h" #include "imap/nntp_err.h" +#include "partlist.h" #include "proc.h" #include "prot.h" #include "proxy.h" @@ -659,6 +660,8 @@ idle_done(); + partlist_local_done(); + if (nntp_in) { prot_NONBLOCK(nntp_in); prot_fill(nntp_in);
View file
cyrus-imapd-2.5.tar.gz/imap/partlist.c
Added
@@ -0,0 +1,628 @@ +/* partlist.c - Partition/backend selection functions + * + * Copyright (c) 1994-2008 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any legal + * details, please contact + * Carnegie Mellon University + * Center for Technology Transfer and Enterprise Creation + * 4615 Forbes Avenue + * Suite 302 + * Pittsburgh, PA 15213 + * (412) 268-7393, fax: (412) 268-7395 + * innovation@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: $ + */ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <syslog.h> +#include <sys/statvfs.h> +#include <sys/types.h> + +#include "libconfig.h" +#include "partlist.h" +#include "xmalloc.h" + + +#define FREE(var) if (var) { free(var); (var) = NULL; } + +static void partlist_bump_action(partlist_t *part_list); +static int partlist_selectpart_index(partlist_t *part_list); +static void partlist_compute_quota(partlist_t *part_list); +static void partlist_fill(const char *key, const char *value, void *rock); +static void partition_filldata(partlist_t *part_list, int idx); + +typedef struct partlist_conf { + partlist_t *part_list; + const char *key_prefix; + size_t excluded_count; + const char **excluded_item; +} partlist_conf_t; + +static partlist_t *partlist_local = NULL; + + +EXPORTED partmode_t partlist_getmode(const char *mode) +{ + if (!strcmp(mode, "freespace-most")) { + return PART_SELECT_MODE_FREESPACE_MOST; + } + else if (!strcmp(mode, "freespace-percent-most")) { + return PART_SELECT_MODE_FREESPACE_PERCENT_MOST; + } + else if (!strcmp(mode, "freespace-percent-weighted")) { + return PART_SELECT_MODE_FREESPACE_PERCENT_WEIGHTED; + } + else if (!strcmp(mode, "freespace-percent-weighted-delta")) { + return PART_SELECT_MODE_FREESPACE_PERCENT_WEIGHTED_DELTA; + } + else { + return PART_SELECT_MODE_RANDOM; + } +} + + +EXPORTED void partlist_initialize(partlist_t *part_list, cb_part_filldata filldata, + const char *key_prefix, const char *key_value, + const char *excluded, partmode_t mode, + int soft_usage_limit, int reinit) +{ + partlist_conf_t part_list_conf; + char *excluded_parts = NULL; + + srand(time(NULL)); + memset(&part_list_conf, 0, sizeof(part_list_conf)); + memset(part_list, 0, sizeof(partlist_t)); + + part_list->mode = mode; + part_list->filldata = (filldata ? filldata : partition_filldata); + part_list->size = 0; + part_list->soft_usage_limit = soft_usage_limit; + part_list->reinit = reinit; + + part_list_conf.part_list = part_list; + part_list_conf.key_prefix = key_prefix; + + if (excluded && (strlen(excluded) > 0)) { + char *item = NULL; + char *lasts; + + excluded_parts = xstrdup(excluded); + item = strtok_r(excluded_parts, " ,\t", &lasts); + while (item) { + part_list_conf.excluded_item = (const char **)xrealloc(part_list_conf.excluded_item, (part_list_conf.excluded_count+1) * sizeof(const char *)); + part_list_conf.excluded_item[part_list_conf.excluded_count++] = item; + item = strtok_r(NULL, " ,\t", &lasts); + } + } + + if (key_value) { + char *items = xstrdup(key_value); + char *item = NULL; + char *lasts; + + item = strtok_r(items, " ,\t", &lasts); + while (item) { + partlist_fill(item, item, &part_list_conf); + item = strtok_r(NULL, " ,\t", &lasts); + } + + FREE(items); + } + else { + config_foreachoverflowstring(partlist_fill, &part_list_conf); + } + + /* excluded items no more necessary */ + FREE(excluded_parts); + FREE(part_list_conf.excluded_item); + + partlist_compute_quota(part_list); +} + + +static void partlist_free(partlist_t *part_list) +{ + int i; + + if (part_list == NULL) { + return; + } + + for (i = 0; i < part_list->size; i++) { + FREE(part_list->items[i].item); + FREE(part_list->items[i].value); + } + FREE(part_list->items); + part_list->size = -1; +} + + +static void partlist_bump_action(partlist_t *part_list) +{ + if ((part_list->reinit > 0) && (part_list->reinit_counter++ >= part_list->reinit)) { + partlist_compute_quota(part_list); + part_list->reinit_counter = 1; + } +} + + +static int partlist_getavailable(partlist_t *part_list) +{ + int count = 0; + int idx; + + for (idx = 0; idx < part_list->size; idx++) { + if (part_list->items[idx].quota != 0.) { + count++; + } + } + + /* When nothing available, refresh quotas after a while */ + if (!count) { + partlist_bump_action(part_list); + } + + return count; +} + +
View file
cyrus-imapd-2.5.tar.gz/imap/partlist.h
Added
@@ -0,0 +1,158 @@ +/* partlist.h - Partition/backend selection functions + * + * Copyright (c) 1994-2010 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any legal + * details, please contact + * Carnegie Mellon University + * Center for Technology Transfer and Enterprise Creation + * 4615 Forbes Avenue + * Suite 302 + * Pittsburgh, PA 15213 + * (412) 268-7393, fax: (412) 268-7395 + * innovation@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: $ + */ + +#include "config.h" + + +typedef struct partitem { + /** Item name */ + char *item; + /** Item value */ + char *value; + /** Item underlying id (filesystem id) */ + unsigned long id; + /** Item available space (KiB) */ + uint64_t available; + /** Item total space (KiB) */ + uint64_t total; + /** Item selection data */ + double quota; +} partitem_t; + +typedef enum partmode { + /** Random */ + PART_SELECT_MODE_RANDOM, + /** Most free space. */ + PART_SELECT_MODE_FREESPACE_MOST, + /** Most free space (percent). */ + PART_SELECT_MODE_FREESPACE_PERCENT_MOST, + /** Weighted free space (percent) */ + PART_SELECT_MODE_FREESPACE_PERCENT_WEIGHTED, + /** Weighted free space (percent) delta */ + PART_SELECT_MODE_FREESPACE_PERCENT_WEIGHTED_DELTA +} partmode_t; + +struct partlist; + +/** + * \brief Item data callback. + * + * @param inout part_list items list structure + * @param in idx item index + */ +typedef void (*cb_part_filldata)(struct partlist *part_list, int idx); + +typedef struct partlist { + /** Data callback */ + cb_part_filldata filldata; + /** Number of items */ + int size; + /** Items */ + partitem_t *items; + /** Mode */ + partmode_t mode; + /** Whether to actually use random mode */ + int force_random; + /** Usage limit */ + int soft_usage_limit; + /** Reinit limit */ + int reinit; + /** Reinit counter */ + int reinit_counter; +} partlist_t; + +/** + * \brief Gets enumerated mode from string. + */ +extern partmode_t partlist_getmode(const char *mode); + +/** + * \brief Initializes items list. + * + * @param inout part_list items list structure + * @param in filldata items data callback, NULL for default (physical partitions) + * @param in key_prefix key prefix for items to search for in configuration + * @param in key_value key value, to be used if list of items is stored in one option + * @param in excluded excluded items list + * @param in mode items mode + * @param in soft_usage_limit usage limit + * @param in reinit reinit items data after given amount of operations + */ +extern void partlist_initialize(partlist_t *part_list, cb_part_filldata filldata, + const char *key_prefix, const char *key_value, + const char *excluded, partmode_t mode, + int soft_usage_limit, int reinit); + +/** + * \brief Selects item value from list. + * + * @param inout part_list items list structure + * @return selected item value, according to requested mode, or NULL if none found + */ +extern const char *partlist_select_value(partlist_t *part_list); + +/** + * \brief Selects local partitions. + * + * @return selected partition, according to requested mode, or NULL if none found + */ +const char *partlist_local_select(void); + +/** + * \brief Finds partition with most freespace (bytes or percents). + * + * @param out available number of KiB available on partition + * @param out total total number of KiB on partition + * @param out tavailable number of KiB available on server + * @param out ttotal total number of KiB on server + * @return partition, or NULL if none found + */ +const char *partlist_local_find_freespace_most(int percent, uint64_t *available, + uint64_t *total, uint64_t *tavailable, + uint64_t *ttotal); + +/** + * \brief Frees local partition data. + */ +extern void partlist_local_done(void);
View file
cyrus-imapd-2.5.tar.gz/imap/pop3d.c
Changed
@@ -64,7 +64,9 @@ #include "assert.h" #include "acl.h" +#ifdef USE_AUTOCREATE #include "autocreate.h" +#endif #include "util.h" #include "auth.h" #include "global.h" @@ -1796,6 +1798,7 @@ r = mboxlist_lookup(inboxname, &mbentry, NULL); +#ifdef USE_AUTOCREATE /* Try once again after autocreate_inbox */ if (r == IMAP_MAILBOX_NONEXISTENT) { /* NOTE - if we have a subfolder, autocreateinbox should still create @@ -1803,6 +1806,7 @@ r = autocreate_user(&popd_namespace, popd_userid); if (!r) r = mboxlist_lookup(inboxname, &mbentry, NULL); } +#endif if (!r && (config_popuseacl = config_getswitch(IMAPOPT_POPUSEACL)) && (!mbentry->acl ||
View file
cyrus-imapd-2.5.tar.gz/imap/reconstruct.c
Changed
@@ -85,6 +85,7 @@ #include "map.h" #include "message.h" #include "message_guid.h" +#include "partlist.h" #include "xmalloc.h" #include "xstrlcpy.h" #include "xstrlcat.h" @@ -368,6 +369,8 @@ quotadb_close(); quotadb_done(); + partlist_local_done(); + cyrus_done(); strarray_fini(&discovered);
View file
cyrus-imapd-2.5.tar.gz/imap/sync_server.c
Changed
@@ -83,6 +83,7 @@ #include "mailbox.h" #include "map.h" #include "mboxlist.h" +#include "partlist.h" #include "proc.h" #include "prot.h" #include "quota.h" @@ -458,6 +459,8 @@ annotatemore_close(); annotate_done(); + partlist_local_done(); + if (sync_in) { prot_NONBLOCK(sync_in); prot_fill(sync_in);
View file
cyrus-imapd-2.5.tar.gz/imap/tls.c
Changed
@@ -122,12 +122,13 @@ #include "nonblock.h" #include "xmalloc.h" #include "tls.h" +#include "tls_th-lock.h" /* Session caching/reuse stuff */ #include "global.h" #include "cyrusdb.h" -#define DB (config_tlscache_db) /* sessions are binary -> MUST use DB3 */ +#define DB (config_tls_sessions_db) /* sessions are binary -> MUST use DB3 */ static struct db *sessdb = NULL; static int sess_dbopen = 0; @@ -152,10 +153,10 @@ { const char *val; - val = config_getstring(IMAPOPT_TLS_CERT_FILE); + val = config_getstring(IMAPOPT_TLS_SERVER_CERT); if (!val || !strcasecmp(val, "disabled")) return 0; - val = config_getstring(IMAPOPT_TLS_KEY_FILE); + val = config_getstring(IMAPOPT_TLS_SERVER_KEY); if (!val || !strcasecmp(val, "disabled")) return 0; return 1; @@ -219,7 +220,7 @@ #if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) /* Logic copied from OpenSSL apps/s_server.c: give the TLS context * DH params to work with DHE-* cipher suites. Hardcoded fallback - * in case no DH params in tls_key_file or tls_cert_file. + * in case no DH params in server_key or server_cert. */ static DH *get_dh1024(void) { @@ -623,6 +624,7 @@ */ /* must be called after cyrus_init */ +// I am the server EXPORTED int tls_init_serverengine(const char *ident, int verifydepth, int askcert, @@ -631,12 +633,22 @@ int off = 0; int verify_flags = SSL_VERIFY_NONE; const char *cipher_list; - const char *CApath; - const char *CAfile; - const char *s_cert_file; - const char *s_key_file; - int requirecert; - int timeout; + const char *client_ca_dir; + const char *client_ca_file; + const char *server_ca_file; + const char *server_cert_file; + const char *server_key_file; + enum enum_value tls_client_certs; + int server_cipher_order; + int timeout; + + /* Whether or not to use any client certificate CA context to + * verify client SSL certificates with. + * + * This is initially switched off by a value of "off" for the + * tls_client_certs setting, or should no client_ca_dir nor + * client_ca_file be specified. */ + int use_client_certs = 1; if (tls_serverengine) return (0); /* already running */ @@ -651,84 +663,184 @@ return -1; } -#if 0 - if (tlsonly) { - s_ctx = SSL_CTX_new(TLSv1_server_method()); - } else { - s_ctx = SSL_CTX_new(SSLv23_server_method()); - } -#endif /* even if we want TLS only, we use SSLv23 server method so we can deal with a client sending an SSLv2 greeting message */ - s_ctx = SSL_CTX_new(SSLv23_server_method()); if (s_ctx == NULL) { return (-1); }; off |= SSL_OP_ALL; /* Work around all known bugs */ - if (tlsonly) { + + const char *tls_versions = config_getstring(IMAPOPT_TLS_VERSIONS); + + if (strstr(tls_versions, "ssl2") == NULL || tlsonly) { off |= SSL_OP_NO_SSLv2; + } + + if (strstr(tls_versions, "ssl3") == NULL || tlsonly) { off |= SSL_OP_NO_SSLv3; } + + if (strstr(tls_versions, "tls1_2") == NULL) { +#if (OPENSSL_VERSION_NUMBER >= 0x1000105fL) + off |= SSL_OP_NO_TLSv1_2; +#else + syslog(LOG_ERR, "ERROR: TLSv1.2 configured, OpenSSL < 1.0.1e insufficient"); +#endif + } + + if (strstr(tls_versions, "tls1_1") == NULL) { +#if (OPENSSL_VERSION_NUMBER >= 0x1000000fL) + off |= SSL_OP_NO_TLSv1_1; +#else + syslog(LOG_ERR, "ERROR: TLSv1.1 configured, OpenSSL < 1.0.0 insufficient"); +#endif + } + + if (strstr(tls_versions, "tls1_0") == NULL) { + off |= SSL_OP_NO_TLSv1; + } + + server_cipher_order = config_getswitch(IMAPOPT_TLS_PREFER_SERVER_CIPHERS); + if (server_cipher_order) + off |= SSL_OP_CIPHER_SERVER_PREFERENCE; + + if (!config_getswitch(IMAPOPT_TLS_COMPRESSION)) { + off |= SSL_OP_NO_COMPRESSION; + syslog(LOG_DEBUG, "TLS client engine: Setting SSL_OP_NO_COMPRESSION"); + } + SSL_CTX_set_options(s_ctx, off); SSL_CTX_set_info_callback(s_ctx, apps_ssl_info_callback); - cipher_list = config_getstring(IMAPOPT_TLS_CIPHER_LIST); + cipher_list = config_getstring(IMAPOPT_TLS_CIPHERS); if (!SSL_CTX_set_cipher_list(s_ctx, cipher_list)) { syslog(LOG_ERR,"TLS server engine: cannot load cipher list '%s'", cipher_list); return (-1); } - CAfile = config_getstring(IMAPOPT_TLS_CA_FILE); - CApath = config_getstring(IMAPOPT_TLS_CA_PATH); + tls_client_certs = config_getenum(IMAPOPT_TLS_CLIENT_CERTS); - if ((!SSL_CTX_load_verify_locations(s_ctx, CAfile, CApath)) || - (!SSL_CTX_set_default_verify_paths(s_ctx))) { - /* just a warning since this is only necessary for client auth */ - syslog(LOG_NOTICE,"TLS server engine: cannot load CA data"); + if (tls_client_certs != IMAP_ENUM_TLS_CLIENT_CERTS_OFF) { + client_ca_dir = config_getstring(IMAPOPT_TLS_CLIENT_CA_DIR); + client_ca_file = config_getstring(IMAPOPT_TLS_CLIENT_CA_FILE); + + if (client_ca_dir || client_ca_file) { + if ((!SSL_CTX_load_verify_locations(s_ctx, client_ca_file, client_ca_dir)) || + (!SSL_CTX_set_default_verify_paths(s_ctx))) { + /* just a warning since this is only necessary for client auth */ + syslog(LOG_NOTICE,"TLS server engine: Failed to load CA data."); + use_client_certs = 0; + } + } else { + syslog(LOG_NOTICE,"TLS server engine: Cannot load CA data."); + use_client_certs = 0; + } + } else { + use_client_certs = 0; } - s_cert_file = config_getstring(IMAPOPT_TLS_CERT_FILE); - s_key_file = config_getstring(IMAPOPT_TLS_KEY_FILE); + server_ca_file = config_getstring(IMAPOPT_TLS_SERVER_CA_FILE); + server_cert_file = config_getstring(IMAPOPT_TLS_SERVER_CERT); + server_key_file = config_getstring(IMAPOPT_TLS_SERVER_KEY); + + /* Only consider adding additional CA certificates -used to verify certificates + * issued to clients, which may have been issued by an intermediate CA and + * not the CA that issued our server certificate- when indeed we are using + * SSL/TLS on this server. + */ + if (server_ca_file && !strcasecmp(server_cert_file, "disabled")) { + SSL_CTX_set_mode(s_ctx,SSL_CTX_get_mode(s_ctx) | SSL_MODE_NO_AUTO_CHAIN); + BIO *filebio = BIO_new_file(server_ca_file, "r"); + + if (filebio) { + X509 *cacert; + syslog(LOG_DEBUG,"TLS server engine: loading additional client_ca_cert from file %s", server_ca_file); + + while ((cacert = PEM_read_bio_X509(filebio,NULL,NULL,NULL)) != NULL) { + char buf[256]; + X509_NAME_oneline(X509_get_subject_name(cacert), buf, sizeof(buf)); + if (!SSL_CTX_add_extra_chain_cert(s_ctx,cacert)) { + syslog(LOG_ERR,"TLS server engine: failed to add client_ca_cert to chain: %s",buf); + X509_free(cacert); + } else { + syslog(LOG_DEBUG,"TLS server engine: added CA cert to chain: %s",buf);
View file
cyrus-imapd-2.5.tar.gz/imap/tls.h
Changed
@@ -64,8 +64,8 @@ int tlsonly); int tls_init_clientengine(int verifydepth, - char *var_tls_cert_file, - char *var_tls_key_file); + const char *var_server_cert, + const char *var_server_key); /* start tls negotiation */ int tls_start_servertls(int readfd, int writefd, int timeout,
View file
cyrus-imapd-2.5.tar.gz/imap/tls_th-lock.c
Added
@@ -0,0 +1,70 @@ +/* tls_th-lock.c */ +/* Derived from openssl-0.9.8i/crypto/threads/th-lock.c + * by Duncan Gibb <duncan.gibb@siriusit.co.uk> + * 4 November 2008 + */ + +#include <config.h> +#include <pthread.h> +#include <syslog.h> + +#include <openssl/ssl.h> + +#include "tls_th-lock.h" + +static pthread_mutex_t *lock_cs; +static long *lock_count; + +void CRYPTO_thread_setup(void) +{ + int i; + + syslog(LOG_DEBUG, "Setting up pthreads TLS."); + + lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); + lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); + + for (i = 0; i < CRYPTO_num_locks(); i++) { + lock_count[i]=0; + pthread_mutex_init(&(lock_cs[i]),NULL); + } + + CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id); + CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback); +} + +void CRYPTO_thread_cleanup(void) +{ + int i; + + CRYPTO_set_locking_callback(NULL); + for (i = 0; i < CRYPTO_num_locks(); i++) { + pthread_mutex_destroy(&(lock_cs[i])); + } + + OPENSSL_free(lock_cs); + OPENSSL_free(lock_count); +} + +void pthreads_locking_callback( + int mode, + int type, + char *file, + int line +) { + if (mode & CRYPTO_LOCK) { + pthread_mutex_lock(&(lock_cs[type])); + lock_count[type]++; + } else { + pthread_mutex_unlock(&(lock_cs[type])); + } +} + +unsigned long pthreads_thread_id(void) +{ + unsigned long ret; + + ret = (unsigned long)pthread_self(); + return(ret); +} +
View file
cyrus-imapd-2.5.tar.gz/imap/tls_th-lock.h
Added
@@ -0,0 +1,22 @@ +/* tls_th-lock.h */ +/* Derived from openssl-0.9.8i/crypto/threads/th-lock.c + * by Duncan Gibb <duncan.gibb@siriusit.co.uk> + * 4 November 2008 + */ + +#ifndef INCLUDED_TLS_TH_LOCK_H +#define INCLUDED_TLS_TH_LOCK_H + +#ifdef HAVE_SSL + +void CRYPTO_thread_setup(void); +void CRYPTO_thread_cleanup(void); +/* +static void pthreads_locking_callback(int mode,int type,char *file,int line); +static unsigned long pthreads_thread_id(void ); +*/ +void pthreads_locking_callback(int mode,int type,char *file,int line); +unsigned long pthreads_thread_id(void ); + +#endif /* HAVE_SSL */ +#endif /* INCLUDED_TLS_TH_LOCK_H */
View file
cyrus-imapd-2.5.tar.gz/imtest/imtest.c
Changed
@@ -490,7 +490,7 @@ return IMTEST_FAIL; } - tls_ctx = SSL_CTX_new(TLSv1_client_method()); + tls_ctx = SSL_CTX_new(SSLv23_client_method()); if (tls_ctx == NULL) { return IMTEST_FAIL; };
View file
cyrus-imapd-2.5.tar.gz/lib/imapoptions
Changed
@@ -46,9 +46,9 @@ .SH NAME imapd.conf \- IMAP configuration file .SH DESCRIPTION -\fB/etc/imapd.conf\fR +\fB/etc/imapd.conf\fR is the configuration file for the Cyrus IMAP server. It defines -local parameters for IMAP. +local parameters for IMAP. .PP Each line of the \fB/etc/imapd.conf\fR file has the form .IP @@ -142,7 +142,7 @@ { "allowplaintext", 0, SWITCH } /* Allow the use of cleartext passwords on the wire. */ - + { "allowusermoves", 0, SWITCH } /* Allow moving user accounts (with associated meta-data) via RENAME or XFER. @@ -151,7 +151,7 @@ moved is not logged in, and cannot login during the move. Failure to do so may result in the user's meta-data (seen state, subscriptions, etc) being corrupted or out of date. */ - + { "altnamespace", 0, SWITCH } /* Use the alternate IMAP namespace, where personal folders reside at the same level in the hierarchy as INBOX. @@ -225,7 +225,7 @@ .\" .IP \fIproxy-type\fR 5 specifies whether this attribute is for the \fBbackend\fR or -\fBproxy\fR servers or both (\fBproxy_and_backend\fR) +\fBproxy\fR servers or both (\fBproxy_and_backend\fR) .\" .IP \fIattrib-names\fR 5 is the space-separated list of available attributes for the @@ -263,15 +263,69 @@ { "auth_mech", "unix", STRINGLIST("unix", "pts", "krb", "krb5")} /* The authorization mechanism to use. */ -{ "autocreatequota", 0, INT } +{ "autocreate_inbox_folders", NULL, STRING } +/* If a user does not have an INBOX created then the INBOX as well as some INBOX + subfolders are created under two conditions. + 1. The user logins via the IMAP or the POP3 protocol. (autocreatequota option must have a nonzero value) + 2. A message arrives for the user through the LMTPD protocol.(createonpost option must be yes) + autocreate_inbox_folders is a list of INBOX's subfolders separated by a "|", that + are automatically created by the server under the previous two situations. */ + +{ "autocreate_post", 0, SWITCH } +/* If enabled, when lmtpd receives an incoming mail for an INBOX that does not exist, + then the INBOX is automatically created by lmtpd. */ + +{ "autocreate_quota", 0, INT } /* If nonzero, normal users may create their own IMAP accounts by creating the mailbox INBOX. The user's quota is set to the value if it is positive, otherwise the user has unlimited quota. */ -{ "autocreatequotamsg", -1, INT } +{ "autocreate_quota_messages", -1, INT } /* When users create their own IMAP accounts by creating the mailbox INBOX, their message quota is set to this value. Default value (-1) is unlimited. */ +{ "autocreate_sieve_folders", NULL, STRING } +/* It is a "|" separated list of subfolders of INBOX that will be automatically created, + if requested by a sieve filter, through the "fileinto" action. (default = null) + i.e. autocreate_sieve_folders: Junk | Spam */ + +{ "autocreate_sieve_script", NULL, STRING } +/* The full path of a file that contains a sieve script. This script automatically becomes a + user's initial default sieve filter script. When this option is not defined, no default + sieve filter is created. The file must be readable by the cyrus daemon. */ + +{ "autocreate_sieve_script_compile", 0, SWITCH } +/* If set to yes and no compiled sieve script file exists, the sieve script which is + compiled on the fly will be saved in the file name that autocreate_sieve_compiledscript + option points to. In order a compiled script to be generated, autocreate_sieve_script and + autocreate_sieve_compiledscript must have valid values */ + +{ "autocreate_sieve_script_compiled", NULL, STRING } +/* The full path of a file that contains a compiled in bytecode sieve script. This script + automatically becomes a user's initial default sieve filter script. If this option is + not specified, or the filename doesn't exist then the script defined by + autocreate_sieve_script is compiled on the fly and installed as the user's default + sieve script */ + +{ "autocreate_subscribe_folders", NULL, STRING } +/* A list of folder names, separated by "|", that the users get automatically subscribed to, + when their INBOX is created. These folder names must have been included in the + autocreateinboxfolders option of the imapd.conf. */ + +{ "autocreate_subscribe_sharedfolders", NULL, STRING } +/* A list of shared folders (bulletin boards), separated by "|", that the users get + automatically subscribed to, after their INBOX is created. The shared folder must + have been created and the user must have the required permissions to get subscribed + to it. Otherwise, subscribing to the shared folder fails. */ + +{ "autocreate_subscribe_sharedfolders_all", 0, SWITCH } +/* If set to yes, the user is automatically subscribed to all shared folders, one has permission + to subscribe to. */ + +{ "autocreate_users", "anyone", STRING } +/* A space separated list of users and/or groups that are allowed their INBOX to be + automatically created. */ + { "berkeley_cachesize", 512, INT } /* Size (in kilobytes) of the shared memory buffer pool (cache) used by the berkeley environment. The minimum allowed value is 20. The @@ -303,55 +357,6 @@ /* Time in seconds. Any imap command that takes longer than this time is logged. */ -{ "createonpost", 0, SWITCH } -/* If yes, when lmtpd receives an incoming mail for an INBOX that does not exist, - then the INBOX is automatically created by lmtpd. */ - -{ "autocreateinboxfolders", NULL, STRING } -/* If a user does not have an INBOX created then the INBOX as well as some INBOX - subfolders are created under two conditions. - 1. The user logins via the IMAP or the POP3 protocol. (autocreatequota option must have a nonzero value) - 2. A message arrives for the user through the LMTPD protocol.(createonpost option must be yes) - autocreateinboxfolders is a list of INBOX's subfolders separated by a "|", that - are automatically created by the server under the previous two situations. */ - -{ "autosubscribeinboxfolders", NULL, STRING } -/* A list of folder names, separated by "|", that the users get automatically subscribed to, - when their INBOX is created. These folder names must have been included in the - autocreateinboxfolders option of the imapd.conf. */ - -{ "autosubscribesharedfolders", NULL, STRING } -/* A list of shared folders (bulletin boards), separated by "|", that the users get - automatically subscribed to, after their INBOX is created. The shared folder must - have been created and the user must have the required permissions to get subscribed - to it. Otherwise, subscribing to the shared folder fails. */ - -{ "autosubscribe_all_sharedfolders", 0, SWITCH } -/* If set to yes, the user is automatically subscribed to all shared folders, one has permission - to subscribe to. */ - -{ "autocreate_sieve_script", NULL, STRING } -/* The full path of a file that contains a sieve script. This script automatically becomes a - user's initial default sieve filter script. When this option is not defined, no default - sieve filter is created. The file must be readable by the cyrus daemon. */ - -{ "autocreate_sieve_compiledscript", NULL, STRING } -/* The full path of a file that contains a compiled in bytecode sieve script. This script - automatically becomes a user's initial default sieve filter script. If this option is - not specified, or the filename doesn't exist then the script defined by - autocreate_sieve_script is compiled on the fly and installed as the user's default - sieve script */ - -{ "generate_compiled_sieve_script", 0, SWITCH } -/* If set to yes and no compiled sieve script file exists, the sieve script which is - compiled on the fly will be saved in the file name that autocreate_sieve_compiledscript - option points to. In order a compiled script to be generated, autocreate_sieve_script and - autocreate_sieve_compiledscript must have valid values */ - -{ "autocreate_users", "anyone", STRING } -/* A space separated list of users and/or groups that are allowed their INBOX to be - automatically created. */ - { "configdirectory", NULL, STRING } /* The pathname of the IMAP configuration directory. This field is required. */ @@ -398,12 +403,12 @@ right, they will automatically be given the new 'x' right. */ { "disable_user_namespace", 0, SWITCH } -/* Preclude list command on user namespace. If set to 'yes', the +/* Preclude list command on user namespace. If set to 'yes', the LIST response will never include any other user's mailbox. Admin users will always see all mailboxes. The default is 'no' */ { "disable_shared_namespace", 0, SWITCH } -/* Preclude list command on user namespace. If set to 'yes', the +/* Preclude list command on shared namespace. If set to 'yes', the LIST response will never include any non-user mailboxes. Admin users will always see all mailboxes. The default is 'no' */ @@ -431,24 +436,24 @@ /* The mode in which message content may be included with MessageAppend and MessageNew. "standard" mode is the default behavior in which message is included up to a size with the notification. In "message" mode, the message - is included and may be truncated to a size. In "header" mode, it includes - headers truncated to a size. In "body" mode, it includes body truncated + is included and may be truncated to a size. In "header" mode, it includes + headers truncated to a size. In "body" mode, it includes body truncated to a size. In "headerbody" mode, it includes full headers and body truncated to a size */ { "event_content_size", 0, INT } -/* Truncate the message content that may be included with MessageAppend and +/* Truncate the message content that may be included with MessageAppend and MessageNew. Set 0 to include the entire message itself */ { "event_exclude_flags", NULL, STRING } /* Don't send event notification for given IMAP flag(s) */
View file
cyrus-imapd-2.5.tar.gz/ptclient/ldap.c
Changed
@@ -77,6 +77,7 @@ #include "auth_pts.h" #include "strhash.h" #include "xmalloc.h" +#include "xstrlcat.h" /* xxx this just uses the UNIX canonicalization semantics, which is * most likely wrong */ @@ -506,12 +507,12 @@ config_getstring(IMAPOPT_LDAP_PASSWORD) : config_getstring(IMAPOPT_LDAP_SASL_PASSWORD)); ptsm->start_tls = config_getswitch(IMAPOPT_LDAP_START_TLS); - ptsm->tls_check_peer = config_getswitch(IMAPOPT_LDAP_TLS_CHECK_PEER); - ptsm->tls_cacert_file = config_getstring(IMAPOPT_LDAP_TLS_CACERT_FILE); - ptsm->tls_cacert_dir = config_getstring(IMAPOPT_LDAP_TLS_CACERT_DIR); - ptsm->tls_ciphers = config_getstring(IMAPOPT_LDAP_TLS_CIPHERS); - ptsm->tls_cert = config_getstring(IMAPOPT_LDAP_TLS_CERT); - ptsm->tls_key = config_getstring(IMAPOPT_LDAP_TLS_KEY); + ptsm->tls_check_peer = config_getswitch(IMAPOPT_LDAP_VERIFY_PEER); + ptsm->tls_cacert_file = config_getstring(IMAPOPT_LDAP_CA_FILE); + ptsm->tls_cacert_dir = config_getstring(IMAPOPT_LDAP_CA_DIR); + ptsm->tls_ciphers = config_getstring(IMAPOPT_LDAP_CIPHERS); + ptsm->tls_cert = config_getstring(IMAPOPT_LDAP_CLIENT_CERT); + ptsm->tls_key = config_getstring(IMAPOPT_LDAP_CLIENT_KEY); p = config_getstring(IMAPOPT_LDAP_MEMBER_METHOD); if (!strcasecmp(p, "filter")) { @@ -628,7 +629,7 @@ return PTSM_OK; } -static int *ptsmodule_standard_root_dn(const char *domain, const char **result) +static int ptsmodule_standard_root_dn(char *domain, const char **result) { /* number of dots */ int dots; @@ -1110,8 +1111,7 @@ if (Uisupper(rdn[0][j])) rdn[0][j]=tolower(rdn[0][j]); } - strlcat((*newstate)->groups[i].id, rdn[0], - sizeof((*newstate)->groups[i].id)); + strlcat((*newstate)->groups[i].id, rdn[0], sizeof((*newstate)->groups[i].id)); (*newstate)->groups[i].hash = strhash((*newstate)->groups[i].id); } @@ -1278,8 +1278,7 @@ vals[0][j]=tolower(vals[0][j]); } - strlcat((*newstate)->groups[i].id, vals[0], - sizeof((*newstate)->groups[i].id)); + strlcat((*newstate)->groups[i].id, vals[0], sizeof((*newstate)->groups[i].id)); (*newstate)->groups[i].hash = strhash((*newstate)->groups[i].id); ldap_value_free(vals); @@ -1314,7 +1313,7 @@ char domain_filter[1024]; char *domain_attrs[] = {(char *)ptsm->domain_name_attribute,(char *)ptsm->domain_result_attribute,NULL}; int rc; - int i; int n; + int n; LDAPMessage *res = NULL; LDAPMessage *entry = NULL; char **vals = NULL;
View file
cyrus-imapd.dsc
Changed
@@ -2,7 +2,7 @@ Source: cyrus-imapd Binary: cyrus-imapd Architecture: any -Version: 2.5~dev2014100701-0~kolab1 +Version: 2.5~dev2014101701-0~kolab1 Maintainer: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> Uploaders: Paul Klos <kolab@klos2day.nl> Homepage: http://www.cyrusimap.org/
View file
debian.changelog
Changed
@@ -1,3 +1,10 @@ +cyrus-imapd (2.5~dev2014101701-0~kolab1) unstable; urgency=low + + * Ship a GIT development snapshot from git.cyrusimap.org + 9704e5d41981a18f46a63af78cf02c63fe3824a6 + + -- Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> Fri, 17 Oct 2014 11:30:13 +0100 + cyrus-imapd (2.5~dev2014100701-0~kolab1) unstable; urgency=low * Ship a GIT development snapshot from git.cyrusimap.org
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.