mirror of
https://github.com/mjl-/mox.git
synced 2024-12-25 16:03:48 +03:00
when opening an account by email address, such as during login attempts, and address is an alias, fail with proper error "no such credentials" instead of with error "no such account", which printing a stack trace
was encountered during smtp session. but could also happen for imapserver and webmail. in smtpserver, we now log error messages for smtp errors that cause us to print a stack trace. would have made logging output more helpful (without having to turn on trace-level logging). hopefully solves issue #238 by mwyvr, thanks for reporting!
This commit is contained in:
parent
0e338b0530
commit
3d4cd00430
3 changed files with 12 additions and 1 deletions
|
@ -63,7 +63,10 @@ func LookupAddress(localpart smtp.Localpart, domain dns.Domain, allowPostmaster,
|
|||
canonical := smtp.NewAddress(localpart, domain).String()
|
||||
|
||||
accAddr, alias, ok := Conf.AccountDestination(canonical)
|
||||
if ok && alias != nil && allowAlias {
|
||||
if ok && alias != nil {
|
||||
if !allowAlias {
|
||||
return "", nil, "", config.Destination{}, ErrAddressNotFound
|
||||
}
|
||||
return "", alias, canonical, config.Destination{}, nil
|
||||
} else if !ok {
|
||||
if accAddr, alias, ok = Conf.AccountDestination("@" + domain.Name()); !ok || alias != nil {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package smtpserver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -62,6 +63,12 @@ func TestAliasSubmitMsgFromDenied(t *testing.T) {
|
|||
ts := newTestServer(t, filepath.FromSlash("../testdata/smtp/mox.conf"), dns.MockResolver{})
|
||||
defer ts.close()
|
||||
|
||||
// Trying to open account by alias should result in proper error.
|
||||
_, _, err := store.OpenEmail(pkglog, "public@mox.example")
|
||||
if err == nil || !errors.Is(err, store.ErrUnknownCredentials) {
|
||||
t.Fatalf("opening alias, got err %v, expected store.ErrUnknownCredentials", err)
|
||||
}
|
||||
|
||||
acc, err := store.OpenAccount(pkglog, "☺")
|
||||
tcheck(t, err, "open account")
|
||||
err = acc.SetPassword(pkglog, password0)
|
||||
|
|
|
@ -751,6 +751,7 @@ func command(c *conn) {
|
|||
if errors.As(err, &serr) {
|
||||
c.writecodeline(serr.code, serr.secode, fmt.Sprintf("%s (%s)", serr.errmsg, mox.ReceivedID(c.cid)), serr.err)
|
||||
if serr.printStack {
|
||||
c.log.Errorx("smtp error", serr.err, slog.Int("code", serr.code), slog.String("secode", serr.secode))
|
||||
debug.PrintStack()
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue