diff --git a/cmd/config.go b/cmd/config.go index 74121f982ca..be8caea5f6c 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -74,6 +74,9 @@ passphrase if needed. if !bytes.Equal(pass1, pass2) { return fmt.Errorf("Passphrase missmatch") } + if len(pass1) == 0 { + return fmt.Errorf("Empty password is forbidden") + } passphrase = pass1 } diff --git a/cmd/root.go b/cmd/root.go index 6234324d91f..2a1d2c4e485 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -70,7 +70,10 @@ func newClient(domain string, scopes ...string) *client.Client { } func newAdminClient() *client.AdminClient { - pass := []byte(os.Getenv("COZY_ADMIN_PASSWORD")) + pass := []byte(os.Getenv("COZY_ADMIN_PASSPHRASE")) + if len(pass) == 0 { + pass = []byte(os.Getenv("COZY_ADMIN_PASSWORD")) + } if !build.IsDevRelease() { if len(pass) == 0 { var err error diff --git a/debian/uninstall-onboarding.sh b/debian/uninstall-onboarding.sh index 5e73cf3247a..f12eea2df7d 100755 --- a/debian/uninstall-onboarding.sh +++ b/debian/uninstall-onboarding.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -export COZY_ADMIN_PASSWORD="$(cat /etc/cozy/.cozy-admin-passphrase)" +export COZY_ADMIN_PASSPHRASE="$(cat /etc/cozy/.cozy-admin-passphrase)" function app_installed { DOMAIN="${1}" diff --git a/docs/config.md b/docs/config.md index edca730d382..e10d2459803 100644 --- a/docs/config.md +++ b/docs/config.md @@ -79,8 +79,8 @@ generate this file, you can use the `cozy-stack config passwd [filepath]` command. This command will ask you for a passphrase and will create the `cozy-admin-passphrase` at the specified path. -You can use the `COZY_ADMIN_PASSWORD` env variable if you do not want to type -the passphrase each time you call `cozy-stack`. +You can use the `COZY_ADMIN_PASSPHRASE` (or `COZY_ADMIN_PASSWORD`) env variable +if you do not want to type the passphrase each time you call `cozy-stack`. ### Example