From 264581a2f1599a27de577549dc75fccefef6a579 Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Sat, 27 Jun 2015 21:00:32 -0300 Subject: sysv-generator: escape names when translating from sysv name While the LSB suggests only [A-Za-z0-9], that doesn't prevent admins from doing the wrong thing. Lets not generate invalid names in that case. --- test/sysv-generator-test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py index af0493b9a8..23d6646bba 100644 --- a/test/sysv-generator-test.py +++ b/test/sysv-generator-test.py @@ -190,6 +190,15 @@ class SysvGeneratorTest(unittest.TestCase): self.assert_enabled('foo.service', ['multi-user', 'graphical']) self.assertNotIn('Overwriting', err) + def test_simple_escaped(self): + '''simple service without dependencies, that requires escaping the name''' + + self.add_sysv('foo+', {}) + self.add_sysv('foo-admin', {}) + err, results = self.run_generator() + self.assertEqual(list(results), ['foo-admin.service', 'foo\\x2b.service']) + self.assertNotIn('Overwriting', err) + def test_simple_enabled_some(self): '''simple service without dependencies, enabled in some runlevels''' @@ -276,6 +285,16 @@ class SysvGeneratorTest(unittest.TestCase): 'foo.service') self.assertNotIn('Overwriting', err) + def test_provides_escaped(self): + '''a script that Provides: a name that requires escaping''' + + self.add_sysv('foo', {'Provides': 'foo foo+'}) + err, results = self.run_generator() + self.assertEqual(list(results), ['foo.service']) + self.assertEqual(os.readlink(os.path.join(self.out_dir, 'foo\\x2b.service')), + 'foo.service') + self.assertNotIn('Overwriting', err) + def test_same_provides_in_multiple_scripts(self): '''multiple init.d scripts provide the same name''' -- cgit v1.2.3-54-g00ecf