Changed from:
-ldflags=-X main.BuildIMAPServer= (no quotes)
To:
-ldflags=-X main.BuildIMAPServer="" (with quotes)
This ensures Go receives the actual IMAP/SMTP credentials
instead of empty strings from defaults in Go code.
Fixed critical bug where 'read -p' without -n returns immediately
on empty input (user pressing Enter), causing variables to be empty.
Solution:
- Changed to 'read -p' (require Enter to submit)
- Added while loops to keep prompting until non-empty values
- IMAP_USERNAME and IMAP_PASSWORD: Required, cannot be empty
- SMTP_USERNAME and SMTP_PASSWORD: Optional, use IMAP values if not provided
- Clearer error messages ("cannot be empty" instead of default value text)
- This preserves user's typed values correctly
Tested with dummy credentials and all checks pass.
Removed confusing headers and simplified logic:
- IMAP credentials are now REQUIRED (no defaults)
- SMTP credentials use IMAP defaults if not specified separately
- IMAP validation applies to both sets
- Clearer prompts without confusing default messages
This should fix empty credential issues by requiring IMAP
credentials to be explicitly entered.
Script now prompts for IMAP/SMTP credentials with visible
labels, making it clear these need to be entered.
Changes:
- Added "Enter IMAP and SMTP credentials" header
- Added "Nextcloud Mail uses different credentials" note
- Made prompts sequential (server, port, user, pass, then again for SMTP)
User experience is now clearer - they see what's expected.
Fixed issue where read -sp (silent prompt) with default
${SMTP_USER:-$IMAP_USER} would use default even when user
provided a value.
Now only uses IMAP defaults when BOTH SMTP username
AND password are empty (user skipped both prompts).
This preserves user's explicit values while correctly
handling the case where user presses Enter on optional
SMTP prompts.
- Build script now shows summary of embedded credentials after build
- quick-test.sh now checks if binary has credentials before running
- This prevents the "dial tcp :143" empty server error
Tests if help output shows empty string in default values.
Build script now validates that IMAP username and password
are not empty before proceeding with the build.
This prevents the binary from being built with empty
credentials which would cause connection errors like:
"dial tcp :143" (empty hostname)
SOLUTION: Pass each -X flag as a separate -ldflags argument.
This isolates each credential value so special characters
in one value don't affect parsing of other values.
Tested successfully with passwords containing:
- Spaces AND quotes: "Pass \quote\ space"
- Hash character: Password#123
- All special characters: P@ss#123 \quote\ space$
This approach handles ALL special characters safely.
Use heredoc to write ldflags to temp file. This allows
passwords containing # (hash) characters to be embedded correctly.
Known limitation: Passwords with both spaces AND quotes together
may still fail. Most other special characters work fine.
The build script was using complex escaping mechanisms that were causing
linker failures with certain passwords.
Simplified to use the same approach as other Nextcloud tools:
- No temp files
- No escaping functions
- Direct variable substitution in ldflags
This matches the pattern used for nextcloud-client, nextcloud-contacts,
and nextcloud-calendar.
Known limitation: Passwords containing spaces, double quotes,
or $ characters may fail to build. Users with such passwords
should use a simpler password or manually modify the build command.
The build was failing with Go linker errors because special characters in
user-provided credentials (especially passwords) were not being properly escaped.
Added escape_ldflag() function to handle:
- Backslashes
- Double quotes
- Spaces
This ensures that any user input (including passwords with special characters)
is safely passed to Go's linker without breaking the build command.
Current compile-time approach is correct for bootstrap architecture:
- Credentials only used during build
- Agent never sees them after
- No binary distribution
- Strings extraction is irrelevant threat
Obfuscation was over-engineering for this use case.
- build-obfuscated.sh: XOR encryption with random 256-bit key
- obfuscation/obfuscation.go: Runtime de-obfuscation package
- OBFUSCATION.md: Documentation and security comparison
- Prevents casual extraction with 'strings' command
- Medium security: Good for personal use, env vars for production
- TEST-PLAN.md: 38 detailed tests covering all features
- quick-test.sh: Automated quick test for basic functionality
- Tests include IMAP, SMTP, attachments, SSL/TLS, error handling
- CLI tools: nextcloud-client, nextcloud-contacts, nextcloud-calendar, nextcloud-mail
- Build script with compile-time credentials
- Skills for all four tools
- Full documentation and examples
- Email tool supports IMAP/SMTP with attachment download
- SSL/TLS support with optional certificate validation