Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
firewall.Firewall Class Reference
Collaboration diagram for firewall.Firewall:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def read
def reply_handler
def error_handler
def write
def add_rule
def check_ipp_client_allowed
def check_ipp_server_allowed
def check_samba_client_allowed
def check_mdns_allowed

Static Public Attributes

string ALLOW_IPP_CLIENT = "--service=ipp-client"
string ALLOW_IPP_SERVER = "--service=ipp"
string ALLOW_SAMBA_CLIENT = "--service=samba-client"
string ALLOW_MDNS = "--service=mdns"

Private Member Functions

def _get_fw_data
def _check_any_allowed

Private Attributes

 _firewall
 _fw_data
 _client_reply_handler
 _client_error_handler

Detailed Description

Definition at line 30 of file firewall.py.


Member Function Documentation

def firewall.Firewall._check_any_allowed (   self,
  search 
) [private]

Definition at line 98 of file firewall.py.

00098 
00099     def _check_any_allowed (self, search):
00100         (args, filename) = self._get_fw_data ()
00101         if filename == None: return True
00102         isect = set (search).intersection (set (args))
00103         return len (isect) != 0

Here is the call graph for this function:

Here is the caller graph for this function:

def firewall.Firewall._get_fw_data (   self,
  reply_handler = None,
  error_handler = None 
) [private]

Definition at line 36 of file firewall.py.

00036 
00037     def _get_fw_data (self, reply_handler=None, error_handler=None):
00038         try:
00039             debugprint ("%s in _get_fw_data: _fw_data is %s" %
00040                         (self, repr(self._fw_data)))
00041             if self._fw_data:
00042                 debugprint ("Using cached firewall data")
00043                 if reply_handler == None:
00044                     return self._fw_data
00045 
00046                 self._client_reply_handler (self._fw_data)
00047         except AttributeError:
00048             try:
00049                 bus = dbus.SystemBus ()
00050                 obj = bus.get_object ("org.fedoraproject.Config.Firewall",
00051                                       "/org/fedoraproject/Config/Firewall")
00052                 iface = dbus.Interface (obj,
00053                                         "org.fedoraproject.Config.Firewall")
00054                 self._firewall = iface
00055                 if reply_handler:
00056                     self._firewall.read (reply_handler=reply_handler,
00057                                          error_handler=error_handler)
00058                     return
00059 
00060                 p = self._firewall.read ()
00061                 self._fw_data = json.loads (p.encode ('utf-8'))
00062             except (dbus.DBusException, ValueError), e:
00063                 self._fw_data = (None, None)
00064                 if error_handler:
00065                     debugprint ("D-Bus exception examining firewall")
00066                     self._client_error_handler (e)
00067 
00068         return self._fw_data

Here is the caller graph for this function:

def firewall.Firewall.add_rule (   self,
  rule 
)

Definition at line 104 of file firewall.py.

00104 
00105     def add_rule (self, rule):
00106         try:
00107             (args, filename) = self._fw_data
00108         except AttributeError:
00109             (args, filename) = self._get_fw_data ()
00110         if filename == None: return
00111 
00112         args.append (rule)
00113         self._fw_data = (args, filename)

Here is the call graph for this function:

Definition at line 114 of file firewall.py.

00114 
00115     def check_ipp_client_allowed (self):
00116         return self._check_any_allowed (set(["--port=631:udp",
00117                                              self.ALLOW_IPP_CLIENT]))

Here is the call graph for this function:

Definition at line 118 of file firewall.py.

00118 
00119     def check_ipp_server_allowed (self):
00120         return self._check_any_allowed (set(["--port=631:tcp",
00121                                              self.ALLOW_IPP_SERVER]))

Here is the call graph for this function:

Definition at line 125 of file firewall.py.

00125 
00126     def check_mdns_allowed (self):
00127         return self._check_any_allowed (set(["--port=5353:udp",
00128                                              self.ALLOW_MDNS]))

Here is the call graph for this function:

Definition at line 122 of file firewall.py.

00122 
00123     def check_samba_client_allowed (self):
00124         return self._check_any_allowed (set([self.ALLOW_SAMBA_CLIENT]))

Here is the call graph for this function:

def firewall.Firewall.error_handler (   self,
  exc 
)

Definition at line 88 of file firewall.py.

00088 
00089     def error_handler (self, exc):
00090         debugprint ("Exception fetching firewall data")
00091         self._client_error_handler (exc)

Here is the caller graph for this function:

def firewall.Firewall.read (   self,
  reply_handler = None,
  error_handler = None 
)

Definition at line 69 of file firewall.py.

00069 
00070     def read (self, reply_handler=None, error_handler=None):
00071         if reply_handler:
00072             self._client_reply_handler = reply_handler
00073             self._client_error_handler = error_handler
00074             self._get_fw_data (reply_handler=self.reply_handler,
00075                                error_handler=self.error_handler)
00076         else:
00077             self._get_fw_data ()

def firewall.Firewall.reply_handler (   self,
  result 
)

Definition at line 78 of file firewall.py.

00078 
00079     def reply_handler (self, result):
00080         try:
00081             self._fw_data = json.loads (result.encode ('utf-8'))
00082         except ValueError, e:
00083             self.error_handler (e)
00084             return
00085 
00086         debugprint ("Firewall data obtained")
00087         self._client_reply_handler (self._fw_data)

Here is the call graph for this function:

def firewall.Firewall.write (   self)

Definition at line 92 of file firewall.py.

00092 
00093     def write (self):
00094         try:
00095             self._firewall.write (json.dumps (self._fw_data[0]))
00096         except:
00097             pass


Member Data Documentation

Definition at line 72 of file firewall.py.

Definition at line 71 of file firewall.py.

Definition at line 53 of file firewall.py.

Definition at line 60 of file firewall.py.

string firewall.Firewall.ALLOW_IPP_CLIENT = "--service=ipp-client" [static]

Definition at line 31 of file firewall.py.

string firewall.Firewall.ALLOW_IPP_SERVER = "--service=ipp" [static]

Definition at line 32 of file firewall.py.

string firewall.Firewall.ALLOW_MDNS = "--service=mdns" [static]

Definition at line 34 of file firewall.py.

string firewall.Firewall.ALLOW_SAMBA_CLIENT = "--service=samba-client" [static]

Definition at line 33 of file firewall.py.


The documentation for this class was generated from the following file: