diff --git a/plugins/date/form_date.cs b/plugins/date/form_date.cs index c04f981..71d0d47 100644 --- a/plugins/date/form_date.cs +++ b/plugins/date/form_date.cs @@ -1,10 +1,12 @@ -
- + + + + diff --git a/plugins/disks/disks.cs b/plugins/disks/disks.cs index 1f7d369..7fa7e38 100644 --- a/plugins/disks/disks.cs +++ b/plugins/disks/disks.cs @@ -1,8 +1,12 @@ - +
+ + + + @@ -11,4 +15,5 @@ +
diff --git a/plugins/language_selection/language_selection.cs b/plugins/language_selection/language_selection.cs index f27a68b..9cccf57 100644 --- a/plugins/language_selection/language_selection.cs +++ b/plugins/language_selection/language_selection.cs @@ -1,12 +1,15 @@ - +
+ + + + + -
-
diff --git a/plugins/network/form_network.cs b/plugins/network/form_network.cs index 07469fa..88fb2bb 100644 --- a/plugins/network/form_network.cs +++ b/plugins/network/form_network.cs @@ -1,10 +1,12 @@ -
- + + + + @@ -52,7 +54,9 @@
- + + + diff --git a/plugins/network/language.hdf b/plugins/network/language.hdf index f177ef1..aa9520a 100644 --- a/plugins/network/language.hdf +++ b/plugins/network/language.hdf @@ -21,7 +21,7 @@ Button { Help { Network = Insert the network address of the CryptoBox server, the network mask and the default gateway. Be aware that you may lose your connection to the server under some circumstances. The actual values are visible in the form fields. - Gateway = If you have a gateway in your LAN and want to make use of it, type it's address in here. It will be added as default route. + Gateway = If you have a gateway in your LAN and want to make use of it, type it's address in here. It will be added as default route. A quadruple of zeros means, there is no gateway set. DHCP = If you enable automatic network configuration make sure you have a well configured DHCP server running. All values will be overridden by the settings from the DHCP server. If you don't know what DHCP means leave this box unchecked. } diff --git a/plugins/network/network.py b/plugins/network/network.py index 5eb6cdb..9330987 100644 --- a/plugins/network/network.py +++ b/plugins/network/network.py @@ -37,7 +37,7 @@ REDIRECT_DELAY = 10 CHANGE_IP_DELAY = 5 ## default network interface (may be overriden by the "interface" setting of the ## network plugin in cryptobox.conf -DEFAULT_INTERFACE = "eth0" +DEFAULT_INTERFACE = "eth2" class network(cryptobox.plugins.base.CryptoBoxPlugin): """The network feature of the CryptoBox. @@ -96,13 +96,14 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): return "form_network" ## request for default gateway change elif store == "set_gateway": + old_ip = __get_current_gw() if self.__IP_is_valid(ip1, ip2, ip3, ip4): new_ip = "%d.%d.%d.%d" % (int(ip1), int(ip2), int(ip3), int(ip4)) else: self.hdf["Data.Warning"] = "Plugins.network.InvalidGatewayIP" self.__prepare_form_data() return "form_network" - if self.__set_gw(new_ip): + if self.__set_gw(old_ip, new_ip): self.cbox.log.info("the gateway IP was successfully changed: %s" % new_ip) self.hdf["Data.Success"] = "Plugins.network.GWChanged" @@ -140,7 +141,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): warnings = [] if not os.path.isfile(self.root_action.IFCONFIG_BIN): warnings.append((55, "Plugins.%s.MissingProgramIfconfig" % self.get_name())) - if not os.path.isfile(self.root_action.GWCONFIG_BIN): + if not os.path.isfile(self.root_action.ROUTE_BIN): warnings.append((52, "Plugins.%s.MissingProgramRoute" % self.get_name())) return warnings @@ -160,6 +161,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): def __prepare_form_data(self): """Set some hdf values. """ + #TODO: the following looks nicer in a loop (oc1, oc2, oc3, oc4) = self.__get_current_ip("ip") self.hdf[self.hdf_prefix + "ip.oc1"] = oc1 self.hdf[self.hdf_prefix + "ip.oc2"] = oc2 @@ -170,6 +172,11 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): self.hdf[self.hdf_prefix + "nm.oc2"] = oc2 self.hdf[self.hdf_prefix + "nm.oc3"] = oc3 self.hdf[self.hdf_prefix + "nm.oc4"] = oc4 + (oc1, oc2, oc3, oc4) = self.__get_current_ip("gw") + self.hdf[self.hdf_prefix + "gw.oc1"] = oc1 + self.hdf[self.hdf_prefix + "gw.oc2"] = oc2 + self.hdf[self.hdf_prefix + "gw.oc3"] = oc3 + self.hdf[self.hdf_prefix + "gw.oc4"] = oc4 def __get_current_ip(self, type="ip"): @@ -186,8 +193,8 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): (stdout, stderr) = proc.communicate() if proc.returncode != 0: return (0, 0, 0, 0) - ## this regex matches the four numbers of the IP if type == "ip": + ## this regex matches the four numbers of the IP match = re.search(r'inet [\w]+:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s', stdout) if match: ## use the previously matched numbers @@ -195,14 +202,31 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): else: return (0, 0, 0, 0) elif type == "nm": - ##TODO: Lars please leave a regex note for fetching the - ## netmask with ifconfig + ## this greps the netmask match = re.search(r'inet [\w]+:.*Mask:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s', stdout) if match: ## use the previously matched numbers return tuple([int(e) for e in match.groups()]) else: return (0, 0, 0, 0) + elif type == "gw": + gw = self.__get_current_gw() + return gw + + def __get_current_gw(self): + proc = subprocess.Popen( + shell = False, + stdout = subprocess.PIPE, + args = [ + self.root_action.ROUTE_BIN, + "-n"]) + (stdout, stderr) = proc.communicate() + if proc.returncode != 0: + self.cbox.log.warn(stderr) + return (0, 0, 0, 0) + #TODO: Lars, please do some regex voodoo here + gwIP = "192.168.0.123" + return gwIP def __set_ip(self, new_ip, new_nm="255.255.255.0"): @@ -240,12 +264,35 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): return True - def __set_gw(self, new_ip): + def __set_gw(self, old_ip, new_ip): """Change the gateway IP adress """ - ## TODO: route add default gw ... - ## as soon as lazy age has implemented this return True - return False + import threading + def delayed_ip_change(): + import time + time.sleep(CHANGE_IP_DELAY) + proc = subprocess.Popen( + shell = False, + stderr = subprocess.PIPE, + args = [ + self.cbox.prefs["Programs"]["super"], + self.cbox.prefs["Programs"]["CryptoBoxRootActions"], + "plugin", + os.path.join(self.plugin_dir, "root_action.py"), + "change_gw", + old_ip, + new_ip]) + proc.wait() + if proc.returncode != 0: + self.cbox.log.warn("failed to change IP address: %s" % new_ip) + self.cbox.log.warn("error output: %s" % str(proc.stderr.read())) + return + thread = threading.Thread() + thread.run = delayed_ip_change + thread.setDaemon(True) + thread.start() + # TODO: how could we guess, if it failed? + return True def __get_interface(self): diff --git a/plugins/network/root_action.py b/plugins/network/root_action.py index 0512b9a..4f85817 100755 --- a/plugins/network/root_action.py +++ b/plugins/network/root_action.py @@ -28,7 +28,7 @@ __revision__ = "$Id" PLUGIN_TYPE = "cryptobox" IFCONFIG_BIN = "/sbin/ifconfig" -GWCONFIG_BIN = "/sbin/route" +ROUTE_BIN = "/sbin/route" import subprocess import re @@ -52,9 +52,22 @@ def __changeIP(interface, ipaddress, netmask="0"): return proc.returncode == 0 -def __changeGW(gwaddress): - ##TODO - return False +def __changeGW(old_gw, gwaddress): + __check_address(old_gw) + __check_address(gwaddress) + if old_gw != "0.0.0.0": + """assuming that a default route exists and deleting it + """ + proc = subprocess.Popen( + shell = False, + args = [ROUTE_BIN, "del", "default", "gw", old_gw]) + proc.wait() + + proc = subprocess.Popen( + shell = False, + args = [ROUTE_BIN, "add", "default", "gw", gwaddress]) + proc.wait() + return proc.returncode == 0 def __check_address(address): """Check for correct numbers in given address @@ -81,8 +94,8 @@ if __name__ == "__main__": if len(args) != 4: raise "InvalidArgNum" result = __changeIP(args[1], args[2], args[3]) elif args[0] == "change_gw": - if len(args) != 2: raise "InvalidArgNum" - result = __changeGW(args[1]) + if len(args) != 3: raise "InvalidArgNum" + result = __changeGW(args[1], args[2]) else: sys.stderr.write("%s: invalid action (%s)\n" % (self_bin, args[0])) sys.exit(1) diff --git a/plugins/plugin_manager/plugin_list.cs b/plugins/plugin_manager/plugin_list.cs index eddfb2c..51ce8cb 100644 --- a/plugins/plugin_manager/plugin_list.cs +++ b/plugins/plugin_manager/plugin_list.cs @@ -1,6 +1,5 @@ - @@ -12,8 +11,11 @@ starts here ?> -
- +
+ + + + @@ -67,8 +69,11 @@
-
- +
+ + + + diff --git a/plugins/plugin_manager/plugin_manager.py b/plugins/plugin_manager/plugin_manager.py index 699e1e4..7a460ac 100644 --- a/plugins/plugin_manager/plugin_manager.py +++ b/plugins/plugin_manager/plugin_manager.py @@ -42,7 +42,8 @@ class plugin_manager(cryptobox.plugins.base.CryptoBoxPlugin): if not plugin: return "plugin_list" ## take only plugins, that are of the same type as the choosen one self.plugins = [e for e in plugin_manager.get_plugins() - if e.plugin_capabilities == plugin.plugin_capabilities] + if e.plugin_capabilities == plugin.plugin_capabilities and \ + e != "volume_props" ] if action == "up": self.__move_up(plugin) elif action == "down": diff --git a/plugins/shutdown/form_shutdown.cs b/plugins/shutdown/form_shutdown.cs index fcd569a..9259795 100644 --- a/plugins/shutdown/form_shutdown.cs +++ b/plugins/shutdown/form_shutdown.cs @@ -1,8 +1,13 @@ - +
+ + + + +
@@ -15,3 +20,4 @@ icon: reboot
+
diff --git a/plugins/system_preferences/show_plugins.cs b/plugins/system_preferences/show_plugins.cs index 2d0c101..3adc5bd 100644 --- a/plugins/system_preferences/show_plugins.cs +++ b/plugins/system_preferences/show_plugins.cs @@ -1,10 +1,12 @@ -
- + + + + -
- + + +
@@ -29,7 +30,9 @@
- + + +
diff --git a/templates/footer.cs b/templates/footer.cs index f5a6478..f75bbc6 100644 --- a/templates/footer.cs +++ b/templates/footer.cs @@ -7,7 +7,9 @@ - + + +

diff --git a/templates/macros.cs b/templates/macros.cs index cfacf0a..8adbf41 100644 --- a/templates/macros.cs +++ b/templates/macros.cs @@ -230,11 +230,15 @@ def:handle_messages() ?>
icon: <?cs var:html_escape(Data.ActivePlugin) ?>

-
+ icon: <?cs var:html_escape(Data.ActivePlugin) ?> diff --git a/www-data/cryptobox.css b/www-data/cryptobox.css index 6a389c0..415f4d6 100644 --- a/www-data/cryptobox.css +++ b/www-data/cryptobox.css @@ -21,6 +21,13 @@ div#main { margin-left: 140px; } +legend img { + width: 32px; + height: 32px; + padding-right: 8px; + float: left; +} + #main h1, h2, h3, legend { font-family: sans-serif, arial; font-weight: normal;