Files
cli/pkg/key/mlock_unix.go
zeekay 76a04394ea Add native BadgerDB incremental snapshots and cleanup tools
- Add `lux snapshot` command with native BadgerDB backup API
  - Incremental backups (only changes since last backup)
  - ~96MB vs 5GB+ for raw file copies (160x smaller)
  - Zstd compression with manifest tracking

- Add `lux snapshot clean` for disk cleanup
  - Removes old logs, stale runs, backup directories
  - Dry-run mode for preview

- Update `lux network stop` to use incremental by default
  - --incremental (default: true)
  - --full flag to force full backup
  - --cleanup flag to clean logs on stop

- Add key migration and session cache improvements
  - Secure memory locking (mlock) for sensitive data
  - Session-based key caching
  - Key migration tooling
2026-01-19 21:00:03 -08:00

33 lines
645 B
Go

// Copyright (C) 2022-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//go:build unix
package key
import (
"golang.org/x/sys/unix"
)
// mlock locks memory to prevent swapping to disk.
// This is a security measure for sensitive data like encryption keys.
func mlock(b []byte) error {
if len(b) == 0 {
return nil
}
return unix.Mlock(b)
}
// munlock unlocks previously locked memory.
func munlock(b []byte) error {
if len(b) == 0 {
return nil
}
return unix.Munlock(b)
}
// mlockSupported returns true if mlock is available on this platform.
func mlockSupported() bool {
return true
}