Skip to content

Commit c9b150e

Browse files
committed
sensor: restart cowrie after log rotation to clear sparse FD offset
1 parent 3b622af commit c9b150e

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

config/ansible/roles/profile_sensor_low/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
# --- HONEYPOTS LOG ROTATION --
6565
- name: "Set the honeypots log rotation"
6666
become: true
67-
ansible.builtin.copy:
68-
src: honeypots.logrotate
67+
ansible.builtin.template:
68+
src: honeypots.logrotate.j2
6969
dest: /etc/lantana/logrotate.d/00_00/honeypots
7070
owner: root
7171
group: root

config/ansible/roles/profile_sensor_low/templates/honeypots.logrotate.j2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,21 @@
1212
compress
1313
delaycompress
1414
copytruncate
15+
sharedscripts
16+
# Cowrie's Twisted writer holds the file descriptor across rotation and
17+
# keeps appending at its remembered offset, leaving a sparse-null region
18+
# at the start of the new file (op_alpha 2026-06-19: cowrie.json reported
19+
# 149 MB, first non-null byte at offset 141 271 814 — Vector tails it
20+
# fine but cat/jq inspection breaks and analyst debug is blocked).
21+
# Restarting the rootless quadlet hands the writer a fresh FD pointing
22+
# at offset 0. Cost: any cowrie SSH session active at the moment of
23+
# rotation disconnects, losing a few seconds of intel — acceptable since
24+
# the cron fires at 00:00 UTC and attacker sessions rarely span midnight.
25+
# Dionaea's writer reopens cleanly on truncation so it doesn't need the
26+
# same treatment.
27+
postrotate
28+
runuser -u {{ system.users.sensor.name }} -- \
29+
env XDG_RUNTIME_DIR=/run/user/{{ system.users.sensor.uid }} \
30+
systemctl --user restart cowrie.service >/dev/null 2>&1 || true
31+
endscript
1532
}

0 commit comments

Comments
 (0)