Created
June 6, 2012 16:26
-
-
Save ThomasAdam/2883073 to your computer and use it in GitHub Desktop.
Detach all but specified client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/trunk/cmd-detach-client.c b/trunk/cmd-detach-client.c | |
index d1010a5..2f70ed3 100644 | |
--- a/trunk/cmd-detach-client.c | |
+++ b/trunk/cmd-detach-client.c | |
@@ -28,7 +28,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *); | |
const struct cmd_entry cmd_detach_client_entry = { | |
"detach-client", "detach", | |
- "s:t:P", 0, 0, | |
+ "as:t:P", 0, 0, | |
"[-P] [-s target-session] " CMD_TARGET_CLIENT_USAGE, | |
CMD_READONLY, | |
NULL, | |
@@ -40,7 +40,7 @@ int | |
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx) | |
{ | |
struct args *args = self->args; | |
- struct client *c; | |
+ struct client *c, *c2; | |
struct session *s; | |
enum msgtype msgtype; | |
u_int i; | |
@@ -65,7 +65,15 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx) | |
if (c == NULL) | |
return (-1); | |
- server_write_client(c, msgtype, NULL, 0); | |
+ if (args_has(args, 'a')) { | |
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) { | |
+ c2 = ARRAY_ITEM(&clients, i); | |
+ if (c != c2) | |
+ server_write_client( | |
+ c2, msgtype, NULL, 0); | |
+ } | |
+ } else | |
+ server_write_client(c, msgtype, NULL, 0); | |
} | |
return (0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment