Fixes for su on freebsd

Addresses multiple issues when using su on freebsd including
* su prompt differs between platforms, so turned that check into a
  regex comparison instead of a simple string comparison
* not using '-c' after su causes problems, so added that for all
  platforms
* fixed quoting issues due to multiple uses of '-c' introduced by
  the above fix

Fixes #7503
Fixes #7507
This commit is contained in:
James Cammarata 2014-05-23 10:06:09 -05:00
parent 10414145b2
commit 1e672a0fec
4 changed files with 20 additions and 6 deletions

View file

@ -3,6 +3,7 @@
import unittest
import os
import os.path
import re
import tempfile
import yaml
import passlib.hash
@ -511,8 +512,8 @@ class TestUtils(unittest.TestCase):
cmd = ansible.utils.make_su_cmd('root', '/bin/sh', '/bin/ls')
self.assertTrue(isinstance(cmd, tuple))
self.assertEqual(len(cmd), 3)
self.assertTrue(' root /bin/sh' in cmd[0])
self.assertTrue(cmd[1] == 'assword: ')
self.assertTrue(' root -c "/bin/sh' in cmd[0])
self.assertTrue(re.compile(cmd[1]))
self.assertTrue('echo SUDO-SUCCESS-' in cmd[0] and cmd[2].startswith('SUDO-SUCCESS-'))
def test_to_unicode(self):