From bd6228197a60b9fa5ab56dfae52551aef6e1e0c3 Mon Sep 17 00:00:00 2001 From: teru Date: Thu, 18 Aug 2016 19:22:54 +0900 Subject: [PATCH 1/6] cosmetic changes --- cmd/mailfull/command/usercheckpw.go | 6 +++--- cmd/mailfull/command/userpasswd.go | 18 +++++++++--------- repository.go | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd/mailfull/command/usercheckpw.go b/cmd/mailfull/command/usercheckpw.go index 6fd8e37..66d93af 100644 --- a/cmd/mailfull/command/usercheckpw.go +++ b/cmd/mailfull/command/usercheckpw.go @@ -81,9 +81,9 @@ func (c *UserCheckPwCommand) Run(args []string) int { } if len(args) != 2 { - input, err1 := c.UI.AskSecret(fmt.Sprintf("Enter password for %s:", address)) - if err1 != nil { - fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err1) + input, err := c.UI.AskSecret(fmt.Sprintf("Enter password for %s:", address)) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) return 1 } diff --git a/cmd/mailfull/command/userpasswd.go b/cmd/mailfull/command/userpasswd.go index 5f5be57..ea568d8 100644 --- a/cmd/mailfull/command/userpasswd.go +++ b/cmd/mailfull/command/userpasswd.go @@ -81,14 +81,14 @@ func (c *UserPasswdCommand) Run(args []string) int { } if len(args) != 2 { - input1, err1 := c.UI.AskSecret(fmt.Sprintf("Enter new password for %s:", address)) - if err1 != nil { - fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err1) + input1, err := c.UI.AskSecret(fmt.Sprintf("Enter new password for %s:", address)) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) return 1 } - input2, err2 := c.UI.AskSecret("Retype new password:") - if err2 != nil { - fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err2) + input2, err := c.UI.AskSecret("Retype new password:") + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) return 1 } if input1 != input2 { @@ -100,9 +100,9 @@ func (c *UserPasswdCommand) Run(args []string) int { hashedPassword := mailfull.NeverMatchHashedPassword if rawPassword != "" { - str, errHash := ssha.Generate(rawPassword, 4) - if errHash != nil { - fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", errHash) + str, err := ssha.Generate(rawPassword, 4) + if err != nil { + fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) return 1 } hashedPassword = str diff --git a/repository.go b/repository.go index a1e27dd..187c997 100644 --- a/repository.go +++ b/repository.go @@ -126,10 +126,10 @@ func OpenRepository(basePath string) (*Repository, error) { for { configDirPath := filepath.Join(rootPath, DirNameConfig) - fi, errStat := os.Stat(configDirPath) - if errStat != nil { - if errStat.(*os.PathError).Err != syscall.ENOENT { - return nil, errStat + fi, err := os.Stat(configDirPath) + if err != nil { + if err.(*os.PathError).Err != syscall.ENOENT { + return nil, err } } else { if fi.IsDir() { From fe16bb86f96832b028b3426582492ee9a3261bfe Mon Sep 17 00:00:00 2001 From: teru Date: Thu, 18 Aug 2016 19:23:27 +0900 Subject: [PATCH 2/6] Disable to delete `postmaster` #14 --- cmd/mailfull/command/userdel.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/mailfull/command/userdel.go b/cmd/mailfull/command/userdel.go index b19c365..9e2d2b4 100644 --- a/cmd/mailfull/command/userdel.go +++ b/cmd/mailfull/command/userdel.go @@ -59,6 +59,11 @@ func (c *UserDelCommand) Run(args []string) int { return 1 } + if userName == "postmaster" { + fmt.Fprintf(c.UI.ErrorWriter, "[ERR] Cannot delete postmaster.\n") + return 1 + } + if err := repo.UserRemove(domainName, userName); err != nil { fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) return 1 From c9201c8fc142b144969950d0ed5c1cc431e67477 Mon Sep 17 00:00:00 2001 From: teru Date: Thu, 18 Aug 2016 19:43:43 +0900 Subject: [PATCH 3/6] Fix README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 55d0832..9ead86e 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Initialize a directory as a Mailfull repository. ``` $ mkdir /path/to/repo && cd /path/to/repo $ mailfull init +$ mailfull commit ``` Generate configurations for Postfix and Dovecot. (Edit as needed.) From 0926ffd3184ad1e59d84a50531f501dd267c47f3 Mon Sep 17 00:00:00 2001 From: teru Date: Thu, 18 Aug 2016 20:33:19 +0900 Subject: [PATCH 4/6] Change the path of session cache database --- generateconfig.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generateconfig.go b/generateconfig.go index a2cc75f..01af7ba 100644 --- a/generateconfig.go +++ b/generateconfig.go @@ -45,7 +45,7 @@ smtpd_sasl_path = private/auth smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem #smtpd_tls_CAfile = -smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache +smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3 smtp_tls_security_level = may From b52a7cde7fd29f78e93a136148ac2507a00154ce Mon Sep 17 00:00:00 2001 From: teru Date: Mon, 22 Aug 2016 15:15:08 +0900 Subject: [PATCH 5/6] Add support for creating GitHub Releases page --- .gitignore | 7 ++++++- Gomfile | 6 ++++++ Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Gomfile create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 39a7681..28875c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -/cli/mailfull/mailfull +/vendor +/build +/release +/github_token + +/cmd/mailfull/mailfull diff --git a/Gomfile b/Gomfile new file mode 100644 index 0000000..c7ebd62 --- /dev/null +++ b/Gomfile @@ -0,0 +1,6 @@ +gom 'github.com/BurntSushi/toml' +gom 'github.com/armon/go-radix' +gom 'github.com/bgentry/speakeasy' +gom 'github.com/jsimonetti/pwscheme' +gom 'github.com/mattn/go-isatty' +gom 'github.com/mitchellh/cli' diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f3e73c9 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +GOVERSION=$(shell go version) +GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION)))) +GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION)))) +DIR_BUILD=build +DIR_RELEASE=release +VERSION=$(patsubst "%",%,$(lastword $(shell grep 'const Version' version.go))) + +.PHONY: build build-linux-amd64 build-linux-386 clean + +default: build + +installdeps: + gom install + +build: + go build -ldflags "-X main.gittag=`git rev-parse --short HEAD`" -v -o build/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/main.go + +build-linux-amd64: + docker run --rm -v $(PWD):/go/src/github.com/directorz/mailfull-go -w /go/src/github.com/directorz/mailfull-go \ + -e GOOS=linux -e GOARCH=amd64 golang:1.7 \ + go build -ldflags "-X main.gittag=`git rev-parse --short HEAD`" -v -o "build/mailfull_linux_amd64/mailfull" cmd/mailfull/main.go + +build-linux-386: + docker run --rm -v $(PWD):/go/src/github.com/directorz/mailfull-go -w /go/src/github.com/directorz/mailfull-go \ + -e GOOS=linux -e GOARCH=386 golang:1.7 \ + go build -ldflags "-X main.gittag=`git rev-parse --short HEAD`" -v -o "build/mailfull_linux_386/mailfull" cmd/mailfull/main.go + +release: release-linux-amd64 release-linux-386 + +release-linux-amd64: build-linux-amd64 + @$(MAKE) release-doc release-targz GOOS=linux GOARCH=amd64 + +release-linux-386: build-linux-386 + @$(MAKE) release-doc release-targz GOOS=linux GOARCH=386 + +release-doc: + cp -a README.md doc $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH) + +release-targz: dir-$(DIR_RELEASE) + tar zcfp $(DIR_RELEASE)/mailfull_$(GOOS)_$(GOARCH).tar.gz -C $(DIR_BUILD) mailfull_$(GOOS)_$(GOARCH) + +dir-$(DIR_RELEASE): + mkdir -p $(DIR_RELEASE) + +release-upload: release-linux-amd64 release-linux-386 release-github-token + ghr -u directorz -r mailfull-go -t $(shell cat github_token) --replace --draft $(VERSION) $(DIR_RELEASE) + +release-github-token: github_token + @echo "file \"github_token\" is required" + +clean: + -rm -rf $(DIR_BUILD) + -rm -rf $(DIR_RELEASE) From c183bba7aa81d2a3a75232465622acf4951d99ee Mon Sep 17 00:00:00 2001 From: teru Date: Mon, 22 Aug 2016 15:19:59 +0900 Subject: [PATCH 6/6] Bump version to v0.0.3 --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 76908b4..51658b0 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package mailfull // Version is a version number. -const Version = "0.0.2" +const Version = "v0.0.3"