From 84c484aa7242106a953d10e97ef92a749d3199b9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 2 Dec 2013 02:07:17 -0800 Subject: [PATCH] Add missing license comments. --- src/protocols/ssh/client.c | 14 ++++++++++++ src/protocols/ssh/client.h | 7 ++++++ src/protocols/ssh/ssh_agent.c | 40 +++++++++++++++++++++++++++++++-- src/protocols/ssh/ssh_agent.h | 41 ++++++++++++++++++++++++++++++++++ src/protocols/ssh/ssh_buffer.c | 36 +++++++++++++++++++++++++++++ src/protocols/ssh/ssh_buffer.h | 36 +++++++++++++++++++++++++++++ src/protocols/ssh/ssh_client.c | 15 ++++++++----- src/protocols/ssh/ssh_key.c | 36 +++++++++++++++++++++++++++++ src/protocols/ssh/ssh_key.h | 36 +++++++++++++++++++++++++++++ 9 files changed, 254 insertions(+), 7 deletions(-) diff --git a/src/protocols/ssh/client.c b/src/protocols/ssh/client.c index be8492c5..95b3247b 100644 --- a/src/protocols/ssh/client.c +++ b/src/protocols/ssh/client.c @@ -68,6 +68,9 @@ const char* GUAC_CLIENT_ARGS[] = { "enable-sftp", "private-key", "passphrase", +#ifdef ENABLE_SSH_AGENT + "enable-agent", +#endif NULL }; @@ -118,6 +121,13 @@ enum __SSH_ARGS_IDX { */ IDX_PASSPHRASE, +#ifdef ENABLE_SSH_AGENT + /** + * Whether SSH agent forwarding support should be enabled. + */ + IDX_ENABLE_AGENT, +#endif + SSH_ARGS_COUNT }; @@ -168,6 +178,10 @@ int guac_client_init(guac_client* client, int argc, char** argv) { client_data->sftp_ssh_session = NULL; strcpy(client_data->sftp_upload_path, "."); +#ifdef ENABLE_SSH_AGENT + client_data->enable_agent = strcmp(argv[IDX_ENABLE_AGENT], "true") == 0; +#endif + /* Read port */ if (argv[IDX_PORT][0] != 0) strcpy(client_data->port, argv[IDX_PORT]); diff --git a/src/protocols/ssh/client.h b/src/protocols/ssh/client.h index b53cad1f..7ebc0f32 100644 --- a/src/protocols/ssh/client.h +++ b/src/protocols/ssh/client.h @@ -103,6 +103,13 @@ typedef struct ssh_guac_client_data { */ bool enable_sftp; +#ifdef ENABLE_SSH_AGENT + /** + * Whether the SSH agent is enabled. + */ + bool enable_agent; +#endif + /** * The SSH client thread. */ diff --git a/src/protocols/ssh/ssh_agent.c b/src/protocols/ssh/ssh_agent.c index 075d8c00..f530184b 100644 --- a/src/protocols/ssh/ssh_agent.c +++ b/src/protocols/ssh/ssh_agent.c @@ -1,4 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-ssh. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #include #include #include @@ -66,13 +102,13 @@ void ssh_auth_agent_list_identities(ssh_auth_agent* auth_agent) { buffer_write_uint32(&pos, 1+4 + key->public_key_length+4 - + sizeof("comment")+3); + + sizeof(SSH_AGENT_COMMENT)+3); buffer_write_byte(&pos, SSH2_AGENT_IDENTITIES_ANSWER); buffer_write_uint32(&pos, 1); buffer_write_string(&pos, key->public_key, key->public_key_length); - buffer_write_string(&pos, "comment", sizeof("comment")-1); + buffer_write_string(&pos, SSH_AGENT_COMMENT, sizeof(SSH_AGENT_COMMENT)-1); libssh2_channel_write(channel, buffer, pos-buffer); libssh2_channel_flush(channel); diff --git a/src/protocols/ssh/ssh_agent.h b/src/protocols/ssh/ssh_agent.h index e6c0e4e9..325012c9 100644 --- a/src/protocols/ssh/ssh_agent.h +++ b/src/protocols/ssh/ssh_agent.h @@ -1,4 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-ssh. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #ifndef _GUAC_SSH_AGENT_H #define _GUAC_SSH_AGENT_H @@ -24,6 +60,11 @@ */ #define SSH2_AGENT_SIGN_RESPONSE 0x0E +/** + * The comment to associate with public keys when listed. + */ +#define SSH_AGENT_COMMENT "Guacamole SSH Agent" + /** * The packet sent by the SSH agent when an operation is not supported. */ diff --git a/src/protocols/ssh/ssh_buffer.c b/src/protocols/ssh/ssh_buffer.c index 33abb10d..7e3d87e1 100644 --- a/src/protocols/ssh/ssh_buffer.c +++ b/src/protocols/ssh/ssh_buffer.c @@ -1,4 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-ssh. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #include #include diff --git a/src/protocols/ssh/ssh_buffer.h b/src/protocols/ssh/ssh_buffer.h index 2a48006b..8ca04bf4 100644 --- a/src/protocols/ssh/ssh_buffer.h +++ b/src/protocols/ssh/ssh_buffer.h @@ -1,4 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-ssh. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #ifndef _GUAC_SSH_BUFFER_H #define _GUAC_SSH_BUFFER_H diff --git a/src/protocols/ssh/ssh_client.c b/src/protocols/ssh/ssh_client.c index f4fbfb31..12a94167 100644 --- a/src/protocols/ssh/ssh_client.c +++ b/src/protocols/ssh/ssh_client.c @@ -372,12 +372,17 @@ void* ssh_client_thread(void* data) { } #ifdef ENABLE_SSH_AGENT - libssh2_session_callback_set(client_data->session, - LIBSSH2_CALLBACK_AUTH_AGENT, (void*) ssh_auth_agent_callback); + /* Start SSH agent forwarding, if enabled */ + if (client_data->enable_agent) { + libssh2_session_callback_set(client_data->session, + LIBSSH2_CALLBACK_AUTH_AGENT, (void*) ssh_auth_agent_callback); - /* Request agent forwarding */ - if (libssh2_channel_request_auth_agent(client_data->term_channel)) - guac_client_log_error(client, "Agent forwarding request failed"); + /* Request agent forwarding */ + if (libssh2_channel_request_auth_agent(client_data->term_channel)) + guac_client_log_error(client, "Agent forwarding request failed"); + else + guac_client_log_info(client, "Agent forwarding enabled."); + } #endif /* Start SFTP session as well, if enabled */ diff --git a/src/protocols/ssh/ssh_key.c b/src/protocols/ssh/ssh_key.c index b647e6fd..9ed4f082 100644 --- a/src/protocols/ssh/ssh_key.c +++ b/src/protocols/ssh/ssh_key.c @@ -1,4 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-ssh. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #include #include diff --git a/src/protocols/ssh/ssh_key.h b/src/protocols/ssh/ssh_key.h index db36cddb..d8b7af33 100644 --- a/src/protocols/ssh/ssh_key.h +++ b/src/protocols/ssh/ssh_key.h @@ -1,4 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-ssh. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #ifndef _GUAC_SSH_KEY_H #define _GUAC_SSH_KEY_H