예제 #1
0
    def test_zz_apparmor(self):
        '''Test apparmor'''
        if self.lsb_release['Release'] < 12.10:
            self._skipped("No profile in 12.04 and under")

        self.aa_unload_at_teardown = True

        # Currently while we have a profile, it is shipped disabled by default.
        # Verify that.
        rc, report = testlib.check_apparmor(self.aa_abs_profile, 12.10, is_running=False)
        expected = 1
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)

        # Verify it is syntactically correct
        rc, report = testlib.cmd(['apparmor_parser', '-p', self.aa_abs_profile])
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)

        # Verify it loads ok
        rc, report = testlib.cmd(['aa-enforce', self.aa_abs_profile])
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)

        self._stop()
        self._start()

        rc, report = testlib.check_apparmor(self.aa_abs_profile, 12.10, is_running=True)
        expected = 1
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)
예제 #2
0
    def test_daemon(self):
        '''Test dhcpd'''
        contents = '''
ddns-update-style none;
default-lease-time 60;
max-lease-time 720;
allow bootp;
authoritative;
log-facility local7;
subnet 192.168.122.0 netmask 255.255.255.0 {
    range 192.168.122.50 192.168.122.60;
}
'''
        testlib.create_fill(self.server_config, contents)
        self.start_daemon()
        time.sleep(2)

        self.assertTrue(
            testlib.check_pidfile(os.path.basename(self.server_binary),
                                  self.server_pidfile))

        rc, report = testlib.check_apparmor(self.server_binary,
                                            9.04,
                                            is_running=True)
        if rc < 0:
            return self._skipped(report)

        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)
    def test_apparmor(self):
        '''Test apparmor'''
        rc, report = testlib.check_apparmor('/usr/sbin/mysqld', 8.04, is_running=True)
        if rc < 0:
            return self._skipped(report)

        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)
    def test_apparmor(self):
        '''Test apparmor'''
        for exe in ['evince', 'evince-previewer', 'evince-thumbnailer']:
            rc, report = testlib.check_apparmor(exe, 9.10, is_running=False)
            if rc < 0:
                return self._skipped(report)

            expected = 0
            result = 'Got exit code %d, expected %d for \'%s\'\n' % (
                rc, expected, exe)
            self.assertEquals(expected, rc, result + report)
    def test_apparmor(self):
        '''Test apparmor'''
        rc, report = testlib.check_apparmor('/usr/sbin/tcpdump',
                                            self.version_with_apparmor,
                                            is_running=False)
        if rc < 0:
            return self._skipped(report)

        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)
    def test_apparmor(self):
        '''Test apparmor'''
        rc, report = testlib.check_apparmor('/usr/sbin/cupsd',
                                            7.10,
                                            is_running=True)
        if rc < 0:
            return self._skipped(report)

        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)

        rc, report = testlib.check_apparmor('/usr/lib/cups/backend/cups-pdf',
                                            7.10,
                                            is_running=False)
        if rc < 0:
            return self._skipped(report)

        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)
예제 #7
0
    def test_zz_apparmor(self):
        '''Test apparmor'''
        if self.lsb_release['Release'] < 12.10:
            self._skipped("No profile in 12.04 and under")
            return

        self.aa_unload_at_teardown = True

        # Currently while we have a profile, it is shipped disabled by default.
        # Verify that.
        rc, report = testlib.check_apparmor(self.aa_abs_profile,
                                            12.10,
                                            is_running=False)
        expected = 1
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)

        # Verify it is syntactically correct
        rc, report = testlib.cmd(
            ['apparmor_parser', '-p', self.aa_abs_profile])
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)

        # Verify it loads ok
        rc, report = testlib.cmd(['aa-enforce', self.aa_abs_profile])
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)

        self._stop()
        self._start()

        rc, report = testlib.check_apparmor(self.aa_abs_profile,
                                            12.10,
                                            is_running=True)
        expected = 1
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(rc, expected, result + report)
예제 #8
0
    def test_apparmor(self):
        '''Test apparmor'''
        # client-- don't check if running here, we do that in the other tests
        for exe in [
                self.server_binary, self.client_binary,
                '/usr/lib/NetworkManager/nm-dhcp-client.action',
                '/usr/lib/connman/scripts/dhclient-script'
        ]:
            rc, report = testlib.check_apparmor(exe, 9.04, is_running=False)
            if rc < 0:
                return self._skipped(report)

            expected = 0
            result = 'Got exit code %d, expected %d\n' % (rc, expected)
            self.assertEquals(expected, rc, result + report)
예제 #9
0
    def test_dhclient(self):
        '''Test dhclient (requires reachable dhcpd)'''
        self.stop_daemon(self.server_pidfile)
        time.sleep(2)

        contents = '''
send host-name "%s";
request subnet-mask, broadcast-address, time-offset, routers,
	domain-name, domain-name-servers, domain-search, host-name,
	netbios-name-servers, netbios-scope, ntp-servers;
''' % (socket.gethostname())
        testlib.create_fill(self.client_config, contents)

        rc, report = testlib.cmd([os.path.basename(self.client_binary)] +
                                 self.client_args)
        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)

        time.sleep(5)
        if not os.path.exists(self.client_pidfile):
            time.sleep(25)

        self.assertTrue(
            os.path.exists(self.client_lease),
            "%s does not exist after 30 seconds" % (self.client_lease))
        self.assertTrue(
            testlib.check_pidfile(os.path.basename(self.client_binary),
                                  self.client_pidfile))

        rc, report = testlib.check_apparmor(self.client_binary,
                                            9.04,
                                            is_running=True)
        if rc < 0:
            return self._skipped(report)

        expected = 0
        result = 'Got exit code %d, expected %d\n' % (rc, expected)
        self.assertEquals(expected, rc, result + report)