From 359ac04e37825b24dfdb7511611c26c37e70f985 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Thu, 19 Oct 2017 10:47:28 +0300 Subject: [PATCH 1/4] Service created by deb starts automatically --- monkey_island/deb-package/DEBIAN/postinst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey_island/deb-package/DEBIAN/postinst index 3b9ba92ff..372718b87 100644 --- a/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey_island/deb-package/DEBIAN/postinst @@ -22,6 +22,8 @@ if [ -d "/etc/systemd/network" ]; then cp ${MONKEY_FOLDER}/ubuntu/systemd/*.service /lib/systemd/system/ chmod +x ${MONKEY_FOLDER}/ubuntu/systemd/start_server.sh systemctl daemon-reload + systemctl enable monkey-mongo + systemctl enable monkey-island fi ${MONKEY_FOLDER}/create_certificate.sh From a8c387c169ce3a6ab4290f21edff1317338a11d6 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Thu, 19 Oct 2017 16:23:30 +0300 Subject: [PATCH 2/4] Make sure monkey mongo starts before monkey island --- monkey_island/deb-package/DEBIAN/postinst | 4 ++-- monkey_island/linux/ubuntu/systemd/monkey-island.service | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey_island/deb-package/DEBIAN/postinst index 372718b87..42b8f1eb0 100644 --- a/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey_island/deb-package/DEBIAN/postinst @@ -22,8 +22,8 @@ if [ -d "/etc/systemd/network" ]; then cp ${MONKEY_FOLDER}/ubuntu/systemd/*.service /lib/systemd/system/ chmod +x ${MONKEY_FOLDER}/ubuntu/systemd/start_server.sh systemctl daemon-reload - systemctl enable monkey-mongo - systemctl enable monkey-island + systemctl enable monkey-mongo + systemctl enable monkey-island fi ${MONKEY_FOLDER}/create_certificate.sh diff --git a/monkey_island/linux/ubuntu/systemd/monkey-island.service b/monkey_island/linux/ubuntu/systemd/monkey-island.service index fe43875ac..8868dc3aa 100644 --- a/monkey_island/linux/ubuntu/systemd/monkey-island.service +++ b/monkey_island/linux/ubuntu/systemd/monkey-island.service @@ -1,5 +1,6 @@ [Unit] Description=Monkey Island Service +Wants=monkey-mongo.service After=network.target [Service] From 75a399874fbe8a1c055f0a1ee756115d9727c4ef Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Thu, 19 Oct 2017 17:04:11 +0300 Subject: [PATCH 3/4] fix ip address unicode bug --- chaos_monkey/network/info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chaos_monkey/network/info.py b/chaos_monkey/network/info.py index 0c841dc9f..27afbb4c4 100644 --- a/chaos_monkey/network/info.py +++ b/chaos_monkey/network/info.py @@ -138,7 +138,7 @@ def get_ips_from_interfaces(): res = [] ifs = get_host_subnets() for net_interface in ifs: - host_addr = ipaddress.ip_address(net_interface['addr']) + host_addr = ipaddress.ip_address(u"%s" % net_interface['addr']) ip_interface = ipaddress.ip_interface(u"%s/%s" % (net_interface['addr'], net_interface['netmask'])) # limit subnet scans to class C only if ip_interface.network.num_addresses > 255: From bf343ee24b7a69a69f552d6a120a9eac7075cde2 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 24 Oct 2017 11:51:53 +0300 Subject: [PATCH 4/4] refine get_ips_from_interfaces --- chaos_monkey/network/info.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chaos_monkey/network/info.py b/chaos_monkey/network/info.py index 27afbb4c4..3bab8cb17 100644 --- a/chaos_monkey/network/info.py +++ b/chaos_monkey/network/info.py @@ -138,12 +138,14 @@ def get_ips_from_interfaces(): res = [] ifs = get_host_subnets() for net_interface in ifs: - host_addr = ipaddress.ip_address(u"%s" % net_interface['addr']) - ip_interface = ipaddress.ip_interface(u"%s/%s" % (net_interface['addr'], net_interface['netmask'])) + address_str = unicode(net_interface['addr']) + netmask_str = unicode(net_interface['netmask']) + host_address = ipaddress.ip_address(address_str) + ip_interface = ipaddress.ip_interface(u"%s/%s" % (address_str, netmask_str)) # limit subnet scans to class C only if ip_interface.network.num_addresses > 255: - ip_interface = ipaddress.ip_interface(u"%s/24" % net_interface['addr']) - addrs = [str(addr) for addr in ip_interface.network.hosts() if addr != host_addr] + ip_interface = ipaddress.ip_interface(u"%s/24" % address_str) + addrs = [str(addr) for addr in ip_interface.network.hosts() if addr != host_address] res.extend(addrs) return res