-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exec-client Command #717
Conversation
Hi
Some comments:
This should not be a new command, please make it a flag (-E?) to
switch-client.
You can add message numbers at the end (after MSG_WAKEUP) without
bumping PROTOCOL_VERSION, please do that.
Instead of looking up default-shell in global_s_options, use the
client's session if it has one.
Don't use alloca() under any circumstances. This is a particularly bad
place to use it because shell_size and cmd_size come from the
use. malloc() it instead.
Otherwise it looks fine, although I'm not particularly convinced this is
needed.
…On Thu, Jan 12, 2017 at 01:45:38PM -0800, jennamagius wrote:
This patch adds a new command, "exec-client", that causes a running,
attached client to detach and morph into a different process, specified by
command. This is useful for when you connect to a remote system via ssh
with tmux as your ssh command. If you then want to connect to a tmux
session owned by a different user, without nesting, it is currently
necessary to disconnect and reauthenticate to SSH. By doing exec-client
/bin/bash, a client can "detach", even if its parent process is not an
interactive shell.
NOTE: This implementation is a little slap-dash, I would appreciate
feedback from people more familiar with the code base on better ways for
implementing this. (Maybe without bumping PROTOCOL_VERSION? Maybe a more
elegant way of acquiring the shell option?)
--------------------------------------------------------------------------
You can view, comment on, or merge this pull request online at:
[1]#717
Commit Summary
* Implement exec-client command.
* Include the actual cmd-exec-client.c
* Remove unneeded args from cmd_exec_client_entry
* Use the shell from the default-shell option
File Changes
* M [2]Makefile.am (1)
* M [3]client.c (14)
* A [4]cmd-exec-client.c (53)
* M [5]cmd.c (2)
* M [6]server-client.c (18)
* M [7]tmux.h (4)
Patch Links:
* [8]https://github.com/tmux/tmux/pull/717.patch
* [9]https://github.com/tmux/tmux/pull/717.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [10]view it on GitHub, or [11]mute the
thread.
Reverse link: [12]unknown
References
Visible links
1. #717
2. https://github.com/tmux/tmux/pull/717/files#diff-0
3. https://github.com/tmux/tmux/pull/717/files#diff-1
4. https://github.com/tmux/tmux/pull/717/files#diff-2
5. https://github.com/tmux/tmux/pull/717/files#diff-3
6. https://github.com/tmux/tmux/pull/717/files#diff-4
7. https://github.com/tmux/tmux/pull/717/files#diff-5
8. https://github.com/tmux/tmux/pull/717.patch
9. https://github.com/tmux/tmux/pull/717.diff
10. #717
11. https://github.com/notifications/unsubscribe-auth/AASkc0qKkbWbV1s1761Md_Zm-4yLUhpLks5rRp8CgaJpZM4LiRZq
12. #717
|
Or actually detach client not switch client
On 12 Jan 2017 10:23 pm, "Nicholas Marriott" <nicholas.marriott@gmail.com>
wrote:
… Hi
Some comments:
This should not be a new command, please make it a flag (-E?) to
switch-client.
You can add message numbers at the end (after MSG_WAKEUP) without
bumping PROTOCOL_VERSION, please do that.
Instead of looking up default-shell in global_s_options, use the
client's session if it has one.
Don't use alloca() under any circumstances. This is a particularly bad
place to use it because shell_size and cmd_size come from the
use. malloc() it instead.
Otherwise it looks fine, although I'm not particularly convinced this is
needed.
On Thu, Jan 12, 2017 at 01:45:38PM -0800, jennamagius wrote:
> This patch adds a new command, "exec-client", that causes a running,
> attached client to detach and morph into a different process,
specified by
> command. This is useful for when you connect to a remote system via
ssh
> with tmux as your ssh command. If you then want to connect to a tmux
> session owned by a different user, without nesting, it is currently
> necessary to disconnect and reauthenticate to SSH. By doing
exec-client
> /bin/bash, a client can "detach", even if its parent process is not an
> interactive shell.
>
> NOTE: This implementation is a little slap-dash, I would appreciate
> feedback from people more familiar with the code base on better ways
for
> implementing this. (Maybe without bumping PROTOCOL_VERSION? Maybe a
more
> elegant way of acquiring the shell option?)
>
> ------------------------------------------------------------
--------------
>
> You can view, comment on, or merge this pull request online at:
>
> [1]#717
>
> Commit Summary
>
> * Implement exec-client command.
> * Include the actual cmd-exec-client.c
> * Remove unneeded args from cmd_exec_client_entry
> * Use the shell from the default-shell option
>
> File Changes
>
> * M [2]Makefile.am (1)
> * M [3]client.c (14)
> * A [4]cmd-exec-client.c (53)
> * M [5]cmd.c (2)
> * M [6]server-client.c (18)
> * M [7]tmux.h (4)
>
> Patch Links:
>
> * [8]https://github.com/tmux/tmux/pull/717.patch
> * [9]https://github.com/tmux/tmux/pull/717.diff
>
> --
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, [10]view it on GitHub, or [11]mute the
> thread.
>
> Reverse link: [12]unknown
>
> References
>
> Visible links
> 1. #717
> 2. https://github.com/tmux/tmux/pull/717/files#diff-0
> 3. https://github.com/tmux/tmux/pull/717/files#diff-1
> 4. https://github.com/tmux/tmux/pull/717/files#diff-2
> 5. https://github.com/tmux/tmux/pull/717/files#diff-3
> 6. https://github.com/tmux/tmux/pull/717/files#diff-4
> 7. https://github.com/tmux/tmux/pull/717/files#diff-5
> 8. https://github.com/tmux/tmux/pull/717.patch
> 9. https://github.com/tmux/tmux/pull/717.diff
> 10. #717
> 11. https://github.com/notifications/unsubscribe-
auth/AASkc0qKkbWbV1s1761Md_Zm-4yLUhpLks5rRp8CgaJpZM4LiRZq
> 12. #717
|
Hello, Thank you for your feedback. I have amended per your recommendations. |
In the MSG_EXEC case in client_dispatch_attached I think you should make the fatalx() check also that strlen(data) != datalen, as it is now a message with only one string (one \0) would run off the end of the buffer. Otherwise this looks fine apart from minor style nits. |
Good call, I made a mental note that I needed to do that, then forgot to actually do it. Done now. |
OK applied with some mostly trivial changes, will be in GitHub next time |
Thank you! :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This patch adds a new command, "exec-client", that causes a running, attached client to detach and morph into a different process, specified by command. This is useful for when you connect to a remote system via ssh with tmux as your ssh command. If you then want to connect to a tmux session owned by a different user, without nesting, it is currently necessary to disconnect and reauthenticate to SSH. By doing exec-client /bin/bash, a client can "detach", even if its parent process is not an interactive shell.
NOTE: This implementation is a little slap-dash, I would appreciate feedback from people more familiar with the code base on better ways for implementing this. (Maybe without bumping PROTOCOL_VERSION? Maybe a more elegant way of acquiring the shell option?)