projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
593ea76
)
network plugin: Add the "network:username" meta data.
author
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Thu, 8 Apr 2010 19:36:06 +0000
(21:36 +0200)
committer
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Thu, 8 Apr 2010 19:36:06 +0000
(21:36 +0200)
src/network.c
patch
|
blob
|
history
diff --git
a/src/network.c
b/src/network.c
index
74325a2
..
5ebde77
100644
(file)
--- a/
src/network.c
+++ b/
src/network.c
@@
-350,7
+350,8
@@
static _Bool check_send_okay (const value_list_t *vl) /* {{{ */
return (!received);
} /* }}} _Bool check_send_okay */
return (!received);
} /* }}} _Bool check_send_okay */
-static int network_dispatch_values (value_list_t *vl) /* {{{ */
+static int network_dispatch_values (value_list_t *vl, /* {{{ */
+ const char *username)
{
int status;
{
int status;
@@
-391,6
+392,18
@@
static int network_dispatch_values (value_list_t *vl) /* {{{ */
return (status);
}
return (status);
}
+ if (username != NULL)
+ {
+ status = meta_data_add_string (vl->meta, "network:username", username);
+ if (status != 0)
+ {
+ ERROR ("network plugin: meta_data_add_string failed.");
+ meta_data_destroy (vl->meta);
+ vl->meta = NULL;
+ return (status);
+ }
+ }
+
plugin_dispatch_values (vl);
stats_values_dispatched++;
plugin_dispatch_values (vl);
stats_values_dispatched++;
@@
-892,7
+905,8
@@
static int parse_part_string (void **ret_buffer, size_t *ret_buffer_len,
#define PP_SIGNED 0x01
#define PP_ENCRYPTED 0x02
static int parse_packet (sockent_t *se,
#define PP_SIGNED 0x01
#define PP_ENCRYPTED 0x02
static int parse_packet (sockent_t *se,
- void *buffer, size_t buffer_size, int flags);
+ void *buffer, size_t buffer_size, int flags,
+ const char *username);
#define BUFFER_READ(p,s) do { \
memcpy ((p), buffer + buffer_offset, (s)); \
#define BUFFER_READ(p,s) do { \
memcpy ((p), buffer + buffer_offset, (s)); \
@@
-987,6
+1001,8
@@
static int parse_part_sign_sha256 (sockent_t *se, /* {{{ */
{
ERROR ("network plugin: gcry_md_setkey failed: %s", gcry_strerror (err));
gcry_md_close (hd);
{
ERROR ("network plugin: gcry_md_setkey failed: %s", gcry_strerror (err));
gcry_md_close (hd);
+ sfree (secret);
+ sfree (pss.username);
return (-1);
}
return (-1);
}
@@
-1008,9
+1024,6
@@
static int parse_part_sign_sha256 (sockent_t *se, /* {{{ */
gcry_md_close (hd);
hd = NULL;
gcry_md_close (hd);
hd = NULL;
- sfree (secret);
- sfree (pss.username);
-
if (memcmp (pss.hash, hash, sizeof (pss.hash)) != 0)
{
WARNING ("network plugin: Verifying HMAC-SHA-256 signature failed: "
if (memcmp (pss.hash, hash, sizeof (pss.hash)) != 0)
{
WARNING ("network plugin: Verifying HMAC-SHA-256 signature failed: "
@@
-1019,9
+1032,12
@@
static int parse_part_sign_sha256 (sockent_t *se, /* {{{ */
else
{
parse_packet (se, buffer + buffer_offset, buffer_len - buffer_offset,
else
{
parse_packet (se, buffer + buffer_offset, buffer_len - buffer_offset,
- flags | PP_SIGNED);
+ flags | PP_SIGNED
, pss.username
);
}
}
+ sfree (secret);
+ sfree (pss.username);
+
*ret_buffer = buffer + buffer_len;
*ret_buffer_len = 0;
*ret_buffer = buffer + buffer_len;
*ret_buffer_len = 0;
@@
-1065,7
+1081,8
@@
static int parse_part_sign_sha256 (sockent_t *se, /* {{{ */
warning_has_been_printed = 1;
}
warning_has_been_printed = 1;
}
- parse_packet (se, buffer + part_len, buffer_size - part_len, flags);
+ parse_packet (se, buffer + part_len, buffer_size - part_len, flags,
+ /* username = */ NULL);
*ret_buffer = buffer + buffer_size;
*ret_buffer_size = 0;
*ret_buffer = buffer + buffer_size;
*ret_buffer_size = 0;
@@
-1184,7
+1201,9
@@
static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */
}
parse_packet (se, buffer + buffer_offset, payload_len,
}
parse_packet (se, buffer + buffer_offset, payload_len,
- flags | PP_ENCRYPTED);
+ flags | PP_ENCRYPTED, pea.username);
+
+ /* XXX: Free pea.username?!? */
/* Update return values */
*ret_buffer = buffer + part_size;
/* Update return values */
*ret_buffer = buffer + part_size;
@@
-1246,7
+1265,8
@@
static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */
#undef BUFFER_READ
static int parse_packet (sockent_t *se, /* {{{ */
#undef BUFFER_READ
static int parse_packet (sockent_t *se, /* {{{ */
- void *buffer, size_t buffer_size, int flags)
+ void *buffer, size_t buffer_size, int flags,
+ const char *username)
{
int status;
{
int status;
@@
-1346,7
+1366,7
@@
static int parse_packet (sockent_t *se, /* {{{ */
if (status != 0)
break;
if (status != 0)
break;
- network_dispatch_values (&vl);
+ network_dispatch_values (&vl
, username
);
sfree (vl.values);
}
sfree (vl.values);
}
@@
-2180,7
+2200,8
@@
static void *dispatch_thread (void __attribute__((unused)) *arg) /* {{{ */
continue;
}
continue;
}
- parse_packet (se, ent->data, ent->data_len, /* flags = */ 0);
+ parse_packet (se, ent->data, ent->data_len, /* flags = */ 0,
+ /* username = */ NULL);
sfree (ent->data);
sfree (ent);
} /* while (42) */
sfree (ent->data);
sfree (ent);
} /* while (42) */