Skip to content

Commit 4a8b3ca

Browse files
committed
Add cli build warning about chmod bits on windows
This shows a warning message about adjusted file/directory permission bits when the `docker build` cli command is executed on windows. Signed-off-by: Ahmet Alp Balkan <[email protected]>
1 parent 8892499 commit 4a8b3ca

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

api/client/commands.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
227227
return err
228228
}
229229
}
230+
231+
// windows: show error message about modified file permissions
232+
// FIXME: this is not a valid warning when the daemon is running windows. should be removed once docker engine for windows can build.
233+
if runtime.GOOS == "windows" {
234+
log.Warn(`SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`)
235+
}
236+
230237
var body io.Reader
231238
// Setup an upload progress bar
232239
// FIXME: ProgressReader shouldn't be this annoying to use

integration-cli/docker_cli_build_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,8 +4551,19 @@ func TestBuildStderr(t *testing.T) {
45514551
if err != nil {
45524552
t.Fatal(err)
45534553
}
4554-
if stderr != "" {
4555-
t.Fatalf("Stderr should have been empty, instead its: %q", stderr)
4554+
4555+
if runtime.GOOS == "windows" {
4556+
// stderr might contain a security warning on windows
4557+
lines := strings.Split(stderr, "\n")
4558+
for _, v := range lines {
4559+
if v != "" && !strings.Contains(v, "SECURITY WARNING:") {
4560+
t.Fatalf("Stderr contains unexpected output line: %q", v)
4561+
}
4562+
}
4563+
} else {
4564+
if stderr != "" {
4565+
t.Fatalf("Stderr should have been empty, instead its: %q", stderr)
4566+
}
45564567
}
45574568
logDone("build - testing stderr")
45584569
}

0 commit comments

Comments
 (0)