]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
2 years agotreewide: update to v3 Tor onions
Eric Wong [Tue, 4 May 2021 01:32:25 +0000 (01:32 +0000)]
treewide: update to v3 Tor onions

v2 onions are insecure, deprecated and going away.  v3 names are
unfortunately longer and more difficult to remember, but should
be more resistant to attack than v2 ones.

2 years agolei up: fix dedupe with remote externals on Maildir + IMAP
Eric Wong [Mon, 3 May 2021 20:57:31 +0000 (20:57 +0000)]
lei up: fix dedupe with remote externals on Maildir + IMAP

LeiToMail Maildir and IMAP write callbacks need to account for
the caller-supplied smsg.  We'll also make better use of the
user-supplied smsg object by ensuring blob deduplication happens
ASAP.

Fixes: e76683309ca4f254 ("lei <q|up>: distinguish between mset and l2m counts")
2 years agolei <q|up>: writes to Maildirs and IMAP use mail-sync
Eric Wong [Sun, 2 May 2021 06:05:42 +0000 (06:05 +0000)]
lei <q|up>: writes to Maildirs and IMAP use mail-sync

This will allow keyword updates from other folders to propagate
to folders where search results may be duplicated.

2 years agonet_writer: use "FLAGS.SILENT" to set keywords
Eric Wong [Sun, 2 May 2021 06:05:41 +0000 (06:05 +0000)]
net_writer: use "FLAGS.SILENT" to set keywords

Instead of "+FLAGS.SILENT" which merely adds to the keywords.
We store all keywords together, so it's unlikely we will rely
on the "+FLAGS.SILENT" or "-FLAGS.SILENT".

2 years agolei: simplify workers_start API
Eric Wong [Sun, 2 May 2021 06:05:40 +0000 (06:05 +0000)]
lei: simplify workers_start API

In most cases, we just name the worker process based
on the command.  The only change is for LeiMirror
vs "lei add-external --mirror", but I doubt it matters.

2 years agolei_input: reject --mail-sync if using HTTP(S) for now
Eric Wong [Sun, 2 May 2021 06:05:39 +0000 (06:05 +0000)]
lei_input: reject --mail-sync if using HTTP(S) for now

I'm not sure how we'll distinguish JMAP vs read-only HTTPS,
yet; but we'll focus on currently-supported stuff, first.

2 years agolei_input: common net_merge_all_done for lei <import|tag>
Eric Wong [Sun, 2 May 2021 06:05:38 +0000 (06:05 +0000)]
lei_input: common net_merge_all_done for lei <import|tag>

I suspect there'll be more lei_input-only things in the future.

2 years agolei <q|up>: combine written/results into one line
Eric Wong [Sun, 2 May 2021 06:05:37 +0000 (06:05 +0000)]
lei <q|up>: combine written/results into one line

Having multiple lines of output mean they can be interleaved in
daemon mode.  Put stats into one line to reduce screen
real-estate size and improve readability.

2 years agolei_auth: s/net_merge_complete/net_merge_all_done/
Eric Wong [Sat, 1 May 2021 06:31:22 +0000 (06:31 +0000)]
lei_auth: s/net_merge_complete/net_merge_all_done/

We use the "done" term elsewhere for similar things, and
my easily-confused mind equates "complete" with shell
completion.

2 years agolei edit-search: support relocating lei.q.output
Eric Wong [Sat, 1 May 2021 06:21:17 +0000 (06:21 +0000)]
lei edit-search: support relocating lei.q.output

The contents of the old lei.q.output will not be removed,
but will be converted into the new one.

2 years agolei import: fix --mail-sync handling in LeiInput
Eric Wong [Sat, 1 May 2021 19:29:05 +0000 (19:29 +0000)]
lei import: fix --mail-sync handling in LeiInput

"lei inspect" also shows "mail-sync" as a field name

2 years agolei: rename ls-sync to ls-mail-sync
Eric Wong [Sat, 1 May 2021 06:21:16 +0000 (06:21 +0000)]
lei: rename ls-sync to ls-mail-sync

This allows tab-completion for "ls-search" to work with fewer
characters ("ls-s<TAB>" instead of "ls-se<TAB>"), and I expect
"ls-search" to be used more frequently than "ls-mail-sync".

This also matches the --mail-sync switch of "lei import"

2 years agolei_saved_search: fix excess indent for first lei.q entry
Eric Wong [Sat, 1 May 2021 06:21:15 +0000 (06:21 +0000)]
lei_saved_search: fix excess indent for first lei.q entry

This was harmless, but ugly and possibly confusing to
users who run "lei edit-search".

2 years agolei <q|up>: distinguish between mset and l2m counts
Eric Wong [Sat, 1 May 2021 06:21:14 +0000 (06:21 +0000)]
lei <q|up>: distinguish between mset and l2m counts

The number of messages we write to --output is usually different
than the mset count due to deduplication from combining multiple
sources.

This change makes the stderr output of "lei up --all=local" way
more useful IMHO.

2 years agoxt/lei-onion-convert: test for NNTP+IMAP onions
Eric Wong [Sat, 1 May 2021 06:21:13 +0000 (06:21 +0000)]
xt/lei-onion-convert: test for NNTP+IMAP onions

These tests require a running Tor instance (defaulting to
127.0.0.1:9050) and Internet connectivity, but otherwise
work pretty well.

2 years agonet_reader: support (imap|nntp).proxy in config file
Eric Wong [Fri, 30 Apr 2021 09:24:38 +0000 (09:24 +0000)]
net_reader: support (imap|nntp).proxy in config file

This allows us to use URL-matching config in git and specify
proxies on a per-host basis.  git 2.26+ users may use wildcards
to enable Tor (on 127.0.0.1:9050) for all NNTP and IMAP .onion
domains.

My ~/.config/lei/config file has the following:

[imap "imap://*.onion"]
proxy = socks5h://127.0.0.1:9050
[nntp "nntp://*.onion"]
proxy = socks5h://127.0.0.1:9050

2 years agonet_reader: Net::NNTP --proxy=socks5h:// support
Eric Wong [Fri, 30 Apr 2021 09:24:37 +0000 (09:24 +0000)]
net_reader: Net::NNTP --proxy=socks5h:// support

Since Net::NNTP doesn't support Socket or RawSocket
options/accessors like Mail::IMAPClient does; we must perform
localized @ISA manipulation and massage Net::NNTP into using
IO::Socket::Socks rather than IO::Socket::IP.

This is a bit fragile, but Net::Cmd and Net::NNTP rarely change;
and I keep an eye on them, anyways.

2 years agolei: IMAP .onion support via --proxy=s switch
Eric Wong [Fri, 30 Apr 2021 09:24:36 +0000 (09:24 +0000)]
lei: IMAP .onion support via --proxy=s switch

Mail::IMAPClient provides the ability to pass a pre-connected
Socket to it.  We can rely on this functionality to use
IO::Socket::Socks in place whatever socket class
Mail::IMAPClient chooses to use.

The --proxy=s is shared with curl(1), though we only support
socks5h:// at the moment.  Is there any need for SOCKS4 or SOCKS5
without name resolution?  Tor .onions require socks5h:// for
name resolution and to prevent data leakage.

2 years agonet_reader: {nn,mic}_for: use prototypes for internal subs
Eric Wong [Fri, 30 Apr 2021 09:24:35 +0000 (09:24 +0000)]
net_reader: {nn,mic}_for: use prototypes for internal subs

We don't use these subs elsewhere, so stick prototypes on them
to give them a little extra checking.

2 years agolei: ensure autoflush(1) is on STDERR
Eric Wong [Fri, 30 Apr 2021 09:24:34 +0000 (09:24 +0000)]
lei: ensure autoflush(1) is on STDERR

This fixes error reporting for oneshot tests in xt/lei-auth-failure.t

2 years agolei: kill old PIDs when dropping
Eric Wong [Fri, 30 Apr 2021 09:24:33 +0000 (09:24 +0000)]
lei: kill old PIDs when dropping

This ensures hitting Ctrl-C on a long-running "lei convert" or
similar will stop the WQ worker, even after we've closed
the WQ socketpair in the daemon.

2 years agolei_curl: improve correctness of LD_PRELOAD check
Eric Wong [Fri, 30 Apr 2021 09:24:32 +0000 (09:24 +0000)]
lei_curl: improve correctness of LD_PRELOAD check

LD_PRELOAD sent by a client can't affect lei-daemon.

2 years agolei sucks: preserve utsname.machine, add "x86" where appropriate
Eric Wong [Fri, 30 Apr 2021 09:24:31 +0000 (09:24 +0000)]
lei sucks: preserve utsname.machine, add "x86" where appropriate

It's helpful for us to distinguish x86 kernels from x86_64
kernels when using an x86 userspace.  OSes are dropping i386
support and only support i486 and newer, so "x86" is a more
appropriate description for that platform than "i386".

2 years agolei_store: fix locking w.r.t epoch creation
Eric Wong [Thu, 29 Apr 2021 19:49:57 +0000 (19:49 +0000)]
lei_store: fix locking w.r.t epoch creation

Prior to this change, it was possible for oneshot lei processes
to race on epoch creation/rollover.  lei-daemon normally
prevents the problem by funnelling all writes to a single
socket, but oneshot lei has no such protection.

2 years agolei import: support shell completion of known folders
Eric Wong [Thu, 29 Apr 2021 09:46:20 +0000 (09:46 +0000)]
lei import: support shell completion of known folders

This also fixes completion of "lei up" for IMAP folders.

2 years agolei import: support UIDVALIDITY in IMAP URL
Eric Wong [Thu, 29 Apr 2021 09:46:19 +0000 (09:46 +0000)]
lei import: support UIDVALIDITY in IMAP URL

Specifying a UIDVALIDITY value allows the user to enforce
a strict match and force failure.  This necessitated changes
to NetReader to allow die() and make error reporting more
suitable for CLI usage rather than daemonized usage of -watch.

2 years agolei import: avoid IMAPTracker, use LeiMailSync more
Eric Wong [Thu, 29 Apr 2021 09:46:18 +0000 (09:46 +0000)]
lei import: avoid IMAPTracker, use LeiMailSync more

IMAPTracker has a UNIQUE constraint on the `url' column,
which may cause compatibility and/or rollback problems
in attempting to deal with UIDVALIDITY changes.

Having multiple sources of truth leads to confusion and bugs,
so relying on LeiMailSync exclusively ought to simplify things.

Furthermore, since LeiMailSync is only written to by LeiStore,
it is safer in that it won't mark a UID or article as imported
until git-fast-import has seen it, and the SQLite commit always
happens after "done\n" is sent to fast-import.

This mostly reverts recent commits to IMAPTracker to support
lei, those are:

1) commit 7632d8f7590daf70c65d4270e750c36552fa9389
   ("net_reader: restart on first UID when UIDVALIDITY changes")
2) commit 311a5d37ad275cd75b1e64d87827c4d13fe4bfab
   ("imap_tracker: prepare for use with lei").

This means public-inbox-watch will not change between 1.6 and
1.7: -watch stops synching a folder when UIDVALIDITY changes.

2 years agocontent_hash: git_sha: allow unblessed SCALAR refs
Eric Wong [Thu, 29 Apr 2021 09:46:17 +0000 (09:46 +0000)]
content_hash: git_sha: allow unblessed SCALAR refs

This will be convenient to avoid the overhead of
PublicInbox::Eml for verifying synchronization in lei.

3 years agolei: avoid close(STD{IN,OUT,ERR}) in oneshot mode
Eric Wong [Wed, 28 Apr 2021 19:37:29 +0000 (19:37 +0000)]
lei: avoid close(STD{IN,OUT,ERR}) in oneshot mode

This seems to fix the occasional "make check-run" failures I've
been chasing.

Some parts of our code assumes we can close($lei->{1})
and similar, which causes IO::Handle::autoflush to behave
badly when STDOUT is the "select"-ed FH of the Perl process.
Since oneshot mode is (hopefully) the uncommon case, we'll
just accept the cost of extra FDs and minimize differences
between lei in oneshot vs daemon mode.

3 years agot/run: support TEST_RUN_LOG to diagnose process death
Eric Wong [Wed, 28 Apr 2021 19:37:28 +0000 (19:37 +0000)]
t/run: support TEST_RUN_LOG to diagnose process death

Knowing which process ran what before dying unexpectedly
helps with debugging.

3 years agolei (lcat|q): support --no-color and --color
Eric Wong [Wed, 28 Apr 2021 07:52:05 +0000 (07:52 +0000)]
lei (lcat|q): support --no-color and --color

This should be familiar to git users who wish to force color
when writing to pipes or disable color.

3 years agolei_view_text: translate background colors from git
Eric Wong [Wed, 28 Apr 2021 07:52:04 +0000 (07:52 +0000)]
lei_view_text: translate background colors from git

This seems to work with or without attributes.  We'll deal with
256-color terminal colors when/if somebody cares for it, but the
usual 16 ought to be more than enough.

3 years agolei_view_text: improve attachment display
Eric Wong [Wed, 28 Apr 2021 07:52:03 +0000 (07:52 +0000)]
lei_view_text: improve attachment display

Support setting a color to distinguish from user-supplied text.
We'll also put the $BLOB:$IDX identifier on a separate line and
just put the entire corresponding lei command in the form of:
"[-- lei blob $BLOB:$IDX --]" to teach users how to access it.

3 years agolei: simple WQ workers use {wq1} field
Eric Wong [Wed, 28 Apr 2021 07:52:02 +0000 (07:52 +0000)]
lei: simple WQ workers use {wq1} field

This lets us share more code and reduces cognitive overhead when
it comes to picking names (because {lsss} was ridiculous).

We'll need to ensure the first error set in lei is the actual
error we exit with, otherwise things can get confusing and
errors may get lost.

3 years agolei: quiet down Eml-related warnings consistently
Eric Wong [Wed, 28 Apr 2021 07:52:01 +0000 (07:52 +0000)]
lei: quiet down Eml-related warnings consistently

"lei import" is probably the only place where it users
might care about warnings.

3 years agot/run.perl: add (GNU) tail and strace support
Eric Wong [Wed, 28 Apr 2021 07:52:00 +0000 (07:52 +0000)]
t/run.perl: add (GNU) tail and strace support

This may help track down some "make check-run" failures
that don't seem to manifest under "make check".

3 years agolei-daemon: note FD count mismatch to client
Eric Wong [Wed, 28 Apr 2021 07:51:59 +0000 (07:51 +0000)]
lei-daemon: note FD count mismatch to client

This should help in some error diagnostics

3 years agolei_p2q: add _lei_wq_eof callback
Eric Wong [Wed, 28 Apr 2021 07:51:58 +0000 (07:51 +0000)]
lei_p2q: add _lei_wq_eof callback

This may help with some error diagnostics.

3 years agoview_diff: minor coding style fixes
Eric Wong [Wed, 28 Apr 2021 07:51:57 +0000 (07:51 +0000)]
view_diff: minor coding style fixes

Prefer "use v5.10", s/base/parent/, rely on "perl -w" for warnings.
We also pass a regexp to the split perlop rather than literal
SV, since split() will compile a new RE every time.

3 years agotests: restore CWD with "lei -C" and run_script
Eric Wong [Wed, 28 Apr 2021 07:51:56 +0000 (07:51 +0000)]
tests: restore CWD with "lei -C" and run_script

This simplifies test_lei users in t/*.t

3 years agot/lei-p2q: add diagnostics
Eric Wong [Wed, 28 Apr 2021 07:51:55 +0000 (07:51 +0000)]
t/lei-p2q: add diagnostics

Maybe this helps fix occasional problems in daemon mode,
but I haven't seen anything on failure, yet...

3 years agodoc: lei q: split --output and --format, note "text"
Eric Wong [Wed, 28 Apr 2021 04:51:07 +0000 (04:51 +0000)]
doc: lei q: split --output and --format, note "text"

I guess --format makes sense for stdout, after all;
and I'm enjoying "-f text" quite a bit, so far.

3 years agodoc: lei q: split =item aliases onto separate lines
Eric Wong [Wed, 28 Apr 2021 04:51:06 +0000 (04:51 +0000)]
doc: lei q: split =item aliases onto separate lines

It makes L</--augment> look nicer without resorting to
L<--augment|/-a, --augment> and similarly verbose nastiness.

Having each option as a separate =item (with a blank line in
between each =item) seems to be the preferred style used within
Perl core documentation (I used perlrun.pod as an example),
so we'll follow Perl core style, here.

This needs to be done for other manpages, at some point...

3 years agodoc: lei: use /tmp for search results pathnames
Eric Wong [Wed, 28 Apr 2021 04:51:05 +0000 (04:51 +0000)]
doc: lei: use /tmp for search results pathnames

This drives the point home about results being volatile
and discardable.

3 years agoview: add [thread overview] anchor next to Date:
Eric Wong [Wed, 28 Apr 2021 06:55:22 +0000 (06:55 +0000)]
view: add [thread overview] anchor next to Date:

The existing Subject: anchor to #r may not be 100% obvious,
and we can't stick the phrase "[thread overview]" into the
same line as the Subject without introducing ambiguity.

Fortunately, we have the Date: header directly under it.
Adding "[thread overview]" after the Date: is unambiguous
and won't make the line too long for valid emails.

This hopefully improves navigation ever-so-slightly thanks
to comments by Son Luong Ngoc.

Reported-by: Son Luong Ngoc <sluongng@gmail.com>
Link: https://public-inbox.org/git/YHhfsqfTJ9NzRwS1@C02YX140LVDN.corpad.adbkng.com/
3 years agolei q + lcat: support --format=text output
Eric Wong [Tue, 27 Apr 2021 11:07:53 +0000 (11:07 +0000)]
lei q + lcat: support --format=text output

This is mainly for "lei lcat" where it's the default,
but I find it useful anyways compared to the JSON view.

Colors are loaded from ~/.config/lei/config, and fall back
to using diff colors from a normal git config
(e.g. ~/.gitconfig).

3 years agolei lcat: extract Message-IDs from URLs and show them
Eric Wong [Tue, 27 Apr 2021 11:07:52 +0000 (11:07 +0000)]
lei lcat: extract Message-IDs from URLs and show them

It's a wrapper around "lei q" which extracts Message-IDs
from URLs, "<$MSGID>", "id:$MSGID" and attempts to display the
local version of the message.

Its main purpose is to extract Message-IDs out of
commonly-understood URLs to save users bandwidth and time
by displaying the message locally.  When reading from stdin,
it will discard things it doesn't understand, so you can just
pipe an entire "Link: $URL" line to it and it'll attempt to
pluck the Message-ID out of the URL.

3 years agolei: standardize on _lei_wq_eof callback for workers
Eric Wong [Tue, 27 Apr 2021 11:07:51 +0000 (11:07 +0000)]
lei: standardize on _lei_wq_eof callback for workers

Simplify our internals a little bit.

3 years agolei blob: support retrieving attachments via $OID:$IDX
Eric Wong [Tue, 27 Apr 2021 11:07:50 +0000 (11:07 +0000)]
lei blob: support retrieving attachments via $OID:$IDX

We'll be supporting some sort of text view for pager or
piping to an $EDITOR buffer.

3 years agolei: add "ls-sync" command for listing sync folders
Eric Wong [Tue, 27 Apr 2021 11:07:49 +0000 (11:07 +0000)]
lei: add "ls-sync" command for listing sync folders

This will be useful, later.

3 years agoURIimap: canonicalize uppercases UIDVALIDITY parameter
Eric Wong [Mon, 26 Apr 2021 11:44:25 +0000 (11:44 +0000)]
URIimap: canonicalize uppercases UIDVALIDITY parameter

And the UID one, too, as well.  This simplifies future
comparison and matching code once case is no longer
taken into account.

3 years agolei p2q: exit with failure if format-patch fails
Eric Wong [Mon, 26 Apr 2021 08:43:23 +0000 (08:43 +0000)]
lei p2q: exit with failure if format-patch fails

Merely redirecting the failure message from git to our stderr is
insufficient.

3 years agolei_input: support PublicInbox::WWW mboxrd URLs
Eric Wong [Mon, 26 Apr 2021 08:30:52 +0000 (08:30 +0000)]
lei_input: support PublicInbox::WWW mboxrd URLs

This gives "lei import", "lei tag", and similar commands
the ability to use URLs recognized by our PSGI frontend
directly.

This is more convenient than an equivalent shell pipeline
since "set -o pipefail" is not portable and errors may be
lost.

3 years agowww: missing /$INBOX/$MSGID/raw returns 404
Eric Wong [Mon, 26 Apr 2021 08:02:16 +0000 (08:02 +0000)]
www: missing /$INBOX/$MSGID/raw returns 404

Don't attempt to return HTTP 300 via Extmsg on it,
since whoever uses /raw is likely piping it to some
other command.

3 years agolei_xsearch: show --output location with match count
Eric Wong [Sat, 24 Apr 2021 23:15:26 +0000 (19:15 -0400)]
lei_xsearch: show --output location with match count

This makes "lei up --all=local" output easier-to-understand
when it's updating multiple saved searches.

3 years agolei_saved_search: avoid reentrancy in ->is_dup
Eric Wong [Sat, 24 Apr 2021 22:42:59 +0000 (22:42 +0000)]
lei_saved_search: avoid reentrancy in ->is_dup

Use a separate git process when calling xoids_for to prevent
reentrancy in ->is_dup.  Reentrancy happens since LeiToMail will
call ->is_dup when inside callbacks when writing mail.

This fixes --dedupe=mid test failures in t/lei-q-save.t

I could only reproduce this consistently on a uniprocessor VM.
"schedtool -a 0x1 -e ..." could not reproduce the problem on
2 and 4-core systems.

3 years agotest_common: don't attempt to seek on pipes and terminals
Eric Wong [Sat, 24 Apr 2021 20:09:36 +0000 (20:09 +0000)]
test_common: don't attempt to seek on pipes and terminals

This allows proper error reporting on daemon failure
when using "check-run".

3 years agoextindex: --gc: use escape pathnames for SQL LIKE properly
Eric Wong [Sat, 24 Apr 2021 10:23:30 +0000 (10:23 +0000)]
extindex: --gc: use escape pathnames for SQL LIKE properly

This allows us to handle odd inboxes w/o a newsgroup configured
if they also make the strange choice of having backslashes in
their path name.  Also, ensure we use case-sensitive LIKE, since
case-insensitive FSes are not worth supporting.

3 years agolei import: keep sync info for Maildir and IMAP folders
Eric Wong [Sat, 24 Apr 2021 09:28:46 +0000 (09:28 +0000)]
lei import: keep sync info for Maildir and IMAP folders

We aren't using it, yet, but the plan is to be able to use
this information to propagate keyword changes back to IMAP
and Maildir folders using some to-be-implemented command.

"lei inspect" is a half-baked new command to make testing this
change easier.  It will be updated to support more SQLite+Xapian
introspection duties in the future, including public-inbox
things independent of lei.

3 years agolei_mail_sync: for bidirectional keyword sync
Eric Wong [Sat, 24 Apr 2021 09:28:45 +0000 (09:28 +0000)]
lei_mail_sync: for bidirectional keyword sync

We'll be using the new class to efficiently propagate keyword
changes from lei/store back to Maildir or IMAP folders.

3 years agodoc: lei_design_notes: add a bit on WAL usage
Eric Wong [Sat, 24 Apr 2021 09:28:44 +0000 (09:28 +0000)]
doc: lei_design_notes: add a bit on WAL usage

3 years agonet_reader: imap_each: add UIDVALIDITY to URL arg
Eric Wong [Sat, 24 Apr 2021 09:28:43 +0000 (09:28 +0000)]
net_reader: imap_each: add UIDVALIDITY to URL arg

This will allow the callback to reliably maintain OID <=> UID
mappings between lei/store and the IMAP folder.

3 years agoURIimap: support ->uidvalidity and ->iuid
Eric Wong [Sat, 24 Apr 2021 09:28:42 +0000 (09:28 +0000)]
URIimap: support ->uidvalidity and ->iuid

These will be useful for keyword synchronization, and perhaps
importing a single IMAP message with ->iuid.

3 years agot/lei_to_mail: split "lei import" test $HOME directory
Eric Wong [Sat, 24 Apr 2021 09:28:41 +0000 (09:28 +0000)]
t/lei_to_mail: split "lei import" test $HOME directory

"lei import" behavior will may change w.r.t. keyword
handling.  Use separate $HOME between different test_lei
to ensure isolation between the tests.

3 years agolei_input: drop outdated comment w.r.t. compression
Eric Wong [Sat, 24 Apr 2021 09:28:40 +0000 (09:28 +0000)]
lei_input: drop outdated comment w.r.t. compression

Followup-to: 49b036771ef3bf45 ("lei_input: support compressed mboxes")
3 years agodoc: INSTALL: add Guix to distribution list
Kyle Meyer [Sat, 24 Apr 2021 02:09:58 +0000 (22:09 -0400)]
doc: INSTALL: add Guix to distribution list

public-inbox has been available in Guix since 2019.

3 years agolei import: support adding keywords and labels on import
Eric Wong [Fri, 23 Apr 2021 11:22:01 +0000 (07:22 -0400)]
lei import: support adding keywords and labels on import

This saves some work and makes it easier to set volatile
metadata on a message at import time.

3 years agolei_to_mail: cwd-agnostic Maildir wakeup
Eric Wong [Fri, 23 Apr 2021 08:06:12 +0000 (04:06 -0400)]
lei_to_mail: cwd-agnostic Maildir wakeup

Since we don't have *at() syscalls readily available to us,
lei-daemon may call ->poke_dst in the wrong relative directory.
Despite not having *at() syscalls, we can still capture the
"$MAILDIR/cur" directory handle at pre_augment time so we can
reliably call futimes(2) on it using the `utime' perlop.

3 years agonet_reader: restart on first UID when UIDVALIDITY changes
Eric Wong [Fri, 23 Apr 2021 07:28:15 +0000 (07:28 +0000)]
net_reader: restart on first UID when UIDVALIDITY changes

In other words, treat the same IMAP folder with a different
UIDVALIDITY as a completely different folder.  If the UIDVALIDITY
changes, we can start from UID=1 without falling behind or
losing data.  If the UIDVALIDITY gets reset to a previously
known-good message, we can still resume where we left off
before the first UIDVALIDITY change.

This affects public-inbox-watch and "lei import"

One potential downside of this is for rare altid users, but
that's mainly intended for NNTP article numbers which are/were
often publicized; not IMAP UIDs which are rarely publicized.

The other potential downside is bandwidth waste in in the rare
case UIDVALIDITY changes while IMAP folder contents remain
unchanged.  There's no extra storage used due to existing
(v1|v2|lei/store) deduplication mechanisms.

Before this change, we were matching offlineimap behavior and
stopped synching an IMAP folder when its UIDVALIDITY changed.
offlineimap behavior made sense for IMAP <=> Maildir
synchronization since Maildirs had no sense of UIDVALIDITY and
could only rely on name mapping.

3 years agodoc: INSTALL: update with more distro info, symlink-install
Eric Wong [Fri, 23 Apr 2021 06:12:49 +0000 (06:12 +0000)]
doc: INSTALL: update with more distro info, symlink-install

3 years agolei up: support symlinked pathnames
Eric Wong [Fri, 23 Apr 2021 01:45:13 +0000 (01:45 +0000)]
lei up: support symlinked pathnames

On my default FreeBSD 11.x system, "/home" is a symlink to
"/usr/home", which causes "lei up" path resolution to fail when
I use outputs in $HOME.  Fall back to a slow path of globbing
and matching pathnames based on st_ino+st_dev.

3 years agolei: saved searches support --dedupe=<mid|oid>
Eric Wong [Fri, 23 Apr 2021 01:45:12 +0000 (01:45 +0000)]
lei: saved searches support --dedupe=<mid|oid>

This is less surprising in case users are used to using --dedupe=
without --save.

3 years agolei: XDG_RUNTIME_DIR=/dev/null disables daemon mode
Eric Wong [Thu, 22 Apr 2021 09:44:16 +0000 (05:44 -0400)]
lei: XDG_RUNTIME_DIR=/dev/null disables daemon mode

We'll support this mode of operation for now to quiet down
testing of oneshot mode where the daemon doesn't persist.

3 years agolei import|convert: drop --no-kw aliases
Eric Wong [Thu, 22 Apr 2021 09:08:22 +0000 (07:08 -0200)]
lei import|convert: drop --no-kw aliases

Supporting --no-keywords and --no-flags aliases is harmful
if users end up assuming "keywords:" and "flags:" are valid
search prefixes (they're not).

3 years agolei import: --incremental default for NNTP and IMAP
Eric Wong [Thu, 22 Apr 2021 09:08:21 +0000 (07:08 -0200)]
lei import: --incremental default for NNTP and IMAP

No point in burning through bandwidth to import stuff we already
saw.  All this logic is shared with -watch but uses a different
pathname for lei since it's tied to lei/store (and not a
public-inbox).

3 years agoimap_tracker: prepare for use with lei
Eric Wong [Thu, 22 Apr 2021 09:08:20 +0000 (07:08 -0200)]
imap_tracker: prepare for use with lei

We'll support nodatacow as we do in other SQLite DBs

3 years agolei: flesh out `forwarded' kw support for Maildir and IMAP
Eric Wong [Wed, 21 Apr 2021 23:50:52 +0000 (23:50 +0000)]
lei: flesh out `forwarded' kw support for Maildir and IMAP

Maildir and IMAP can both handle `forwarded'.  Ensure we don't
lose `forwarded' when reading from stores which do not support
it, but ensure we can set it when reading from IMAP and Maildir
stores.

3 years agodoc: add lei_design_notes.txt and lei-store-format(5)
Eric Wong [Wed, 21 Apr 2021 10:03:15 +0000 (10:03 +0000)]
doc: add lei_design_notes.txt and lei-store-format(5)

lei itself is a somewhat weird design, but lei/store is
a fairly normal hybrid of extindex with v2-style storage.

3 years agolei: share common *done_wait callbacks
Eric Wong [Wed, 21 Apr 2021 18:36:10 +0000 (18:36 +0000)]
lei: share common *done_wait callbacks

Code is the enemy, and there's no need to duplicate things, here.
There may be further opportunities along these lines to further
deduplicate things...

3 years agot/lei-daemon: skip inaccessible socket test as root
Eric Wong [Tue, 20 Apr 2021 22:06:08 +0000 (22:06 +0000)]
t/lei-daemon: skip inaccessible socket test as root

"chmod 0000" on a Unix socket can't stop root from connecting to it;
so just skip the test for rare cases when testing as root.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210420213712.qfpftr2r543cqg7l@nitro.local/
3 years agolei_query: avoid POSIX::lround for older Perls
Eric Wong [Tue, 20 Apr 2021 19:02:06 +0000 (00:02 +0500)]
lei_query: avoid POSIX::lround for older Perls

POSIX.pm shipped with Perl 5.16.3 did not support lround,
at least.  So just rely on built-in core functions.

3 years agotest_common: fix xbail for Perl 5.16
Eric Wong [Tue, 20 Apr 2021 19:02:05 +0000 (00:02 +0500)]
test_common: fix xbail for Perl 5.16

Our use of `ref' was triggering ambiguity in older versions of
the Perl parser.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210420174912.h6d2yv7zu5xr4yfc@nitro.local/
3 years agolei edit-search: command to tweak search parameters
Eric Wong [Tue, 20 Apr 2021 07:16:55 +0000 (07:16 +0000)]
lei edit-search: command to tweak search parameters

This may be useful for users to tweak search parameters.
This command is also the reason lei.saved-search is a git-config
file rather than JSON.

3 years agolei forget-search: new command to forget saved searches
Eric Wong [Tue, 20 Apr 2021 07:16:54 +0000 (07:16 +0000)]
lei forget-search: new command to forget saved searches

Readers may lose interest in subscription topics.  This lets
them avoid clutter by forgetting a saved search.

This does not and will not destroy the contents of an --output
mailbox.  In other words, this is similar to unsubscribing
from an Atom/RSS feed or NNTP group.

I've also decided we won't support 'mv-search', since it'll
probably be rarely used and "lei convert" can be used, instead.

3 years agolei up: support --all=local
Eric Wong [Mon, 19 Apr 2021 23:49:01 +0000 (14:49 -0900)]
lei up: support --all=local

Users may wish to update several saved searches at once.  We can
support parallel updates in lei-daemon so users won't have to do
it themselves via xargs or similar.

Supporting IMAP outputs would be significantly more involved
since we'd have to pre-authenticate for every single IMAP
output before entering the redispatch loop.

3 years agolei up: more error checking for config loading
Eric Wong [Mon, 19 Apr 2021 23:49:00 +0000 (14:49 -0900)]
lei up: more error checking for config loading

We'll support editing the saved search config file, so user
errors may happen and we need to throw sensible errors in that
case.

3 years agoconfig: favor ->get_all when possible
Eric Wong [Mon, 19 Apr 2021 23:48:59 +0000 (14:48 -0900)]
config: favor ->get_all when possible

It's slightly less code.

3 years agolei up: fix help output and ARGV handling
Eric Wong [Mon, 19 Apr 2021 23:48:58 +0000 (14:48 -0900)]
lei up: fix help output and ARGV handling

We don't support changing search terms once "lei q --save" is
used.

3 years agolei-sigpipe: update and move test from xt => t
Eric Wong [Tue, 20 Apr 2021 09:01:00 +0000 (09:01 +0000)]
lei-sigpipe: update and move test from xt => t

We have "lei import" and better test infrastructure for lei,
now, so we can more easily test SIGPIPE without relying on
an already-configured instance.

3 years agolei q: --save and --augment may be combined
Eric Wong [Mon, 19 Apr 2021 08:52:15 +0000 (08:52 +0000)]
lei q: --save and --augment may be combined

This necessitated fixing pause_dedupe to release the handle
used by ->lock_for_scope_fast, but otherwise no changes to
the LeiToMail package.

3 years agolei_saved_search: split "lei q --save" and "lei up" init paths
Eric Wong [Mon, 19 Apr 2021 08:52:14 +0000 (08:52 +0000)]
lei_saved_search: split "lei q --save" and "lei up" init paths

They're more different than alike, and having two separate
methods seems less confusing to me.

3 years agoconfig: git_config_dump blesses
Eric Wong [Mon, 19 Apr 2021 08:52:13 +0000 (08:52 +0000)]
config: git_config_dump blesses

I don't know if it's worth it to sub (or super)class
PublicInbox::Config into something more generic for
lei, but this change simplifies a good chunk of lei
code that reuses the public-inbox config parsing.

3 years agolei_saved_search: avoid needless var shadowing
Eric Wong [Mon, 19 Apr 2021 08:52:12 +0000 (08:52 +0000)]
lei_saved_search: avoid needless var shadowing

While perl (5.28) doesn't complain about this, it's confusing to
my easily-confused mind.

3 years agolei q: implement import-before default for --save
Eric Wong [Mon, 19 Apr 2021 08:52:11 +0000 (08:52 +0000)]
lei q: implement import-before default for --save

This makes "lei q --save" as safe as "lei q" to prevent against
accidental data loss when clobbering an existing output,

3 years agolei: support unlinked/missing saved searches
Eric Wong [Mon, 19 Apr 2021 08:52:10 +0000 (08:52 +0000)]
lei: support unlinked/missing saved searches

It's conceivable a user will want to erase all previous
results but still rerun/refresh a search to get new results.
We probably won't support prune functionality, here, and
instead require explicit removal of saved searches.

3 years agodoc config: mention obfuscation-related options
Kyle Meyer [Mon, 19 Apr 2021 03:00:00 +0000 (23:00 -0400)]
doc config: mention obfuscation-related options

Obfuscation has been available since v1.0.0.  Help those that want to
use the feature figure out how.

3 years agolei ls-search: command to list saved searches
Eric Wong [Sun, 18 Apr 2021 08:40:14 +0000 (08:40 +0000)]
lei ls-search: command to list saved searches

Going forward, we'll probably support JSON for all the "ls-*"
subcommands.  This also provides the basis for "lei up" shell
completion.

3 years agoavoid wrong/needless squote_maybe shortcuts
Eric Wong [Sun, 18 Apr 2021 08:31:39 +0000 (08:31 +0000)]
avoid wrong/needless squote_maybe shortcuts

We'll keep it in PublicInbox::Config for now, since I'm not
sure if there's a better place to put it.

3 years agolei_saved_search: avoid git-config
Eric Wong [Sat, 17 Apr 2021 20:19:12 +0000 (20:19 +0000)]
lei_saved_search: avoid git-config

Repeated vfork+execv costing us around 20ms on t/lei-q-save.t,
so just learn to quote git-config values and write directly to
the config file.

3 years agolei up: further improve Maildir canonicalization
Eric Wong [Sat, 17 Apr 2021 19:00:53 +0000 (19:00 +0000)]
lei up: further improve Maildir canonicalization

We want to be able to use "lei up ." when inside a Maildir.
We'll also relax Maildir/mbox basenames to be any non-'/'
character after converting relative paths to absolute.  The
old restriction on allowed characters was unnecessary and made
it impossible to reliably map "." when used as the sole argument
for "lei up".