Skip to content

Commit 0455b5d

Browse files
committed
v36tov35: add tests for special mode bits masking
Add tests to verify that special mode bits (setuid/setgid/sticky) are correctly masked out when down-translating from v3.6 to v3.5. v3.6 supports special mode bits, but v3.5 and earlier do not, so the bits must be masked during translation to avoid applying permissions that would not have been applied in earlier versions.
1 parent bb46699 commit 0455b5d

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

translate_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,6 +3295,56 @@ func TestTranslate3_6to3_5(t *testing.T) {
32953295
}
32963296
assert.Equal(t, downtranslateConfig3_5, res)
32973297

3298+
// Test that special mode bits are correctly masked out during translation
3299+
res, err = v36tov35.Translate(types3_6.Config{
3300+
Ignition: types3_6.Ignition{
3301+
Version: "3.6.0",
3302+
},
3303+
Storage: types3_6.Storage{
3304+
Files: []types3_6.File{
3305+
{
3306+
Node: types3_6.Node{
3307+
Path: "/root/file.txt",
3308+
},
3309+
FileEmbedded1: types3_6.FileEmbedded1{
3310+
Mode: util.IntP(01777),
3311+
},
3312+
},
3313+
},
3314+
},
3315+
})
3316+
assert.NoError(t, err)
3317+
// Verify that special mode bits were masked out (01777 -> 0777)
3318+
assert.Equal(t, util.IntP(0777), res.Storage.Files[0].Mode)
3319+
3320+
res, err = v36tov35.Translate(types3_6.Config{
3321+
Ignition: types3_6.Ignition{
3322+
Version: "3.6.0",
3323+
},
3324+
Storage: types3_6.Storage{
3325+
Directories: []types3_6.Directory{
3326+
{
3327+
Node: types3_6.Node{
3328+
Path: "/rootdir",
3329+
Overwrite: util.BoolP(true),
3330+
User: types3_6.NodeUser{
3331+
ID: util.IntP(1000),
3332+
},
3333+
Group: types3_6.NodeGroup{
3334+
Name: util.StrP("groupname"),
3335+
},
3336+
},
3337+
DirectoryEmbedded1: types3_6.DirectoryEmbedded1{
3338+
Mode: util.IntP(01777),
3339+
},
3340+
},
3341+
},
3342+
},
3343+
})
3344+
assert.NoError(t, err)
3345+
// Verify that special mode bits were masked out (01777 -> 0777)
3346+
assert.Equal(t, util.IntP(0777), res.Storage.Directories[0].Mode)
3347+
32983348
// Translation with unsupported custom clevis pin
32993349
_, err = v36tov35.Translate(types3_6.Config{
33003350
Ignition: types3_6.Ignition{

0 commit comments

Comments
 (0)