aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/main.go b/main.go
index 13d3da6..4e5abce 100644
--- a/main.go
+++ b/main.go
@@ -13,9 +13,9 @@ import (
"syscall"
ldap "bottin/ldapserver"
+ message "bottin/goldap"
consul "github.com/hashicorp/consul/api"
- message "github.com/lor00x/goldap/message"
log "github.com/sirupsen/logrus"
)
@@ -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.Debug("BOTTIN_DEFAULT_ADMIN_PW environment variable is set, using it for admin's password")
}
- admin_pass_str := base64.RawURLEncoding.EncodeToString(admin_pass)
+
admin_pass_hash := SSHAEncode([]byte(admin_pass_str))
admin_dn := "cn=admin," + server.config.Suffix