permission-guard
A robust permission management service for Kodachi OS that monitors and corrects file ownership to prevent root-owned files in user directories
Version: 9.0.1 | Size: 3.2MB | Author: Warith Al Maawali
License: Proprietary | Website: https://digi77.com
File Information
Property | Value |
---|---|
Binary Name | permission-guard |
Version | 9.0.1 |
Build Date | 2025-01-28T00:00:00Z |
Rust Version | unknown |
File Size | 3.2MB |
JSON Data | View Raw JSON |
SHA256 Checksum
Features
Feature | Description |
---|---|
Feature | Real-time file permission monitoring |
Feature | Automatic permission correction |
Feature | Configurable watch directories |
Feature | Pattern-based exclusions |
Feature | Daemon mode for background operation |
Feature | JSON and text output formats |
Feature | Field filtering and pagination |
Feature | Comprehensive error handling |
Security Features
Feature | Description |
---|---|
Authentication | Integrates with system user permissions |
Encryption | Secure configuration storage |
Inputvalidation | All paths and inputs are sanitized and validated |
Ratelimiting | Configurable scan intervals prevent resource exhaustion |
System Requirements
Requirement | Value |
---|---|
OS | Linux (Debian-based) |
Privileges | root/sudo |
Dependencies | systemd, inotify support |
Global Options
Flag | Description |
---|---|
-h, --help |
Print help information |
-v, --version |
Print version information |
-n, --info |
Display detailed information |
-e, --examples |
Show usage examples |
--json |
Output in JSON format |
-o, --output-format <text|json> |
Force output format (default: text) |
--verbose |
Enable verbose output |
--quiet |
Suppress non-essential output |
--no-color |
Disable colored output |
--timeout <SECS> |
Set timeout (default: 30) |
--retry <COUNT> |
Retry attempts (default: 3) |
-c, --config <FILE> |
Use custom configuration file |
--json-filter <FIELD1,FIELD2> |
Return only specified fields in JSON output |
--json-pretty |
Pretty-print JSON output with indentation |
--fields <FIELD_LIST> |
Select specific fields to include in output |
--limit <NUMBER> |
Limit number of results returned |
--offset <NUMBER> |
Skip first N results (for pagination) |
--user-override <USER> |
Override target user (username or UID) |
-d, --daemon |
Run as daemon (background process) |
--pid-file <FILE> |
Custom PID file location |
--stop-daemon |
Stop running daemon |
--daemon-status |
Show daemon status |
Commands
Monitoring Commands
watch
Start continuous monitoring with auto-fix
Usage:
Options:
- --auto-fix
: Enable automatic fixing
- --no-auto-fix
: Disable automatic fixing
- --scan-interval <SECS>
: Scan interval in seconds
- --recursive
: Enable recursive monitoring
- --no-recursive
: Disable recursive monitoring
Examples:
scan
Perform one-time scan
Usage:
Options:
- --fix
: Fix permissions automatically
- --dry-run
: Preview changes without applying
- --recursive
: Enable recursive scanning
- --no-recursive
: Disable recursive scanning
Examples:
Management Commands
status
Show current status and configuration
Usage:
Options:
- --detailed
: Show detailed information
Examples:
config
Manage configuration
Usage:
Options:
- show
: Display current embedded configuration
- init
: Show initialization info (config is embedded)
- set <KEY> <VALUE>
: Set configuration value (read-only, use CLI args)
- add-watch <PATH>
: Add directory to watch list (read-only, use CLI args)
- remove-watch <PATH>
: Remove directory from watch list (read-only, use CLI args)
- add-exclude <PATH>
: Add directory to exclude list (read-only, use CLI args)
- remove-exclude <PATH>
: Remove directory from exclude list (read-only, use CLI args)
- add-pattern <PATTERN>
: Add exclude pattern (read-only, built-in patterns optimized)
- remove-pattern <PATTERN>
: Remove exclude pattern (read-only, built-in patterns optimized)
Examples:
Examples
Basic Usage
Common operations
Start monitoring with auto-fix
Expected Output: Starts continuous monitoring of the directoryOne-time scan and fix
Expected Output: Scans directory and fixes permission issuesPreview changes without applying
Expected Output: Shows what would be changed without making modificationsGet status in JSON format
Expected Output: JSON response with current statusCheck current runtime status
Expected Output: Shows current daemon status and active configurationDefault operation with JSON output
Expected Output: JSON formatted help informationAdvanced Usage
Complex operations
Custom scan interval
Expected Output: Monitors directory with 30 second scan intervalMonitor multiple directories with custom interval
Expected Output: Monitors both directories, scanning every 60 secondsNote
Useful for less frequently changing directories
Scan multiple directories
Expected Output: Scans and fixes permissions in multiple directoriesOverride target user
Expected Output: Scans and fixes permissions for specific userNon-recursive scan
Expected Output: Scans only the specified directory, not subdirectoriesWatch without auto-fix
Expected Output: Monitors directory but doesn't automatically fix permissionsRun as background daemon
Expected Output: Starts daemon process and returnsNote
Use --daemon-status to check if running
Troubleshooting
Debug and error handling
Preview changes with verbose output
Expected Output: Detailed scan results without making changesNote
Use to understand what would be changed
Check daemon status
Expected Output: Shows if daemon is running and its PIDScan with extended timeout
Expected Output: Scans large directory with 60 second timeoutNote
Useful for large directory structures
JSON Output Examples
Using JSON format for automation
Runtime status in JSON format
Expected Output: JSON response with current runtime status and active configurationEmbedded config template in JSON
Expected Output: JSON formatted embedded configuration defaults and constraintsNote
Shows embedded defaults, not runtime configuration
Scan results in JSON
Expected Output: JSON array of permission issues foundNote
Dry-run shows what would be changed
Fix permissions with JSON output
Expected Output: JSON response with fix resultsWatch with JSON logging (no terminal output)
Expected Output: JSON events written to stdoutNote
Useful for piping to log processors
Detailed runtime status in JSON
Expected Output: Comprehensive JSON with runtime status, active config, and system infoNote
Shows actual runtime state, not embedded defaults
Override user with JSON
Expected Output: JSON scan results with custom userNote
Useful for multi-user systems
Pretty JSON with field filtering
Expected Output: Formatted JSON with only specified fieldsNote
Use --fields to limit output to relevant data
Filter JSON output fields
Expected Output: JSON with only files_scanned and files_corrected fieldsNote
Reduces output size for automated processing
Paginated JSON output
Expected Output: JSON response with pagination (skip 5, return 10)Note
Useful for large result sets
Configuration Management
Managing service configuration
Display embedded configuration template
Expected Output: Shows embedded configuration defaults and security constraintsNote
Use 'status --detailed' to see runtime configuration
Daemon Operations
Running as background service
Start as background daemon
Expected Output: Starts daemon process and returns controlNote
Use --daemon-status to check if running
Check if daemon is running
Expected Output: Shows daemon status and PID if runningDaemon status in JSON format
Expected Output: JSON response with daemon status, PID, and PID file locationNote
Useful for automated monitoring scripts
Stop running daemon
Expected Output: Stops the background daemon processStop daemon with JSON response
Expected Output: JSON confirmation of daemon stop operationCustom PID file
Expected Output: Daemon with custom PID file locationNote
Useful for multiple instances
Daemon mode for one-time scan
Expected Output: Runs scan in background and keeps daemon aliveNote
Daemon stays running after command completion
Multiple daemon instances
Expected Output: First daemon instance with unique PID fileNote
Run multiple instances by using different PID files
Check specific daemon instance
Expected Output: Status of daemon using specified PID fileStop specific daemon instance
Expected Output: Stops daemon using specified PID fileAdvanced Options and Validation
Using advanced CLI features and error handling
Extended timeout with retry attempts
Expected Output: Scan with 120s timeout and up to 5 retry attemptsNote
Useful for unreliable environments or large directories
Verbose output without colors
Expected Output: Detailed scan information in plain textNote
Good for logging to files or piping to other tools
Minimal output with JSON
Expected Output: JSON status without extra logging messagesNote
Reduces noise for automated processing
Override with numeric UID
Expected Output: Scans and fixes permissions for user ID 1001Note
Useful when username is not available
Invalid user override handling
Expected Output: Error response: User 'nonexistent' not foundNote
Shows input validation in action
Path validation example
Expected Output: Error response about invalid or unsafe pathNote
Demonstrates security path validation
Explicit JSON output format
Expected Output: Status in JSON format (same as --json)Note
Alternative way to specify JSON output
Debug logging via environment variable
Expected Output: Scan with detailed debug informationNote
Set RUST_LOG for different verbosity levels
Disable colors via environment
Expected Output: Status output without ANSI color codesNote
Useful for terminals that don't support colors
Environment Variables
Variable | Description | Default | Values |
---|---|---|---|
RUST_LOG |
Set logging level | info | error |
NO_COLOR |
Disable all colored output when set | unset | 1 |
HTTP_PROXY |
HTTP proxy for network requests | unset | http://proxy:port |
HTTPS_PROXY |
HTTPS proxy for secure requests | unset | https://proxy:port |
PERMISSION_GUARD_CONFIG |
Path to configuration file | ~/.config/permission-guard/config.json | /path/to/config.json |
Exit Codes
Code | Description |
---|---|
0 | Success |
1 | General error |
10 | Command error |
2 | Invalid arguments |
3 | Permission denied |
4 | Network error |
5 | File not found |
6 | Timeout |
7 | Authentication error |
8 | Internal error |
9 | Validation error |