Skip to content

Commit 7250145

Browse files
committed
feat(x): login user independent socket path for windows service
1 parent b960240 commit 7250145

3 files changed

Lines changed: 59 additions & 7 deletions

File tree

x/api/defaults.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ func DefaultSocketPath() string {
5454
return filepath.Join(os.TempDir(), "docker-secrets-engine", "engine.sock")
5555
}
5656

57-
func DaemonSocketPath() string {
58-
if dir, err := os.UserCacheDir(); err == nil {
59-
return filepath.Join(dir, "docker-secrets-engine", "daemon.sock")
60-
}
61-
return filepath.Join(os.TempDir(), "docker-secrets-engine", "daemon.sock")
62-
}
63-
6457
func DefaultSecretsEngineDirectory() (string, error) {
6558
dir, err := os.UserConfigDir()
6659
if err != nil {

x/api/defaults_unix.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2025-2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build !windows
16+
17+
package api
18+
19+
import (
20+
"os"
21+
"path/filepath"
22+
)
23+
24+
func DaemonSocketPath() string {
25+
if dir, err := os.UserCacheDir(); err == nil {
26+
return filepath.Join(dir, "docker-secrets-engine", "daemon.sock")
27+
}
28+
return filepath.Join(os.TempDir(), "docker-secrets-engine", "daemon.sock")
29+
}

x/api/defaults_windows.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2025-2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build windows
16+
17+
package api
18+
19+
import (
20+
"os"
21+
"path/filepath"
22+
)
23+
24+
func DaemonSocketPath() string {
25+
base := os.Getenv("ProgramData")
26+
if base == "" {
27+
base = `C:\ProgramData`
28+
}
29+
return filepath.Join(base, "Docker", "SecretsEngine", "daemon.sock")
30+
}

0 commit comments

Comments
 (0)