#Shell dagger root escape
1 messages · Page 1 of 1 (latest)
does .. escape your dagger root? What if you try something in your home directory with an absolute path?
@steep radish fyi
What about if you give an absolute path and not a relative one?
Yep, absolute path fails with dagger shell, but works with dagger call:
✅
dagger call grep-dir --directory-arg /Users/jeremyadams/src/barrrr --pattern foo
❌
shell-path-repro ➤ pwd
/Users/jeremyadams/src/barrrr/shell-path-repro
shell-path-repro ➤ dagger -c 'grep-dir /Users/jeremyadams/src/barrrr foo'
▶ connect 0.2s
▶ detect module: . 0.5s
▶ load module: /Users/jeremyadams/src/barrrr/shell-path-repro 0.3s
▼ grep-dir 0.0s ERROR
! function "grep-dir": failed to get value for argument "directory-arg": failed to
get content hash: failed to get snapshot: failed to receive stat message: rpc
error: code = NotFound desc = get full root path: rpc error: code = NotFound desc
= eval symlinks: lstat /Users/jeremyadams/src/barrrr/shell-path-repro/Users: no
such file or directory
╰─▼ Host.directory(
│ ┆ path: "/Users/jeremyadams/src/barrrr/shell-path-repro/Users/jeremyadams/src/barrrr"
│ ): Directory! 0.0s ERROR
! failed to get content hash: failed to get snapshot: failed to receive stat
message: rpc error: code = NotFound desc = get full root path: rpc error: code =
NotFound desc = eval symlinks: lstat /Users/jeremyadams/src/barrrr/shell-path-
repro/Users: no such file or directory
╰─▼ upload /Users/jeremyadams/src/barrrr/shell-path-repro/Users/jeremyadams/src/barrrr from qhq2l5qub0za2y0v2llozndz4 (client id: mb7wwfu0lxsx3f1vbzo08qd4a, session id: 6vse81jfiqpml9ip4qo13ohnj) 0.0s ERROR
! failed to get snapshot: failed to receive stat message: rpc error: code =
NotFound desc = get full root path: rpc error: code = NotFound desc = eval
symlinks: lstat /Users/jeremyadams/src/barrrr/shell-path-repro/Users: no such
file or directory
╰─✘ filesync 0.0s ERROR
! failed to receive stat message: rpc error: code = NotFound desc = get full
root path: rpc error: code = NotFound desc = eval symlinks: lstat
/Users/jeremyadams/src/barrrr/shell-path-repro/Users: no such file or
directory
In that case 👆 the module was also a git repo and the parent .. directory was neither.
Here's another case where the module was NOT a git repo, but the parent .. directory was a git repo (not a module).
❌
shell-path-repro ➤ dagger -c 'grep-dir /Users/jeremyadams/src/bazzzz foo'
▶ connect 0.2s
▶ detect module: . 0.5s
▶ load module: /Users/jeremyadams/src/bazzzz/shell-path-repro 1.8s
▼ grep-dir 0.0s ERROR
! function "grep-dir": failed to get value for argument "directory-arg": failed to
get content hash: failed to get snapshot: failed to receive stat message: rpc
error: code = NotFound desc = get full root path: rpc error: code = NotFound desc
= eval symlinks: lstat /Users/jeremyadams/src/bazzzz/Users: no such file or
directory
╰─▼ Host.directory(
│ ┆ path: "/Users/jeremyadams/src/bazzzz/Users/jeremyadams/src/bazzzz"
│ ): Directory! 0.0s ERROR
! failed to get content hash: failed to get snapshot: failed to receive stat
message: rpc error: code = NotFound desc = get full root path: rpc error: code =
NotFound desc = eval symlinks: lstat /Users/jeremyadams/src/bazzzz/Users: no
such file or directory
╰─▼ upload /Users/jeremyadams/src/bazzzz/Users/jeremyadams/src/bazzzz from qhq2l5qub0za2y0v2llozndz4 (client id: o1ny00i5tk0rg1r0podiw6tzs, session id: kfq9miwkxzmo7k6oc11ss6gln) 0.0s ERROR
! failed to get snapshot: failed to receive stat message: rpc error: code =
NotFound desc = get full root path: rpc error: code = NotFound desc = eval
symlinks: lstat /Users/jeremyadams/src/bazzzz/Users: no such file or directory
╰─✘ filesync 0.0s ERROR
! failed to receive stat message: rpc error: code = NotFound desc = get full
root path: rpc error: code = NotFound desc = eval symlinks: lstat
/Users/jeremyadams/src/bazzzz/Users: no such file or directory
@mint nest is this a know issue with absolute path args to Dagger Shell?
Noticing that the paths mentioned in errors look oddly constructed:
/Users/jeremyadams/src/bazzzz/Users # Users again!?
/Users/jeremyadams/src/barrrr/shell-path-repro/Users # pwd + /Users ??
if you open an issue, i'll take a look sometime!
@honest rock have you seen this behavior? Going to put an issue together.
I have not run into this
seems relevant, reading...https://github.com/dagger/dagger/issues/10279#issuecomment-2897997191
@verbal moon would be good to get your insight here on what's expected behavior. See backtrace.
Hey, just back from PTO. On a superficial look I can say that local relative paths are relative to your current working directory inside the shell session (.pwd), while absolute paths are relative to the context directory (git repo root), like a function argument's defaultPath. To access files from the host outside the context directory you need to use the Host API:
dagger -c 'grep-dir $(host | directory /Users/jeremyadams/src/bazzzz) foo'