Daemon Architecture¶
The OmniVault CLI uses a daemon (background service) architecture for secure secret management.
Why a Daemon?¶
The daemon architecture provides several security benefits:
- Session-Based Unlock - Unlock once, access secrets multiple times without re-entering password
- Memory Protection - Encryption keys stay in daemon memory, not in CLI process
- Auto-Lock - Automatic locking after inactivity
- Single Point of Control - One process manages all vault access
How It Works¶
┌─────────────┐ Unix Socket ┌──────────────┐
│ omnivault │ ◄──────────────────► │ omnivaultd │
│ (CLI) │ HTTP/JSON │ (Daemon) │
└─────────────┘ └──────┬───────┘
│
▼
┌──────────────┐
│ ~/.omnivault │
│ vault.enc │
│ vault.meta │
└──────────────┘
- CLI sends commands to daemon via Unix socket (macOS/Linux) or TCP (Windows)
- Daemon holds encryption key in memory
- Daemon performs all cryptographic operations
- Files on disk are always encrypted
Communication¶
Unix Socket¶
On macOS and Linux, the daemon listens on a Unix socket:
Unix sockets provide:
- Local-only access (no network exposure)
- File permission-based security
- Fast IPC performance
HTTP API¶
The daemon exposes an HTTP API over the socket:
| Endpoint | Method | Description |
|---|---|---|
/status |
GET | Daemon and vault status |
/init |
POST | Initialize new vault |
/unlock |
POST | Unlock vault |
/lock |
POST | Lock vault |
/secrets |
GET | List secrets |
/secret/:path |
GET | Get secret |
/secret/:path |
PUT | Set secret |
/secret/:path |
DELETE | Delete secret |
/stop |
POST | Stop daemon |
Lifecycle¶
Starting¶
- Checks if daemon is already running
- Starts new process in background
- Creates Unix socket
- Writes PID file
Running¶
While running, the daemon:
- Listens for CLI commands
- Manages vault lock state
- Resets auto-lock timer on activity
- Holds encryption key in memory (when unlocked)
Stopping¶
- Sends stop command via socket
- Daemon locks vault (clears key from memory)
- Daemon shuts down HTTP server
- Removes socket and PID files
Graceful Shutdown¶
On SIGINT or SIGTERM:
- Vault is locked
- Active requests complete
- Socket is removed
- Process exits
Auto-Lock¶
The daemon automatically locks the vault after a period of inactivity.
How It Works¶
- Timer starts when vault is unlocked
- Each vault operation resets the timer
- When timer expires, vault is locked
- Default timeout: 15 minutes
Activity Reset¶
These operations reset the auto-lock timer:
get- Reading a secretset- Writing a secretdelete- Deleting a secretlist- Listing secrets
These operations do NOT reset the timer:
status- Checking statuslock- Manual lockunlock- Already unlocked
Files¶
The daemon creates and manages these files:
| File | Purpose | Permissions |
|---|---|---|
~/.omnivault/ |
Config directory | 700 |
vault.enc |
Encrypted secrets | 600 |
vault.meta |
Salt and parameters | 600 |
omnivaultd.sock |
Unix socket | 600 |
omnivaultd.pid |
Daemon PID | 644 |
Platform Differences¶
macOS / Linux¶
- Uses Unix socket at
~/.omnivault/omnivaultd.sock - Standard Unix permissions apply
- Process daemonization via
Setpgid - Graceful shutdown via SIGTERM
Windows¶
- Uses TCP on
127.0.0.1:19839 - Vault files stored in
%LOCALAPPDATA%\OmniVault\ - Process termination via
Process.Kill() - No socket file (TCP-based IPC)
| Feature | macOS/Linux | Windows |
|---|---|---|
| IPC | Unix Socket | TCP localhost |
| Address | ~/.omnivault/omnivaultd.sock |
127.0.0.1:19839 |
| Config Dir | ~/.omnivault/ |
%LOCALAPPDATA%\OmniVault\ |
| Shutdown | SIGTERM | Process.Kill() |
Debugging¶
Run the daemon in foreground to see logs:
Example output:
Starting OmniVault daemon...
INFO daemon started socket=/Users/you/.omnivault/omnivaultd.sock
INFO vault unlocked
INFO secret accessed path=database/password
INFO vault auto-locked due to inactivity
Security Considerations¶
Socket Permissions¶
The Unix socket is created with permissions 600:
- Only the owner can connect
- Other users cannot access the daemon
Memory Security¶
When locked:
- Encryption key is zeroed from memory
- No secrets can be decrypted
- Vault file remains encrypted
No Network Access¶
The daemon:
- Never listens on network interfaces
- Only accepts local Unix socket connections
- Cannot be accessed remotely