OwnerMatch¶
Example:
>>> from linuxnet.iptables import OwnerMatch
>>> m = OwnerMatch()
>>> m.uid().equals(10).gid().not_equals(100, 200).socket_exists()
<linuxnet.iptables.matches.ownermatch.OwnerMatch object at 0x7f6adcd98240>
>>> m.to_iptables_args()
['-m', 'owner', '--uid-owner', '10', '!', '--gid-owner', '100-200']
>>> mm = OwnerMatch()
>>> mm.socket_exists().equals()
<linuxnet.iptables.matches.ownermatch.OwnerMatch object at 0x7f6adbe862b0>
>>> mm.to_iptables_args()
['-m', 'owner', '--socket-exists']
- class OwnerMatch[source]¶
Match against userid, groupid, or socket existence.
Only numeric userid, groupid values are supported.
- uid() UidCriterion[source]¶
Compare with the UID
- gid() GidCriterion[source]¶
Compare with the GID
- socket_exists() SocketExistsCriterion[source]¶
Match if there is a socket for this packet
UidCriterion¶
- class UidCriterion(match: Match)[source]¶
Compare with a uid, or uid range
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- equals(from_num: int, to_num: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
to_numis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- is_positive() bool¶
Returns the ‘polarity’ of the criterion;
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set
GidCriterion¶
- class GidCriterion(match: Match)[source]¶
Compare with a gid, or gid range
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- equals(from_num: int, to_num: Optional[int] = None) Match¶
Compare with a number (or inclusion in number-range if
to_numis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- Return type:
a tuple of (int, int|None)
- is_positive() bool¶
Returns the ‘polarity’ of the criterion;
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set
SocketExistsCriterion¶
- class SocketExistsCriterion(match: Match)[source]¶
Perform a socket existence test
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- get_value() bool¶
Returns the criterion value
- is_positive() bool¶
Returns the ‘polarity’ of the criterion;
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set