~rockorager/offmap

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH offmap v2] password-cmd: support a password command

Details
Message ID
<20221130165548.108436-1-tim@timculverhouse.com>
DKIM signature
pass
Download raw message
Patch: +25 -5
Support using a command which returns the password. Update
documentation.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
---
 doc/offmap.5.scd |  9 +++++++--
 imap/imap.go     | 21 ++++++++++++++++++---
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/doc/offmap.5.scd b/doc/offmap.5.scd
index f7913d58e2ce..a958c74f0fcf 100644
--- a/doc/offmap.5.scd
+++ b/doc/offmap.5.scd
@@ -35,8 +35,13 @@ password = "my-password"
*username* (required)
	The username to login to the IMAP server with.

*password* (required)
	The password to use for the IMAP server.
*password* (optional)
	The password to use for the IMAP server. Either this or *password-cmd*
	are required.

*password-cmd* (optional)
	A command to run which returns the password. Either this or *password*
	are required. 

*max-connections* (optional)
	The maximum number of IMAP clients to spawn. Some providers limit the
diff --git a/imap/imap.go b/imap/imap.go
index be500ecd4277..626be2f7528a 100644
--- a/imap/imap.go
+++ b/imap/imap.go
@@ -4,6 +4,7 @@ import (
	"fmt"
	"io"
	"os"
	"os/exec"
	"path"
	"strconv"
	"strings"
@@ -51,11 +52,25 @@ func NewStore(cfg *viper.Viper) (*Store, error) {
	if store.username == "" {
		return nil, fmt.Errorf("imap: no username set")
	}
	// TODO support password commands
	store.password = cfg.GetString("password")
	if store.password == "" {

	switch {
	case cfg.GetString("password-cmd") != "":
		cmd := exec.Command("sh", "-c", cfg.GetString("password-cmd"))
		out, err := cmd.Output()
		if err != nil {
			return nil, fmt.Errorf("imap: could not get password: %v", err)
		}
		lines := strings.Split(string(out), "\n")
		if len(lines) < 1 {
			return nil, fmt.Errorf("imap: no output from password-cmd")
		}
		store.password = lines[0]
	case cfg.GetString("password") != "":
		store.password = cfg.GetString("password")
	default:
		return nil, fmt.Errorf("imap: no password set")
	}

	store.maxConns = cfg.GetInt("max-connections")
	if store.maxConns < 1 {
		store.maxConns = 2
-- 
2.38.1

[offmap/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<COPSF8UQHQ70.26KFYYMYZXC26@cirno>
In-Reply-To
<20221130165548.108436-1-tim@timculverhouse.com> (view parent)
DKIM signature
missing
Download raw message
offmap/patches/.build.yml: SUCCESS in 1m17s

[password-cmd: support a password command][0] v2 from [Tim Culverhouse][1]

[0]: https://lists.sr.ht/~rockorager/offmap/patches/37248
[1]: tim@timculverhouse.com

✓ #895060 SUCCESS offmap/patches/.build.yml https://builds.sr.ht/~rockorager/job/895060
Details
Message ID
<COPSVQ9HDEMW.UTS3NAI3DWRU@hades.moritz.sh>
In-Reply-To
<20221130165548.108436-1-tim@timculverhouse.com> (view parent)
DKIM signature
pass
Download raw message
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
-- 
Moritz Poldrack
https://moritz.sh
Reply to thread Export thread (mbox)