| 1 | [Unit] |
| 2 | Description=lchat webhook-ingest sidecar for %i |
| 3 | After=network-online.target lchat@%i.service |
| 4 | Wants=network-online.target |
| 5 | |
| 6 | [Service] |
| 7 | # add-hooks writes /data/%i-hooks.env (0600) with LCHAT_BASE, the service |
| 8 | # identity's one-time agent invite, the session path, and the socket path. |
| 9 | EnvironmentFile=-/data/%i-hooks.env |
| 10 | # Same versioned Go binary as the instance (the per-host live symlink), so the |
| 11 | # ingest sidecar's code stays in lock-step with the app by construction — |
| 12 | # exactly the lchat-bot@ arrangement. `hooks run` reads everything from the |
| 13 | # EnvironmentFile above. |
| 14 | ExecStart=/opt/lchat/live/%i hooks run |
| 15 | Restart=always |
| 16 | RestartSec=2 |
| 17 | |
| 18 | # --- hardening (see docs/instance-router.md § Hardening) --- |
| 19 | # Unlike the bot sidecar this process DOES listen — on a unix socket under |
| 20 | # /run/lchat that only the router dials; it still binds no TCP port and needs |
| 21 | # no capabilities. It is the inverse of the bot: inbound requests come in, |
| 22 | # encrypted posts go out, and nothing here can read a conversation. |
| 23 | User=lchat |
| 24 | Group=lchat |
| 25 | CapabilityBoundingSet= |
| 26 | NoNewPrivileges=yes |
| 27 | ProtectSystem=strict |
| 28 | ProtectHome=yes |
| 29 | # Writes its service-identity session under /data/%i-hooks/ and its listening |
| 30 | # socket under /run/lchat. HOME lands in the private /tmp. |
| 31 | ReadWritePaths=/data /run/lchat |
| 32 | Environment=HOME=/tmp |
| 33 | PrivateTmp=yes |
| 34 | PrivateDevices=yes |
| 35 | ProtectClock=yes |
| 36 | ProtectHostname=yes |
| 37 | ProtectKernelTunables=yes |
| 38 | ProtectKernelModules=yes |
| 39 | ProtectKernelLogs=yes |
| 40 | ProtectControlGroups=yes |
| 41 | ProtectProc=invisible |
| 42 | RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX |
| 43 | RestrictNamespaces=yes |
| 44 | RestrictRealtime=yes |
| 45 | RestrictSUIDSGID=yes |
| 46 | LockPersonality=yes |
| 47 | MemoryDenyWriteExecute=yes |
| 48 | SystemCallFilter=@system-service |
| 49 | SystemCallErrorNumber=EPERM |
| 50 | SystemCallArchitectures=native |
| 51 | MemoryMax=256M |
| 52 | TasksMax=256 |
| 53 | |
| 54 | [Install] |
| 55 | WantedBy=multi-user.target |
| 56 | |