bsmtp: fix and update code, and change CLI parsing to CLI11#1316
Conversation
937023d to
30e0cf4
Compare
|
First build and local test reveal a problem with bsmtp Beware of -h as being replaced by -m which will imply a change in any existing configuration (doesn't sound like a good idea) |
1a32d67 to
236a3e5
Compare
bruno-at-bareos
left a comment
There was a problem hiding this comment.
bsmtp review
- Tested with long options : ok
bsmtp \
--debug-level 100 \
--debug-timestamps \
--from-address "hostmaster@localhost.localdomain" \
--subject "bsmtp CLI11 test - final review - short options" \
--mailhost remotesmtp@domain.tld \
--utf8 \
--ipv6-protocol \
--reply-to "bareos@localhost.localdomain" \
--copy-to "admins@localhost.localdomain" \
hostmaster@localhost.localdomain \
<<< "bsmtp is the perfect tool to work with long options"
Tested with short options: ok
bsmtp \
--d100 \
--dt \
-f "hostmaster@localhost.localdomain" \
-s "bsmtp CLI11 test - final review - short options" \
-h remotesmtp@domain.tld:25 \
-8 \
-6 \
-r "bareos@localhost.localdomain" \
-c "admins@localhost.localdomain
hostmaster@localhost.localdomain \
<<< "bsmtp is the perfect tool to work with long options"
Failing cases:
If passing an ipv4 or ipv4:port is accepted and work, trying to pass an ipv6 is failing, the address being truncated by the first semi-column.
bsmtp \
--debug-level 200 \
--debug-timestamps \
--from-address "hostmaster@localhost.localdomain" \
--subject "bsmtp CLI11 test - final review - short options" \
--mailhost 2001:DB8::baba \
--utf8 \
--ipv6-protocol \
hostmaster@localhost.localdomain <<< "bsmtp is the perfect tool to work with long options availaible. ipv6 addr"
29-Nov-2022 13:15:27.673392 bsmtp (20): tools/bsmtp.cc:259-0 host=2001:DB8::baba
29-Nov-2022 13:15:27.673729 bsmtp (20): tools/bsmtp.cc:348-0 My hostname is: 1741065bd803
29-Nov-2022 13:15:27.673751 bsmtp (20): tools/bsmtp.cc:374-0 From addr=hostmaster@localhost.localdomain
bsmtp: tools/bsmtp.cc:401-0 Error unknown mail host "2001": ERR=Address family for hostname not supported
Also passing an ipv6+port separated by semi-column has to be supported.
The common syntax used look like [::1]:25
I've also let some other comments in code (flags named changes)
23c5b5f to
9593a87
Compare
1a2bdce to
214582c
Compare
1196e8f to
0b06fde
Compare
424fe8a to
04adb8e
Compare
bruno-at-bareos
left a comment
There was a problem hiding this comment.
Everything looks fine and have been tested manually are ok.
We should really check if we can add the ipv6 []:port parsing option to bring this tool on top notch level ;-)
core/src/tools/bsmtp.cc
Outdated
| Dmsg1(10, "Reply-To: %s\r\n", reply_addr.c_str()); | ||
| } | ||
|
|
||
| #if defined(HAVE_WIN32) |
There was a problem hiding this comment.
Note for the future: it is possible that soon or later having a sender not being equal to from will add spam weight to mail and as such make the mail undelivered.
There was a problem hiding this comment.
we should think about sending the e-mail with the null-sender, as we never want a bounce.
701a72e to
cd86704
Compare
610150a to
10043db
Compare
d05c16f to
a64d0b3
Compare
- refactor: reorder variables where needed - refactor: bsmtp: make global variables local and update functions - refactor: bsmtp: change char* to std::string - bsmtp: replace change from and cc long option names - docs: update help documentation - bsmtp: make CLI correctly parse IPv6 addresses - fix --mailhost signature in bsmtp.txt - remove unneed sender header Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
a64d0b3 to
33de7c5
Compare
Description
A few months ago, we upgraded the bareos daemons to use CLI11 as a CLI arguments parsing tool, but
bsmtpandbscryptowere left behind. This PR brings them to the fold.Please check
If you have any questions or problems, please give a comment in the PR.
Helpful documentation and best practices
Checklist for the reviewer of the PR (will be processed by the Bareos team)
General
Separate commit for CHANGELOG.md ("update CHANGELOG.md"). The PR number is correct.Source code quality
bareos-check-sources --since-mergedoes not report any problemsTests
bstmp is still manually tested.