capistrano / capistrano/sshkit

ble`within` does not seem to respect `as`

Open
#373 3 comments 0 reactions 0 assignees View on GitHub
bug? help wanted
Dominant language
Ruby
Stars
1.2k
Forks
257
PR merge metrics
No merged PRs in 30d

Description

From the readme, `within`/`as`/`with` should be stackable. But this scenario, that does not work as expected:

``` ruby
require 'sshkit'
require 'sshkit/dsl'

include SSHKit::DSL

# Set up a directory that your user cannot enter
`sudo mkdir -p /tmp/only_root`
`sudo chmod og-rwx /tmp/only_root`

on :local do
# But root should be able to enter it...
as :root do
within '/tmp/only_root' do
execute :ls # --> Permission denied
end
end
end
```

It looks like `within` always runs as the user executing the script, which is unexpected. I would have thought that it's done as the user of the enclosing `as`. I've tried with the local and netssh backends and get the same results.

This is with SSHKit 1.11.3 and Ruby 2.3.1 on Centos 6.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.