1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/usr/bin/python
#
# Copyright 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import errno
from socket import * # pylint: disable=wildcard-import
import unittest
import gzip
import net_test
class RemovedFeatureTest(net_test.NetworkTest):
KCONFIG = None
@classmethod
def loadKernelConfig(cls):
cls.KCONFIG = {}
with gzip.open('/proc/config.gz') as f:
for line in f:
line = line.strip()
parts = line.split("=")
if (len(parts) == 2):
# Lines of the form:
# CONFIG_FOO=y
cls.KCONFIG[parts[0]] = parts[1]
@classmethod
def setUpClass(cls):
cls.loadKernelConfig()
def assertFeatureEnabled(self, featureName):
return self.assertEqual("y", self.KCONFIG[featureName])
def assertFeatureAbsent(self, featureName):
return self.assertTrue(featureName not in self.KCONFIG)
def testNetfilterRejectWithSocketError(self):
"""Verify that the CONFIG_IP{,6}_NF_TARGET_REJECT_SKERR option is gone.
The commits to be reverted include:
android-3.10: 6f489c42
angler: 6f489c42
bullhead: 6f489c42
shamu: 6f489c42
flounder: 6f489c42
See b/28424847 and b/28719525 for more context.
"""
self.assertFeatureEnabled("CONFIG_IP_NF_FILTER")
self.assertFeatureEnabled("CONFIG_IP_NF_TARGET_REJECT")
self.assertFeatureAbsent("CONFIG_IP_NF_TARGET_REJECT_SKERR")
self.assertFeatureEnabled("CONFIG_IP6_NF_FILTER")
self.assertFeatureEnabled("CONFIG_IP6_NF_TARGET_REJECT")
self.assertFeatureAbsent("CONFIG_IP6_NF_TARGET_REJECT_SKERR")
@unittest.skipUnless(net_test.LINUX_VERSION >= (4, 19, 0), "removed in 4.14-r")
def testRemovedAndroidParanoidNetwork(self):
"""Verify that ANDROID_PARANOID_NETWORK is gone."""
AID_NET_RAW = 3004
with net_test.RunAsUidGid(12345, AID_NET_RAW):
self.assertRaisesErrno(errno.EPERM, socket, AF_PACKET, SOCK_RAW, 0)
@unittest.skipUnless(net_test.LINUX_VERSION >= (4, 19, 0), "exists in 4.14-P")
def testRemovedQtaguid(self):
self.assertRaisesErrno(errno.ENOENT, open, "/proc/net/xt_qtaguid")
if __name__ == "__main__":
unittest.main()
|