mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +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:
parent
52e7054c49
commit
4202fbe108
2 changed files with 31 additions and 7 deletions
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.xcheck(err, "closing account")
|
||||||
ctl.xwriteok()
|
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":
|
case "queue":
|
||||||
/* protocol:
|
/* protocol:
|
||||||
> "queue"
|
> "queue"
|
||||||
|
|
12
main.go
12
main.go
|
@ -889,15 +889,13 @@ Any email address configured for the account can be used.
|
||||||
}
|
}
|
||||||
mustLoadConfig()
|
mustLoadConfig()
|
||||||
|
|
||||||
acc, _, err := store.OpenEmail(args[0])
|
|
||||||
xcheckf(err, "open account")
|
|
||||||
|
|
||||||
pw := xreadpassword()
|
pw := xreadpassword()
|
||||||
|
|
||||||
err = acc.SetPassword(pw)
|
ctl := xctl()
|
||||||
xcheckf(err, "setting password")
|
ctl.xwrite("setaccountpassword")
|
||||||
err = acc.Close()
|
ctl.xwrite(args[0])
|
||||||
xcheckf(err, "closing account")
|
ctl.xwrite(pw)
|
||||||
|
ctl.xreadok()
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdDeliver(c *cmd) {
|
func cmdDeliver(c *cmd) {
|
||||||
|
|
Loading…
Reference in a new issue