X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetwork.c;h=e28316d5385cc3e3cbaa9dec7b473654cdadc50d;hb=f123d3873170fb2bc06a1ea03396e57128d2ab63;hp=be4c3baeb71b42dbc13ec74e59382c09ced1c488;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f;p=collectd.git diff --git a/src/network.c b/src/network.c index be4c3bae..e28316d5 100644 --- a/src/network.c +++ b/src/network.c @@ -292,7 +292,7 @@ static char *send_buffer; static char *send_buffer_ptr; static int send_buffer_fill; static cdtime_t send_buffer_last_update; -static value_list_t send_buffer_vl = VALUE_LIST_STATIC; +static value_list_t send_buffer_vl = VALUE_LIST_INIT; static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER; /* XXX: These counters are incremented from one place only. The spot in which @@ -1003,14 +1003,6 @@ static int parse_part_sign_sha256(sockent_t *se, /* {{{ */ buffer_len = *ret_buffer_len; buffer_offset = 0; - if (se->data.server.userdb == NULL) { - c_complain( - LOG_NOTICE, &complain_no_users, - "network plugin: Received signed network packet but can't verify it " - "because no user DB has been configured. Will accept it."); - return (0); - } - /* Check if the buffer has enough data for this structure. */ if (buffer_len <= PART_SIGNATURE_SHA256_SIZE) return (-ENOMEM); @@ -1027,6 +1019,18 @@ static int parse_part_sign_sha256(sockent_t *se, /* {{{ */ return (-1); } + if (se->data.server.userdb == NULL) { + c_complain( + LOG_NOTICE, &complain_no_users, + "network plugin: Received signed network packet but can't verify it " + "because no user DB has been configured. Will accept it."); + + *ret_buffer = buffer + pss_head_length; + *ret_buffer_len -= pss_head_length; + + return (0); + } + /* Copy the hash. */ BUFFER_READ(pss.hash, sizeof(pss.hash)); @@ -1226,9 +1230,9 @@ static int parse_part_encr_aes256(sockent_t *se, /* {{{ */ part_size - buffer_offset, /* in = */ NULL, /* in len = */ 0); if (err != 0) { - sfree(pea.username); ERROR("network plugin: gcry_cipher_decrypt returned: %s. Username: %s", gcry_strerror(err), pea.username); + sfree(pea.username); return (-1); } @@ -1250,8 +1254,6 @@ static int parse_part_encr_aes256(sockent_t *se, /* {{{ */ parse_packet(se, buffer + buffer_offset, payload_len, flags | PP_ENCRYPTED, pea.username); - /* XXX: Free pea.username?!? */ - /* Update return values */ *ret_buffer = buffer + part_size; *ret_buffer_len = buffer_len - part_size; @@ -3082,7 +3084,6 @@ static int network_stats_read(void) /* {{{ */ vl.values = values; vl.values_len = 2; vl.time = 0; - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "network", sizeof(vl.plugin)); /* Octets received / sent */ @@ -3163,7 +3164,8 @@ static int network_init(void) { if (dispatch_thread_running == 0) { int status; status = plugin_thread_create(&dispatch_thread_id, NULL /* no attributes */, - dispatch_thread, NULL /* no argument */); + dispatch_thread, NULL /* no argument */, + "network disp"); if (status != 0) { char errbuf[1024]; ERROR("network: pthread_create failed: %s", @@ -3176,7 +3178,8 @@ static int network_init(void) { if (receive_thread_running == 0) { int status; status = plugin_thread_create(&receive_thread_id, NULL /* no attributes */, - receive_thread, NULL /* no argument */); + receive_thread, NULL /* no argument */, + "network recv"); if (status != 0) { char errbuf[1024]; ERROR("network: pthread_create failed: %s",