aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/main.go b/main.go
index 13d3da6..91c3bbd 100644
--- a/main.go
+++ b/main.go
@@ -320,12 +320,19 @@ func (server *Server) init() error {
return err
}
- admin_pass := make([]byte, 8)
- _, err = rand.Read(admin_pass)
- if err != nil {
- return err
+
+ admin_pass_str, environnement_variable_exist := os.LookupEnv("BOTTIN_DEFAULT_ADMIN_PW")
+ if !environnement_variable_exist {
+ admin_pass := make([]byte, 8)
+ _, err = rand.Read(admin_pass)
+ if err != nil {
+ return err
+ }
+ admin_pass_str = base64.RawURLEncoding.EncodeToString(admin_pass)
+ } else {
+ server.logger.Printf("It seems that exists a password in environnement variable")
}
- admin_pass_str := base64.RawURLEncoding.EncodeToString(admin_pass)
+
admin_pass_hash := SSHAEncode([]byte(admin_pass_str))
admin_dn := "cn=admin," + server.config.Suffix