mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
dovecot-auth-cli: Add help message
The dovecot-auth-cli binary can be useful to debug and troubleshoot dovecot auth issues. This patch adds a small help message to make it easier for users to understand how to use it.
This commit is contained in:
@@ -8,12 +8,31 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"blitiri.com.ar/go/chasquid/internal/dovecot"
|
"blitiri.com.ar/go/chasquid/internal/dovecot"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const help = `
|
||||||
|
Usage:
|
||||||
|
dovecot-auth-cli <path prefix> exists user@domain
|
||||||
|
dovecot-auth-cli <path prefix> auth user@domain password
|
||||||
|
|
||||||
|
Example:
|
||||||
|
dovecot-auth-cli /var/run/dovecot/auth-chasquid exists user@domain
|
||||||
|
dovecot-auth-cli /var/run/dovecot/auth-chasquid auth user@domain password
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if len(flag.Args()) < 3 {
|
||||||
|
fmt.Fprint(os.Stderr, help)
|
||||||
|
fmt.Print("no: invalid arguments\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
a := dovecot.NewAuth(flag.Arg(0)+"-userdb", flag.Arg(0)+"-client")
|
a := dovecot.NewAuth(flag.Arg(0)+"-userdb", flag.Arg(0)+"-client")
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
@@ -25,11 +44,11 @@ func main() {
|
|||||||
case "auth":
|
case "auth":
|
||||||
ok, err = a.Authenticate(flag.Arg(2), flag.Arg(3))
|
ok, err = a.Authenticate(flag.Arg(2), flag.Arg(3))
|
||||||
default:
|
default:
|
||||||
fmt.Printf("unknown subcommand\n")
|
err = fmt.Errorf("unknown subcommand %q", flag.Arg(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
fmt.Printf("yes\n")
|
fmt.Print("yes\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
c = ./dovecot-auth-cli .missingsocket something
|
c = ./dovecot-auth-cli .missingsocket something else
|
||||||
c <- unknown subcommand
|
c <- no: unknown subcommand "something"
|
||||||
c wait 0
|
c wait 0
|
||||||
|
|||||||
Reference in New Issue
Block a user