Skip to content

Commit 8c3fa40

Browse files
distribute default rules with the pkgs
- distribute daemon/data/rules/ with the daemon packages. - added a new system fw rule to allow localhost connections (disabled by default). Closes: #965.
1 parent d513c93 commit 8c3fa40

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

daemon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ install:
1616
-t $(DESTDIR)/etc/opensnitchd/
1717
@install -Dm644 network_aliases.json \
1818
-t $(DESTDIR)/etc/opensnitchd/
19+
@install -Dm600 data/rules/* $(DESTDIR)/etc/opensnitchd/rules/
1920
@systemctl daemon-reload
2021

2122
opensnitchd: $(SRC)

daemon/system-fw.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,28 @@
150150
"Hook": "output",
151151
"Policy": "accept",
152152
"Rules": [
153+
{
154+
"Enabled": false,
155+
"Position": "0",
156+
"Description": "allow localhost connections",
157+
"Parameters": "",
158+
"Expressions": [
159+
{
160+
"Statement": {
161+
"Op": "==",
162+
"Name": "ip",
163+
"Values": [
164+
{
165+
"Key": "daddr",
166+
"Value": "127.0.0.0-127.255.255.255"
167+
}
168+
]
169+
}
170+
}
171+
],
172+
"Target": "accept",
173+
"TargetParameters": ""
174+
},
153175
{
154176
"Enabled": true,
155177
"Position": "0",
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
daemon/default-config.json etc/opensnitchd/
22
daemon/system-fw.json etc/opensnitchd/
3-
daemon//network_aliases.json etc/opensnitchd/
3+
daemon/network_aliases.json etc/opensnitchd/
4+
daemon/data/rules/* etc/opensnitchd/rules/
45
ebpf_prog/opensnitch.o usr/lib/opensnitchd/ebpf/
56
ebpf_prog/opensnitch-dns.o usr/lib/opensnitchd/ebpf/
67
ebpf_prog/opensnitch-procs.o usr/lib/opensnitchd/ebpf/

utils/packaging/daemon/rpm/opensnitch.spec

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ install -m 644 ebpf_prog/opensnitch.o %{buildroot}/usr/lib/opensnitchd/ebpf/open
6969
install -m 644 ebpf_prog/opensnitch-dns.o %{buildroot}/usr/lib/opensnitchd/ebpf/opensnitch-dns.o
7070
install -m 644 ebpf_prog/opensnitch-procs.o %{buildroot}/usr/lib/opensnitchd/ebpf/opensnitch-procs.o
7171

72+
B=""
73+
r="/etc/opensnitchd/rules/000-allow-localhost.json"
74+
if [ -f $r ]; then
75+
B="-b"
76+
fi
77+
install -m 600 $B daemon/data/rules/000-allow-localhost.json %{buildroot}$r
78+
B=""
79+
r="/etc/opensnitchd/rules/000-allow-localhost6.json"
80+
if [ -f $r ]; then
81+
B="-b"
82+
fi
83+
install -m 600 $B daemon/data/rules/000-allow-localhost6.json %{buildroot}$r
84+
7285
# upgrade, uninstall
7386
%preun
7487
systemctl stop opensnitch.service || true

0 commit comments

Comments
 (0)