`mode` of a generated directory is random when it has a generated child
評価
調査の方向性
internal/slicer/slicer.goのrelPathsの反復処理付近と、internal/fsutil/create.goのcreateDir付近を読みます。YAMLの例でディレクトリモードが断続的に発生する問題を再現し、その後、生成されたパスがどのように作成され、順序付けられるかを調べます。生成された子要素がある場合も含め、繰り返し実行したカットで/dir/に要求されたモードが一貫して適用されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
the mode listed for a make: true directory is applied on some cuts and not on others, when something else generated lands under that directory. same release, same archive, same slice, different rootfs.
# test-package.yaml
package: test-package
slices:
myslice:
contents:
/dir/: {make: true, mode: 0700}
/dir/file: {text: data}
generated content is created by ranging over a map (relPaths in internal/slicer/slicer.go), so the order differs from run to run. when /dir/file comes first, fsutil.Create makes its parent with the default 0755 (MakeParents: true). when /dir/ then gets its turn, createDir in internal/fsutil/create.go sees os.IsExist and returns without touching the mode. it's the same map order that makes the generated case in #332 come and go.
this is live in chisel-releases. python3.14-minimal_bins on ubuntu-26.04 lists both /usr/local/lib/python3.14/ and /usr/local/lib/python3.14/dist-packages/ as {make: true, mode: 02775}:
$ git clone -q --depth 1 -b ubuntu-26.04 https://github.com/canonical/chisel-releases
$ for i in $(seq 10); do
rm -rf ./rootfs && mkdir ./rootfs
chisel cut --release ./chisel-releases --arch amd64 --root ./rootfs python3.14-minimal_bins 2> /dev/null
stat -c '%a' ./rootfs/usr/local/lib/python3.14
done | sort | uniq -c
1 755
9 775
repro
a minimal one using chisel-proxy:
$ alias chisel-proxy='go run github.com/lczyk/chisel-proxy/cmd/[email protected]'
$ mkdir -p test-package/usr/share/doc/test-package
$ echo readme > test-package/usr/share/doc/test-package/README
$ for i in $(seq 10); do
rm -rf ./rootfs && mkdir ./rootfs
chisel-proxy cut --arch amd64 ./test-package ./test-package.yaml \
-- --root ./rootfs test-package_myslice > /dev/null 2>&1
stat -c '%a' ./rootfs/dir
done | sort | uniq -c
7 700
3 755
obv a bit random, go's map order is not an even shuffle.
a child copied from the deb in place of the generated one (/dir/file: with /dir/file in the package) is not random, but the listed mode never applies: 4 cuts out of 4 gave 755, since extraction always runs first.
proposal
sort the paths before creating them, so a directory is always made before what goes in it:
for _, relPath := range slices.Sorted(maps.Keys(relPaths)) {
slices := relPaths[relPath]
with that, all ten cuts print 700.
- 主要言語
- Go
- スター
- 434
- フォーク
- 74
- 平均マージ
- 1日 30分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
canonical/chisel のほかの issue
-
cut fails on uncompressed deb対応中かも @yuminn-k が 29 日前に担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
-
`prefer` drops a path when the preferred package lists it `until: mutate`対応中かも @18Abhinav07 が 8 日前に担当しました。 オープンBug
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
canonical/chisel の issue をすべて見る
似ている issue
-
mcpx scan: flag unsafe tool names対応中かも @zeyadbadawyy が今日担当しました。 オープンarea/scan enhancement good first issue priority/medium size/small
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rohitgollarahalli/mcpx#45 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
Windows 主机
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Lee-xeo/Claude-Cage#1550 ·
メンテナーはふだん 1 日以内に返信
-
(bug) ui: spanPaint can index spans past their end (panic: index out of range)対応中かも @MaxMiksa が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信