On Tue, 2010-06-01 at 14:26 +0200, Nikola Pajkovsky wrote:
Imagine this:
------------
| colector |
------------
| network
----------------------------
| | | |
--- --- --- ---
PC1 PC2 PC3 PC4
Colecotr will be colect and process all fails on PC{1;4}
so we need to know treir *hostnames*
I find it unlikely that bugs will be hostname dependent, but
more info is better than less, so it's ok.
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
inc/CrashTypes.h | 1 +
lib/Utils/make_descr.cpp | 1 +
src/Daemon/MiddleWare.cpp | 11 +++++++++++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/inc/CrashTypes.h b/inc/CrashTypes.h
index 4e80f8d..0581fc5 100644
--- a/inc/CrashTypes.h
+++ b/inc/CrashTypes.h
@@ -47,6 +47,7 @@
#define FILENAME_COMMENT "comment"
#define FILENAME_REPRODUCE "reproduce"
#define FILENAME_RATING "rating"
+#define FILENAME_HOSTNAME "hostname"
// Apart from CD_UID, which is also stored as a file in dump directory,
// these items only exist in db. (CD_UID is also a file because
diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp
index 3eeb404..7db30bc 100644
--- a/lib/Utils/make_descr.cpp
+++ b/lib/Utils/make_descr.cpp
@@ -74,6 +74,7 @@ static const char *const blacklisted_items_bz[] = {
FILENAME_ANALYZER ,
FILENAME_COREDUMP ,
FILENAME_DESCRIPTION, /* package description - basically useless */
+ FILENAME_HOSTNAME ,
CD_UID ,
CD_UUID ,
CD_INFORMALL ,
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index fafe073..4909a60 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -793,6 +793,16 @@ static mw_result_t SavePackageDescriptionToDebugDump(
}
std::string description = GetDescription(packageName.c_str());
+
+ // HOST_NAME_MAX is defined in limits.h
+ char host[HOST_NAME_MAX];
+ int ret = gethostname(host, HOST_NAME_MAX);
NAME
gethostname - get name of current host
DESCRIPTION
The gethostname() function shall return the standard host name
for the current machine. The namelen argument shall specify the size
of the array pointed to by the name argument. The returned name
shall be null-terminated, except that if namelen is an insufficient
length to hold the host name, then the returned name shall be truncated
and it is unspecified whether the returned name is null-terminated.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Therefore, it's safer to do:
char host[HOST_NAME_MAX + 1];
int ret = gethostname(host, HOST_NAME_MAX);
host[HOST_NAME_MAX] = '\0'; /* just in case */
+ if (ret < 0)
+ {
+ perror_msg("gethostname");
+ host[0] = '\0';
+ }
+
try
{
CDebugDump dd;
@@ -800,6 +810,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(
dd.SaveText(FILENAME_PACKAGE, package.c_str());
dd.SaveText(FILENAME_DESCRIPTION, description.c_str());
dd.SaveText(FILENAME_COMPONENT, component.c_str());
+ dd.SaveText(FILENAME_HOSTNAME, host);
}
catch (CABRTException& e)
{
--
vda