1
0
mirror of https://github.com/directorz/mailfull-go.git synced 2025-12-17 09:37:02 +00:00

Merge pull request #16 from directorz/feature/implements

Feature/implements
This commit is contained in:
teru
2016-08-22 15:20:37 +09:00
committed by GitHub
10 changed files with 89 additions and 19 deletions

7
.gitignore vendored
View File

@@ -1 +1,6 @@
/cli/mailfull/mailfull /vendor
/build
/release
/github_token
/cmd/mailfull/mailfull

6
Gomfile Normal file
View File

@@ -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'

53
Makefile Normal file
View File

@@ -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)

View File

@@ -39,6 +39,7 @@ Initialize a directory as a Mailfull repository.
``` ```
$ mkdir /path/to/repo && cd /path/to/repo $ mkdir /path/to/repo && cd /path/to/repo
$ mailfull init $ mailfull init
$ mailfull commit
``` ```
Generate configurations for Postfix and Dovecot. (Edit as needed.) Generate configurations for Postfix and Dovecot. (Edit as needed.)

View File

@@ -81,9 +81,9 @@ func (c *UserCheckPwCommand) Run(args []string) int {
} }
if len(args) != 2 { if len(args) != 2 {
input, err1 := c.UI.AskSecret(fmt.Sprintf("Enter password for %s:", address)) input, err := c.UI.AskSecret(fmt.Sprintf("Enter password for %s:", address))
if err1 != nil { if err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err1) fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1 return 1
} }

View File

@@ -59,6 +59,11 @@ func (c *UserDelCommand) Run(args []string) int {
return 1 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 { if err := repo.UserRemove(domainName, userName); err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err) fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1 return 1

View File

@@ -81,14 +81,14 @@ func (c *UserPasswdCommand) Run(args []string) int {
} }
if len(args) != 2 { if len(args) != 2 {
input1, err1 := c.UI.AskSecret(fmt.Sprintf("Enter new password for %s:", address)) input1, err := c.UI.AskSecret(fmt.Sprintf("Enter new password for %s:", address))
if err1 != nil { if err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err1) fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1 return 1
} }
input2, err2 := c.UI.AskSecret("Retype new password:") input2, err := c.UI.AskSecret("Retype new password:")
if err2 != nil { if err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err2) fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1 return 1
} }
if input1 != input2 { if input1 != input2 {
@@ -100,9 +100,9 @@ func (c *UserPasswdCommand) Run(args []string) int {
hashedPassword := mailfull.NeverMatchHashedPassword hashedPassword := mailfull.NeverMatchHashedPassword
if rawPassword != "" { if rawPassword != "" {
str, errHash := ssha.Generate(rawPassword, 4) str, err := ssha.Generate(rawPassword, 4)
if errHash != nil { if err != nil {
fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", errHash) fmt.Fprintf(c.UI.ErrorWriter, "[ERR] %v\n", err)
return 1 return 1
} }
hashedPassword = str hashedPassword = str

View File

@@ -45,7 +45,7 @@ smtpd_sasl_path = private/auth
smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
#smtpd_tls_CAfile = #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 smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = may smtp_tls_security_level = may

View File

@@ -126,10 +126,10 @@ func OpenRepository(basePath string) (*Repository, error) {
for { for {
configDirPath := filepath.Join(rootPath, DirNameConfig) configDirPath := filepath.Join(rootPath, DirNameConfig)
fi, errStat := os.Stat(configDirPath) fi, err := os.Stat(configDirPath)
if errStat != nil { if err != nil {
if errStat.(*os.PathError).Err != syscall.ENOENT { if err.(*os.PathError).Err != syscall.ENOENT {
return nil, errStat return nil, err
} }
} else { } else {
if fi.IsDir() { if fi.IsDir() {

View File

@@ -1,4 +1,4 @@
package mailfull package mailfull
// Version is a version number. // Version is a version number.
const Version = "0.0.2" const Version = "v0.0.3"