Skip to content

Wait for IMAP server greeting before authenticating#248

Merged
wesm merged 1 commit into
mainfrom
issue-218
Apr 7, 2026
Merged

Wait for IMAP server greeting before authenticating#248
wesm merged 1 commit into
mainfrom
issue-218

Conversation

@wesm
Copy link
Copy Markdown
Member

@wesm wesm commented Apr 7, 2026

Closes #218

Summary

  • Add WaitGreeting() call after IMAP dial and before Login/Authenticate, per RFC 3501 client requirements
  • Fixes unexpected EOF when connecting through local OAuth proxies (e.g. email-oauth2-proxy) that need time to establish the upstream TLS session before issuing the greeting

🤖 Generated with Claude Code

The IMAP client sent LOGIN/AUTHENTICATE immediately after TCP
connect without waiting for the server's `* OK` greeting. This
broke connections through local OAuth proxies (e.g.
email-oauth2-proxy) where the proxy needs time to establish its
upstream TLS session before it can issue the greeting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented Apr 7, 2026

roborev: Combined Review (0aefd7e)

No medium-or-higher findings; the change looks clean.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@wesm wesm merged commit 3720b26 into main Apr 7, 2026
4 checks passed
sternryan added a commit to sternryan/msgvault that referenced this pull request Apr 26, 2026
Reconciles 172 ahead / 37 behind state with upstream wesm/msgvault.

Strategy: accept upstream wholesale for connector code (M365, iMessage,
gvoice, IMAP XOAUTH2) where upstream's implementations are more
battle-tested and already cover the fork's bug fixes. Hand-resolve
store/sync/search/cmd/build files to union both feature sets.

Preserved from fork:
- SQLCipher encryption-at-rest (passphrase, AES-GCM token encryption)
- Advisory file locking (tryLock, lockFile, syscall.Flock)
- AI Archive Intelligence subsystem (internal/embedding/, vec_messages,
  pipeline_runs, --semantic search)
- Web UI (React/TypeScript SPA in web/)
- Hot-path search tokenizer (dispatchToken, toLowerFast, parseSizeFast)
- migrateAddContentID, InitVectorTable, content_id attachment column

Adopted from upstream:
- Dialect interface + loggedDB wrapper + structured logging pipeline
  (kenn-io#276 PostgreSQL dialect refactor foundation)
- OpenReadOnly() for MCP read-only access
- IsBusyError, SchemaStale helpers
- Unified text import (kenn-io#238) — M365 OAuth (kenn-io#228), iMessage (kenn-io#224),
  Google Voice (kenn-io#225) — all wholesale
- Search enhancements: regex, FTS5 snippets, sorting (kenn-io#252),
  domain normalization (normalizeAddr, looksLikeDomain, gTLDs)
- rebuild-fts command (kenn-io#287), 8 bug fixes from kenn-io#254
- IMAP date filtering (kenn-io#222), greeting wait (kenn-io#248)
- Vector subsystem (kenn-io#277) — coexists with fork's AI Archive
  Intelligence as parallel implementation; future cleanup needed

Build/runtime fixes applied during merge:
- Replaced mattn/go-sqlite3 imports with mutecomm/go-sqlcipher/v4
  (drop-in API-compatible) to resolve duplicate symbol linker errors
- Dropped sqlite_vec from default BUILD_TAGS (requires SQLite 3.38+
  APIs sqlcipher v4.4.2 does not expose; re-enable when sqlcipher
  upgrades)
- safeRowsAffected helper in db_logger.go: defer recover around
  RowsAffected() call (sqlcipher returns nil internal Result for
  multi-statement DDL)
- Wired normalizeAddr into hot-path tokenizer for from:/to:/cc:/bcc:

Stubbed under unreachable build tag (need follow-up decision):
- cmd/msgvault/cmd/sync_gvoice.go — fork's sync API obsolete vs
  upstream's import-based gvoice
- cmd/msgvault/cmd/sync_imessage.go — same situation

Verified: go build ./... passing, go vet clean, 45/45 test packages
pass with 0 failures. See MERGE_REPORT.md for file-by-file resolution
notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IMAP Login can run before server greeting (breaks email-oauth2-proxy / fast upstream setup)

1 participant