-
Notifications
You must be signed in to change notification settings - Fork 2
Import 2.23.3 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Import 2.23.3 #24
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- a/usr/share/perl5/Lemonldap/NG/Common/EmailTransport.pm | ||
| +++ b/usr/share/perl5/Lemonldap/NG/Common/EmailTransport.pm | ||
| @@ -6,7 +6,53 @@ use MIME::Entity; | ||
| use Email::Sender::Simple qw(sendmail); | ||
| use Email::Date::Format qw(email_date); | ||
|
|
||
| -our $VERSION = '2.23.0'; | ||
| +our $VERSION = '2.23.3'; | ||
| + | ||
| +# Check that SMTPAuthMech can be honored: it requires Authen::SASL and an | ||
| +# Email::Sender version providing the sasl_authenticator attribute (>= 1.300032) | ||
| +# Returns an error message, or undef when the configuration is usable | ||
| +sub checkSasl { | ||
| + my ( $class, $conf, $transportClass ) = @_; | ||
| + return undef unless $conf->{SMTPAuthMech} and $conf->{SMTPAuthUser}; | ||
| + $transportClass ||= 'Email::Sender::Transport::SMTP'; | ||
| + return "Choosing the SASL mechanism (SMTPAuthMech) is not supported by " | ||
| + . "$transportClass, Email::Sender 1.300032 or higher is required" | ||
| + unless $transportClass->can('sasl_authenticator'); | ||
| + eval { require Authen::SASL; }; | ||
| + return "Choosing the SASL mechanism (SMTPAuthMech) requires Authen::SASL" | ||
| + if $@; | ||
| + return undef; | ||
| +} | ||
| + | ||
| +# Build the SASL related arguments given to the transport constructor. | ||
| +# When SMTPAuthMech is set, an Authen::SASL object restricted to the wanted | ||
| +# mechanism(s) is used instead of sasl_username/sasl_password: else Net::SMTP | ||
| +# builds itself a SASL client using all the mechanisms advertised by the | ||
| +# server, and picks the "strongest" one, which may be broken server side | ||
| +# (DIGEST-MD5 on some providers for example). | ||
| +# NB: sasl_authenticator and sasl_username are mutually exclusive. | ||
| +sub _saslArgs { | ||
| + my ( $transportClass, $conf ) = @_; | ||
| + return () unless $conf->{SMTPAuthUser}; | ||
| + if ( $conf->{SMTPAuthMech} ) { | ||
| + my $error = __PACKAGE__->checkSasl( $conf, $transportClass ); | ||
| + die "$error\n" if $error; | ||
| + return ( | ||
| + sasl_authenticator => Authen::SASL->new( | ||
| + mechanism => $conf->{SMTPAuthMech}, | ||
| + callback => { | ||
| + user => $conf->{SMTPAuthUser}, | ||
| + authname => $conf->{SMTPAuthUser}, | ||
| + pass => $conf->{SMTPAuthPass}, | ||
| + }, | ||
| + ) | ||
| + ); | ||
| + } | ||
| + return ( | ||
| + sasl_username => $conf->{SMTPAuthUser}, | ||
| + sasl_password => $conf->{SMTPAuthPass}, | ||
| + ); | ||
| +} | ||
|
|
||
| sub new { | ||
| my ( $class, $conf ) = @_; | ||
| @@ -25,14 +71,7 @@ sub new { | ||
| $transport = Email::Sender::Transport::SMTPS->new( | ||
| host => $conf->{SMTPServer}, | ||
| ( $conf->{SMTPPort} ? ( port => $conf->{SMTPPort} ) : () ), | ||
| - ( | ||
| - $conf->{SMTPAuthUser} | ||
| - ? ( | ||
| - sasl_username => $conf->{SMTPAuthUser}, | ||
| - sasl_password => $conf->{SMTPAuthPass} | ||
| - ) | ||
| - : () | ||
| - ), | ||
| + _saslArgs( 'Email::Sender::Transport::SMTPS', $conf ), | ||
| ssl => $smtpTls, | ||
| ); | ||
| return $transport; | ||
| @@ -49,17 +88,11 @@ sub new { | ||
| $transport = Email::Sender::Transport::SMTP->new( | ||
| host => $conf->{SMTPServer}, | ||
| ( $conf->{SMTPPort} ? ( port => $conf->{SMTPPort} ) : () ), | ||
| - ( | ||
| - $conf->{SMTPAuthUser} | ||
| - ? ( | ||
| - sasl_username => $conf->{SMTPAuthUser}, | ||
| - sasl_password => $conf->{SMTPAuthPass} | ||
| - ) | ||
| - : () | ||
| - ), | ||
| + _saslArgs( 'Email::Sender::Transport::SMTP', $conf ), | ||
| ( $smtpTls ? ( ssl => $smtpTls ) : () ), | ||
| ( | ||
| - $conf->{SMTPTLSOpts} ? ( ssl_options => $conf->{SMTPTLSOpts} ) | ||
| + $conf->{SMTPTLSOpts} | ||
| + ? ( ssl_options => $conf->{SMTPTLSOpts} ) | ||
| : () | ||
| ), | ||
| ); | ||
| @@ -91,7 +124,10 @@ sub configTest { | ||
| } | ||
| } | ||
| } | ||
| - return $res, $message; | ||
| + if ( my $error = $class->checkSasl($conf) ) { | ||
| + $message = ( $message ? "$message. " : "" ) . $error; | ||
| + } | ||
| + return ( $res, $message ); | ||
| } | ||
|
|
||
| sub sendTestMail { | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- a/usr/share/perl5/Lemonldap/NG/Common/EmailTransport.pm | ||
| +++ b/usr/share/perl5/Lemonldap/NG/Common/EmailTransport.pm | ||
| @@ -6,7 +6,53 @@ use MIME::Entity; | ||
| use Email::Sender::Simple qw(sendmail); | ||
| use Email::Date::Format qw(email_date); | ||
|
|
||
| -our $VERSION = '2.23.0'; | ||
| +our $VERSION = '2.23.3'; | ||
| + | ||
| +# Check that SMTPAuthMech can be honored: it requires Authen::SASL and an | ||
| +# Email::Sender version providing the sasl_authenticator attribute (>= 1.300032) | ||
| +# Returns an error message, or undef when the configuration is usable | ||
| +sub checkSasl { | ||
| + my ( $class, $conf, $transportClass ) = @_; | ||
| + return undef unless $conf->{SMTPAuthMech} and $conf->{SMTPAuthUser}; | ||
| + $transportClass ||= 'Email::Sender::Transport::SMTP'; | ||
| + return "Choosing the SASL mechanism (SMTPAuthMech) is not supported by " | ||
| + . "$transportClass, Email::Sender 1.300032 or higher is required" | ||
| + unless $transportClass->can('sasl_authenticator'); | ||
| + eval { require Authen::SASL; }; | ||
| + return "Choosing the SASL mechanism (SMTPAuthMech) requires Authen::SASL" | ||
| + if $@; | ||
| + return undef; | ||
| +} | ||
| + | ||
| +# Build the SASL related arguments given to the transport constructor. | ||
| +# When SMTPAuthMech is set, an Authen::SASL object restricted to the wanted | ||
| +# mechanism(s) is used instead of sasl_username/sasl_password: else Net::SMTP | ||
| +# builds itself a SASL client using all the mechanisms advertised by the | ||
| +# server, and picks the "strongest" one, which may be broken server side | ||
| +# (DIGEST-MD5 on some providers for example). | ||
| +# NB: sasl_authenticator and sasl_username are mutually exclusive. | ||
| +sub _saslArgs { | ||
| + my ( $transportClass, $conf ) = @_; | ||
| + return () unless $conf->{SMTPAuthUser}; | ||
| + if ( $conf->{SMTPAuthMech} ) { | ||
| + my $error = __PACKAGE__->checkSasl( $conf, $transportClass ); | ||
| + die "$error\n" if $error; | ||
| + return ( | ||
| + sasl_authenticator => Authen::SASL->new( | ||
| + mechanism => $conf->{SMTPAuthMech}, | ||
| + callback => { | ||
| + user => $conf->{SMTPAuthUser}, | ||
| + authname => $conf->{SMTPAuthUser}, | ||
| + pass => $conf->{SMTPAuthPass}, | ||
| + }, | ||
| + ) | ||
| + ); | ||
| + } | ||
| + return ( | ||
| + sasl_username => $conf->{SMTPAuthUser}, | ||
| + sasl_password => $conf->{SMTPAuthPass}, | ||
| + ); | ||
| +} | ||
|
|
||
| sub new { | ||
| my ( $class, $conf ) = @_; | ||
| @@ -25,14 +71,7 @@ sub new { | ||
| $transport = Email::Sender::Transport::SMTPS->new( | ||
| host => $conf->{SMTPServer}, | ||
| ( $conf->{SMTPPort} ? ( port => $conf->{SMTPPort} ) : () ), | ||
| - ( | ||
| - $conf->{SMTPAuthUser} | ||
| - ? ( | ||
| - sasl_username => $conf->{SMTPAuthUser}, | ||
| - sasl_password => $conf->{SMTPAuthPass} | ||
| - ) | ||
| - : () | ||
| - ), | ||
| + _saslArgs( 'Email::Sender::Transport::SMTPS', $conf ), | ||
| ssl => $smtpTls, | ||
| ); | ||
| return $transport; | ||
| @@ -49,17 +88,11 @@ sub new { | ||
| $transport = Email::Sender::Transport::SMTP->new( | ||
| host => $conf->{SMTPServer}, | ||
| ( $conf->{SMTPPort} ? ( port => $conf->{SMTPPort} ) : () ), | ||
| - ( | ||
| - $conf->{SMTPAuthUser} | ||
| - ? ( | ||
| - sasl_username => $conf->{SMTPAuthUser}, | ||
| - sasl_password => $conf->{SMTPAuthPass} | ||
| - ) | ||
| - : () | ||
| - ), | ||
| + _saslArgs( 'Email::Sender::Transport::SMTP', $conf ), | ||
| ( $smtpTls ? ( ssl => $smtpTls ) : () ), | ||
| ( | ||
| - $conf->{SMTPTLSOpts} ? ( ssl_options => $conf->{SMTPTLSOpts} ) | ||
| + $conf->{SMTPTLSOpts} | ||
| + ? ( ssl_options => $conf->{SMTPTLSOpts} ) | ||
| : () | ||
| ), | ||
| ); | ||
| @@ -91,7 +124,10 @@ sub configTest { | ||
| } | ||
| } | ||
| } | ||
| - return $res, $message; | ||
| + if ( my $error = $class->checkSasl($conf) ) { | ||
| + $message = ( $message ? "$message. " : "" ) . $error; | ||
| + } | ||
| + return ( $res, $message ); | ||
| } | ||
|
|
||
| sub sendTestMail { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
checkSasltestscan('sasl_authenticator')on a class that is not loaded. Both base patch files carry the sameEmailTransport.pmhunk, so the false "Email::Sender 1.300032 or higher is required" message appears in both image families.base-no-s6/2.23.3.patch#L13-L24: load$transportClasswithrequirebefore thecantest.base/2.23.3.patch#L13-L24: apply the identicalrequireguard.📍 Affects 2 files
base-no-s6/2.23.3.patch#L13-L24(this comment)base/2.23.3.patch#L13-L24🤖 Prompt for AI Agents