mirror of
https://github.com/directorz/mailfull-go.git
synced 2025-12-21 03:27:02 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3d3684fda | ||
|
|
c183bba7aa | ||
|
|
b52a7cde7f | ||
|
|
0926ffd318 | ||
|
|
c9201c8fc1 | ||
|
|
fe16bb86f9 | ||
|
|
bd6228197a | ||
|
|
1329747f54 | ||
|
|
ab3c3315f9 | ||
|
|
a76596c348 | ||
|
|
65f9c77e0d | ||
|
|
34768d90f1 | ||
|
|
798579eda8 | ||
|
|
a5f0184852 | ||
|
|
d0003ee454 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1 +1,6 @@
|
|||||||
/cli/mailfull/mailfull
|
/vendor
|
||||||
|
/build
|
||||||
|
/release
|
||||||
|
/github_token
|
||||||
|
|
||||||
|
/cmd/mailfull/mailfull
|
||||||
|
|||||||
6
Gomfile
Normal file
6
Gomfile
Normal 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'
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hikaru KASHIWAZAKI
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
53
Makefile
Normal file
53
Makefile
Normal 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)
|
||||||
@@ -3,6 +3,8 @@ mailfull-go
|
|||||||
|
|
||||||
A management tool for virtual domain email for Postfix and Dovecot written in Go.
|
A management tool for virtual domain email for Postfix and Dovecot written in Go.
|
||||||
|
|
||||||
|
[](https://godoc.org/github.com/directorz/mailfull-go)
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
|
|
||||||
@@ -37,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.)
|
||||||
@@ -64,3 +67,8 @@ Add a new domain and user.
|
|||||||
```
|
```
|
||||||
|
|
||||||
Enjoy!
|
Enjoy!
|
||||||
|
|
||||||
|
More info
|
||||||
|
---------
|
||||||
|
|
||||||
|
See [documentation](doc/README.md)
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
5
doc/README.md
Normal file
5
doc/README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Documentation
|
||||||
|
=============
|
||||||
|
|
||||||
|
- [Configuration](configuration.md)
|
||||||
|
- [Migrating from mailfull](migrating_from_mailfull.md)
|
||||||
12
doc/configuration.md
Normal file
12
doc/configuration.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
`.mailfull/config`
|
||||||
|
|
||||||
|
| key | type | default | required | description |
|
||||||
|
|:----|:-----|:--------|:---------|:------------|
|
||||||
|
| dir_database | string | `"./etc"` | no | A relative path from repository dir (or a absolute path) |
|
||||||
|
| dir_maildata | string | `"./domains"` | no | A relative path from repository dir (or a absolute path) |
|
||||||
|
| username | string | The username who executed `mailfull init` | **yes** | It used for setting owner of database files and maildata files. |
|
||||||
|
| cmd_postalias | string | `"postalias"` | no | Command name or path |
|
||||||
|
| cmd_postmap | string | `"postmap"` | no | Command name or path |
|
||||||
24
doc/migrating_from_mailfull.md
Normal file
24
doc/migrating_from_mailfull.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
Migrating from mailfull
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Migrating from [directorz/mailfull](https://github.com/directorz/mailfull)
|
||||||
|
|
||||||
|
Change directory to Mailfull directory.
|
||||||
|
|
||||||
|
```
|
||||||
|
# su - mailfull
|
||||||
|
$ cd /home/mailfull
|
||||||
|
```
|
||||||
|
|
||||||
|
Initialize a directory as a Mailfull repository.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mailfull init
|
||||||
|
```
|
||||||
|
|
||||||
|
Delete unnecessary files.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ rm -rf .git .gitignore bin docs lib README.md README.ja.md
|
||||||
|
$ find domains -maxdepth 2 -name '.vforward' | xargs rm -f
|
||||||
|
```
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ type RepositoryConfig struct {
|
|||||||
DirDatabasePath string `toml:"dir_database"`
|
DirDatabasePath string `toml:"dir_database"`
|
||||||
DirMailDataPath string `toml:"dir_maildata"`
|
DirMailDataPath string `toml:"dir_maildata"`
|
||||||
Username string `toml:"username"`
|
Username string `toml:"username"`
|
||||||
CmdPostalias string `toml:"postalias"`
|
CmdPostalias string `toml:"cmd_postalias"`
|
||||||
CmdPostmap string `toml:"postmap"`
|
CmdPostmap string `toml:"cmd_postmap"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize normalizes paramaters of the RepositoryConfig.
|
// Normalize normalizes paramaters of the RepositoryConfig.
|
||||||
@@ -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() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package mailfull
|
package mailfull
|
||||||
|
|
||||||
// Version is a version number.
|
// Version is a version number.
|
||||||
const Version = "0.0.1"
|
const Version = "v0.0.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user