Skip to content

Commit 5c85381

Browse files
committed
tests/../files: ensure customfilepermissions behave the same as before 3.6.0
Ensure bugfix does not effect existing versions of configs using 'mode'. This means 3.5.0 - 3.2.0 should continue to lose bits on permissions.
1 parent 9d1ae04 commit 5c85381

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed

tests/positive/files/file.go

+184
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func init() {
2929
register.Register(register.PositiveTest, AppendToNonexistentFile())
3030
register.Register(register.PositiveTest, ApplyDefaultFilePermissions())
3131
register.Register(register.PositiveTest, ApplyCustomFilePermissions())
32+
register.Register(register.PositiveTest, ApplyCustomFilePermissionsBeforeBugfix())
3233
register.Register(register.PositiveTest, CreateFileFromCompressedDataURL())
3334
// TODO: Investigate why ignition's C code hates our environment
3435
// register.Register(register.PositiveTest, UserGroupByName())
@@ -554,6 +555,189 @@ func ApplyCustomFilePermissions() types.Test {
554555
}
555556
}
556557

558+
func ApplyCustomFilePermissionsBeforeBugfix() types.Test {
559+
// This test is put here to ensure that we don't accidentally fix configs that were not working before the fix.
560+
// Ensure all versions before the bugfix are still losing special bits.
561+
// Bug #2042
562+
name := "files.customperms.pre-#2042-fix"
563+
in := types.GetBaseDisk()
564+
out := types.GetBaseDisk()
565+
config := `{
566+
"ignition": { "version": "$version" },
567+
"passwd": {
568+
"users": [
569+
{
570+
"name": "auser",
571+
"uid": 1001,
572+
"shouldExist": false
573+
}
574+
],
575+
"groups": [
576+
{
577+
"name": "auser",
578+
"gid": 1001,
579+
"shouldExist": false
580+
}
581+
]
582+
},
583+
"storage": {
584+
"files": [
585+
{
586+
"path": "/foo/setuidsetgid",
587+
"contents": { "source": "data:,hello%20world%0A" },
588+
"mode": 3565
589+
},
590+
{
591+
"path": "/foo/auser/setuidsetgid",
592+
"contents": { "source": "data:,hello%20world%0A" },
593+
"mode": 3565,
594+
"user": { "id": 1001 },
595+
"group": { "id": 1001 }
596+
}, {
597+
"path": "/foo/root/setuidsetgid",
598+
"contents": { "source": "data:,hello%20world%0A" },
599+
"mode": 3565,
600+
"user": { "id": 0 },
601+
"group": { "id": 0 }
602+
},
603+
{
604+
"path": "/foo/setuid",
605+
"contents": { "source": "data:,hello%20world%0A" },
606+
"mode": 2541
607+
},
608+
{
609+
"path": "/foo/auser/setuid",
610+
"contents": { "source": "data:,hello%20world%0A" },
611+
"mode": 2541,
612+
"user": { "id": 1001 },
613+
"group": { "id": 1001 }
614+
},
615+
{
616+
"path": "/foo/root/setuid",
617+
"contents": { "source": "data:,hello%20world%0A" },
618+
"mode": 2541,
619+
"user": { "id": 0 },
620+
"group": { "id": 0 }
621+
},
622+
{
623+
"path": "/foo/setgid",
624+
"contents": { "source": "data:,hello%20world%0A" },
625+
"mode": 1517
626+
},
627+
{
628+
"path": "/foo/auser/setgid",
629+
"contents": { "source": "data:,hello%20world%0A" },
630+
"mode": 1517,
631+
"user": { "id": 1001 },
632+
"group": { "id": 1001 }
633+
},
634+
{
635+
"path": "/foo/root/setgid",
636+
"contents": { "source": "data:,hello%20world%0A" },
637+
"mode": 1517,
638+
"user": { "id": 0 },
639+
"group": { "id": 0 }
640+
}
641+
]
642+
}
643+
}`
644+
out[0].Partitions.AddFiles("ROOT", []types.File{
645+
{
646+
Node: types.Node{
647+
Directory: "foo",
648+
Name: "setuidsetgid",
649+
},
650+
Contents: "hello world\n",
651+
Mode: 0755,
652+
},
653+
{
654+
Node: types.Node{
655+
Directory: "foo/auser",
656+
Name: "setuidsetgid",
657+
User: 1001,
658+
Group: 1001,
659+
},
660+
Contents: "hello world\n",
661+
Mode: 0755,
662+
},
663+
{
664+
Node: types.Node{
665+
Directory: "foo/root",
666+
Name: "setuidsetgid",
667+
User: 0,
668+
Group: 0,
669+
},
670+
Contents: "hello world\n",
671+
Mode: 0755,
672+
},
673+
{
674+
Node: types.Node{
675+
Directory: "foo",
676+
Name: "setuid",
677+
},
678+
Contents: "hello world\n",
679+
Mode: 0755,
680+
},
681+
{
682+
Node: types.Node{
683+
Directory: "foo/auser",
684+
Name: "setuid",
685+
User: 1001,
686+
Group: 1001,
687+
},
688+
Contents: "hello world\n",
689+
Mode: 0755,
690+
},
691+
{
692+
Node: types.Node{
693+
Directory: "foo/root",
694+
Name: "setuid",
695+
User: 0,
696+
Group: 0,
697+
},
698+
Contents: "hello world\n",
699+
Mode: 0755,
700+
},
701+
{
702+
Node: types.Node{
703+
Directory: "foo",
704+
Name: "setgid",
705+
},
706+
Contents: "hello world\n",
707+
Mode: 0755,
708+
},
709+
{
710+
Node: types.Node{
711+
Directory: "foo/auser",
712+
Name: "setgid",
713+
User: 1001,
714+
Group: 1001,
715+
},
716+
Contents: "hello world\n",
717+
Mode: 0755,
718+
},
719+
{
720+
Node: types.Node{
721+
Directory: "foo/root",
722+
Name: "setgid",
723+
User: 0,
724+
Group: 0,
725+
},
726+
Contents: "hello world\n",
727+
Mode: 0755,
728+
},
729+
})
730+
731+
return types.Test{
732+
Name: name,
733+
In: in,
734+
Out: out,
735+
Config: config,
736+
ConfigMaxVersion: "3.5.0",
737+
ConfigMinVersion: "3.2.0",
738+
}
739+
}
740+
557741
func CreateFileFromCompressedDataURL() types.Test {
558742
name := "files.create.compressed"
559743
in := types.GetBaseDisk()

0 commit comments

Comments
 (0)