summaryrefslogtreecommitdiff
path: root/libmailutils
AgeCommit message (Collapse)AuthorFiles
11 daysFix typosSergey Poznyakoff25
11 daysFix a corner case in mu_make_file_name_sufSergey Poznyakoff1
If dir is '/' (optionally followed by another '/'), copy it verbatim. * libmailutils/string/mkfilename.c (mu_make_file_name_suf):
11 daysForgotten to add with 22ceaddfb8Sergey Poznyakoff1
12 daysFix memory and fd leak in maildir and amdSergey Poznyakoff1
* libmailutils/base/amd.c (amd_expunge): Close and destroy the associated message stream. * libproto/maildir/maildir.c (maildir_close): Fix erroneously reverted condition.
2021-11-03Free allocated memory on exit.Sergey Poznyakoff3
See also 91d35ab2ee. * include/mailutils/cfg.h (mu_cfg_section): New members: ident_storage and label_storage. * libmailutils/cfg/driver.c (mu_config_destroy_container): Free the storage allocated for ident and label. Do this onlyw if the decreased refcount hits zero. (mu_config_container_register_section): Assign allocated strings to ident_storage and label_storage. (mu_config_root_register_section): Register an onexit routine for freeing the allocated memory. * libmailutils/cli/capa.c (capa_free): Register an onexit routine for freeing the allocated memory. * libmailutils/opt/progname.c (mu_set_program_name): Likewise.
2021-11-03Minor changeSergey Poznyakoff1
* libmailutils/stdstream/basestr.c (std_log_bootstrap): Mark stream as open.
2021-11-03Free some allocated memory on exit.Sergey Poznyakoff4
This eliminates certain "memory leaks", that have little (if any) practical importance, bu make leak detection tools overly vociferous. * libmailutils/base/monitor.c (static_monitor_dealloc): New function. (mu_monitor_rdlock, mu_monitor_wrlock): Install static_monitor_dealloc as onexit handler. * libmailutils/filter/filter.c (filter_dealloc): New function: deallocate filter_list. (mu_filter_get_list): Install filter_dealloc as onexit handler. * libmailutils/locus/ident.c (nametab_dealloc): New function. (mu_ident_ref): Install nametab_dealloc as onexit handler. * libmailutils/stdstream/basestr.c (std_log_bootstrap): Unref transport after setting it up to log stream. (stdstream_flushall): Call mu_stream_destroy instead of mu_stream_flush.
2021-11-03Move mimetypes support into the librarySergey Poznyakoff8
* configure.ac: Build libmailutils/mimetypes/Makefile * include/mailutils/Makefile.am: New header mimetypes.h * mimeview/mimeview.h: moved from include/mailutils/mimetypes.h * include/mailutils/sys/Makefile.am: Add mimetypes.h * include/mailutils/sys/mimetypes.h: New file. * include/mailutils.h: Include mailutils/mimetypes.h * libmailutils/Makefile.am: Build mimetypes. * libmailutils/mimetypes/.gitignore: New file. * libmailutils/mimetypes/eval.c: New file. * libmailutils/mimetypes/grammar.y: Moved from mimeview/grammar.y * libmailutils/mimetypes/lexer.l: Moved from mimeview/lexer.l. * libmailutils/diag/debcat: Add mimetypes. * mimeview/Makefile.am: Update. * mimeview/tests/testsuite.at: Change debug level. * include/mailutils/stream.h (mu_fd_stream_create): filename is const. * libmailutils/stream/file_stream.c: Likewise.
2021-11-01Require GNU bison and flexSergey Poznyakoff8
* am/bison.m4: Use AC_PATH_PROG. * am/flex.m4: Likewise. * configure.ac: Remove MU_YLWRAP. * include/mailutils/yyloc.h (YYLTYPE): Remove. This needs be defined in each grammar source individually. * mu-aux/Makefile.am: Remove gylwrap. * mu-aux/gylwrap: Remove. * libmailutils/cfg/Makefile.am: Rewrite rules for building grammars and lexers. * libmailutils/datetime/Makefile.am: Likewise. * libmu_sieve/Makefile.am: Likewise. * mail/Makefile.am: Likewise. * mh/Makefile.am: Likewise. * mimeview/Makefile.am: Likewise. * libmailutils/cfg/gylwrap.conf: Remove. * libmailutils/datetime/gylwrap.conf: Remove. * libmu_sieve/gylwrap.conf: Remove. * mh/gylwrap.conf: Remove. * mimeview/gylwrap.conf: Remove. * libmailutils/cfg/lexer.l: Use %option prefix * libmu_sieve/sieve-lex.l: Likewise. * mh/mh_alias_lex.l: Likewise. * mimeview/lexer.l: Likewise. * libmailutils/cfg/parser.y: Use api.prefix and %code requires. * libmailutils/datetime/parsedate.y: Likewise. * mh/mh_alias_gram.y: Likewise. * mh/mh_fmtgram.y: Likewise. * mh/pick-gram.y: Likewise. * libmu_sieve/sieve-gram.y: Likewise. * mimeview/grammar.y: Likewise. * testsuite/lib/mailutils.exp (mu_create_config): Fix source location.
2021-09-30Fix timezone calculation (see https://savannah.gnu.org/bugs/?61239)Sergey Poznyakoff1
* libmailutils/datetime/utcoff.c (mu_utc_offset): Fix the timezone correction.
2021-08-27BugfixSergey Poznyakoff1
* libmailutils/stream/stream.c (mu_stream_timed_getdelim): If buffer points to NULL, assume size = 0.
2021-08-26Test TLS streamsSergey Poznyakoff1
* configure.ac: Configure test directory in libmu_auth * libmu_auth/Makefile.am: Likewise. * libmu_auth/tests/.gitignore: New file. * libmu_auth/tests/Makefile.am: New file. * libmu_auth/tests/atlocal.in: New file. * libmu_auth/tests/genfile.c: New file. * libmu_auth/tests/testsuite.at: New file. * libmu_auth/tests/tls.at: New file. * libmu_auth/tests/tlscpy.c: New file. * pop3d/cmd.c: Fix typo.
2021-08-25New function: mu_starttlsSergey Poznyakoff4
* libmu_auth/tlsfdstr.c (mu_tlsfd_stream_create): Accept conf==NULL. (mu_starttls): New function. * include/mailutils/tls.h (mu_starttls): New proto. * include/mailutils/imapio.h (mu_imapio_get_transport) (mu_imapio_set_transport): New functions. * libmailutils/imapio/transport.c (mu_imapio_get_transport) (mu_imapio_set_transport): New functions. * libmailutils/stream/iostream.c (mu_iostream_create): Accept NULL out stream. * libmailutils/stream/tcp.c: Support MU_IOCTL_FD (_tcp_instance): New member fd_borrowed. (_tcp_close): Don't close fd if fd_borrowed is set. (_tcp_ioctl): Handle MU_IOCTL_FD. * libmailutils/stream/xscript-stream.c (_xscript_ctl): Accept pstr[1] == NULL. * libmu_auth/notls.c (mu_tlsfd_stream_create) (mu_tlsfd_stream2_convert) (mu_starttls): New placeholders. * libproto/imap/folder.c (_mu_imap_folder_open): Use mu_tlsfd_stream_convert. Fix stream leak. * libproto/imap/starttls.c (mu_imap_starttls): Use mu_starttls. * libproto/mailer/smtp.c (smtp_open): Use mu_tlsfd_stream_convert. * libproto/mailer/smtp_starttls.c (mu_smtp_starttls): Use mu_starttls. * libproto/pop/pop3_stls.c (mu_pop3_stls): Likewise. * libproto/pop/mailbox.c (pop_open): Use mu_tlsfd_stream_convert. Fix stream leak. * mu/libexec/imap.c (com_connect): Use mu_tlsfd_stream_convert. Fix stream leak. * mu/libexec/pop.c: Likewise. * mu/libexec/smtp.c: Likewise. * imap4d/io.c (imap4d_init_tls_server): Use mu_starttls. * pop3d/extra.c: Likewise.
2021-08-25New function mu_tlsfd_stream2_convertSergey Poznyakoff1
* libmu_auth/tlsfdstr.c (mu_tlsfd_stream_create): Remove last argument. All uses changed. (mu_tlsfd_stream2_convert): New function. * include/mailutils/tls.h (mu_tlsfd_stream_create): Change signature (flags removed). (mu_tlsfd_stream2_convert): New proto. (mu_tlsfd_stream_convert): New inline function. * libmailutils/diag/errors (MU_ERR_TRANSPORT_GET) (MU_ERR_TRANSPORT_SET): New error codes. * imap4d/io.c (imap4d_init_tls_server): Use mu_tlsfd_stream2_convert. * pop3d/extra.c (pop3d_init_tls_server): Use mu_tlsfd_stream2_convert.
2021-08-24Intermediate streams: propagate _MU_STR_EVENT_CLRFLAG to the underlying ↵Sergey Poznyakoff2
transport * libmailutils/stream/fltstream.c: Propagate mu_stream_clearerr to the transport stream. * libmailutils/stream/iostream.c: Likewise. * libmu_auth/tls.c: Likewise. * libmu_auth/tlsiostr.c: Likewise. * libmu_auth/tlsfdstr.c (_tlsfd_read, _tlsfd_write): Translate GNUTLS_E_TIMEDOUT to MU_ERR_TIMEOUT. * imap4d/bye.c (imap4d_bye_command): Clear stream error on ERR_TIMEOUT. ---
2021-08-23Fix handling of MU_IOCTL_SUBSTREAM in iostreamSergey Poznyakoff1
* libmailutils/stream/iostream.c (_iostream_ctl): Fix handling of MU_IOCTL_SUBSTREAM (get/set) requests. * imap4d/io.c (io_setio): Unreference the source stream. (imap4d_init_tls_server): Fix reference decrement for tlsstream. * pop3d/extra.c (pop3d_setio): Unreference the source stream. (pop3d_init_tls_server): Fix reference decrement for tlsstream.
2021-08-21Implement "timed" versions of the stream read-up-to-delimiter operationsSergey Poznyakoff4
* include/mailutils/stream.h (MU_IOCTL_TIMEOUT): New ioctl code. (mu_stream_timed_readdelim,mu_stream_timed_readline): New protos. (mu_stream_readdelim,mu_stream_readline,mu_stream_getdelim) (mu_stream_getline): Rewrite as inline functions. * include/mailutils/datetime.h (mu_timeval_cmp, mu_timeval_add) (mu_timeval_sub): New inline functions for operations over struct timeval. * include/mailutils/sys/file_stream.h (_mu_file_stream): New member: io_timeout. * libmailutils/diag/errors (MU_ERR_TIMEOUT, MU_ERR_SET_TIMEOUT) (MU_ERR_WRITE, MU_ERR_TLS): New error codes. * libmailutils/stream/file_stream.c (fd_read,fd_write): Take into account I/O timeout. (fd_ioctl): Handle MU_IOCTL_TIMEOUT. * libmailutils/stream/stream.c (mu_stream_timed_readdelim) (mu_stream_timed_readline): New functions. * libmu_auth/tls.c (_tls_open): Special handling for time-out errors. * libmailutils/stream/iostream.c (_iostream_ctl): Pass MU_IOCTL_TIMEOUT to the transport stream.
2021-07-27Prefer User-Agent header over X-MailerSergey Poznyakoff1
* NEWS: Update. * doc/texinfo/programs/mail.texi: Update. * include/mailutils/header.h (MU_HEADER_USER_AGENT): New define. * mail/mail.c (default_setup): Set useragent * mail/mail.h (mailvar_name_useragent): New define. * mail/mailline.c (header_generator): Add MU_HEADER_USER_AGENT. * mail/mailvar.c: Mew variable: "useragent". Retain "xmailer" as an alias. * mail/send.c (mail_compose_send): Add the User-Agent header if the "useragent" variable is set. * libmailutils/tests/hdrcpy.at: Use User-Agent instead of X-Mailer. * mail/tests/send.at: Likewise. * mail/tests/sendbyname.at: Likewise. * mail/tests/sendrec.at: Likewise. * mail/testsuite/mail/Followup.exp: Likewise. * mail/testsuite/mail/Reply.exp: Likewise. * mail/testsuite/mail/reply.exp: Likewise. * mail/testsuite/mail/send.exp: Likewise. * mh/repl.c: Likewise. * mh/send.c: New .mtstailor vareiable "user-agent".
2021-07-19Fix in quoted-printable decoderSergey Poznyakoff1
* libmailutils/filter/qpflt.c (_qp_decoder): Accept soft line breaks (RFC 2045, 6.7, page 19)
2021-07-16Rename the FROMRB filter to FROMRDSergey Poznyakoff6
Old name is retained as an alias.
2021-07-15Fix stream reference bug in mu_filter_stream_createSergey Poznyakoff2
If the mu_filter_xcode_t function failed in mu_filter_init request, mu_filter_stream_create would leave the transport reference counter incremented by one. * libmailutils/stream/fltstream.c (mu_filter_stream_create): On failure, decrement reference counter of transport stream. * libmailutils/tests/fltcnt.c: Test for the above bug as well.
2021-07-15Fix stream reference bug in mu_filter_chain_create family functions.Sergey Poznyakoff6
This change affects the following two functions: mu_filter_chain_create, mu_filter_chain_create_pred. In previous versions, if these functions failed to create the requested filter chain, they decremented reference counter of their transport (input stream) argument. This change restores the proper behavior: - On success, reference counter is incremented by 1. - On error, reference counter doesn't change. * libmailutils/filter/fltchain.c (_add_next_link): Make sure the transport reference counter does not change. * libmailutils/tests/Makefile.am: Add new auxiliary program and test case. * libmailutils/tests/fltcnt.at: New file. * libmailutils/tests/fltcnt.c: New file. * libmailutils/tests/testsuite.at: Include new test.
2021-07-14Minor changeSergey Poznyakoff1
* libmailutils/stream/streamref.c (mu_streamref_create_abridged):Don't reposition the underlying stream to beginning.
2021-06-11Fix handling of MIME messages that have only one part.Sergey Poznyakoff1
* libmailutils/mime/mime.c (_mime_part_size): Fix handling of one part MIME messages. Don't touch psize memory in case of error. (_mime_body_stream_read): Fix handling of one part MIME messages. Previous implementation used to add an extra newline at the end. * mh/tests/mhn.at: Reflect the above changes. * sieve/tests/vacation.at: Reflect the above changes.
2021-06-06mail: revamp parsing of adresses in send modeSergey Poznyakoff1
In particular, this fixes parsing of addresses with comma in the local part. * include/mailutils/address.h (MU_ADDRESS_HINT_INITIALIZER): New define. * libmailutils/address/addrstream.c (mu_stream_format_address): Format local user names without surrounding angle quotes. * mail/mail.h (util_header_expand): Rename to util_header_expand_aliases. All uses changed. (util_address_expand_aliases): New function. * mail/send.c (compose_header_set): Expand aliases if inplacealiases is set. Avoid useless recursion. * mail/util.c (send_message): Create addresses via mu_address_create_hint to avoid appending local domain to the unqualified user names. (mail_send0): Likewise. (util_address_expand_aliases): New function. (util_header_expand): Rename to util_header_expand_aliases. Use util_address_expand_aliases and regular address parsing functions instead of wordsplit. Unwrap header values.
2021-05-23fix memory leak in folder scannerSergey Poznyakoff2
* libmailutils/mailbox/folder.c (mu_folder_enumerate): Set the destroy_item function on the created list. * libmailutils/mailbox/fsfolder.c (list_helper): Free the resp structure when it is no longer needed.
2021-05-22folder scan returns mailbox names without the leading directory prefix.Sergey Poznyakoff9
For example, suppose folder /foo/bar contains mailboxes a, b, and c. Then scanning the mu_folder_t object for '/foo' will return 'bar/a', 'bar/b', and 'bar/c'. Scanning the mu_folder_t for '/foo/bar' will return 'a', 'b', and 'c', and so on. * libmailutils/string/mkfilename.c (mu_make_file_name_suf): Reasonable handling of corner cases. Document its behavior. * libmailutils/mailbox/fsfolder.c (struct folder_scan_data): New member: prefix_len (list_helper): Return the portion of the file name after the base directory prefix. (_fsfolder_list): Initialize sdata.prefix_len. * libmailutils/tests/fsfolder.c: Remove prefix handling code. * libmailutils/tests/fsfolder00.at: Change expectations. * libmailutils/tests/fsfolder02.at: Likewise. * libmailutils/tests/fsfolder03.at: Likewise. * libmailutils/tests/fsfolder04.at: Likewise. * include/mailutils/sys/imap.h (struct _mu_imap): New members: separator and prefix_len. * libproto/imap/folder.c (_mu_imap_folder_separator): New function. (_mu_imap_folder_pathname): New function. (_mu_imap_folder_list): Prefix the original refname with the base directory of the folder. (_mu_imap_folder_lsub,_mu_imap_folder_subscribe) (_mu_imap_folder_unsubscribe,_mu_imap_folder_delete) (_mu_imap_folder_rename): Adjust input mailbox names. * libproto/imap/genlist.c (list_untagged_handler): Return the portion of the file name after the base directory prefix. * libproto/imap/tests/imapfolder.c: Minor change. Update for changed folder behavior * imap4d/list.c (struct refinfo): Replace dirlen with delim - a character to be inserted between the original reference and mailbox name. (list_fun): Insert delimiter, if required. (list_ref): Set refinfo.delim, unless the reference prefix already ends with a delimiter or is the same as the namespace prefix. Mail 'folders' command: add support for remote folders. * mail/folders.c: Handle remote folders correctly. * mail/mail.h (util_get_folder): New proto. * mail/mailline.c (struct filegen): Remove path_len. (new_folder): Rename to util_get_folder and move to util.c (filegen_init): Initialize prefix_len from the argument. * mail/util.c (util_get_folder): New function.
2021-05-21Bugfix in mu_list_clearSergey Poznyakoff1
The bug affected imap client code, in particular. * libmailutils/list/clear.c (mu_list_clear): Reset list item count.
2021-05-01Revise the mailbox locking functions.Sergey Poznyakoff6
The locker is created by the following call: mu_locker_create_ext(&locker, filename, &hints); The last arguments points to a structure mu_locker_hints_t, which defines the settings for the locker. NULL value implies default. Settings of an existing locker can be modified using the following call: mu_locker_modify(locker, &hints); Current settings can be examined using mu_locker_get_hints. The functions mu_locker_destroy, mu_locker_lock_mode, mu_locker_lock, mu_locker_touchlock, mu_locker_unlock, and mu_locker_remove_lock remained unchanged. Rest of functions is deprecated, but retained for a couple of releases for the sake of backward compatibility. Constants (locker types, flags, etc) are also revisited. This commit also fixes a bug in mu_spawnvp function, which was discovered when testing external lockers. * include/mailutils/locker.h: Major rewrite. (MU_LOCKER_DEFAULT_EXPIRE_TIME) (MU_LOCKER_DEFAULT_RETRY_COUNT) (MU_LOCKER_DEFAULT_RETRY_SLEEP) (MU_LOCKER_DEFAULT_EXT_LOCKER): New defines. (mu_locker_hints_t): New data type. (MU_LOCKER_FLAG_RETRY) (MU_LOCKER_FLAG_EXPIRE_TIME) (MU_LOCKER_FLAG_CHECK_PID) (MU_LOCKER_FLAG_TYPE,MU_LOCKER_FLAGS_ALL): New defines. (mu_locker_create_ext, mu_locker_modify) (mu_locker_get_hints): New functions. (mu_locker_create,mu_locker_set_default_flags) (mu_locker_set_default_retry_timeout) (mu_locker_set_default_retry_count) (mu_locker_set_default_expire_timeout) (mu_locker_set_default_external_program) (mu_locker_set_flags,mu_locker_mod_flags) (mu_locker_set_expire_time,mu_locker_set_retries) (mu_locker_set_retry_sleep,mu_locker_set_external) (mu_locker_get_flags,mu_locker_get_expire_time) (mu_locker_get_retries,mu_locker_get_retry_sleep): Mark as deprecated. * libmailutils/base/locker.c: Rewrite. * libmailutils/cli/stdcapa.c: New locking statements: type and retry-sleep. retry-timeout is deprecated. * libmailutils/tests/lck.c: Use new locker functions. * libmailutils/tests/lock.at: Test the external locker. * libmailutils/base/spawnvp.c (mu_spawnvp): Restore the default SIGCHLD handler while waiting for the process to terminate. * dotlock/dotlock.c: Use new locker functions. * lib/manlock.c: Likewise. * libmailutils/base/amd.c: Likewise. * libmu_dbm/berkeley.c: Likewise. * libmu_sieve/extensions/vacation.c: Likewise. * libproto/dotmail/dotmail.c: Likewise. * libproto/mbox/mboxrd.c: Likewise. * mail/copy.c: Likewise. * mda/lmtpd/lmtpd.c: Modify mu_locker_defaults instead of using deprecated functions. * mda/mda/mda.c: Likewise. * mda/putmail/putmail.c: Likewise. * NEWS: Document changes. * configure.ac: Version 3.12.90. * doc/texinfo/Makefile.am: Add programs/dotlock.texi * doc/texinfo/programs.texi: Rewrite the locking section. New section: dotlock. * doc/texinfo/programs/dotlock.texi: New file.
2021-04-29libopt: don't show hidden options in the --usage output.Sergey Poznyakoff1
* libmailutils/opt/help.c (option_summary): Skip options with MU_OPTION_HIDDEN bit set. (mu_option_describe_options): Reset margin to 0 so that eventual extra_doc is formatted correctly.
2021-04-29Further improvements of the locker interface.Sergey Poznyakoff7
This fixes a bug that prevented previous versions of mailutils to retry aquiring the lock. Locking configuration (the "locking" section) is improved. * dotlock/dotlock.c: New options: --retry (-r), --delay (-t), --pid-check (-p). Use the "locking" capability. * libmailutils/base/locker.c: Remove the uses of assert(). (mu_locker_lock_mode): Fix the retry loop. (lock_dotlock): Use mu_asprintf to create temporary lock name. Return EAGAIN on temporary error conditions. (lock_kernel): Fix typo (EACCES). * libmailutils/cli/stdcapa.c (cb_locker_flags): Locker flags are deprecated. (cb_locker_retry_timeout,cb_locker_retry_count): Clear the MU_LOCKER_RETRY flag, if supplied a zero value. (cb_locker_external): Clear the MU_LOCKER_EXTERNAL flag (revert to the dotlock locker type) if the value is a false boolean value. * libmailutils/tests/Makefile.am: Add new test. * libmailutils/tests/testsuite.at: Include new test, * libmailutils/tests/lck.c: New test program. * libmailutils/tests/lock.at: New test.
2021-04-27Fix misattributed locker flags.Sergey Poznyakoff1
* libmailutils/cli/stdcapa.c (cb_locker_expire_timeout) (cb_locker_external): Pass proper first argument to mu_locker_set_default_flags.
2021-04-18Bugfix in the configuration file lexer.Sergey Poznyakoff1
String values like the following caused failure: "foo \ bar \ baz \ qux" The second and third physical lines would not be recognized by the scanner. The bug was due to a long-standing copy-paste error.
2021-01-12Remove left-over mailutils.rc supportSergey Poznyakoff1
* libmailutils/cli/cli.c (MU_LEGACY_CONFIG_FILE): Remove. (mu_cli_ext): No handling for the pre-3.0 configuration file.
2021-01-11Force character signedness in strout testSergey Poznyakoff1
2021-01-11strout test: don't wait for the input forever.Sergey Poznyakoff1
* libmailutils/tests/strout.c: Run no longer than 30 seconds. Standardize exit codes.
2021-01-05Minor changesSergey Poznyakoff1
2021-01-05Fix version outputSergey Poznyakoff1
* include/mailutils/cli.h (mu_copyright_year): New extern. (mu_version_print): New proto. * libmailutils/cli/cli.c (mu_copyright_year): New variable. Should be updated once a year. (mu_version_print): New function. (mu_version_hook): Use mu_version_print. * mail/mail.c (mail_warranty): Use mu_version_print.
2021-01-05Update copyright yearsSergey Poznyakoff551
2020-12-30Fix coredump on NULL input to mu_url_create_hintSergey Poznyakoff1
In particular, this caused inc to coredump when called without explicit -file option. * libmailutils/url/create.c (mu_url_create_hint): Return EINVAL if str is NULL. * mh/tests/inc.at: Add new test.
2020-12-21MH: provide a mh_profile setting to control assignment of sequence numbersSergey Poznyakoff1
The "Volatile-uidnext" setting controls how sequence numbers are allocated. By default they increase monotonically. If Volatile-uidnext is set to "true", each new incorporated message is assigned the sequence number equal to that of the last message increased by one. When the last message in the mailbox is deleted, the value of UIDNEXT is recalculated and UIDVALIDITY is increased. This follows the behavior of traditional MH implementations. * doc/texinfo/mu-mh.texi: Document chnges. * include/mailutils/sys/amd.h (MU_AMD_VOLATILE_UIDNEXT): New constant. * libmailutils/base/amd.c (amd_expunge): Reset uidvalidity and uidnext if MU_AMD_VOLATILE_UIDNEXT capability is set and the last message was removed. * libproto/mh/mh.c (_mailbox_mh_init): New mh_profile setting "Volatile-uidnext". If set to true, it instructs mailutils to mimic the traditional MH behavior when assigning sequence number to the new message. * testsuite/mbop.c (main): Use MBOP_PRE_OPEN_HOOK (if defined) as the name of the function to call before opening the mailbox. * libproto/mh/tests/mbop.c (mbop_pre_open_hook): New function. If the MH environment variable is set, take its value as the name of the mh_profile and read settings from it. * libproto/mh/tests/Makefile.am: Add uidvol.at * libproto/mh/tests/atlocal.in: Unset MH. * libproto/mh/tests/testsuite.at: Include uidvol.at * libproto/mh/tests/uidvol.at: New file.
2020-12-04amd: reset the UIDNEXT after resetting the uidvaliditySergey Poznyakoff1
This happens automatically for plaintext mailboxes, but needs to be done explicitly for directory-based ones. * libmailutils/base/amd.c (amd_set_uidvalidity): Reset the UIDNEXT * testsuite/mbop.c: New command: uidvalidity_reset
2020-11-30New functions for closing all fds and daemonizingSergey Poznyakoff8
* configure.ac: Select a suitable interface for closing all file descriptors greater than or equal to a chosen one. * include/mailutils/daemon.h (mu_daemon): New proto. * include/mailutils/util.h (mu_close_fds): New proto. * lib/daemon.c: Removed. * lib/Makefile.am: Remove daemon.c * libmailutils/base/Makefile.am: Add closefds.c * libmailutils/base/closefds.c: New file. * libmailutils/base/daemon.c: Rename to libmailutils/base/pidfile.c * libmailutils/base/daemon.c: New file. * libmailutils/diag/bt.c: Use mu_close_fds. * libmailutils/server/acl.c: Likewise. * mh/mh_whatnow.c: Likewise. * libmailutils/stream/prog_stream.c: Likewise. * libmailutils/server/msrv.c: Use mu_daemon. * mh/send.c: Likewise. * mda/lib/util.c (mda_close_fds): Remove.
2020-11-29Optimize the observable interfaceSergey Poznyakoff1
A bitmask of all requested event types is stored in the observable structure. When an event is reported, mu_observable_notify first check if the event type bit is set in that bitmap. If so, it starts iterating over observers. That should allow us to avoid the loop in most cases. * include/mailutils/observer.h (mu_observable_wants): New proto. * include/mailutils/sys/observer.h (_mu_observable): New member: types. * libmailutils/base/observer.c (mu_observable_attach): Compute bitmask of all types requested by attached observers. (mu_observable_detach): Likewise. (mu_observable_notify): Check if the event type is marked in the bitmap, skip iteration if it is not. (mu_observable_wants): New function.
2020-11-27Don't use __FILE__ and __LINE__ in mu_debug.Sergey Poznyakoff1
This is spurious as it can be enabled by the debug.line-info configuration directive.
2020-11-27mu_scan_datetime: Fix error recovery. %Z handles both time-zone forms.Sergey Poznyakoff3
The value stored in the memory location pointed to by the endp argument has changed. On the MU_ERR_PARSE error, it is (as earlier) the position in input where conversion stopped. On the MU_ERR_FORMAT, however, it is the character in fmt where the format error was detected. * libmailutils/datetime/scantime.c (peek_state): Return MU_ERR_FORMAT if mu_list_tail fails (the list is empty). This reflects unbalanced closing parenthesis or bracket. (scan_recovery): fix algorithm. (mu_scan_datetime): %Z handles both abbreviated time-zones and time-zones as hour offset from GMT. Improve error handling. On MU_ERR_PARSE error, point *endp to the character in input where conversion stopped. On MU_ERR_FORMAT error, point it to the character in fmt, where the format error was detected. * libmailutils/tests/scantime.c: Improve error handling. * libmailutils/tests/scantime.at: More testcases.
2020-11-26mboxrb: Keep timestamps in normalized formSergey Poznyakoff2
* include/mailutils/datetime.h (mu_timezone_offset): New proto. * libmailutils/datetime/scantime.c: New conversion: %Z (timezone abbreviation). * libmailutils/datetime/parsedate.y (mu_timezone_offset): New function. Returns time offset in seconds corresponding to the given timezone abbreviation. * include/mailutils/sys/mboxrb.h (mu_mboxrb_hdr): Remove unneeded enum. (mu_mboxrb_message): Remove env_date_start, New member "date" holds the string representation of the envelope timestamp in normalized form - ctime(3), UTC. * libproto/mbox/mboxrb.c (scan_message_finalize): New function. (scan_message_begin): New function. When initializing the message, timestamps in obsolete forms are converted to normalized representation. (mboxrb_rescan_unlocked): Use scan_message_finalize and scan_message_begin. * libproto/mbox/message.c (mboxrb_envelope_date): Get normalized timestamp from the date member, * libproto/mbox/tests/env.at: Reflect the above changes.
2020-11-25Replace mbox format driver with mboxrbSergey Poznyakoff2
* NEWS: update * configure.ac: Revert 9763fd4a. * include/mailutils/registrar.h: Likewise. * libproto/Makefile.am: Likewise. * libmailutils/stream/stream.c (mu_stream_size): Fix size calculation in case of line and full buffering scheme. * libmailutils/stream/streamcpy.c (mu_stream_copy_nl): Change semantics. Ensure that the copied data ends with two newline characters. Append them if necessary. * testsuite/mbop.c: New commands: message_lines and message_size. * libproto/mbox/mboxrb.c (mboxrb_mailbox_init_stream): Always add MU_STREAM_READ permission. Use the same flags for mu_mapfile_stream_create and mu_file_stream_create. (mboxrb_rescan_unlocked): Count terminating newline as part of the message. (mailbox_append_message): Make sure each message ends with an empty line. (mboxrb_tracker_sync): Update mailbox mesg_count. (mboxrb_flush_temp): Truncate the temporary stream to the new size. (mboxrb_flush_unlocked): Clear all modifications only in FLUSH_UIDVALIDITY mode. (mboxrb_message_copy_with_uid): Fix message_end computation. Use mu_stream_copy_nl to copy message body. (mu_mboxrb_message_reconstruct): Update ref on return. * po/POTFILES.in: Update. * mail/copy.c (append_to_file): Use mu_stream_stat_buffer to compute statistics. * mail/mail.c: Allow for opening read-only mailboxes. * libproto/mbox/tests/body.at: Fix the expected byte count. * libproto/mbox/tests/qget.at: Likewise. * libproto/mbox/tests/delete.at: Add more tests. * mail/tests/align.at: Fix the expected byte and line count. * mail/tests/hold.at: Likewise. * mail/testsuite/mail/read.exp: Likewise. * mail/testsuite/mail/tag.exp: Likewise. * mail/testsuite/mail/z.exp: Likewise. * mail/tests/copy04.at: Don't use line count and size in comparison. * mail/testsuite/mail/write.exp: Use regexps instead of exact strings for the same reason. * pop3d/testsuite/pop3d/read.exp: Fix the expected byte count. * readmsg/tests/all.at: Expect extra newline in output. * readmsg/tests/hdr.at: Likewise. * readmsg/tests/nohdr.at: Likewise. * readmsg/tests/twomsg.at: Likewise. * readmsg/tests/weed.at: Likewise. * sieve/tests/redirect.at: Fix the expected byte count. * sieve/tests/reject.at: Expect extra newline in output. * mh/inc.c (incmbx): Parse truncate and nomoveto URL parameters prior to opening the mailbox. If notruncate is requested, open the mailbox read-only. * mh/mh_format.c (str_compress_ws): Fix copying between overlapping memory regions. * libtests/Makefile.am: Remove lstuid tests. * libtests/testsuite.at: Likewise. * libtests/lstuid.c: Remove. * libtests/lstuid00.at: Remove. * libtests/lstuid01.at: Remove. * libtests/lstuid02.at: Remove. * libtests/mime.at: Fix the expected byte count. * imap4d/tests/IDEF0956.at: Fix the expected byte count. * map4d/tests/fetch.at: Likewise. * imap4d/tests/append00.at: Remove X-* headers and Status from the mbox prior to comparison. * imap4d/tests/append01.at: Likewise. * libproto/mbox: Remove old code. Replace it with mboxrb. * mail/tests/nohome.at: Update lines/sizes. * mail/testsuite/mail/folder.exp: Likewise. * mail/testsuite/mail/tag.exp: Likewise. * mail/testsuite/mail/z.exp: Likewise. * mda/mda/tests/mda.at: Fix shell quoting. * mda/putmail/tests/putmail.at: Remove extra newline from the expectation. Eliminate X-IMAPbase and X-UID from the resulting mailbox. * mda/tests/mda.sh: Eliminate X-IMAPbase and X-UID from the output. * pop3d/testsuite/pop3d/read.exp: Fix expected lines/sizes * readmsg/tests/hdr.at: Fix extra whitespace. * sieve/tests/action.at: Eliminate X-IMAPbase and X-UID. Fix extra whitespace in the expected From_ line. * sieve/tests/addheader.at: Likewise. * sieve/tests/pipeact.at: Likewise.
2020-11-23Implement mboxrb format (a replacement for the mbox used currently)Sergey Poznyakoff6
* configure.ac: New format: mboxrb * include/mailutils/filter.h (mu_fromrb_filter): New extern. * include/mailutils/registrar.h (mu_mboxrb_record): New extern. (mu_register_all_mbox_formats) (mu_register_local_mbox_formats): Add mu_mboxrb_record. * libmailutils/filter/filter.c (mu_filter_get_list): Add mu_fromrb_filter * libproto/Makefile.am [MU_COND_SUPPORT_MBOXRB]: Add mboxrb * bootstrap.conf: Remove special handling for testsuite/maildir (fixes 1d846d2d92). * testsuite/mbop.c: Implement the -r (--read-only) option. * include/mailutils/sys/Makefile.am: Add mboxrb.h * include/mailutils/sys/mboxrb.h: New file. * libmailutils/filter/Makefile.am (libfilter_la_SOURCES): Add fromrb.c * libmailutils/filter/fromrb.c: New file. * libmailutils/tests/Makefile.am: New file. * libmailutils/tests/fromrb.at: New file. * libmailutils/tests/testsuite.at: New file. * libproto/mboxrb/Makefile.am: New file. * libproto/mboxrb/mboxrb.c: New file. * libproto/mboxrb/message.c: New file. * libproto/mboxrb/tests/.gitignore: New file. * libproto/mboxrb/tests/Makefile.am: New file. * libproto/mboxrb/tests/atlocal.in: New file. * libproto/mboxrb/tests/attr.at: New file. * libproto/mboxrb/tests/autodetect.at: New file. * libproto/mboxrb/tests/body.at: New file. * libproto/mboxrb/tests/count.at: New file. * libproto/mboxrb/tests/env.at: New file. * libproto/mboxrb/tests/header.at: New file. * libproto/mboxrb/tests/testsuite.at: New file.
2020-11-19Make sure UIDs are monotonically increased in dotmail, mh, and maildir.Sergey Poznyakoff1
* include/mailutils/sys/amd.h (_MU_AMD_PROP_UIDNEXT): New define. (MU_AMD_PROP): Remove. (MU_AMD_F_PROP): New flag. (_amd_data): New member: flags. Remove next_uid (amd_reset_uidvalidity): Change return type. (amd_update_uidnext,amd_alloc_uid): New protos. * include/mailutils/sys/dotmail.h (mu_dotmail_mailbox): New member uidvalidity_changed. * libmailutils/base/amd.c (_amd_prop_create): Set MU_AMD_F_PROP flag if the prop file exists. (amd_initial_scan): New function. (amd_get_uidvalidity, amd_set_uidvalidity) (amd_uidnext): Rewrite using amd_initial_scan. (amd_reset_uidvalidity): Return int. (amd_update_uidnext,amd_alloc_uid): New functions. * libproto/dotmail/dotmail.c (dotmail_close): Flush UID parameters if uidvalidity_changed is set. (dotmail_flush): Take three-state mode as its third argument. (dotmail_flush_unlocked): Likewise. If operating in FLUSH_UIDVALIDITY mode, clear all other modifications to the messages in the mailbox. Clear uidvalidity_changed on success. (dotmail_expunge, dotmail_sync): Update call to dotmail_flush. (dotmail_alloc_next_uid): Set uidvalidity_changed. (dotmail_rescan_unlocked): Check if the assigned UID is greater than the previously assigned one and less than the UIDNEXT value. Raise uidvalidity_changed if UIDs were re-allocated. (mu_dotmail_mailbox_uid_setup): Set uidvalidity_scanned. * libproto/dotmail/tests/Makefile.am: Add new test. * libproto/dotmail/tests/testsuite.at: Likewise. * libproto/dotmail/tests/uidnext.at: New test. * libproto/maildir/mbox.c: Use amd_update_uidnext to synchronize the computed and predicted uidnext value. (maildir_next_uid): Remove. * libproto/maildir/tests/Makefile.am: Add new test. * libproto/maildir/tests/testsuite.at: Likewise. * libproto/maildir/tests/uidnext.at: New test. * libproto/mh/mbox.c (_mh_next_seq): Remove function. (mh_scan0): Use amd_update_uidnext to synchronize the computed and predicted uidnext value. * libproto/mh/tests/Makefile.am: Add new test. * libproto/mh/tests/testsuite.at: Likewise. * libproto/mh/tests/uidnext.at: New test.

Return to:

Send suggestions and report system problems to the System administrator.