mirror of https://github.com/portainer/portainer
fix(encryption): set correct default secret key path (#12848)
Co-authored-by: Gorbasch <57012534+mbegerau@users.noreply.github.com>community
parent
3ac0be4e35
commit
30859ff9f9
|
@ -309,13 +309,13 @@ func initKeyPair(fileService portainer.FileService, signatureService portainer.D
|
||||||
|
|
||||||
// dbSecretPath build the path to the file that contains the db encryption
|
// dbSecretPath build the path to the file that contains the db encryption
|
||||||
// secret. Normally in Docker this is built from the static path inside
|
// secret. Normally in Docker this is built from the static path inside
|
||||||
// /run/portainer for example: /run/portainer/<keyFilenameFlag> but for ease of
|
// /run/secrets for example: /run/secrets/<keyFilenameFlag> but for ease of
|
||||||
// use outside Docker it also accepts an absolute path
|
// use outside Docker it also accepts an absolute path
|
||||||
func dbSecretPath(keyFilenameFlag string) string {
|
func dbSecretPath(keyFilenameFlag string) string {
|
||||||
if path.IsAbs(keyFilenameFlag) {
|
if path.IsAbs(keyFilenameFlag) {
|
||||||
return keyFilenameFlag
|
return keyFilenameFlag
|
||||||
}
|
}
|
||||||
return path.Join("/run/portainer", keyFilenameFlag)
|
return path.Join("/run/secrets", keyFilenameFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadEncryptionSecretKey(keyfilename string) []byte {
|
func loadEncryptionSecretKey(keyfilename string) []byte {
|
||||||
|
|
|
@ -43,12 +43,12 @@ func TestDBSecretPath(t *testing.T) {
|
||||||
keyFilenameFlag string
|
keyFilenameFlag string
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{keyFilenameFlag: "secret.txt", expected: "/run/portainer/secret.txt"},
|
{keyFilenameFlag: "secret.txt", expected: "/run/secrets/secret.txt"},
|
||||||
{keyFilenameFlag: "/tmp/secret.txt", expected: "/tmp/secret.txt"},
|
{keyFilenameFlag: "/tmp/secret.txt", expected: "/tmp/secret.txt"},
|
||||||
{keyFilenameFlag: "/run/portainer/secret.txt", expected: "/run/portainer/secret.txt"},
|
{keyFilenameFlag: "/run/secrets/secret.txt", expected: "/run/secrets/secret.txt"},
|
||||||
{keyFilenameFlag: "./secret.txt", expected: "/run/portainer/secret.txt"},
|
{keyFilenameFlag: "./secret.txt", expected: "/run/secrets/secret.txt"},
|
||||||
{keyFilenameFlag: "../secret.txt", expected: "/run/secret.txt"},
|
{keyFilenameFlag: "../secret.txt", expected: "/run/secret.txt"},
|
||||||
{keyFilenameFlag: "foo/bar/secret.txt", expected: "/run/portainer/foo/bar/secret.txt"},
|
{keyFilenameFlag: "foo/bar/secret.txt", expected: "/run/secrets/foo/bar/secret.txt"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
Loading…
Reference in New Issue