Skip to content

Commit a14dd93

Browse files
committed
Configure repository for compatibility with modern Git versions in release build containers
`DistTasks.yml` contains the tasks used to produce the release builds of the project for each of the host targets. The builds are produced in Docker containers. A regression was introduced in several of the tasks at the time the project's Go version was bumped to 1.21.5. As a security measure (see CVE-2022-24765), starting from 2.30.3 Git requires the repository folder to be owned by the operating system user's account. Due to it having been checked out outside the container, the repository does not meet this requirement inside the container. An older version of Git was installed in the Go 1.18.3 Docker image, so this was not a problem before the bump, but a newer version is used in the Go 1.21.5 containers, which causes some tasks to fail: ``` error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. Error: failed building for linux/armv6: exit status 1 failed building for linux/armv6: exit status 1 task: Failed to run task "dist:Linux_ARMv6": exit status 1 ``` The solution is to configure Git to allow the use of the repository, despite the "dubious ownership" of its folder. This is done via the `safe.directory` Git configuration variable.
1 parent 0fb9206 commit a14dd93

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: DistTasks.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ tasks:
131131
desc: Builds Linux ARMv6 binaries
132132
dir: "{{.DIST_DIR}}"
133133
cmds:
134+
# "git config safe.directory" is required until this is fixed https://github.com/elastic/golang-crossbuild/issues/232
134135
- |
135136
docker run -v `pwd`/..:/home/build -w /home/build \
136137
-e CGO_ENABLED=1 \
137138
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
138-
--build-cmd "{{.BUILD_COMMAND}}" \
139+
--build-cmd "git config --global --add safe.directory /home/build && {{.BUILD_COMMAND}}" \
139140
-p "{{.BUILD_PLATFORM}}"
140141
141142
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
@@ -201,11 +202,12 @@ tasks:
201202
desc: Builds Mac OS X 64 bit binaries
202203
dir: "{{.DIST_DIR}}"
203204
cmds:
205+
# "git config safe.directory" is required until this is fixed https://github.com/elastic/golang-crossbuild/issues/232
204206
- |
205207
docker run -v `pwd`/..:/home/build -w /home/build \
206208
-e CGO_ENABLED=1 \
207209
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
208-
--build-cmd "{{.BUILD_COMMAND}}" \
210+
--build-cmd "git config --global --add safe.directory /home/build && {{.BUILD_COMMAND}}" \
209211
-p "{{.BUILD_PLATFORM}}"
210212
211213
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
@@ -235,11 +237,12 @@ tasks:
235237
desc: Builds Mac OS X ARM64 binaries
236238
dir: "{{.DIST_DIR}}"
237239
cmds:
240+
# "git config safe.directory" is required until this is fixed https://github.com/elastic/golang-crossbuild/issues/232
238241
- |
239242
docker run -v `pwd`/..:/home/build -w /home/build \
240243
-e CGO_ENABLED=1 \
241244
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
242-
--build-cmd "{{.BUILD_COMMAND}}" \
245+
--build-cmd "git config --global --add safe.directory /home/build && {{.BUILD_COMMAND}}" \
243246
-p "{{.BUILD_PLATFORM}}"
244247
245248
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}

0 commit comments

Comments
 (0)