Fix host agent socket activation
This commit is contained in:
@@ -11,8 +11,6 @@ Group=root
|
|||||||
ExecStart=/usr/local/bin/netbox-store-agent --config /etc/netbox-store-agent/agent.toml daemon
|
ExecStart=/usr/local/bin/netbox-store-agent --config /etc/netbox-store-agent/agent.toml daemon
|
||||||
StateDirectory=netbox-store-agent
|
StateDirectory=netbox-store-agent
|
||||||
StateDirectoryMode=0711
|
StateDirectoryMode=0711
|
||||||
RuntimeDirectory=netbox-store-agent
|
|
||||||
RuntimeDirectoryMode=0755
|
|
||||||
UMask=0077
|
UMask=0077
|
||||||
NoNewPrivileges=true
|
NoNewPrivileges=true
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ class SystemdUnitTests(unittest.TestCase):
|
|||||||
self.assertIn("SocketMode=0660", socket_unit)
|
self.assertIn("SocketMode=0660", socket_unit)
|
||||||
self.assertIn("SocketGroup=netbox", socket_unit)
|
self.assertIn("SocketGroup=netbox", socket_unit)
|
||||||
|
|
||||||
def test_state_traversal_does_not_relax_service_umask(self):
|
def test_service_does_not_own_socket_runtime_directory(self):
|
||||||
service_unit = Path("systemd/netbox-store-agent.service").read_text(encoding="utf-8")
|
service_unit = Path("systemd/netbox-store-agent.service").read_text(encoding="utf-8")
|
||||||
|
|
||||||
self.assertIn("StateDirectoryMode=0711", service_unit)
|
self.assertIn("StateDirectoryMode=0711", service_unit)
|
||||||
self.assertIn("RuntimeDirectoryMode=0755", service_unit)
|
self.assertNotIn("RuntimeDirectory=netbox-store-agent", service_unit)
|
||||||
self.assertIn("UMask=0077", service_unit)
|
self.assertIn("UMask=0077", service_unit)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -512,10 +512,15 @@ info "Datenbank und statische Dateien aktualisieren"
|
|||||||
info "Dienste aktivieren und neu starten"
|
info "Dienste aktivieren und neu starten"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable netbox-store-agent.socket
|
systemctl enable netbox-store-agent.socket
|
||||||
|
systemctl stop netbox-store-agent.service
|
||||||
systemctl restart netbox-store-agent.socket
|
systemctl restart netbox-store-agent.socket
|
||||||
systemctl restart netbox-store-agent.service
|
|
||||||
systemctl restart netbox netbox-rq
|
systemctl restart netbox netbox-rq
|
||||||
|
|
||||||
|
if [[ ! -S /run/netbox-store-agent/agent.sock ]]; then
|
||||||
|
systemctl status netbox-store-agent.socket --no-pager -l || true
|
||||||
|
die "Der Agent-Socket /run/netbox-store-agent/agent.sock wurde nicht erstellt."
|
||||||
|
fi
|
||||||
|
|
||||||
info "Socket-Zugriff als NetBox-Dienstkonto prüfen"
|
info "Socket-Zugriff als NetBox-Dienstkonto prüfen"
|
||||||
runuser -u "$NETBOX_USER" -- \
|
runuser -u "$NETBOX_USER" -- \
|
||||||
/opt/netbox-store-agent/venv/bin/netbox-store-agent capabilities
|
/opt/netbox-store-agent/venv/bin/netbox-store-agent capabilities
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ sudo bash /tmp/netbox-store-install.sh
|
|||||||
sudo /opt/netbox/venv/bin/python -m py_compile \
|
sudo /opt/netbox/venv/bin/python -m py_compile \
|
||||||
/opt/netbox/netbox/netbox/configuration.py</code></pre>
|
/opt/netbox/netbox/netbox/configuration.py</code></pre>
|
||||||
|
|
||||||
|
<h3>Socket-Prüfung meldet „No such file or directory“</h3>
|
||||||
|
<p>Lade den aktuellen Installer erneut herunter und führe ihn noch einmal aus. Eine ältere systemd-Unit konnte beim Neustart das Verzeichnis des Agent-Sockets entfernen. Der aktuelle Installer ersetzt die Unit und startet den Agent über korrekte Socket-Aktivierung.</p>
|
||||||
|
|
||||||
<h3>API_TOKEN_PEPPERS-Warnung</h3>
|
<h3>API_TOKEN_PEPPERS-Warnung</h3>
|
||||||
<p>Diese NetBox-Einstellung gehört nicht zum Plugin und wird deshalb nicht automatisch verändert:</p>
|
<p>Diese NetBox-Einstellung gehört nicht zum Plugin und wird deshalb nicht automatisch verändert:</p>
|
||||||
<pre><code>sudo /opt/netbox/venv/bin/python /opt/netbox/netbox/generate_secret_key.py</code></pre>
|
<pre><code>sudo /opt/netbox/venv/bin/python /opt/netbox/netbox/generate_secret_key.py</code></pre>
|
||||||
|
|||||||
@@ -498,6 +498,7 @@ test('public and admin templates render safely with complete artifact evidence',
|
|||||||
assertTrue(str_contains($installation, 'Dry-Run: Nein'));
|
assertTrue(str_contains($installation, 'Dry-Run: Nein'));
|
||||||
assertTrue(str_contains($installation, 'Release-Artefakte'));
|
assertTrue(str_contains($installation, 'Release-Artefakte'));
|
||||||
assertTrue(str_contains($installation, 'configuration.py must contain exactly one static PLUGINS assignment'));
|
assertTrue(str_contains($installation, 'configuration.py must contain exactly one static PLUGINS assignment'));
|
||||||
|
assertTrue(str_contains($installation, 'Socket-Prüfung meldet'));
|
||||||
assertTrue(str_contains($installation, 'python -m py_compile'));
|
assertTrue(str_contains($installation, 'python -m py_compile'));
|
||||||
assertTrue(str_contains($installation, 'https://netbox.mrblake.cc'));
|
assertTrue(str_contains($installation, 'https://netbox.mrblake.cc'));
|
||||||
assertTrue(str_contains($installation, 'API_TOKEN_PEPPERS'));
|
assertTrue(str_contains($installation, 'API_TOKEN_PEPPERS'));
|
||||||
|
|||||||
Reference in New Issue
Block a user