Skip to content

Commit fe8b66d

Browse files
committed
run: handle relabeling bind mounts ourselves
Handle requested relabeling of bind mounts (i.e., the "z" and "Z" flags) directly, instead of letting the runtime handle the relabeling. Signed-off-by: Nalin Dahyabhai <[email protected]>
1 parent 352eda3 commit fe8b66d

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

.cirrus.yml

+29-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ env:
2222
IN_PODMAN: 'false'
2323
# root or rootless
2424
PRIV_NAME: root
25+
# default "name of runtime in the task alias" value
26+
RUNTIME_N: ""
2527

2628
####
2729
#### Cache-image names to test with
@@ -196,7 +198,7 @@ conformance_task:
196198

197199

198200
integration_task:
199-
name: "Integration $DISTRO_NV w/ $STORAGE_DRIVER"
201+
name: "Integration $DISTRO_NV$RUNTIME_N w/ $STORAGE_DRIVER"
200202
alias: integration
201203
skip: *not_build_docs
202204
depends_on: *smoke_vendor
@@ -207,6 +209,14 @@ integration_task:
207209
DISTRO_NV: "${FEDORA_NAME}"
208210
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
209211
STORAGE_DRIVER: 'vfs'
212+
BUILDAH_RUNTIME: crun
213+
RUNTIME_N: " using crun"
214+
- env:
215+
DISTRO_NV: "${FEDORA_NAME}"
216+
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
217+
STORAGE_DRIVER: 'vfs'
218+
BUILDAH_RUNTIME: runc
219+
RUNTIME_N: " using runc"
210220
# Disabled until we update to f41/42 as f40 does not have go 1.22
211221
# - env:
212222
# DISTRO_NV: "${PRIOR_FEDORA_NAME}"
@@ -221,6 +231,14 @@ integration_task:
221231
DISTRO_NV: "${FEDORA_NAME}"
222232
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
223233
STORAGE_DRIVER: 'overlay'
234+
BUILDAH_RUNTIME: crun
235+
RUNTIME_N: " using crun"
236+
- env:
237+
DISTRO_NV: "${FEDORA_NAME}"
238+
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
239+
STORAGE_DRIVER: 'overlay'
240+
BUILDAH_RUNTIME: runc
241+
RUNTIME_N: " using runc"
224242
# Disabled until we update to f41/42 as f40 does not have go 1.22
225243
# - env:
226244
# DISTRO_NV: "${PRIOR_FEDORA_NAME}"
@@ -255,7 +273,7 @@ integration_task:
255273
golang_version_script: '$GOSRC/$SCRIPT_BASE/logcollector.sh golang'
256274

257275
integration_rootless_task:
258-
name: "Integration rootless $DISTRO_NV w/ $STORAGE_DRIVER"
276+
name: "Integration rootless $DISTRO_NV$RUNTIME_N w/ $STORAGE_DRIVER"
259277
alias: integration_rootless
260278
skip: *not_build_docs
261279
depends_on: *smoke_vendor
@@ -268,6 +286,15 @@ integration_rootless_task:
268286
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
269287
STORAGE_DRIVER: 'overlay'
270288
PRIV_NAME: rootless
289+
BUILDAH_RUNTIME: runc
290+
RUNTIME_N: " using runc"
291+
- env:
292+
DISTRO_NV: "${FEDORA_NAME}"
293+
IMAGE_NAME: "${FEDORA_CACHE_IMAGE_NAME}"
294+
STORAGE_DRIVER: 'overlay'
295+
PRIV_NAME: rootless
296+
BUILDAH_RUNTIME: crun
297+
RUNTIME_N: " using crun"
271298
# Disabled until we update to f40/41 as f39 does not have go 1.22
272299
# - env:
273300
# DISTRO_NV: "${PRIOR_FEDORA_NAME}"

run_linux.go

+27
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,33 @@ rootless=%d
543543

544544
defer b.cleanupTempVolumes()
545545

546+
// Handle mount flags that request that the source locations for "bind" mountpoints be
547+
// relabeled, and filter those flags out of the list of mount options we pass to the
548+
// runtime.
549+
for i := range spec.Mounts {
550+
switch spec.Mounts[i].Type {
551+
default:
552+
continue
553+
case "bind", "rbind":
554+
break
555+
}
556+
zflag := ""
557+
for _, opt := range spec.Mounts[i].Options {
558+
if opt == "z" || opt == "Z" {
559+
zflag = opt
560+
}
561+
}
562+
if zflag == "" {
563+
continue
564+
}
565+
spec.Mounts[i].Options = slices.DeleteFunc(spec.Mounts[i].Options, func(opt string) bool {
566+
return opt == "z" || opt == "Z"
567+
})
568+
if err := relabel(spec.Mounts[i].Source, b.MountLabel, zflag == "z"); err != nil {
569+
return fmt.Errorf("setting file label %q on %q: %w", b.MountLabel, spec.Mounts[i].Source, err)
570+
}
571+
}
572+
546573
switch isolation {
547574
case define.IsolationOCI:
548575
var moreCreateArgs []string

0 commit comments

Comments
 (0)