Windows: Fix security warning regression
| ... | ... |
@@ -269,8 +269,9 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 269 | 269 |
} |
| 270 | 270 |
} |
| 271 | 271 |
|
| 272 |
- // Windows: show error message about modified file permissions. |
|
| 273 |
- if response.OSType == "windows" {
|
|
| 272 |
+ // Windows: show error message about modified file permissions if the |
|
| 273 |
+ // daemon isn't running Windows. |
|
| 274 |
+ if response.OSType != "windows" && runtime.GOOS == "windows" {
|
|
| 274 | 275 |
fmt.Fprintln(cli.err, `SECURITY WARNING: You are building a Docker image from Windows against a non-Windows 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.`) |
| 275 | 276 |
} |
| 276 | 277 |
|
| ... | ... |
@@ -4920,8 +4920,26 @@ func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
|
| 4920 | 4920 |
if outRegexp.Find([]byte(stdout)) == nil {
|
| 4921 | 4921 |
c.Fatalf("Test %s expected stdout to match the [%v] regexp, but it is [%v]", te.Name, outRegexp, stdout)
|
| 4922 | 4922 |
} |
| 4923 |
- if stderr != "" {
|
|
| 4924 |
- c.Fatalf("Test %s expected stderr to be empty, but it is [%#v]", te.Name, stderr)
|
|
| 4923 |
+ if runtime.GOOS == "windows" {
|
|
| 4924 |
+ // stderr contains a security warning on Windows if the daemon isn't Windows |
|
| 4925 |
+ lines := strings.Split(stderr, "\n") |
|
| 4926 |
+ warningCount := 0 |
|
| 4927 |
+ for _, v := range lines {
|
|
| 4928 |
+ warningText := "SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host." |
|
| 4929 |
+ if strings.Contains(v, warningText) {
|
|
| 4930 |
+ warningCount++ |
|
| 4931 |
+ } |
|
| 4932 |
+ if v != "" && !strings.Contains(v, warningText) {
|
|
| 4933 |
+ c.Fatalf("Stderr contains unexpected output line: %q", v)
|
|
| 4934 |
+ } |
|
| 4935 |
+ } |
|
| 4936 |
+ if warningCount != 1 && daemonPlatform != "windows" {
|
|
| 4937 |
+ c.Fatalf("Test %s didn't get security warning running from Windows to non-Windows", te.Name)
|
|
| 4938 |
+ } |
|
| 4939 |
+ } else {
|
|
| 4940 |
+ if stderr != "" {
|
|
| 4941 |
+ c.Fatalf("Test %s expected stderr to be empty, but it is [%#v]", te.Name, stderr)
|
|
| 4942 |
+ } |
|
| 4925 | 4943 |
} |
| 4926 | 4944 |
} |
| 4927 | 4945 |
|