[nanny] Initial Win32 Filtering
- From: Roberto Majadas <telemaco src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nanny] Initial Win32 Filtering
- Date: Sun, 23 Jan 2011 18:00:40 +0000 (UTC)
commit 8478655c094c418db60aa6d155080fab6fd64491
Author: Roberto Majadas <roberto majadas openshine com>
Date: Tue Sep 14 19:49:41 2010 +0200
Initial Win32 Filtering
daemon/src/Makefile.am | 3 +-
daemon/src/QuarterBack.py | 1 +
daemon/src/Win32Filtering.py | 101 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 1 deletions(-)
---
diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am
index 36f349c..7af5690 100644
--- a/daemon/src/Makefile.am
+++ b/daemon/src/Makefile.am
@@ -13,7 +13,8 @@ corelib_PYTHON = __init__.py \
LinuxUsersManager.py \
LinuxSessionFiltering.py \
LinuxSessionCKFiltering.py \
- Win32UsersManager.py
+ Win32Filtering \
+ Win32UsersManager.py
if HAS_HACHOIR_REGEX
dgimporterdir = $(pythondir)/nanny/daemon
diff --git a/daemon/src/QuarterBack.py b/daemon/src/QuarterBack.py
index 0b257a9..3fe5be1 100644
--- a/daemon/src/QuarterBack.py
+++ b/daemon/src/QuarterBack.py
@@ -37,6 +37,7 @@ if os.name == "posix" :
from LinuxSessionCKFiltering import LinuxSessionCKFiltering as SessionFilter
from FilterManager import FilterManager as FilterManager
elif os.name == "nt" :
+ from Win32Filtering import Win32Filtering as FirewallFilter
from Win32UsersManager import Win32UsersManager as UsersManager
from Chrono import Chrono
diff --git a/daemon/src/Win32Filtering.py b/daemon/src/Win32Filtering.py
new file mode 100644
index 0000000..40509c4
--- /dev/null
+++ b/daemon/src/Win32Filtering.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2009,2010 Junta de Andalucia
+#
+# Authors:
+# Roberto Majadas <roberto.majadas at openshine.com>
+# Cesar Garcia Tapia <cesar.garcia.tapia at openshine.com>
+# Luis de Bethencourt <luibg at openshine.com>
+# Pablo Vieytes <pvieytes at openshine.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+
+import gobject
+import os
+
+from twisted.internet import reactor
+from time import localtime, strftime
+
+(
+SESSION_APPID,
+WEB_APPID,
+MAIL_APPID,
+IM_APPID) = range(4)
+
+iptables_weekdays = {"mon" : "Mon",
+ "tue" : "Tue",
+ "wed" : "Wed",
+ "thu" : "Thu",
+ "fri" : "Fri",
+ "sat" : "Sat",
+ "sun" : "Sun"}
+
+services_ports = {WEB_APPID : "80, 443, 8080",
+ MAIL_APPID : "25, 110, 109, 995, 143, 220, 993, 465",
+ IM_APPID : "1863, 5222, 5269",
+ }
+
+class Win32Filtering(gobject.GObject) :
+ def __init__(self, quarterback) :
+ gobject.GObject.__init__(self)
+ self.quarterback = quarterback
+
+ reactor.addSystemEventTrigger("before", "startup", self.start)
+ reactor.addSystemEventTrigger("before", "shutdown", self.stop)
+
+ self.quarterback.connect("update-blocks", self.__update_blocks_cb)
+
+ def start(self):
+ print "Start Win32 Filtering"
+ self.__update_blocks_cb(self.quarterback, self.quarterback.blocks)
+
+ def stop(self):
+ print "Stop Win32 Filtering"
+
+ def __update_blocks_cb(self, quarterback, blocks):
+ #Create pre-chain
+ rules=[]
+ for user_id in blocks.keys() :
+ for app_id in blocks[user_id].keys() :
+ if app_id == SESSION_APPID :
+ continue
+
+ if quarterback.get_available_time(user_id, app_id) == 0 :
+ rules.append(
+ (user_id,
+ strftime("%a", localtime()),
+ "00:01",
+ "23:59",
+ services_ports[app_id]
+ )
+ )
+
+ to_block = quarterback.get_blocks(user_id, app_id)
+ for week_day in to_block.keys() :
+ for i_time, e_time in to_block[week_day] :
+ rules.append(
+ (user_id,
+ iptables_weekdays[week_day],
+ i_time,
+ e_time,
+ services_ports[app_id]
+ )
+ )
+
+ #apply rules firewall
+ print ("update_firewall_rules : WIP")
+
+gobject.type_register(Win32Filtering)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]