Allow cwd but block .env #384
-
|
Hi all, I'm trying to allow the current directory but disallow the .env |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
|
hi @agardnerIT - version 18 will solve this for you {
"meta": {
"name": "env"
},
"workdir": {
"access": "readwrite"
},
"extends": "claude-code",
"policy": {
"add_deny_access": ["$WORKDIR/.env"]
}
}
|
Beta Was this translation helpful? Give feedback.
-
|
Yup, this works now. Fabulous! |
Beta Was this translation helpful? Give feedback.
-
|
@lukehinds is there the CLI equivalent? or this is just profile feature? |
Beta Was this translation helpful? Give feedback.
-
|
This is not working on v0.57.0 |
Beta Was this translation helpful? Give feedback.
-
|
hi @poliveira89 sorry for such a later answer - this is a disparity between macos and linux. On Linux today there is no way to "allow the whole workdir but carve out .env" with a single broad grant. The only workaround that works on Linux right now is to not grant the whole directory - grant the specific subpaths the agent needs instead (so .env is simply never in the allow-list), e.g. allow ./src, ./tests, etc. rather than the cwd root. This is by design of how Landlock works. Landlock is strictly allow-list: there is no "deny a child of an allowed parent" primitive. Would the suggestion from @quinncomendant work for you and you inject in phantom tokens that are typically in your env. |
Beta Was this translation helpful? Give feedback.

hi @agardnerIT - version 18 will solve this for you
{ "meta": { "name": "env" }, "workdir": { "access": "readwrite" }, "extends": "claude-code", "policy": { "add_deny_access": ["$WORKDIR/.env"] } }