github.com/coreos/mantle@v0.13.0/kola/tests/systemd/sysusers.go (about) 1 // Copyright 2016 CoreOS, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package systemd 16 17 import ( 18 "github.com/coreos/mantle/kola/cluster" 19 "github.com/coreos/mantle/kola/register" 20 ) 21 22 func init() { 23 register.Register(®ister.Test{ 24 Run: gshadowParser, 25 ClusterSize: 1, 26 Name: "systemd.sysusers.gshadow", 27 Distros: []string{"cl", "fcos"}, 28 }) 29 } 30 31 // Verify that glibc's parsing of /etc/gshadow does not cause systemd-sysusers 32 // to segfault on specially constructed lines. 33 // 34 // One line must fit into the character buffer (1024 bytes, unless a previous 35 // line was longer) but have enough group members such that 36 // 37 // line length + alignment + sizeof(char *) * (#adm + 1 + #mem + 1) > 1024. 38 // 39 // The parser would return early to avoid overflow, leaving the static result 40 // struct pointing to pointers from the previous line which are now invalid, 41 // causing segfaults when those pointers are dereferenced. 42 // 43 // Tests: https://github.com/coreos/bugs/issues/1394 44 func gshadowParser(c cluster.TestCluster) { 45 m := c.Machines()[0] 46 47 c.MustSSH(m, `sudo sh -c "echo 'grp0:*::root' >> /etc/gshadow"`) 48 c.MustSSH(m, `sudo sh -c "echo 'grp1:*::somebody.a1,somebody.a2,somebody.a3,somebody.a4,somebody.a5,somebody.a6,somebody.a7,somebody.a8,somebody.a9,somebody.a10,somebody.a11,somebody.a12,somebody.a13,somebody.a14,somebody.a15,somebody.a16,somebody.a17,somebody.a18,somebody.a19,somebody.a20,somebody.a21,somebody.a22,somebody.a23,somebody.a24,somebody.a25,somebody.a26,somebody.a27,somebody.a28,somebody.a29,somebody.a30,somebody.a31,somebody.a32,somebody.a33,somebody.a34,somebody.a35,somebody.a36,somebody.a37,somebody.a38,somebody.a39,somebody.a40,somebody.a41,somebody.a42,somebody.a43,somebody.a44,somebody.a45,somebody.a46,somebody.a47,a1234' >> /etc/gshadow"`) 49 c.MustSSH(m, `sudo sh -c "echo 'grp2:*::root' >> /etc/gshadow"`) 50 c.MustSSH(m, `sudo systemd-sysusers`) 51 }