-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetcap.py
46 lines (34 loc) · 1.46 KB
/
setcap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# setcap plugin for Zeekctl
#
# This plugin will execute 'setcap' on each node after an install
#
# Options:
# The plugin is off by default. To enable it, add "setcap.enabled=1" to zeekctl.cfg.
#
# Dave Crawford (@pingtrip)
import ZeekControl.plugin
class setcap(ZeekControl.plugin.Plugin):
def __init__(self):
super(setcap, self).__init__(apiversion=1)
def name(self):
return "setcap"
def prefix(self):
return "setcap"
def pluginVersion(self):
return 1
def init(self):
if self.getOption("enabled") == "0":
return False
return True
def options(self):
return [("enabled", "string", "0", "Set to enable plugin"),
("command", "string", "", "Full command to execute on each node.")]
def cmd_install_post(self):
self.message("setcap plugin: executing setcap on each node:")
uniq_nodes = {}
for n in self.nodes():
if n.type == 'standalone' or n.type == 'worker':
uniq_nodes[n.host] = n
cmds = [(n, self.getOption('command')) for n in uniq_nodes.values()]
for (n, success, output) in self.executeParallel(cmds):
self.message("{0} - Executing setcap: {1}".format(n.host, 'SUCCESS' if success else 'FAIL: ' + output[0]))