mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 12:24:38 +03:00
make the setaccountpassword talk through ctl
otherwise, setting a password will block if something has the account open, e.g. any imap connection. so in practice it only worked when mox isn't running.
This commit is contained in:
26
ctl.go
26
ctl.go
@ -403,6 +403,32 @@ func servectlcmd(ctx context.Context, log *mlog.Log, ctl *ctl, xcmd *string, shu
|
||||
ctl.xcheck(err, "closing account")
|
||||
ctl.xwriteok()
|
||||
|
||||
case "setaccountpassword":
|
||||
/* protocol:
|
||||
> "setaccountpassword"
|
||||
> address
|
||||
> password
|
||||
< "ok" or error
|
||||
*/
|
||||
|
||||
addr := ctl.xread()
|
||||
pw := ctl.xread()
|
||||
|
||||
acc, _, err := store.OpenEmail(addr)
|
||||
ctl.xcheck(err, "open account")
|
||||
defer func() {
|
||||
if acc != nil {
|
||||
acc.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
err = acc.SetPassword(pw)
|
||||
ctl.xcheck(err, "setting password")
|
||||
err = acc.Close()
|
||||
ctl.xcheck(err, "closing account")
|
||||
acc = nil
|
||||
ctl.xwriteok()
|
||||
|
||||
case "queue":
|
||||
/* protocol:
|
||||
> "queue"
|
||||
|
Reference in New Issue
Block a user