~yolanda.robla/nova/precise-security

« back to all changes in this revision

Viewing changes to nova/tests/test_nova_rootwrap.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-06-05 09:50:59 UTC
  • mto: (79.1.1 precise-proposed)
  • mto: This revision was merged to the branch mainline in revision 81.
  • Revision ID: package-import@ubuntu.com-20120605095059-kb1utt7b1a5yff2a
Tags: upstream-2012.1+stable~20120612-3ee026e
ImportĀ upstreamĀ versionĀ 2012.1+stable~20120612-3ee026e

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        p = subprocess.Popen(["/bin/sleep", "5"])
70
70
        f = filters.KillFilter("/bin/kill", "root",
71
71
                               ["-ALRM"],
72
 
                               ["/bin/sleep"])
 
72
                               ["/bin/sleep", "/usr/bin/sleep"])
73
73
        usercmd = ['kill', '-9', p.pid]
74
74
        # Incorrect signal should fail
75
75
        self.assertFalse(f.match(usercmd))
79
79
 
80
80
        f = filters.KillFilter("/bin/kill", "root",
81
81
                               ["-9", ""],
82
 
                               ["/bin/sleep"])
 
82
                               ["/bin/sleep", "/usr/bin/sleep"])
83
83
        usercmd = ['kill', '-9', os.getpid()]
84
84
        # Our own PID does not match /bin/sleep, so it should fail
85
85
        self.assertFalse(f.match(usercmd))
103
103
        usercmd = ['kill', 'notapid']
104
104
        self.assertFalse(f.match(usercmd))
105
105
 
 
106
    def test_KillFilter_deleted_exe(self):
 
107
        """Makes sure deleted exe's are killed correctly"""
 
108
        # See bug #967931.
 
109
        def fake_readlink(blah):
 
110
            return '/bin/commandddddd (deleted)'
 
111
 
 
112
        f = filters.KillFilter("/bin/kill", "root",
 
113
                               [""],
 
114
                               ["/bin/commandddddd"])
 
115
        usercmd = ['kill', 1234]
 
116
        # Providing no signal should work
 
117
        self.stubs.Set(os, 'readlink', fake_readlink)
 
118
        self.assertTrue(f.match(usercmd))
 
119
 
106
120
    def test_ReadFileFilter(self):
107
121
        goodfn = '/good/file.name'
108
122
        f = filters.ReadFileFilter(goodfn)