Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/seport.pyc

�
�Udac@`s^ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	d
Zydd
lZe
ZWn#ek
r�e	j�ZeZnXd
Zydd
lZe
ZWn#ek
r�e	j�ZeZnXddlmZmZddlmZed
�Zd�Zd�Zddd�Zdd�Zd�Ze dkrZe�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_byse
---
module: seport
short_description: Manages SELinux network port type definitions
description:
    - Manages SELinux network port type definitions.
version_added: "2.0"
options:
  ports:
    description:
      - Ports or port ranges.
      - Can be a list (since 2.6) or comma separated string.
    type: list
    required: true
  proto:
    description:
      - Protocol for the specified port.
    type: str
    required: true
    choices: [ tcp, udp ]
  setype:
    description:
      - SELinux type for the specified port.
    type: str
    required: true
  state:
    description:
      - Desired boolean value.
    type: str
    choices: [ absent, present ]
    default: present
  reload:
    description:
      - Reload SELinux policy after commit.
    type: bool
    default: yes
  ignore_selinux_state:
    description:
    - Run independent of selinux runtime state
    type: bool
    default: no
    version_added: '2.8'
notes:
   - The changes are persistent across reboots.
   - Not tested on any debian based system.
requirements:
- libselinux-python
- policycoreutils-python
author:
- Dan Keder (@dankeder)
sm
- name: Allow Apache to listen on tcp port 8888
  seport:
    ports: 8888
    proto: tcp
    setype: http_port_t
    state: present

- name: Allow sshd to listen on tcp port 8991
  seport:
    ports: 8991
    proto: tcp
    setype: ssh_port_t
    state: present

- name: Allow memcached to listen on tcp ports 10000-10100 and 10112
  seport:
    ports: 10000-10100,10112
    proto: tcp
    setype: memcache_port_t
    state: present

- name: Allow memcached to listen on tcp ports 10000-10100 and 10112
  seport:
    ports:
      - 10000-10100
      - 10112
    proto: tcp
    setype: memcache_port_t
    state: present
N(t
AnsibleModuletmissing_required_lib(t	to_nativecC`s|tkrtStj�S(N(tTruetselinuxtis_selinux_enabled(tignore_selinux_state((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pytget_runtime_statusxscC`s4|j�}||f|kr,|||fSgSdS(sF Get the list of ports that have the specified type definition.

    :param seport: Instance of seobject.portRecords

    :type setype: str
    :param setype: SELinux type.

    :type proto: str
    :param proto: Protocol ('tcp' or 'udp')

    :rtype: list
    :return: List of ports that have the specified SELinux type.
    N(tget_all_by_type(tseporttsetypetprototrecords((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pytsemanage_port_get_ports|scC`s|jdd�}t|�dkr4|j|�nt|d�t|d�|f}|j�}||krw||SdSdS(sk Get the SELinux type of the specified port.

    :param seport: Instance of seobject.portRecords

    :type port: str
    :param port: Port or port range (example: "8080", "8080-9090")

    :type proto: str
    :param proto: Protocol ('tcp' or 'udp')

    :rtype: tuple
    :return: Tuple containing the SELinux type and MLS/MCS level, or None if not found.
    t-iiN(tsplittlentextendtinttget_alltNone(RtportRtportstkeyR((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pytsemanage_port_get_type�s#ts0tc
	C`s)y�tj|�}|j|�t}t|||�}	x�|D]�}
|
|	kr>t}t||
|�}|dkr�|jr�|j	|
|||�q�|dk	r�|jr�|j
|
|||�q�q>q>WWnTttt
ttfk
r$}|jdd|jjt|�fdtj��nX|S(s� Add SELinux port type definition to the policy.

    :type module: AnsibleModule
    :param module: Ansible module

    :type ports: list
    :param ports: List of ports and port ranges to add (e.g. ["8080", "8080-9090"])

    :type proto: str
    :param proto: Protocol ('tcp' or 'udp')

    :type setype: str
    :param setype: SELinux type

    :type do_reload: bool
    :param do_reload: Whether to reload SELinux policy after commit

    :type serange: str
    :param serange: SELinux MLS/MCS range (defaults to 's0')

    :type sestore: str
    :param sestore: SELinux store

    :rtype: bool
    :return: True if the policy was changed, otherwise False
    tmsgs%s: %s
t	exceptionN(tseobjecttportRecordst
set_reloadtFalseRRR Rt
check_modetaddtmodifyt
ValueErrortIOErrortKeyErrortOSErrortRuntimeErrort	fail_jsont	__class__t__name__R
t	tracebackt
format_exc(
tmoduleRRRt	do_reloadtserangetsestoreRtchanget
ports_by_typeRt	port_typete((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pytsemanage_port_add�s 

$6c	C`s�yztj|�}|j|�t}t|||�}x?|D]7}	|	|kr>t}|jsu|j|	|�quq>q>WWnTtt	t
ttfk
r�}
|j
dd|
jjt|
�fdtj��nX|S(sM Delete SELinux port type definition from the policy.

    :type module: AnsibleModule
    :param module: Ansible module

    :type ports: list
    :param ports: List of ports and port ranges to delete (e.g. ["8080", "8080-9090"])

    :type proto: str
    :param proto: Protocol ('tcp' or 'udp')

    :type setype: str
    :param setype: SELinux type.

    :type do_reload: bool
    :param do_reload: Whether to reload SELinux policy after commit

    :type sestore: str
    :param sestore: SELinux store

    :rtype: bool
    :return: True if the policy was changed, otherwise False
    R#s%s: %s
R$(R%R&R'R(RRR)tdeleteR,R-R.R/R0R1R2R3R
R4R5(R6RRRR7R9RR:R;RR=((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pytsemanage_port_del�s

	6cC`stdtdtdddt�dtdddt�d	tdd
dtddd
g�dtdd
dt�dtdd
dddddg�dtdddt��dt�}ts�|jdtd�dt�nts�|jdtd�dt	�n|j
d}t|�s$|jdd�n|j
d}|j
d	}|j
d}|j
d}|j
d}i|d6|d	6|d6|d6}|dkr�t|||||�|d<nD|dkr�t
|||||�|d<n|jddj|��|j|�dS(Nt
argument_specRttypetbooltdefaultRtlisttrequiredRtstrtchoicesttcptudpRtstatetpresenttabsenttreloadtsupports_check_modeR#slibselinux-pythonR$spolicycoreutils-pythons!SELinux is disabled on this host.tchangeds&Invalid value of argument "state": {0}(RtdictR(RtHAVE_SELINUXR1R	tSELINUX_IMP_ERRt
HAVE_SEOBJECTtSEOBJECT_IMP_ERRtparamsRR>R@tformatt	exit_json(R6RRRRRKR7tresult((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pytmains@!!	






t__main__(!t
__future__RRRRBt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR4RRSRRRRtImportErrorR5R(RUR%RTtansible.module_utils.basicRR	tansible.module_utils._textR
RRR R>R@RZR3(((sA/usr/lib/python2.7/site-packages/ansible/modules/system/seport.pyt<module>s>


4 





		/)	/

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]