fix: replace hardcoded /Users/user fallback with os.homedir()
The HOME_DIR fallback '/Users/user' is macOS-specific and incorrect. Use os.homedir() from Node's os module which works cross-platform and returns the actual home directory from /etc/passwd on Linux. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { readEnvFile } from './env.js';
|
import { readEnvFile } from './env.js';
|
||||||
@@ -19,7 +20,7 @@ export const SCHEDULER_POLL_INTERVAL = 60000;
|
|||||||
|
|
||||||
// Absolute paths needed for container mounts
|
// Absolute paths needed for container mounts
|
||||||
const PROJECT_ROOT = process.cwd();
|
const PROJECT_ROOT = process.cwd();
|
||||||
const HOME_DIR = process.env.HOME || '/Users/user';
|
const HOME_DIR = process.env.HOME || os.homedir();
|
||||||
|
|
||||||
// Mount security: allowlist stored OUTSIDE project root, never mounted into containers
|
// Mount security: allowlist stored OUTSIDE project root, never mounted into containers
|
||||||
export const MOUNT_ALLOWLIST_PATH = path.join(
|
export const MOUNT_ALLOWLIST_PATH = path.join(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* Allowlist location: ~/.config/nanoclaw/mount-allowlist.json
|
* Allowlist location: ~/.config/nanoclaw/mount-allowlist.json
|
||||||
*/
|
*/
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ export function loadMountAllowlist(): MountAllowlist | null {
|
|||||||
* Expand ~ to home directory and resolve to absolute path
|
* Expand ~ to home directory and resolve to absolute path
|
||||||
*/
|
*/
|
||||||
function expandPath(p: string): string {
|
function expandPath(p: string): string {
|
||||||
const homeDir = process.env.HOME || '/Users/user';
|
const homeDir = process.env.HOME || os.homedir();
|
||||||
if (p.startsWith('~/')) {
|
if (p.startsWith('~/')) {
|
||||||
return path.join(homeDir, p.slice(2));
|
return path.join(homeDir, p.slice(2));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user