diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/lib-storage/index/shared | |
parent | Initial commit. (diff) | |
download | dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib-storage/index/shared')
-rw-r--r-- | src/lib-storage/index/shared/Makefile.am | 19 | ||||
-rw-r--r-- | src/lib-storage/index/shared/Makefile.in | 817 | ||||
-rw-r--r-- | src/lib-storage/index/shared/shared-list.c | 310 | ||||
-rw-r--r-- | src/lib-storage/index/shared/shared-storage.c | 379 | ||||
-rw-r--r-- | src/lib-storage/index/shared/shared-storage.h | 22 |
5 files changed, 1547 insertions, 0 deletions
diff --git a/src/lib-storage/index/shared/Makefile.am b/src/lib-storage/index/shared/Makefile.am new file mode 100644 index 0000000..07980d6 --- /dev/null +++ b/src/lib-storage/index/shared/Makefile.am @@ -0,0 +1,19 @@ +noinst_LTLIBRARIES = libstorage_shared.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-imap \ + -I$(top_srcdir)/src/lib-index \ + -I$(top_srcdir)/src/lib-storage \ + -I$(top_srcdir)/src/lib-storage/index + +libstorage_shared_la_SOURCES = \ + shared-list.c \ + shared-storage.c + +headers = \ + shared-storage.h + +pkginc_libdir=$(pkgincludedir) +pkginc_lib_HEADERS = $(headers) diff --git a/src/lib-storage/index/shared/Makefile.in b/src/lib-storage/index/shared/Makefile.in new file mode 100644 index 0000000..3c7d4e1 --- /dev/null +++ b/src/lib-storage/index/shared/Makefile.in @@ -0,0 +1,817 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/lib-storage/index/shared +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_checktype2.m4 \ + $(top_srcdir)/m4/ac_typeof.m4 $(top_srcdir)/m4/arc4random.m4 \ + $(top_srcdir)/m4/blockdev.m4 $(top_srcdir)/m4/c99_vsnprintf.m4 \ + $(top_srcdir)/m4/clock_gettime.m4 $(top_srcdir)/m4/crypt.m4 \ + $(top_srcdir)/m4/crypt_xpg6.m4 $(top_srcdir)/m4/dbqlk.m4 \ + $(top_srcdir)/m4/dirent_dtype.m4 $(top_srcdir)/m4/dovecot.m4 \ + $(top_srcdir)/m4/fd_passing.m4 $(top_srcdir)/m4/fdatasync.m4 \ + $(top_srcdir)/m4/flexible_array_member.m4 \ + $(top_srcdir)/m4/glibc.m4 $(top_srcdir)/m4/gmtime_max.m4 \ + $(top_srcdir)/m4/gmtime_tm_gmtoff.m4 \ + $(top_srcdir)/m4/ioloop.m4 $(top_srcdir)/m4/iovec.m4 \ + $(top_srcdir)/m4/ipv6.m4 $(top_srcdir)/m4/libcap.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libwrap.m4 \ + $(top_srcdir)/m4/linux_mremap.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/mmap_write.m4 \ + $(top_srcdir)/m4/mntctl.m4 $(top_srcdir)/m4/modules.m4 \ + $(top_srcdir)/m4/notify.m4 $(top_srcdir)/m4/nsl.m4 \ + $(top_srcdir)/m4/off_t_max.m4 $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/pr_set_dumpable.m4 \ + $(top_srcdir)/m4/q_quotactl.m4 $(top_srcdir)/m4/quota.m4 \ + $(top_srcdir)/m4/random.m4 $(top_srcdir)/m4/rlimit.m4 \ + $(top_srcdir)/m4/sendfile.m4 $(top_srcdir)/m4/size_t_signed.m4 \ + $(top_srcdir)/m4/sockpeercred.m4 $(top_srcdir)/m4/sql.m4 \ + $(top_srcdir)/m4/ssl.m4 $(top_srcdir)/m4/st_tim.m4 \ + $(top_srcdir)/m4/static_array.m4 $(top_srcdir)/m4/test_with.m4 \ + $(top_srcdir)/m4/time_t.m4 $(top_srcdir)/m4/typeof.m4 \ + $(top_srcdir)/m4/typeof_dev_t.m4 \ + $(top_srcdir)/m4/uoff_t_max.m4 $(top_srcdir)/m4/vararg.m4 \ + $(top_srcdir)/m4/want_apparmor.m4 \ + $(top_srcdir)/m4/want_bsdauth.m4 \ + $(top_srcdir)/m4/want_bzlib.m4 \ + $(top_srcdir)/m4/want_cassandra.m4 \ + $(top_srcdir)/m4/want_cdb.m4 \ + $(top_srcdir)/m4/want_checkpassword.m4 \ + $(top_srcdir)/m4/want_clucene.m4 $(top_srcdir)/m4/want_db.m4 \ + $(top_srcdir)/m4/want_gssapi.m4 $(top_srcdir)/m4/want_icu.m4 \ + $(top_srcdir)/m4/want_ldap.m4 $(top_srcdir)/m4/want_lua.m4 \ + $(top_srcdir)/m4/want_lz4.m4 $(top_srcdir)/m4/want_lzma.m4 \ + $(top_srcdir)/m4/want_mysql.m4 $(top_srcdir)/m4/want_pam.m4 \ + $(top_srcdir)/m4/want_passwd.m4 $(top_srcdir)/m4/want_pgsql.m4 \ + $(top_srcdir)/m4/want_prefetch.m4 \ + $(top_srcdir)/m4/want_shadow.m4 \ + $(top_srcdir)/m4/want_sodium.m4 $(top_srcdir)/m4/want_solr.m4 \ + $(top_srcdir)/m4/want_sqlite.m4 \ + $(top_srcdir)/m4/want_stemmer.m4 \ + $(top_srcdir)/m4/want_systemd.m4 \ + $(top_srcdir)/m4/want_textcat.m4 \ + $(top_srcdir)/m4/want_unwind.m4 $(top_srcdir)/m4/want_zlib.m4 \ + $(top_srcdir)/m4/want_zstd.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(pkginc_lib_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libstorage_shared_la_LIBADD = +am_libstorage_shared_la_OBJECTS = shared-list.lo shared-storage.lo +libstorage_shared_la_OBJECTS = $(am_libstorage_shared_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/shared-list.Plo \ + ./$(DEPDIR)/shared-storage.Plo +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libstorage_shared_la_SOURCES) +DIST_SOURCES = $(libstorage_shared_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(pkginc_libdir)" +HEADERS = $(pkginc_lib_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPARMOR_LIBS = @APPARMOR_LIBS@ +AR = @AR@ +AUTH_CFLAGS = @AUTH_CFLAGS@ +AUTH_LIBS = @AUTH_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BINARY_CFLAGS = @BINARY_CFLAGS@ +BINARY_LDFLAGS = @BINARY_LDFLAGS@ +BISON = @BISON@ +CASSANDRA_CFLAGS = @CASSANDRA_CFLAGS@ +CASSANDRA_LIBS = @CASSANDRA_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CDB_LIBS = @CDB_LIBS@ +CFLAGS = @CFLAGS@ +CLUCENE_CFLAGS = @CLUCENE_CFLAGS@ +CLUCENE_LIBS = @CLUCENE_LIBS@ +COMPRESS_LIBS = @COMPRESS_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPT_LIBS = @CRYPT_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DICT_LIBS = @DICT_LIBS@ +DLLIB = @DLLIB@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FLEX = @FLEX@ +FUZZER_CPPFLAGS = @FUZZER_CPPFLAGS@ +FUZZER_LDFLAGS = @FUZZER_LDFLAGS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KRB5CONFIG = @KRB5CONFIG@ +KRB5_CFLAGS = @KRB5_CFLAGS@ +KRB5_LIBS = @KRB5_LIBS@ +LD = @LD@ +LDAP_LIBS = @LDAP_LIBS@ +LDFLAGS = @LDFLAGS@ +LD_NO_WHOLE_ARCHIVE = @LD_NO_WHOLE_ARCHIVE@ +LD_WHOLE_ARCHIVE = @LD_WHOLE_ARCHIVE@ +LIBCAP = @LIBCAP@ +LIBDOVECOT = @LIBDOVECOT@ +LIBDOVECOT_COMPRESS = @LIBDOVECOT_COMPRESS@ +LIBDOVECOT_DEPS = @LIBDOVECOT_DEPS@ +LIBDOVECOT_DSYNC = @LIBDOVECOT_DSYNC@ +LIBDOVECOT_LA_LIBS = @LIBDOVECOT_LA_LIBS@ +LIBDOVECOT_LDA = @LIBDOVECOT_LDA@ +LIBDOVECOT_LDAP = @LIBDOVECOT_LDAP@ +LIBDOVECOT_LIBFTS = @LIBDOVECOT_LIBFTS@ +LIBDOVECOT_LIBFTS_DEPS = @LIBDOVECOT_LIBFTS_DEPS@ +LIBDOVECOT_LOGIN = @LIBDOVECOT_LOGIN@ +LIBDOVECOT_LUA = @LIBDOVECOT_LUA@ +LIBDOVECOT_LUA_DEPS = @LIBDOVECOT_LUA_DEPS@ +LIBDOVECOT_SQL = @LIBDOVECOT_SQL@ +LIBDOVECOT_STORAGE = @LIBDOVECOT_STORAGE@ +LIBDOVECOT_STORAGE_DEPS = @LIBDOVECOT_STORAGE_DEPS@ +LIBEXTTEXTCAT_CFLAGS = @LIBEXTTEXTCAT_CFLAGS@ +LIBEXTTEXTCAT_LIBS = @LIBEXTTEXTCAT_LIBS@ +LIBICONV = @LIBICONV@ +LIBICU_CFLAGS = @LIBICU_CFLAGS@ +LIBICU_LIBS = @LIBICU_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSODIUM_CFLAGS = @LIBSODIUM_CFLAGS@ +LIBSODIUM_LIBS = @LIBSODIUM_LIBS@ +LIBTIRPC_CFLAGS = @LIBTIRPC_CFLAGS@ +LIBTIRPC_LIBS = @LIBTIRPC_LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@ +LIBUNWIND_LIBS = @LIBUNWIND_LIBS@ +LIBWRAP_LIBS = @LIBWRAP_LIBS@ +LINKED_STORAGE_LDADD = @LINKED_STORAGE_LDADD@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LUA_CFLAGS = @LUA_CFLAGS@ +LUA_LIBS = @LUA_LIBS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MODULE_LIBS = @MODULE_LIBS@ +MODULE_SUFFIX = @MODULE_SUFFIX@ +MYSQL_CFLAGS = @MYSQL_CFLAGS@ +MYSQL_CONFIG = @MYSQL_CONFIG@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOPLUGIN_LDFLAGS = @NOPLUGIN_LDFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PANDOC = @PANDOC@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PGSQL_CFLAGS = @PGSQL_CFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PG_CONFIG = @PG_CONFIG@ +PIE_CFLAGS = @PIE_CFLAGS@ +PIE_LDFLAGS = @PIE_LDFLAGS@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +QUOTA_LIBS = @QUOTA_LIBS@ +RANLIB = @RANLIB@ +RELRO_LDFLAGS = @RELRO_LDFLAGS@ +RPCGEN = @RPCGEN@ +RUN_TEST = @RUN_TEST@ +SED = @SED@ +SETTING_FILES = @SETTING_FILES@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SQLITE_CFLAGS = @SQLITE_CFLAGS@ +SQLITE_LIBS = @SQLITE_LIBS@ +SQL_CFLAGS = @SQL_CFLAGS@ +SQL_LIBS = @SQL_LIBS@ +SSL_CFLAGS = @SSL_CFLAGS@ +SSL_LIBS = @SSL_LIBS@ +STRIP = @STRIP@ +SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS = @SYSTEMD_LIBS@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +ZSTD_CFLAGS = @ZSTD_CFLAGS@ +ZSTD_LIBS = @ZSTD_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +dict_drivers = @dict_drivers@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +rundir = @rundir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sql_drivers = @sql_drivers@ +srcdir = @srcdir@ +ssldir = @ssldir@ +statedir = @statedir@ +sysconfdir = @sysconfdir@ +systemdservicetype = @systemdservicetype@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LTLIBRARIES = libstorage_shared.la +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-imap \ + -I$(top_srcdir)/src/lib-index \ + -I$(top_srcdir)/src/lib-storage \ + -I$(top_srcdir)/src/lib-storage/index + +libstorage_shared_la_SOURCES = \ + shared-list.c \ + shared-storage.c + +headers = \ + shared-storage.h + +pkginc_libdir = $(pkgincludedir) +pkginc_lib_HEADERS = $(headers) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/lib-storage/index/shared/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/lib-storage/index/shared/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libstorage_shared.la: $(libstorage_shared_la_OBJECTS) $(libstorage_shared_la_DEPENDENCIES) $(EXTRA_libstorage_shared_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libstorage_shared_la_OBJECTS) $(libstorage_shared_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shared-list.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shared-storage.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-pkginc_libHEADERS: $(pkginc_lib_HEADERS) + @$(NORMAL_INSTALL) + @list='$(pkginc_lib_HEADERS)'; test -n "$(pkginc_libdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkginc_libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkginc_libdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkginc_libdir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkginc_libdir)" || exit $$?; \ + done + +uninstall-pkginc_libHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(pkginc_lib_HEADERS)'; test -n "$(pkginc_libdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkginc_libdir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(pkginc_libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/shared-list.Plo + -rm -f ./$(DEPDIR)/shared-storage.Plo + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pkginc_libHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/shared-list.Plo + -rm -f ./$(DEPDIR)/shared-storage.Plo + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pkginc_libHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-noinstLTLIBRARIES \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-pkginc_libHEADERS install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-pkginc_libHEADERS + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/lib-storage/index/shared/shared-list.c b/src/lib-storage/index/shared/shared-list.c new file mode 100644 index 0000000..c69c4db --- /dev/null +++ b/src/lib-storage/index/shared/shared-list.c @@ -0,0 +1,310 @@ +/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "imap-match.h" +#include "mailbox-tree.h" +#include "mailbox-list-private.h" +#include "index-storage.h" +#include "shared-storage.h" + +extern struct mailbox_list shared_mailbox_list; + +static struct mailbox_list *shared_list_alloc(void) +{ + struct mailbox_list *list; + pool_t pool; + + pool = pool_alloconly_create("shared list", 2048); + list = p_new(pool, struct mailbox_list, 1); + *list = shared_mailbox_list; + list->pool = pool; + return list; +} + +static void shared_list_deinit(struct mailbox_list *list) +{ + pool_unref(&list->pool); +} + +static void shared_list_copy_error(struct mailbox_list *shared_list, + struct mail_namespace *backend_ns) +{ + const char *str; + enum mail_error error; + + str = mailbox_list_get_last_error(backend_ns->list, &error); + mailbox_list_set_error(shared_list, error, str); +} + +static int +shared_get_storage(struct mailbox_list **list, const char *vname, + struct mail_storage **storage_r) +{ + struct mail_namespace *ns = (*list)->ns; + const char *name; + + name = mailbox_list_get_storage_name(*list, vname); + if (*name == '\0' && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) { + /* trying to access the shared/ prefix itself */ + *storage_r = ns->storage; + return 0; + } + + if (shared_storage_get_namespace(&ns, &name) < 0) + return -1; + *list = ns->list; + return mailbox_list_get_storage(list, vname, storage_r); +} + +static char shared_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED) +{ + return '/'; +} + +static int +shared_list_get_path(struct mailbox_list *list, const char *name, + enum mailbox_list_path_type type, const char **path_r) +{ + struct mail_namespace *ns = list->ns; + + if (mail_namespace_get_default_storage(list->ns) == NULL || + name == NULL || + shared_storage_get_namespace(&ns, &name) < 0) { + /* we don't have a directory we can use. */ + *path_r = NULL; + return 0; + } + return mailbox_list_get_path(ns->list, name, type, path_r); +} + +static const char * +shared_list_get_temp_prefix(struct mailbox_list *list, bool global ATTR_UNUSED) +{ + i_panic("shared mailbox list: Can't return a temp prefix for '%s'", + list->ns->prefix); +} + +static const char * +shared_list_join_refpattern(struct mailbox_list *list, + const char *ref, const char *pattern) +{ + struct mail_namespace *ns = list->ns; + const char *ns_ref, *prefix = list->ns->prefix; + size_t prefix_len = strlen(prefix); + + if (*ref != '\0' && str_begins(ref, prefix)) + ns_ref = ref + prefix_len; + else + ns_ref = NULL; + + if (ns_ref != NULL && *ns_ref != '\0' && + shared_storage_get_namespace(&ns, &ns_ref) == 0) + return mailbox_list_join_refpattern(ns->list, ref, pattern); + + /* fallback to default behavior */ + if (*ref != '\0') + pattern = t_strconcat(ref, pattern, NULL); + return pattern; +} + +static void +shared_list_create_missing_namespaces(struct mailbox_list *list, + const char *const *patterns) +{ + struct mail_namespace *ns; + char sep = mail_namespace_get_sep(list->ns); + const char *list_pat, *name; + unsigned int i; + + for (i = 0; patterns[i] != NULL; i++) { + const char *last = NULL, *p; + + /* we'll require that the pattern begins with the list's + namespace prefix. we could also handle other patterns + (e.g. %/user/%), but it's more of a theoretical problem. */ + if (strncmp(list->ns->prefix, patterns[i], + list->ns->prefix_len) != 0) + continue; + list_pat = patterns[i] + list->ns->prefix_len; + + for (p = list_pat; *p != '\0'; p++) { + if (*p == '%' || *p == '*') + break; + if (*p == sep) + last = p; + } + if (last != NULL) { + ns = list->ns; + name = t_strdup_until(list_pat, last); + (void)shared_storage_get_namespace(&ns, &name); + } + } +} + +static struct mailbox_list_iterate_context * +shared_list_iter_init(struct mailbox_list *list, const char *const *patterns, + enum mailbox_list_iter_flags flags) +{ + struct mailbox_list_iterate_context *ctx; + pool_t pool; + char sep = mail_namespace_get_sep(list->ns); + + pool = pool_alloconly_create("mailbox list shared iter", 1024); + ctx = p_new(pool, struct mailbox_list_iterate_context, 1); + ctx->pool = pool; + ctx->list = list; + ctx->flags = flags; + ctx->glob = imap_match_init_multiple(pool, patterns, FALSE, sep); + array_create(&ctx->module_contexts, pool, sizeof(void *), 5); + + if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 && + (list->ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) T_BEGIN { + shared_list_create_missing_namespaces(list, patterns); + } T_END; + return ctx; +} + +static const struct mailbox_info * +shared_list_iter_next(struct mailbox_list_iterate_context *ctx ATTR_UNUSED) +{ + return NULL; +} + +static int shared_list_iter_deinit(struct mailbox_list_iterate_context *ctx) +{ + pool_unref(&ctx->pool); + return 0; +} + +static int +shared_list_subscriptions_refresh(struct mailbox_list *src_list, + struct mailbox_list *dest_list) +{ + char sep; + + if (dest_list->subscriptions == NULL) { + sep = mail_namespace_get_sep(src_list->ns); + dest_list->subscriptions = mailbox_tree_init(sep); + } + return 0; +} + +static int shared_list_set_subscribed(struct mailbox_list *list, + const char *name, bool set) +{ + struct mail_namespace *ns = list->ns; + int ret; + + if (shared_storage_get_namespace(&ns, &name) < 0) + return -1; + ret = mailbox_list_set_subscribed(ns->list, name, set); + if (ret < 0) + shared_list_copy_error(list, ns); + return ret; +} + +static int +shared_list_delete_mailbox(struct mailbox_list *list, const char *name) +{ + struct mail_namespace *ns = list->ns; + int ret; + + if (shared_storage_get_namespace(&ns, &name) < 0) + return -1; + ret = ns->list->v.delete_mailbox(ns->list, name); + if (ret < 0) + shared_list_copy_error(list, ns); + return ret; +} + +static int +shared_list_delete_dir(struct mailbox_list *list, const char *name) +{ + struct mail_namespace *ns = list->ns; + int ret; + + if (shared_storage_get_namespace(&ns, &name) < 0) + return -1; + ret = mailbox_list_delete_dir(ns->list, name); + if (ret < 0) + shared_list_copy_error(list, ns); + return ret; +} + +static int +shared_list_delete_symlink(struct mailbox_list *list, const char *name) +{ + struct mail_namespace *ns = list->ns; + int ret; + + if (shared_storage_get_namespace(&ns, &name) < 0) + return -1; + ret = mailbox_list_delete_symlink(ns->list, name); + if (ret < 0) + shared_list_copy_error(list, ns); + return ret; +} + +static int shared_list_rename_get_ns(struct mailbox_list *oldlist, + const char **oldname, + struct mailbox_list *newlist, + const char **newname, + struct mail_namespace **ns_r) +{ + struct mail_namespace *old_ns = oldlist->ns, *new_ns = newlist->ns; + + if (shared_storage_get_namespace(&old_ns, oldname) < 0 || + shared_storage_get_namespace(&new_ns, newname) < 0) + return -1; + if (old_ns != new_ns) { + mailbox_list_set_error(oldlist, MAIL_ERROR_NOTPOSSIBLE, + "Can't rename shared mailboxes across storages."); + return -1; + } + *ns_r = old_ns; + return 0; +} + +static int +shared_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname, + struct mailbox_list *newlist, const char *newname) +{ + struct mail_namespace *ns; + int ret; + + if (shared_list_rename_get_ns(oldlist, &oldname, + newlist, &newname, &ns) < 0) + return -1; + + ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname); + if (ret < 0) + shared_list_copy_error(oldlist, ns); + return ret; +} + +struct mailbox_list shared_mailbox_list = { + .name = "shared", + .props = 0, + .mailbox_name_max_length = MAILBOX_LIST_NAME_MAX_LENGTH, + + .v = { + .alloc = shared_list_alloc, + .deinit = shared_list_deinit, + .get_storage = shared_get_storage, + .get_hierarchy_sep = shared_list_get_hierarchy_sep, + .get_vname = mailbox_list_default_get_vname, + .get_storage_name = mailbox_list_default_get_storage_name, + .get_path = shared_list_get_path, + .get_temp_prefix = shared_list_get_temp_prefix, + .join_refpattern = shared_list_join_refpattern, + .iter_init = shared_list_iter_init, + .iter_next = shared_list_iter_next, + .iter_deinit = shared_list_iter_deinit, + .subscriptions_refresh = shared_list_subscriptions_refresh, + .set_subscribed = shared_list_set_subscribed, + .delete_mailbox = shared_list_delete_mailbox, + .delete_dir = shared_list_delete_dir, + .delete_symlink = shared_list_delete_symlink, + .rename_mailbox = shared_list_rename_mailbox, + } +}; diff --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c new file mode 100644 index 0000000..978949e --- /dev/null +++ b/src/lib-storage/index/shared/shared-storage.c @@ -0,0 +1,379 @@ +/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "str.h" +#include "ioloop.h" +#include "var-expand.h" +#include "index-storage.h" +#include "mail-storage-service.h" +#include "mailbox-list-private.h" +#include "fail-mail-storage.h" +#include "shared-storage.h" + +#include <ctype.h> + +extern struct mail_storage shared_storage; + +static struct mail_storage *shared_storage_alloc(void) +{ + struct shared_storage *storage; + pool_t pool; + + pool = pool_alloconly_create("shared storage", 1024); + storage = p_new(pool, struct shared_storage, 1); + storage->storage = shared_storage; + storage->storage.pool = pool; + return &storage->storage; +} + +static int +shared_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, + const char **error_r) +{ + struct shared_storage *storage = SHARED_STORAGE(_storage); + const char *driver, *p; + char *wildcardp, key; + bool have_username; + + /* location must begin with the actual mailbox driver */ + p = strchr(ns->set->location, ':'); + if (p == NULL) { + *error_r = "Shared mailbox location not prefixed with driver"; + return -1; + } + driver = t_strdup_until(ns->set->location, p); + storage->location = p_strdup(_storage->pool, ns->set->location); + storage->unexpanded_location = + p_strdup(_storage->pool, ns->unexpanded_set->location); + storage->storage_class_name = p_strdup(_storage->pool, driver); + + if (mail_user_get_storage_class(_storage->user, driver) == NULL && + strcmp(driver, "auto") != 0) { + *error_r = t_strconcat("Unknown shared storage driver: ", + driver, NULL); + return -1; + } + + wildcardp = strchr(ns->prefix, '%'); + if (wildcardp == NULL) { + *error_r = "Shared namespace prefix doesn't contain %"; + return -1; + } + storage->ns_prefix_pattern = p_strdup(_storage->pool, wildcardp); + + have_username = FALSE; + for (p = storage->ns_prefix_pattern; *p != '\0'; p++) { + if (*p != '%') + continue; + + key = p[1]; + if (key == 'u' || key == 'n') + have_username = TRUE; + else if (key != '%' && key != 'd') + break; + } + if (*p != '\0') { + *error_r = "Shared namespace prefix contains unknown variables"; + return -1; + } + if (!have_username) { + *error_r = "Shared namespace prefix doesn't contain %u or %n"; + return -1; + } + if (p[-1] != mail_namespace_get_sep(ns) && + (ns->flags & (NAMESPACE_FLAG_LIST_PREFIX | + NAMESPACE_FLAG_LIST_CHILDREN)) != 0) { + *error_r = "Shared namespace prefix doesn't end with hierarchy separator"; + return -1; + } + + /* truncate prefix after the above checks are done, so they can log + the full prefix in error conditions */ + *wildcardp = '\0'; + ns->prefix_len = strlen(ns->prefix); + return 0; +} + +static void +shared_storage_get_list_settings(const struct mail_namespace *ns ATTR_UNUSED, + struct mailbox_list_settings *set) +{ + set->layout = "shared"; +} + +static void +get_nonexistent_user_location(struct shared_storage *storage, + const char *username, string_t *location) +{ + /* user wasn't found. we'll still need to create the storage + to avoid exposing which users exist and which don't. */ + str_append(location, storage->storage_class_name); + str_append_c(location, ':'); + + /* use a reachable but nonexistent path as the mail root directory */ + str_append(location, storage->storage.user->set->base_dir); + str_append(location, "/user-not-found/"); + str_append(location, username); +} + +static bool shared_namespace_exists(struct mail_namespace *ns) +{ + const char *path; + struct stat st; + + if (!mailbox_list_get_root_path(ns->list, MAILBOX_LIST_PATH_TYPE_DIR, + &path)) { + /* we can't know if this exists */ + return TRUE; + } + return stat(path, &st) == 0; +} + +int shared_storage_get_namespace(struct mail_namespace **_ns, + const char **_name) +{ + struct mail_storage *_storage = (*_ns)->storage; + struct mailbox_list *list = (*_ns)->list; + struct shared_storage *storage = SHARED_STORAGE(_storage); + struct mail_user *user = _storage->user; + struct mail_namespace *new_ns, *ns = *_ns; + struct mail_namespace_settings *ns_set, *unexpanded_ns_set; + struct mail_user *owner; + const char *domain = NULL, *username = NULL, *userdomain = NULL; + const char *name, *p, *next, **dest, *error; + string_t *prefix, *location; + char ns_sep = mail_namespace_get_sep(ns); + int ret; + + p = storage->ns_prefix_pattern; + for (name = *_name; *p != '\0';) { + if (*p != '%') { + if (*p != *name) + break; + p++; name++; + continue; + } + switch (*++p) { + case 'd': + dest = &domain; + break; + case 'n': + dest = &username; + break; + case 'u': + dest = &userdomain; + break; + default: + /* we checked this already above */ + i_unreached(); + } + p++; + + next = strchr(name, *p != '\0' ? *p : ns_sep); + if (next == NULL) { + *dest = name; + name = ""; + break; + } + *dest = t_strdup_until(name, next); + name = next; + } + if (*p != '\0') { + if (*name == '\0' || + (name[1] == '\0' && *name == ns_sep)) { + /* trying to open <prefix>/<user> mailbox */ + name = "INBOX"; + } else { + mailbox_list_set_critical(list, + "Invalid namespace prefix %s vs %s", + storage->ns_prefix_pattern, *_name); + return -1; + } + } + + /* successfully matched the name. */ + if (userdomain != NULL) { + /* user@domain given */ + domain = strchr(userdomain, '@'); + if (domain == NULL) + username = userdomain; + else { + username = t_strdup_until(userdomain, domain); + domain++; + } + } else if (username == NULL) { + /* trying to open namespace "shared/domain" + namespace prefix. */ + mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(*_name)); + return -1; + } else { + if (domain == NULL) { + /* no domain given, use ours (if we have one) */ + domain = i_strchr_to_next(user->username, '@'); + } + userdomain = domain == NULL ? username : + t_strconcat(username, "@", domain, NULL); + } + if (*userdomain == '\0') { + mailbox_list_set_error(list, MAIL_ERROR_PARAMS, + "Empty username doesn't exist"); + return -1; + } + + /* expand the namespace prefix and see if it already exists. + this should normally happen only when the mailbox is being opened */ + struct var_expand_table tab[] = { + { 'u', userdomain, "user" }, + { 'n', username, "username" }, + { 'd', domain, "domain" }, + { 'h', NULL, "home" }, + { '\0', NULL, NULL } + }; + + prefix = t_str_new(128); + str_append(prefix, ns->prefix); + if (var_expand(prefix, storage->ns_prefix_pattern, tab, &error) <= 0) { + mailbox_list_set_critical(list, + "Failed to expand namespace prefix '%s': %s", + storage->ns_prefix_pattern, error); + return -1; + } + + *_ns = mail_namespace_find_prefix(user->namespaces, str_c(prefix)); + if (*_ns != NULL) { + *_name = mailbox_list_get_storage_name(ns->list, + t_strconcat(ns->prefix, name, NULL)); + return 0; + } + + owner = mail_user_alloc(event_get_parent(user->event), userdomain, + user->set_info, user->unexpanded_set); + owner->_service_user = user->_service_user; + mail_storage_service_user_ref(owner->_service_user); + owner->creator = user; + owner->autocreated = TRUE; + owner->session_id = p_strdup(owner->pool, user->session_id); + if (mail_user_init(owner, &error) < 0) { + if (!owner->nonexistent) { + mailbox_list_set_critical(list, + "Couldn't create namespace '%s' for user %s: %s", + ns->prefix, userdomain, error); + mail_user_deinit(&owner); + return -1; + } + ret = 0; + } else if (!var_has_key(storage->location, 'h', "home")) { + ret = 1; + } else { + /* we'll need to look up the user's home directory */ + if ((ret = mail_user_get_home(owner, &tab[3].value)) < 0) { + mailbox_list_set_critical(list, "Namespace '%s': " + "Could not lookup home for user %s", + ns->prefix, userdomain); + mail_user_deinit(&owner); + return -1; + } + } + + location = t_str_new(256); + if (ret > 0 && + var_expand(location, storage->location, tab, &error) <= 0) { + mailbox_list_set_critical(list, + "Failed to expand namespace location '%s': %s", + storage->location, error); + return -1; + } + + /* create the new namespace */ + new_ns = i_new(struct mail_namespace, 1); + new_ns->refcount = 1; + new_ns->type = MAIL_NAMESPACE_TYPE_SHARED; + new_ns->user = user; + new_ns->prefix = i_strdup(str_c(prefix)); + new_ns->owner = owner; + new_ns->flags = (NAMESPACE_FLAG_SUBSCRIPTIONS & ns->flags) | + NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_HIDDEN | + NAMESPACE_FLAG_AUTOCREATED | NAMESPACE_FLAG_INBOX_ANY; + new_ns->user_set = user->set; + new_ns->mail_set = _storage->set; + i_array_init(&new_ns->all_storages, 2); + + if (ret <= 0) { + get_nonexistent_user_location(storage, userdomain, location); + new_ns->flags |= NAMESPACE_FLAG_UNUSABLE; + e_debug(ns->user->event, + "shared: Tried to access mails of " + "nonexistent user %s", userdomain); + } + + ns_set = p_new(user->pool, struct mail_namespace_settings, 1); + ns_set->type = "shared"; + ns_set->separator = p_strdup_printf(user->pool, "%c", ns_sep); + ns_set->prefix = new_ns->prefix; + ns_set->location = p_strdup(user->pool, str_c(location)); + ns_set->hidden = TRUE; + ns_set->list = "yes"; + new_ns->set = ns_set; + + unexpanded_ns_set = + p_new(user->pool, struct mail_namespace_settings, 1); + *unexpanded_ns_set = *ns_set; + unexpanded_ns_set->location = + p_strdup(user->pool, storage->unexpanded_location); + new_ns->unexpanded_set = unexpanded_ns_set; + + /* We need to create a prefix="" namespace for the owner */ + if (mail_namespaces_init_location(owner, str_c(location), &error) < 0) { + /* owner gets freed by namespace deinit */ + mail_namespace_destroy(new_ns); + return -1; + } + + if (mail_storage_create(new_ns, NULL, _storage->flags | + MAIL_STORAGE_FLAG_NO_AUTOVERIFY, &error) < 0) { + mailbox_list_set_critical(list, "Namespace '%s': %s", + new_ns->prefix, error); + /* owner gets freed by namespace deinit */ + mail_namespace_destroy(new_ns); + return -1; + } + if ((new_ns->flags & NAMESPACE_FLAG_UNUSABLE) == 0 && + !shared_namespace_exists(new_ns)) { + /* this user doesn't have a usable storage */ + new_ns->flags |= NAMESPACE_FLAG_UNUSABLE; + } + /* mark the shared namespace root as usable, since it now has + child namespaces */ + ns->flags |= NAMESPACE_FLAG_USABLE; + *_name = mailbox_list_get_storage_name(new_ns->list, + t_strconcat(new_ns->prefix, name, NULL)); + *_ns = new_ns; + if (_storage->class_flags == 0) { + /* flags are unset if we were using "auto" storage */ + _storage->class_flags = + mail_namespace_get_default_storage(new_ns)->class_flags; + } + + mail_user_add_namespace(user, &new_ns); + return 0; +} + +struct mail_storage shared_storage = { + .name = MAIL_SHARED_STORAGE_NAME, + .class_flags = 0, /* unknown at this point */ + + .v = { + NULL, + shared_storage_alloc, + shared_storage_create, + index_storage_destroy, + NULL, + shared_storage_get_list_settings, + NULL, + fail_mailbox_alloc, + NULL, + NULL, + } +}; diff --git a/src/lib-storage/index/shared/shared-storage.h b/src/lib-storage/index/shared/shared-storage.h new file mode 100644 index 0000000..5463b1c --- /dev/null +++ b/src/lib-storage/index/shared/shared-storage.h @@ -0,0 +1,22 @@ +#ifndef SHARED_STORAGE_H +#define SHARED_STORAGE_H + +struct shared_storage { + struct mail_storage storage; + union mailbox_list_module_context list_module_ctx; + + const char *ns_prefix_pattern; + const char *location, *unexpanded_location; + + const char *storage_class_name; +}; + +#define SHARED_STORAGE(s) container_of(s, struct shared_storage, storage) + +struct mailbox_list *shared_mailbox_list_alloc(void); + +/* Returns -1 = error, 0 = user doesn't exist, 1 = ok */ +int shared_storage_get_namespace(struct mail_namespace **_ns, + const char **_name); + +#endif |