git » chasquid » commit 170aaaf

chasquid-util: Create the domain directory when adding a user

author Alberto Bertogli
2016-11-22 20:25:30 UTC
committer Alberto Bertogli
2016-11-22 20:25:30 UTC
parent 279fff3cf8290cdd4b2dbcbd379b4b7d8b7d9489

chasquid-util: Create the domain directory when adding a user

When adding a user, chasquid-util should create the domain directory if
it doesn't exist, but currently doesn't do that.

This patch fixes this by adding the missing os.MkdirAll call.

Thanks to Martin Ferrari for the bug report!

cmd/chasquid-util/chasquid-util.go +2 -0

diff --git a/cmd/chasquid-util/chasquid-util.go b/cmd/chasquid-util/chasquid-util.go
index 9ec05e4..43282cb 100644
--- a/cmd/chasquid-util/chasquid-util.go
+++ b/cmd/chasquid-util/chasquid-util.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"os"
+	"path/filepath"
 	"syscall"
 
 	"bytes"
@@ -86,6 +87,7 @@ func userDBFromArgs(create bool) (string, string, *userdb.DB) {
 	if err != nil {
 		if create && os.IsNotExist(err) {
 			fmt.Println("Creating database")
+			os.MkdirAll(filepath.Dir(userDBForDomain(domain)), 0755)
 		} else {
 			Fatalf("Error loading database: %v", err)
 		}