Changeset 6dce755701391df148a6d93e5c9cb138d73ee5c1
- Timestamp:
- 09/26/09 15:51:57
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1253980317 +0000
- git-parent:
[4a67d452816c39b086e4f2ba5be9d12cf51aa81b]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1253980317 +0000
- Message:
think this should cover it, needs testing. refs #176
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb9a4230 |
r6dce755 |
|
| 55 | 55 | noit_module_t *self; |
|---|
| 56 | 56 | noit_check_t *check; |
|---|
| | 57 | struct { |
|---|
| | 58 | char *kex; |
|---|
| | 59 | char *hostkey; |
|---|
| | 60 | char *crypt_cs; |
|---|
| | 61 | char *crypt_sc; |
|---|
| | 62 | char *mac_cs; |
|---|
| | 63 | char *mac_sc; |
|---|
| | 64 | char *comp_cs; |
|---|
| | 65 | char *comp_sc; |
|---|
| | 66 | } methods; |
|---|
| 57 | 67 | enum { |
|---|
| 58 | 68 | WANT_CONNECT = 0, |
|---|
| … | … | |
| 82 | 92 | libssh2_session_free(ci->session); |
|---|
| 83 | 93 | } |
|---|
| | 94 | if(ci->methods.kex) free(ci->methods.kex); |
|---|
| | 95 | if(ci->methods.hostkey) free(ci->methods.hostkey); |
|---|
| | 96 | if(ci->methods.crypt_cs) free(ci->methods.crypt_cs); |
|---|
| | 97 | if(ci->methods.crypt_sc) free(ci->methods.crypt_sc); |
|---|
| | 98 | if(ci->methods.mac_cs) free(ci->methods.mac_cs); |
|---|
| | 99 | if(ci->methods.mac_sc) free(ci->methods.mac_sc); |
|---|
| | 100 | if(ci->methods.comp_cs) free(ci->methods.comp_cs); |
|---|
| | 101 | if(ci->methods.comp_sc) free(ci->methods.comp_sc); |
|---|
| 84 | 102 | if(ci->error) free(ci->error); |
|---|
| 85 | 103 | memset(ci, 0, sizeof(*ci)); |
|---|
| … | … | |
| 137 | 155 | } |
|---|
| 138 | 156 | ci->session = libssh2_session_init(); |
|---|
| | 157 | #define set_method(a,b) do { \ |
|---|
| | 158 | int rv; \ |
|---|
| | 159 | if(ci->methods.a && \ |
|---|
| | 160 | (rv = libssh2_session_method_pref(ci->session, b, ci->methods.a)) != 0) { \ |
|---|
| | 161 | ci->timed_out = 0; \ |
|---|
| | 162 | ci->error = strdup((rv == LIBSSH2_ERROR_METHOD_NOT_SUPPORTED) ? \ |
|---|
| | 163 | #a " method not supported" : "error setting " #a); \ |
|---|
| | 164 | return 0; \ |
|---|
| | 165 | } \ |
|---|
| | 166 | } while(0) |
|---|
| | 167 | set_method(kex, LIBSSH2_METHOD_KEX); |
|---|
| | 168 | set_method(hostkey, LIBSSH2_METHOD_HOSTKEY); |
|---|
| | 169 | set_method(crypt_cs, LIBSSH2_METHOD_CRYPT_CS); |
|---|
| | 170 | set_method(crypt_sc, LIBSSH2_METHOD_CRYPT_SC); |
|---|
| | 171 | set_method(mac_cs, LIBSSH2_METHOD_MAC_CS); |
|---|
| | 172 | set_method(mac_sc, LIBSSH2_METHOD_MAC_SC); |
|---|
| | 173 | set_method(comp_cs, LIBSSH2_METHOD_COMP_CS); |
|---|
| | 174 | set_method(comp_sc, LIBSSH2_METHOD_COMP_SC); |
|---|
| 139 | 175 | if (libssh2_session_startup(ci->session, e->fd)) { |
|---|
| 140 | 176 | ci->timed_out = 0; |
|---|
| … | … | |
| 260 | 296 | ssh_port = (unsigned short)atoi(port_str); |
|---|
| 261 | 297 | } |
|---|
| | 298 | #define config_method(a) do { \ |
|---|
| | 299 | const char *v; \ |
|---|
| | 300 | if(noit_hash_retr_str(check->config, "method_" #a, strlen("method_" #a), \ |
|---|
| | 301 | &v)) \ |
|---|
| | 302 | ci->methods.a = strdup(v); \ |
|---|
| | 303 | } while(0) |
|---|
| | 304 | config_method(kex); |
|---|
| | 305 | config_method(hostkey); |
|---|
| | 306 | config_method(crypt_cs); |
|---|
| | 307 | config_method(crypt_sc); |
|---|
| | 308 | config_method(mac_cs); |
|---|
| | 309 | config_method(mac_sc); |
|---|
| | 310 | config_method(comp_cs); |
|---|
| | 311 | config_method(comp_sc); |
|---|
| 262 | 312 | memset(&sockaddr, 0, sizeof(sockaddr)); |
|---|
| 263 | 313 | sockaddr.sin6.sin6_family = check->target_family; |
|---|
| rd8db299 |
r6dce755 |
|
| 10 | 10 | default="22" |
|---|
| 11 | 11 | allowed="\d+">The TCP port on which the remote server's ssh service is running.</parameter> |
|---|
| | 12 | <parameter name="method_kex" |
|---|
| | 13 | required="optional" |
|---|
| | 14 | default="" |
|---|
| | 15 | allowed="^diffie-hellman-(?:group1-sha1|group14-sha1|group-exchange-sha1)$">The key exchange method to use.</parameter> |
|---|
| | 16 | <parameter name="method_hostkey" |
|---|
| | 17 | required="optional" |
|---|
| | 18 | default="" |
|---|
| | 19 | allowed="^(?:ssh-dss|ssh-rsa)$">The host key algorithm supported.</parameter> |
|---|
| | 20 | <parameter name="method_crypt_cs" |
|---|
| | 21 | required="optional" |
|---|
| | 22 | default="" |
|---|
| | 23 | allowed="^(?:aes256-cbc|aes192-cbc|aes128-cbc|blowfish-cbc|arcfour|cast128-cbc|3des-cbc|none)$">The encryption algorithm used from client to server.</parameter> |
|---|
| | 24 | <parameter name="method_crypt_sc" |
|---|
| | 25 | required="optional" |
|---|
| | 26 | default="" |
|---|
| | 27 | allowed="^(?:aes256-cbc|aes192-cbc|aes128-cbc|blowfish-cbc|arcfour|cast128-cbc|3des-cbc|none)$">The encryption algorithm used from server to client.</parameter> |
|---|
| | 28 | <parameter name="method_mac_cs" |
|---|
| | 29 | required="optional" |
|---|
| | 30 | default="" |
|---|
| | 31 | allowed="^(?:hmac-sha1|hmac-sha1-96|hmac-md5|hmac-md5-96|hmac-ripemd160|none)$">The message authentication code algorithm used from client to server.</parameter> |
|---|
| | 32 | <parameter name="method_mac_sc" |
|---|
| | 33 | required="optional" |
|---|
| | 34 | default="" |
|---|
| | 35 | allowed="^(?:hmac-sha1|hmac-sha1-96|hmac-md5|hmac-md5-96|hmac-ripemd160|none)$">The message authentication code algorithm used from server to client.</parameter> |
|---|
| | 36 | <parameter name="method_comp_cs" |
|---|
| | 37 | required="optional" |
|---|
| | 38 | default="none" |
|---|
| | 39 | allowed="^(?:zlib|none)$">The compress algorithm used from client to server.</parameter> |
|---|
| | 40 | <parameter name="method_comp_sc" |
|---|
| | 41 | required="optional" |
|---|
| | 42 | default="none" |
|---|
| | 43 | allowed="^(?:zlib|none)$">The compress algorithm used from server to client.</parameter> |
|---|
| 12 | 44 | </checkconfig> |
|---|
| 13 | 45 | <examples> |
|---|