Skip to content

fix: set correct permissions on linux implementations#14

Merged
Warashi merged 2 commits into
mainfrom
linux-landlock-non-existent-dir
Jul 8, 2025
Merged

fix: set correct permissions on linux implementations#14
Warashi merged 2 commits into
mainfrom
linux-landlock-non-existent-dir

Conversation

@Warashi
Copy link
Copy Markdown
Owner

@Warashi Warashi commented Jul 8, 2025

This PR adds two functionalities.

  1. ignore non-existent path
  2. set correct permission on dirs or files

Warashi and others added 2 commits July 8, 2025 15:36
When using presets or -allow flags with non-existent directories,
Linux now silently skips them instead of causing landlock errors.
This improves compatibility with presets that may include paths
that don't exist on all systems.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Previously, all allowed paths were treated as directories with landlock.RWDirs(),
which caused errors when trying to apply directory access rules to non-directory
files like /dev/tty (character device).

This fix checks the file type using os.Stat() and applies the appropriate rule:
- landlock.RWDirs() for directories
- landlock.RWFiles() for regular files, device files, etc.

This resolves the error:
"landlock_add_rule: inconsistent access rights (using directory access rights on a regular file?)"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Warashi Warashi merged commit a581dd3 into main Jul 8, 2025
9 checks passed
@Warashi Warashi deleted the linux-landlock-non-existent-dir branch July 8, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant