From 93fc69645c4ba709a1de3751c9bcb9805c2ec0ce Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Thu, 6 Nov 2014 13:06:24 +0100 Subject: [PATCH] Several bug fixes and journald logging improvements --- ...-for-password-if-the-env-var-is-empt.patch | 3 +- ...fix-a-bug-in-ureport-response-parser.patch | 2 +- ...rhtsupport-re-prompt-for-credentials.patch | 2 +- ...t-attach-the-contact-email-to-bthash.patch | 2 +- ...ent-rhsm-entitlement-in-the-man-page.patch | 2 +- ...-ureport-before-creating-description.patch | 2 +- ...tsuite-add-unittests-for-uReport-API.patch | 1221 +++++++++++++++++ ...d-atlocal.in-to-work-with-last-commi.patch | 33 + ...ltiple-cert-file-in-rhsm-entitlement.patch | 100 ++ ...t-certs-with-rhsm-and-drop-rhsm-enti.patch | 84 ++ ...-entitlement-cert-dir-from-rhsm-conf.patch | 106 ++ ...tently-die-on-all-client-auth-errors.patch | 78 ++ ...-use-uReport-URL-from-ureport.config.patch | 57 + ...upport-do-not-leak-the-hints-results.patch | 53 + ...-back-to-the-hardcoded-rhsm-cert-dir.patch | 42 + ...scription-of-two-functions-in-urepor.patch | 41 + ...memory-leak-related-to-AuthDataItems.patch | 27 + 0020-doc-fix-asciidoc-misrendering.patch | 31 + ...uite-add-tests-ureport-to-EXTRA_DIST.patch | 26 + ...-use-rhsm-ssl-client-auth-by-default.patch | 32 + ...e-to-configure-ContactEmail-from-GUI.patch | 35 + ...be-able-to-turn-uReport-off-from-GUI.patch | 34 + ...RH-Portal-URL-c.-o.-to-Advanced-sect.patch | 53 + ...onsistently-die-on-all-client-auth-e.patch | 75 + ...-expected-ureport-exiting-on-rhsm-ce.patch | 137 ++ ...e-values-for-CODE_-fields-being-logg.patch | 47 + libreport.spec | 44 +- 27 files changed, 2358 insertions(+), 11 deletions(-) create mode 100644 0008-testsuite-add-unittests-for-uReport-API.patch create mode 100644 0009-testsuite-changed-atlocal.in-to-work-with-last-commi.patch create mode 100644 0010-ureport-allow-multiple-cert-file-in-rhsm-entitlement.patch create mode 100644 0011-ureport-use-entit-certs-with-rhsm-and-drop-rhsm-enti.patch create mode 100644 0012-ureport-get-rhsm-entitlement-cert-dir-from-rhsm-conf.patch create mode 100644 0013-ureport-consistently-die-on-all-client-auth-errors.patch create mode 100644 0014-rhtsupport-never-use-uReport-URL-from-ureport.config.patch create mode 100644 0015-rhtsupport-do-not-leak-the-hints-results.patch create mode 100644 0017-ureport-fall-back-to-the-hardcoded-rhsm-cert-dir.patch create mode 100644 0018-ureport-wrong-description-of-two-functions-in-urepor.patch create mode 100644 0019-ureport-fix-a-memory-leak-related-to-AuthDataItems.patch create mode 100644 0020-doc-fix-asciidoc-misrendering.patch create mode 100644 0021-testsuite-add-tests-ureport-to-EXTRA_DIST.patch create mode 100644 0022-ureport-use-rhsm-ssl-client-auth-by-default.patch create mode 100644 0023-ureport-be-able-to-configure-ContactEmail-from-GUI.patch create mode 100644 0024-rhtsupport-be-able-to-turn-uReport-off-from-GUI.patch create mode 100644 0025-rhtsupport-move-RH-Portal-URL-c.-o.-to-Advanced-sect.patch create mode 100644 0026-Revert-ureport-consistently-die-on-all-client-auth-e.patch create mode 100644 0027-testsuite-do-not-expected-ureport-exiting-on-rhsm-ce.patch create mode 100644 0029-Prevent-duplicate-values-for-CODE_-fields-being-logg.patch diff --git a/0002-upload-don-t-ask-for-password-if-the-env-var-is-empt.patch b/0002-upload-don-t-ask-for-password-if-the-env-var-is-empt.patch index d6d73b3..5e8f051 100644 --- a/0002-upload-don-t-ask-for-password-if-the-env-var-is-empt.patch +++ b/0002-upload-don-t-ask-for-password-if-the-env-var-is-empt.patch @@ -1,8 +1,7 @@ From c7eaedb85aa65b53e2a874592007b1242abbcfa6 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Wed, 8 Oct 2014 12:26:29 +0200 -Subject: [PATCH 2/7] upload: don't ask for password if the env var is empty - string +Subject: [PATCH] upload: don't ask for password if the env var is empty string Related to rhbz#1066486 diff --git a/0003-lib-fix-a-bug-in-ureport-response-parser.patch b/0003-lib-fix-a-bug-in-ureport-response-parser.patch index c651775..d215f4b 100644 --- a/0003-lib-fix-a-bug-in-ureport-response-parser.patch +++ b/0003-lib-fix-a-bug-in-ureport-response-parser.patch @@ -1,7 +1,7 @@ From 28d979c3824d0e90e14ba7f7be679e66fb53c851 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Wed, 8 Oct 2014 12:37:24 +0200 -Subject: [PATCH 3/7] lib: fix a bug in ureport response parser +Subject: [PATCH] lib: fix a bug in ureport response parser Revealed by coverity diff --git a/0004-rhtsupport-re-prompt-for-credentials.patch b/0004-rhtsupport-re-prompt-for-credentials.patch index 38c2206..d536716 100644 --- a/0004-rhtsupport-re-prompt-for-credentials.patch +++ b/0004-rhtsupport-re-prompt-for-credentials.patch @@ -1,7 +1,7 @@ From f2a0d8fc954afef291c0989c756bbe455c1ccc92 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Fri, 26 Sep 2014 18:40:46 +0200 -Subject: [PATCH 4/7] rhtsupport: re-prompt for credentials +Subject: [PATCH] rhtsupport: re-prompt for credentials Related to rhbz#1104313 diff --git a/0005-rhtsupport-attach-the-contact-email-to-bthash.patch b/0005-rhtsupport-attach-the-contact-email-to-bthash.patch index c6328e7..4b817ae 100644 --- a/0005-rhtsupport-attach-the-contact-email-to-bthash.patch +++ b/0005-rhtsupport-attach-the-contact-email-to-bthash.patch @@ -1,7 +1,7 @@ From e71aebba83efe673bfb554a9fbf1533b7a96bde8 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Wed, 8 Oct 2014 12:10:10 +0200 -Subject: [PATCH 5/7] rhtsupport: attach the contact email to bthash +Subject: [PATCH] rhtsupport: attach the contact email to bthash Related to rhbz#1150388 diff --git a/0006-ureport-document-rhsm-entitlement-in-the-man-page.patch b/0006-ureport-document-rhsm-entitlement-in-the-man-page.patch index 072cffe..8d4315f 100644 --- a/0006-ureport-document-rhsm-entitlement-in-the-man-page.patch +++ b/0006-ureport-document-rhsm-entitlement-in-the-man-page.patch @@ -1,7 +1,7 @@ From 8f350e29a97311e620aa915e4fb977cae615dfb9 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Thu, 9 Oct 2014 13:16:00 +0200 -Subject: [PATCH 6/7] ureport: document rhsm-entitlement in the man page +Subject: [PATCH] ureport: document rhsm-entitlement in the man page Related: #1140224 diff --git a/0007-rhtsupport-send-ureport-before-creating-description.patch b/0007-rhtsupport-send-ureport-before-creating-description.patch index 549f0ef..bf3ca1e 100644 --- a/0007-rhtsupport-send-ureport-before-creating-description.patch +++ b/0007-rhtsupport-send-ureport-before-creating-description.patch @@ -1,7 +1,7 @@ From 0f59cec364a05aa8b1137739ecb4076f16a0406a Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Thu, 9 Oct 2014 14:02:11 +0200 -Subject: [PATCH 7/7] rhtsupport: send ureport before creating description +Subject: [PATCH] rhtsupport: send ureport before creating description Because we want to include the URL to uReport stored in 'reported_to' file in the description. diff --git a/0008-testsuite-add-unittests-for-uReport-API.patch b/0008-testsuite-add-unittests-for-uReport-API.patch new file mode 100644 index 0000000..a27dd17 --- /dev/null +++ b/0008-testsuite-add-unittests-for-uReport-API.patch @@ -0,0 +1,1221 @@ +From c20aa59614de15a5840dfcf44bcfc674a56795ab Mon Sep 17 00:00:00 2001 +From: Matej Habrnal +Date: Wed, 22 Oct 2014 00:14:55 +0200 +Subject: [PATCH] testsuite: add unittests for uReport API + +Fixes #294 + +Signed-off-by: Matej Habrnal +--- + tests/Makefile.am | 3 +- + tests/testsuite.at | 1 + + tests/ureport.at | 1101 ++++++++++++++++++++ + tests/ureport/certs/correct/cert-key.pem | 5 + + tests/ureport/certs/correct/cert.pem | 13 + + tests/ureport/certs/incorrect_content/cert-key.pem | 5 + + tests/ureport/certs/incorrect_content/cert.pem | 0 + tests/ureport/rhsm/__init__.py | 0 + tests/ureport/rhsm/config.py | 8 + + 9 files changed, 1135 insertions(+), 1 deletion(-) + create mode 100644 tests/ureport.at + create mode 100644 tests/ureport/certs/correct/cert-key.pem + create mode 100644 tests/ureport/certs/correct/cert.pem + create mode 100644 tests/ureport/certs/incorrect_content/cert-key.pem + create mode 100644 tests/ureport/certs/incorrect_content/cert.pem + create mode 100644 tests/ureport/rhsm/__init__.py + create mode 100644 tests/ureport/rhsm/config.py + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 4731bad..cda9375 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -41,7 +41,8 @@ TESTSUITE_AT = \ + xml_definition.at \ + report_python.at \ + xfuncs.at \ +- string_list.at ++ string_list.at \ ++ ureport.at + + EXTRA_DIST += $(TESTSUITE_AT) + TESTSUITE = $(srcdir)/testsuite +diff --git a/tests/testsuite.at b/tests/testsuite.at +index 60b2e94..abad32b 100644 +--- a/tests/testsuite.at ++++ b/tests/testsuite.at +@@ -16,3 +16,4 @@ m4_include([libreport_types.at]) + m4_include([xml_definition.at]) + m4_include([report_python.at]) + m4_include([string_list.at]) ++m4_include([ureport.at]) +diff --git a/tests/ureport.at b/tests/ureport.at +new file mode 100644 +index 0000000..22d34e9 +--- /dev/null ++++ b/tests/ureport.at +@@ -0,0 +1,1101 @@ ++# -*- Autotest -*- ++ ++AT_BANNER([ureport]) ++ ++## ---------------------------- ## ++## ureport_server_config_init ## ++## ---------------------------- ## ++ ++AT_TESTFUN([ureport_server_config_init], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++ ++#define DESTROYED_POINTER (void *)0xdeadbeef ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ assert(config.ur_url == NULL); ++ assert(config.ur_ssl_verify == true); ++ assert(config.ur_client_cert == NULL); ++ assert(config.ur_client_key == NULL); ++ assert(config.ur_username == NULL); ++ assert(config.ur_password == NULL); ++ assert(config.ur_http_headers != NULL); ++ assert(config.ur_prefs.urp_auth_items == NULL); ++ ++ config.ur_url = (char *)"url"; ++ config.ur_ssl_verify = false; ++ config.ur_client_cert = (char *)"cert"; ++ config.ur_client_key = (char *)"key"; ++ config.ur_username = (char *)"username"; ++ config.ur_password = (char *)"password"; ++ free_map_string(config.ur_http_headers); ++ config.ur_prefs.urp_auth_items = DESTROYED_POINTER; ++ ++ ureport_server_config_init(&config); ++ ++ assert(config.ur_url == NULL); ++ assert(config.ur_ssl_verify == true); ++ assert(config.ur_client_cert == NULL); ++ assert(config.ur_client_key == NULL); ++ assert(config.ur_username == NULL); ++ assert(config.ur_password == NULL); ++ assert(config.ur_http_headers != NULL); ++ assert(config.ur_prefs.urp_auth_items == NULL); ++ ++ return 0; ++} ++]]) ++ ++## ------------------------------- ## ++## ureport_server_config_destroy ## ++## ------------------------------- ## ++ ++AT_TESTFUN([ureport_server_config_destroy], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++ ++#define DESTROYED_POINTER (void *)0xdeadbeef ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ config.ur_url = strdup("url"); ++ config.ur_client_cert = strdup("cert"); ++ config.ur_client_key = strdup("key"); ++ config.ur_username = strdup("username"); ++ config.ur_password = strdup("password"); ++ ++ assert(strcmp(config.ur_url, "url") == 0); ++ assert(strcmp(config.ur_client_cert, "cert") == 0); ++ assert(strcmp(config.ur_client_key, "key") == 0); ++ assert(strcmp(config.ur_username, "username") == 0); ++ assert(strcmp(config.ur_password , "password") == 0); ++ ++ ureport_server_config_destroy(&config); ++ ++ assert(config.ur_url == DESTROYED_POINTER); ++ assert(config.ur_client_cert == DESTROYED_POINTER); ++ assert(config.ur_client_key == DESTROYED_POINTER); ++ assert(config.ur_username == DESTROYED_POINTER); ++ assert(config.ur_password == DESTROYED_POINTER); ++ assert(config.ur_prefs.urp_auth_items == DESTROYED_POINTER); ++ assert(config.ur_http_headers == DESTROYED_POINTER); ++ ++ return 0; ++} ++]]) ++ ++## ---------------------------- ## ++## ureport_server_config_load ## ++## ---------------------------- ## ++ ++AT_TESTFUN([ureport_server_config_load], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ /* value from env */ ++ /* IncludeAuthData set to 'no' */ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ setenv("uReport_URL", "env_url", 1); ++ setenv("uReport_SSLVerify", "yes", 1); ++ setenv("SSLClientAuth", "", 1); ++ setenv("uReport_IncludeAuthData", "no", 1); ++ setenv("uReport_AuthDataItems", "hostname", 1); ++ ++ map_string_t *settings = new_map_string(); ++ ++ ureport_server_config_load(&config, settings); ++ ++ assert(strcmp(config.ur_url, "env_url") == 0); ++ assert(config.ur_ssl_verify == true); ++ ++ GList *l = config.ur_prefs.urp_auth_items; ++ assert(l == NULL); ++ ++ ureport_server_config_destroy(&config); ++ ++ /* value from env */ ++ /* IncludeAuthData set to 'yes' but AuthDataItems is empty. */ ++ ureport_server_config_init(&config); ++ ++ setenv("uReport_URL", "env_url", 1); ++ setenv("uReport_SSLVerify", "yes", 1); ++ setenv("SSLClientAuth", "", 1); ++ setenv("uReport_IncludeAuthData", "yes", 1); ++ setenv("uReport_AuthDataItems", "", 1); ++ ++ ureport_server_config_load(&config, settings); ++ ++ assert(strcmp(config.ur_url, "env_url") == 0); ++ assert(config.ur_ssl_verify == true); ++ ++ l = config.ur_prefs.urp_auth_items; ++ assert(l == NULL); ++ ++ ureport_server_config_destroy(&config); ++ ++ /* value from env */ ++ /* IncludeAuthData set to 'yes' */ ++ ureport_server_config_init(&config); ++ ++ setenv("uReport_URL", "env_url", 1); ++ setenv("uReport_SSLVerify", "no", 1); ++ setenv("SSLClientAuth", "", 1); ++ setenv("uReport_IncludeAuthData", "yes", 1); ++ setenv("uReport_AuthDataItems", "hostname, time", 1); ++ ++ ureport_server_config_load(&config, settings); ++ ++ assert(strcmp(config.ur_url, "env_url") == 0); ++ assert(config.ur_ssl_verify == false); ++ ++ l = config.ur_prefs.urp_auth_items; ++ assert(strcmp(l->data, "hostname") == 0); ++ assert(strcmp(l->next->data, "time") == 0); ++ ++ ureport_server_config_destroy(&config); ++ ++ /* value from settings */ ++ /* IncludeAuthData set to 'no' */ ++ ureport_server_config_init(&config); ++ ++ unsetenv("uReport_URL"); ++ unsetenv("uReport_SSLVerify"); ++ unsetenv("uReport_IncludeAuthData"); ++ unsetenv("uReport_AuthDataItems"); ++ ++ insert_map_string(settings, xstrdup("URL"), xstrdup("settings_url")); ++ insert_map_string(settings, xstrdup("SSLVerify"), xstrdup("yes")); ++ insert_map_string(settings, xstrdup("SSLClientAuth"), xstrdup("")); ++ insert_map_string(settings, xstrdup("IncludeAuthData"), xstrdup("no")); ++ insert_map_string(settings, xstrdup("AuthDataItems"), xstrdup("hostname")); ++ ++ ureport_server_config_load(&config, settings); ++ ++ assert(strcmp(config.ur_url, "settings_url") == 0); ++ assert(config.ur_ssl_verify == true); ++ ++ l = config.ur_prefs.urp_auth_items; ++ assert(l == NULL); ++ ++ ureport_server_config_destroy(&config); ++ free_map_string(settings); ++ ++ /* value from settings */ ++ /* IncludeAuthData set to 'yes' but AuthDataItems is empty. */ ++ ureport_server_config_init(&config); ++ ++ settings = new_map_string(); ++ insert_map_string(settings, xstrdup("URL"), xstrdup("settings_url")); ++ insert_map_string(settings, xstrdup("SSLVerify"), xstrdup("yes")); ++ insert_map_string(settings, xstrdup("SSLClientAuth"), xstrdup("")); ++ insert_map_string(settings, xstrdup("IncludeAuthData"), xstrdup("yes")); ++ insert_map_string(settings, xstrdup("AuthDataItems"), xstrdup("")); ++ ++ ureport_server_config_load(&config, settings); ++ ++ assert(strcmp(config.ur_url, "settings_url") == 0); ++ assert(config.ur_ssl_verify == true); ++ ++ l = config.ur_prefs.urp_auth_items; ++ assert(l == NULL); ++ ++ ureport_server_config_destroy(&config); ++ free_map_string(settings); ++ ++ /* value from settings */ ++ /* IncludeAuthData set to 'yes' */ ++ ureport_server_config_init(&config); ++ ++ settings = new_map_string(); ++ insert_map_string(settings, xstrdup("URL"), xstrdup("settings_url")); ++ insert_map_string(settings, xstrdup("SSLVerify"), xstrdup("no")); ++ insert_map_string(settings, xstrdup("SSLClientAuth"), xstrdup("")); ++ insert_map_string(settings, xstrdup("IncludeAuthData"), xstrdup("yes")); ++ insert_map_string(settings, xstrdup("AuthDataItems"), xstrdup("hostname, type")); ++ ++ ureport_server_config_load(&config, settings); ++ ++ assert(strcmp(config.ur_url, "settings_url") == 0); ++ assert(config.ur_ssl_verify == false); ++ ++ l = config.ur_prefs.urp_auth_items; ++ assert(strcmp(l->data, "hostname") == 0); ++ assert(strcmp(l->next->data, "type") == 0); ++ ++ ureport_server_config_destroy(&config); ++ free_map_string(settings); ++ ++ return 0; ++} ++]]) ++ ++ ++## ------------------------------- ## ++## ureport_server_config_set_url ## ++## ------------------------------- ## ++ ++AT_TESTFUN([ureport_server_config_set_url], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++ ++#define DESTROYED_POINTER (void *)0xdeadbeef ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ ureport_server_config_set_url(&config, strdup("url")); ++ ++ assert(strcmp(config.ur_url, "url") == 0); ++ ++ ureport_server_config_set_url(&config, strdup("next.url")); ++ ++ assert(strcmp(config.ur_url, "next.url") == 0); ++ ++ ureport_server_config_destroy(&config); ++ ++ return 0; ++} ++]]) ++ ++## --------------------------------------- ## ++## ureport_server_config_set_client_auth ## ++## --------------------------------------- ## ++ ++AT_TESTFUN([ureport_server_config_set_client_auth], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++ ++#define DESTROYED_POINTER (void *)0xdeadbeef ++#define RHSM_WEB_SERVICE_URL "https://api.access.redhat.com/rs/telemetry/abrt" ++ ++#define TESTING_CERTS_CORRECT_DIR_PATH "../../ureport/certs/correct" ++#define TESTING_CERTS_INCORRECT_CONTENT_DIR_PATH "../../ureport/certs/incorrect_content" ++#define TESTING_PYTHONPATH "../../ureport/" ++#define WRONG_TESTING_PYTHONPATH "../../ureportxxxxxx/" ++ ++#define RHSMENT_PEM_DIR_PATH "/etc/pki/entitlement" ++ ++#define RHSMENT_ENT_DATA_BEGIN_TAG "-----BEGIN ENTITLEMENT DATA-----" ++#define RHSMENT_ENT_DATA_END_TAG "-----END ENTITLEMENT DATA-----" ++#define RHSMENT_SIG_DATA_BEGIN_TAG "-----BEGIN RSA SIGNATURE-----" ++#define RHSMENT_SIG_DATA_END_TAG "-----END RSA SIGNATURE-----" ++ ++char *my_strdup(const char *str) ++{ ++ if (str == NULL) ++ return NULL; ++ else ++ return strdup(str); ++} ++ ++void set_ureport_server_config(struct ureport_server_config *config, ++ const char *url, ++ bool ver, ++ const char *cert, ++ const char *key, ++ const char *uname, ++ const char *passwd) ++{ ++ config->ur_url = my_strdup(url); ++ config->ur_ssl_verify = ver; ++ config->ur_client_cert = my_strdup(cert); ++ config->ur_client_key = my_strdup(key); ++ config->ur_username = my_strdup(uname); ++ config->ur_password = my_strdup(passwd); ++ ++ return; ++} ++ ++void my_assert(const char *str1, const char *str2) ++{ ++ if (str1 == NULL || str2 == NULL) ++ assert( str1 == NULL && str2 == NULL ); ++ else ++ assert(strcmp(str1, str2) == 0); ++ ++ return; ++} ++ ++void assert_ureport_server_config(struct ureport_server_config *config, ++ const char *url, ++ bool ver, ++ const char *cert, ++ const char *key, ++ const char *username, ++ const char *password) ++{ ++ my_assert(config->ur_url, url); ++ assert(config->ur_ssl_verify == ver); ++ my_assert(config->ur_client_cert, cert); ++ my_assert(config->ur_client_key, key); ++ my_assert(config->ur_username, username); ++ my_assert(config->ur_password , password); ++ ++ return; ++} ++ ++int test_ureport_server_config_set_client_auth_exit_code(struct ureport_server_config *config, ++ const char *client_auth) ++{ ++ ureport_server_config_init(config); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ { ++ perror_msg("fork"); ++ return -1; ++ } ++ ++ if (pid == 0) ++ { ++ ureport_server_config_set_client_auth(config, client_auth); ++ exit(0); ++ } ++ int status; ++ wait(&status); ++ ++ ureport_server_config_destroy(config); ++ ++ return status; ++} ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ ureport_server_config_set_client_auth(&config, NULL); ++ ++ set_ureport_server_config(&config, "url", true, "cert", "key", "username", "passwd"); ++ ++ /* client_auth == NULL */ ++ ureport_server_config_set_client_auth(&config, NULL); ++ assert_ureport_server_config(&config, "url", true, "cert", "key", "username", "passwd"); ++ ++ /* client_auth == "" */ ++ ureport_server_config_set_client_auth(&config, ""); ++ assert_ureport_server_config(&config, "url", true, NULL, NULL, "username", "passwd"); ++ ++ ureport_server_config_destroy(&config); ++ ++ /* client_auth == rhsm */ ++ /* ur_url == NULL */ ++ /* no certs */ ++ char *empty_cert_dir = mkdtemp(strdup("/tmp/cert_XXXXXX")); ++ assert(empty_cert_dir); ++ setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", empty_cert_dir, 1); ++ ++ int status = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm"); ++ assert(status != 0 && status != -1); ++ ++ assert(rmdir(empty_cert_dir) == 0); ++ ++ /* client_auth == rhsm */ ++ /* ur_url == NULL */ ++ /* certs exists (incorrect content) */ ++ ++ setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_INCORRECT_CONTENT_DIR_PATH, 1); ++ ++ status = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm"); ++ assert(status != 0 && status != -1); ++ ++ /* client_auth == rhsm */ ++ /* ur_url == NULL */ ++ /* certs exists (correct) */ ++ ureport_server_config_init(&config); ++ ++ setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", TESTING_CERTS_CORRECT_DIR_PATH, 1); ++ ++ ureport_server_config_set_client_auth(&config, "rhsm"); ++ ++ assert_ureport_server_config(&config, RHSM_WEB_SERVICE_URL, true, ++ TESTING_CERTS_CORRECT_DIR_PATH"/cert.pem", ++ TESTING_CERTS_CORRECT_DIR_PATH"/cert-key.pem", ++ NULL, NULL); ++ ++ char *ent = xasprintf(RHSMENT_ENT_DATA_BEGIN_TAG"%s"RHSMENT_ENT_DATA_END_TAG, "entitlementdata"); ++ assert(0 == strcmp(ent, ++ get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Data"))); ++ ++ char *sig= xasprintf(RHSMENT_SIG_DATA_BEGIN_TAG"%s"RHSMENT_SIG_DATA_END_TAG, "rsasignature"); ++ assert(0 == strcmp(sig, ++ get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Sig"))); ++ ++ free(ent); ++ free(sig); ++ ureport_server_config_destroy(&config); ++ ++ /* client_auth == cert:key */ ++ /* ur_url == NULL */ ++ ureport_server_config_init(&config); ++ set_ureport_server_config(&config, NULL, true, NULL, NULL, "username", "passwd"); ++ ureport_server_config_set_client_auth(&config, "cert:key"); ++ assert_ureport_server_config(&config, NULL, true, "cert", "key", NULL, NULL); ++ ++ ureport_server_config_destroy(&config); ++ ++ /* client_auth == cert:key */ ++ /* ur_url != NULL */ ++ ureport_server_config_init(&config); ++ set_ureport_server_config(&config, "url", true, NULL, NULL, "username", "passwd"); ++ ureport_server_config_set_client_auth(&config, "cert:key"); ++ assert_ureport_server_config(&config, "url", true, "cert", "key", NULL, NULL); ++ ++ ureport_server_config_destroy(&config); ++ ++ /* wrong client_auth */ ++ int ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "cert:"); ++ assert(ret_val != 0 && ret_val != -1); ++ ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, ":key"); ++ assert(ret_val != 0 && ret_val != -1); ++ ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "cert"); ++ assert(ret_val != 0 && ret_val != -1); ++ ++/* rhsm_config_get_entitlement_cert_dir */ ++/* certs exists (correct content) */ ++ unsetenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH"); ++ setenv("PYTHONPATH", TESTING_PYTHONPATH, 1); ++ ++ ureport_server_config_init(&config); ++ ureport_server_config_set_client_auth(&config, "rhsm"); ++ ++ char *abs_path_cert = realpath(TESTING_CERTS_CORRECT_DIR_PATH"/cert.pem", NULL); ++ char *abs_path_key = realpath(TESTING_CERTS_CORRECT_DIR_PATH"/cert-key.pem", NULL); ++ ++ assert_ureport_server_config(&config, RHSM_WEB_SERVICE_URL, true, ++ abs_path_cert, ++ abs_path_key, ++ NULL, NULL); ++ free(abs_path_cert); ++ free(abs_path_key); ++ ++ ent = xasprintf(RHSMENT_ENT_DATA_BEGIN_TAG"%s"RHSMENT_ENT_DATA_END_TAG, "entitlementdata"); ++ assert(0 == strcmp(ent, ++ get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Data"))); ++ ++ sig= xasprintf(RHSMENT_SIG_DATA_BEGIN_TAG"%s"RHSMENT_SIG_DATA_END_TAG, "rsasignature"); ++ assert(0 == strcmp(sig, ++ get_map_string_item_or_NULL(config.ur_http_headers, "X-RH-Entitlement-Sig"))); ++ ++ free(ent); ++ free(sig); ++ ureport_server_config_destroy(&config); ++ ++ /* python script fails, '/etc/pki/entitlement' is returned */ ++ ++ /* set cert dir path to '/etc/pki/entitlement' */ ++ /* store return value of ureport_server_config_set_client_auth */ ++ setenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH", RHSMENT_PEM_DIR_PATH, 1); ++ ++ int exp_ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm"); ++ ++ /* Do the same with unset LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH and wrong PYTHONPATH */ ++ /* function rhsm_config_get_entitlement_cert_dir has to return RHSMENT_PEM_DIR_PATH */ ++ unsetenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH"); ++ setenv("PYTHONPATH", WRONG_TESTING_PYTHONPATH, 1); ++ ++ int rec_ret_val = test_ureport_server_config_set_client_auth_exit_code(&config, "rhsm"); ++ ++ /* we expect the same return value */ ++// assert(exp_ret_val == rec_ret_val); ++ ++ return 0; ++} ++]]) ++ ++## -------------------------------------- ## ++## ureport_server_config_set_basic_auth ## ++## -------------------------------------- ## ++ ++AT_TESTFUN([ureport_server_config_set_basic_auth], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++ ++void my_assert(const char *str1, const char *str2) ++{ ++ if (str1 == NULL || str2 == NULL) ++ assert( str1 == NULL && str2 == NULL ); ++ else ++ assert(strcmp(str1, str2) == 0); ++ ++ return; ++} ++ ++void assert_ureport_server_config(struct ureport_server_config *config, ++ const char *url, ++ bool ver, ++ const char *cert, ++ const char *key, ++ const char *username, ++ const char *password) ++{ ++ my_assert(config->ur_url, url); ++ assert(config->ur_ssl_verify == ver); ++ my_assert(config->ur_client_cert, cert); ++ my_assert(config->ur_client_key, key); ++ my_assert(config->ur_username, username); ++ my_assert(config->ur_password , password); ++ ++ return; ++} ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ ureport_server_config_set_basic_auth(&config, NULL, NULL); ++ assert_ureport_server_config(&config, NULL, true, NULL, NULL, NULL, NULL); ++ ++ ureport_server_config_set_basic_auth(&config, "usr", NULL); ++ assert_ureport_server_config(&config, NULL, true, NULL, NULL, "usr", NULL); ++ ++ ureport_server_config_set_basic_auth(&config, NULL, "passwd"); ++ assert_ureport_server_config(&config, NULL, true, NULL, NULL, NULL, "passwd"); ++ ++ ureport_server_config_set_basic_auth(&config, "usr", "passwd"); ++ assert_ureport_server_config(&config, NULL, true, NULL, NULL, "usr", "passwd"); ++ ++ return 0; ++} ++]]) ++ ++## ------------------------------------ ## ++## ureport_server_response_from_reply ## ++## ------------------------------------ ## ++ ++AT_TESTFUN([ureport_server_response_from_reply], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++ ++ ++int main(void) ++{ ++ ++ /* curl_resul is not CURL_OK */ ++ struct post_state ps; ++ ++ ps.curl_result = 1; ++ strcpy(ps.errmsg, "err"); ++ ps.body = (char *)"body"; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ ureport_server_config_set_url(&config, strdup("url")); ++ ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ /* curl_resul is CURLE_OK */ ++ /* http_resp_code == 404 */ ++ ps.curl_result = CURLE_OK; ++ ps.http_resp_code = 404; ++ ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ ps.http_resp_code = 500; ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ ps.http_resp_code = 503; ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ ps.http_resp_code = 404; ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ ps.http_resp_code = 201; ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ /* unable parse json */ ++ ps.http_resp_code = 202; ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ /* correct json && invalid format */ ++ ps.body = (char *)"{ \"resultxxxxxxxx\" : true }"; ++ assert(ureport_server_response_from_reply(&ps, &config) == NULL); ++ ++ /* correct json && valid format */ ++ ps.body = (char *)"{ 'result' : true, \ ++ 'message': 'message', \ ++ 'bthash': '691cf824e3e07457156125636e86c50279e29496', \ ++ 'reported_to': [ { 'type': 'url', \ ++ 'value': 'value', \ ++ 'reporter': 'ABRT Server' } ] }"; ++ ++ struct ureport_server_response *response = ureport_server_response_from_reply(&ps, &config); ++ assert(strcmp(response->urr_value, "true") == 0); ++ assert(strcmp(response->urr_message, "message") == 0); ++ assert(strcmp(response->urr_bthash, "691cf824e3e07457156125636e86c50279e29496") == 0); ++ ++ GList *urr_reported_to_list = response->urr_reported_to_list; ++ assert(strcmp(urr_reported_to_list->data, "ABRT Server: URL=value") == 0); ++ ++ ureport_server_response_free(response); ++ ++ return 0; ++ ++} ++]]) ++ ++## ----------------------------------------- ## ++## ureport_server_response_save_in_dump_dir ## ++## ----------------------------------------- ## ++ ++AT_TESTFUN([ureport_server_response_save_in_dump_dir], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "dump_dir.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ /* reported to*/ ++ struct post_state ps; ++ ps.curl_result = CURLE_OK; ++ ps.http_resp_code = 202; ++ ps.body = (char *)"{ 'result' : true, \ ++ 'message': 'message', \ ++ 'bthash': '691cf824e3e07457156125636e86c50279e29496', \ ++ 'reported_to': [ { 'type': 'url', \ ++ 'value': 'value', \ ++ 'reporter': 'ABRT Server' } ] }"; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ureport_server_config_set_url(&config, strdup("url")); ++ ++ struct dump_dir *dd = dd_create("./test", (uid_t)-1L, DEFAULT_DUMP_DIR_MODE); ++ assert(dd != NULL); ++ dd_create_basic_files(dd, (uid_t)-1L, NULL); ++ dd_save_text(dd, FILENAME_TYPE, "CCpp"); ++ dd_close(dd); ++ ++ struct ureport_server_response *response = ureport_server_response_from_reply(&ps, &config); ++ assert(ureport_server_response_save_in_dump_dir(response, "./test", &config)); ++ ++ /* dump dir do not exist */ ++ assert(false == ureport_server_response_save_in_dump_dir(response, "not_existing_dir", &config)); ++ ++ dd = dd_opendir("./test", 0); ++ char *reported_to = dd_load_text_ext(dd, FILENAME_REPORTED_TO, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); ++ ++ assert(strstr(reported_to, "uReport: BTHASH=691cf824e3e07457156125636e86c50279e29496") != NULL); ++ assert(strstr(reported_to, "url/reports/bthash/691cf824e3e07457156125636e86c50279e29496") != NULL); ++ assert(strstr(reported_to, "ABRT Server: URL=value") != NULL); ++ /* not-reportable must not exist */ ++ assert(!dd_exist(dd, FILENAME_NOT_REPORTABLE)); ++ ++ free(config.ur_url); ++ ureport_server_response_free(response); ++ free(reported_to); ++ dd_close(dd); ++ delete_dump_dir("./test"); ++ ++ /* not-reportable*/ ++ ps.curl_result = CURLE_OK; ++ ps.http_resp_code = 202; ++ ps.body = (char *)"{ 'result' : true, \ ++ 'message': 'message', \ ++ 'solutions': [ { 'cause': 'solution_cause', \ ++ 'url': 'solution_url', \ ++ 'note': 'solution_note' } ], \ ++ 'bthash': '691cf824e3e07457156125636e86c50279e29496', \ ++ 'reported_to': [ { 'type': 'url', \ ++ 'value': 'value', \ ++ 'reporter': 'ABRT Server' } ] }"; ++ ++ ureport_server_config_init(&config); ++ ureport_server_config_set_url(&config, strdup("url")); ++ ++ dd = dd_create("./test", (uid_t)-1L, DEFAULT_DUMP_DIR_MODE); ++ assert(dd != NULL); ++ dd_create_basic_files(dd, (uid_t)-1L, NULL); ++ dd_save_text(dd, FILENAME_TYPE, "CCpp"); ++ dd_close(dd); ++ ++ response = ureport_server_response_from_reply(&ps, &config); ++ assert(ureport_server_response_save_in_dump_dir(response, "./test", &config)); ++ ++ dd = dd_opendir("./test", 0); ++ reported_to = dd_load_text_ext(dd, FILENAME_REPORTED_TO, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); ++ ++ assert(strstr(reported_to, "uReport: BTHASH=691cf824e3e07457156125636e86c50279e29496") != NULL); ++ assert(strstr(reported_to, "url/reports/bthash/691cf824e3e07457156125636e86c50279e29496") != NULL); ++ assert(strstr(reported_to, "ABRT Server: URL=value") != NULL); ++ /* not-reportable must exist */ ++ char *not_reportable = dd_load_text_ext(dd, FILENAME_NOT_REPORTABLE, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); ++ ++ assert(strstr(not_reportable, "Your problem seems to be caused by solution_cause") != NULL); ++ ++ ++ free(config.ur_url); ++ ureport_server_response_free(response); ++ free(reported_to); ++ free(not_reportable); ++ dd_close(dd); ++ delete_dump_dir("./test"); ++ ++ return 0; ++ ++} ++]]) ++ ++ ++## --------------------------------------- ## ++## ureport_server_response_get_report_url ## ++## --------------------------------------- ## ++ ++AT_TESTFUN([ureport_server_response_get_report_url], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++#define BTHASH_URL_SFX "reports/bthash/" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ /* reported to*/ ++ struct post_state ps; ++ ps.curl_result = CURLE_OK; ++ ps.http_resp_code = 202; ++ ps.body = (char *)"{ 'result' : true, \ ++ 'message': 'message', \ ++ 'bthash': '691cf824e3e07457156125636e86c50279e29496', \ ++ 'reported_to': [ { 'type': 'url', \ ++ 'value': 'value', \ ++ 'reporter': 'ABRT Server' } ] }"; ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ureport_server_config_set_url(&config, strdup("url")); ++ ++ struct ureport_server_response *response = ureport_server_response_from_reply(&ps, &config); ++ ++ char *report_url = ureport_server_response_get_report_url(response, &config); ++ ++ char *expect_bthash_url = concat_path_file(config.ur_url, BTHASH_URL_SFX); ++ char *expect_report_url = concat_path_file(expect_bthash_url, response->urr_bthash); ++ free(expect_bthash_url); ++ ++ assert(strcmp(report_url, expect_report_url) == 0); ++ ++ free(config.ur_url); ++ free(expect_report_url); ++ free(report_url); ++ ureport_server_response_free(response); ++ ++ return 0; ++} ++]]) ++ ++## ---------------- ## ++## ureport_do_post ## ++## ---------------- ## ++ ++AT_TESTFUN([ureport_do_post], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct dump_dir *dd = dd_create("./test", (uid_t)-1L, DEFAULT_DUMP_DIR_MODE); ++ assert(dd != NULL); ++ dd_create_basic_files(dd, (uid_t)-1L, NULL); ++ dd_save_text(dd, FILENAME_TYPE, "CCpp"); ++ dd_save_text(dd, FILENAME_ANALYZER, "CCpp"); ++ dd_save_text(dd, FILENAME_PKG_EPOCH, "pkg_epoch"); ++ dd_save_text(dd, FILENAME_PKG_ARCH, "pkg_arch"); ++ dd_save_text(dd, FILENAME_PKG_RELEASE, "pkg_release"); ++ dd_save_text(dd, FILENAME_PKG_VERSION, "pkg_version"); ++ dd_save_text(dd, FILENAME_PKG_NAME, "pkg_name"); ++ const char *bt = "{ \"signal\": 6, \"executable\": \"/usr/bin/will_abort\" }"; ++ dd_save_text(dd, FILENAME_CORE_BACKTRACE, bt); ++ dd_close(dd); ++ ++ char *json = ureport_from_dump_dir_ext("./test", NULL); ++ ++ /* wrong url */ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ struct post_state *post_state = ureport_do_post(json, &config, "not_exist"); ++ assert(post_state->curl_result == CURLE_COULDNT_RESOLVE_HOST); ++ ++ free(post_state); ++ free(json); ++ ureport_server_config_destroy(&config); ++ delete_dump_dir("./test"); ++ ++ return 0; ++} ++]]) ++ ++## --------------- ## ++## ureport_submit ## ++## --------------- ## ++ ++AT_TESTFUN([ureport_submit], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct dump_dir *dd = dd_create("./test", (uid_t)-1L, DEFAULT_DUMP_DIR_MODE); ++ assert(dd != NULL); ++ dd_create_basic_files(dd, (uid_t)-1L, NULL); ++ dd_save_text(dd, FILENAME_TYPE, "CCpp"); ++ dd_save_text(dd, FILENAME_ANALYZER, "CCpp"); ++ dd_save_text(dd, FILENAME_PKG_EPOCH, "pkg_epoch"); ++ dd_save_text(dd, FILENAME_PKG_ARCH, "pkg_arch"); ++ dd_save_text(dd, FILENAME_PKG_RELEASE, "pkg_release"); ++ dd_save_text(dd, FILENAME_PKG_VERSION, "pkg_version"); ++ dd_save_text(dd, FILENAME_PKG_NAME, "pkg_name"); ++ const char *bt = "{ \"signal\": 6, \"executable\": \"/usr/bin/will_abort\" }"; ++ dd_save_text(dd, FILENAME_CORE_BACKTRACE, bt); ++ dd_close(dd); ++ ++ char *json = ureport_from_dump_dir_ext("./test", NULL); ++ ++ /* wrong url */ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ struct ureport_server_response *response = ureport_submit(json, &config); ++ ++ assert(response == NULL); ++ ++ ureport_server_response_free(response); ++ free(json); ++ ureport_server_config_destroy(&config); ++ delete_dump_dir("./test"); ++ ++ return 0; ++} ++]]) ++ ++## --------------------------- ## ++## ureport_json_attachment_new ## ++## --------------------------- ## ++ ++AT_TESTFUN([ureport_json_attachment_new], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ char *json = ureport_json_attachment_new("data_bthash", "data_type", "data_data"); ++ assert(strcmp(json, "{ \"bthash\": \"data_bthash\", \"type\": \"data_type\", \"data\": \"data_data\" }") == 0); ++ free(json); ++ ++ json = ureport_json_attachment_new("", "", ""); ++ assert(strcmp(json, "{ \"bthash\": \"\", \"type\": \"\", \"data\": \"\" }") == 0); ++ free(json); ++ ++ return 0; ++} ++]]) ++ ++## --------------------- ## ++## ureport_attach_string ## ++## --------------------- ## ++ ++AT_TESTFUN([ureport_attach_string], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ /* wrong url */ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ bool res = ureport_attach_string("691cf824e3e07457156125636e86c50279e29496", "email", "abrt@email.com", &config); ++ assert(res == true); ++ ++ ureport_server_config_destroy(&config); ++ ++ return 0; ++} ++]]) ++ ++## ------------------ ## ++## ureport_attach_int ## ++## ------------------ ## ++ ++AT_TESTFUN([ureport_attach_int], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ /* wrong url */ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ bool res = ureport_attach_int("691cf824e3e07457156125636e86c50279e29496", "count", 5, &config); ++ assert(res == true); ++ ++ ureport_server_config_destroy(&config); ++ ++ return 0; ++} ++]]) ++ ++## ------------------------- ## ++## ureport_from_dump_dir_ext ## ++## ------------------------- ## ++ ++AT_TESTFUN([ureport_from_dump_dir_ext], ++[[ ++#include "internal_libreport.h" ++#include "ureport.h" ++#include ++#include "libreport_curl.h" ++#include "problem_data.h" ++ ++int main(void) ++{ ++ g_verbose=3; ++ ++ struct dump_dir *dd = dd_create("./test", (uid_t)-1L, DEFAULT_DUMP_DIR_MODE); ++ assert(dd != NULL); ++ dd_create_basic_files(dd, (uid_t)-1L, NULL); ++ dd_save_text(dd, FILENAME_TYPE, "CCpp"); ++ dd_save_text(dd, FILENAME_ANALYZER, "CCpp"); ++ dd_save_text(dd, FILENAME_PKG_EPOCH, "pkg_epoch"); ++ dd_save_text(dd, FILENAME_PKG_ARCH, "pkg_arch"); ++ dd_save_text(dd, FILENAME_PKG_RELEASE, "pkg_release"); ++ dd_save_text(dd, FILENAME_PKG_VERSION, "pkg_version"); ++ dd_save_text(dd, FILENAME_PKG_NAME, "pkg_name"); ++ const char *bt = "{ \"signal\": 6, \"executable\": \"/usr/bin/will_abort\" }"; ++ dd_save_text(dd, FILENAME_CORE_BACKTRACE, bt); ++ dd_close(dd); ++ ++ /* no auth */ ++ char *ureport = ureport_from_dump_dir_ext("./test", NULL); ++ assert(strstr(ureport, "auth") == NULL); ++ free(ureport); ++ ++ /* auth */ ++ dd = dd_opendir("./test", 0); ++ dd_save_text(dd, FILENAME_HOSTNAME, "env_hostname"); ++ dd_close(dd); ++ ++ struct ureport_server_config config; ++ ureport_server_config_init(&config); ++ ++ map_string_t *settings = new_map_string(); ++ ++ setenv("uReport_IncludeAuthData", "yes", 1); ++ setenv("uReport_AuthDataItems", "hostname", 1); ++ ++ ureport_server_config_load(&config, settings); ++ ++ ureport = ureport_from_dump_dir_ext("./test", &config.ur_prefs); ++ assert(strstr(ureport, "auth") != NULL); ++ assert(strstr(ureport, "\"hostname\": \"env_hostname\"") != NULL); ++ free(ureport); ++ ++ ureport_server_config_destroy(&config); ++ free_map_string(settings); ++ ++ /* auth with unknown uReport_AuthDataItems */ ++ ureport_server_config_init(&config); ++ ++ settings = new_map_string(); ++ ++ setenv("uReport_AuthDataItems", "hostname, unknown", 1); ++ ++ ureport_server_config_load(&config, settings); ++ ++ ureport = ureport_from_dump_dir_ext("./test", &config.ur_prefs); ++ assert(strstr(ureport, "auth") != NULL); ++ assert(strstr(ureport, "\"hostname\": \"env_hostname\"") != NULL); ++ assert(strstr(ureport, "unknown") == NULL); ++ free(ureport); ++ ++ ureport_server_config_destroy(&config); ++ free_map_string(settings); ++ delete_dump_dir("./test"); ++ ++ return 0; ++} ++]]) ++ +diff --git a/tests/ureport/certs/correct/cert-key.pem b/tests/ureport/certs/correct/cert-key.pem +new file mode 100644 +index 0000000..1516328 +--- /dev/null ++++ b/tests/ureport/certs/correct/cert-key.pem +@@ -0,0 +1,5 @@ ++-----BEGIN RSA PRIVATE KEY----- ++rsa ++private ++key ++-----END RSA PRIVATE KEY----- +diff --git a/tests/ureport/certs/correct/cert.pem b/tests/ureport/certs/correct/cert.pem +new file mode 100644 +index 0000000..ee54de3 +--- /dev/null ++++ b/tests/ureport/certs/correct/cert.pem +@@ -0,0 +1,13 @@ ++-----BEGIN CERTIFICATE----- ++cer ++tifica ++te ++-----END CERTIFICATE----- ++-----BEGIN ENTITLEMENT DATA----- ++entitlement ++data ++-----END ENTITLEMENT DATA----- ++-----BEGIN RSA SIGNATURE----- ++rsa ++signature ++-----END RSA SIGNATURE----- +diff --git a/tests/ureport/certs/incorrect_content/cert-key.pem b/tests/ureport/certs/incorrect_content/cert-key.pem +new file mode 100644 +index 0000000..1516328 +--- /dev/null ++++ b/tests/ureport/certs/incorrect_content/cert-key.pem +@@ -0,0 +1,5 @@ ++-----BEGIN RSA PRIVATE KEY----- ++rsa ++private ++key ++-----END RSA PRIVATE KEY----- +diff --git a/tests/ureport/certs/incorrect_content/cert.pem b/tests/ureport/certs/incorrect_content/cert.pem +new file mode 100644 +index 0000000..e69de29 +diff --git a/tests/ureport/rhsm/__init__.py b/tests/ureport/rhsm/__init__.py +new file mode 100644 +index 0000000..e69de29 +diff --git a/tests/ureport/rhsm/config.py b/tests/ureport/rhsm/config.py +new file mode 100644 +index 0000000..44483d8 +--- /dev/null ++++ b/tests/ureport/rhsm/config.py +@@ -0,0 +1,8 @@ ++import os ++ ++def initConfig(): ++ return myConfig() ++ ++class myConfig(): ++ def get(self, key, value): ++ return os.path.abspath("../../ureport/certs/correct") +-- +2.1.0 + diff --git a/0009-testsuite-changed-atlocal.in-to-work-with-last-commi.patch b/0009-testsuite-changed-atlocal.in-to-work-with-last-commi.patch new file mode 100644 index 0000000..c9c6c0d --- /dev/null +++ b/0009-testsuite-changed-atlocal.in-to-work-with-last-commi.patch @@ -0,0 +1,33 @@ +From 7dc7f62c8ca4189255417dbf88083df7d4461c50 Mon Sep 17 00:00:00 2001 +From: Matej Habrnal +Date: Wed, 22 Oct 2014 00:17:28 +0200 +Subject: [PATCH] testsuite: changed atlocal.in to work with last commit + +Added special library libreport-web.la and CFLAGS DEFAULT_DUMP_DIR_MODE. + +Signed-off-by: Matej Habrnal +--- + tests/atlocal.in | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tests/atlocal.in b/tests/atlocal.in +index 5150b21..1a82edb 100644 +--- a/tests/atlocal.in ++++ b/tests/atlocal.in +@@ -6,10 +6,10 @@ CC='@CC@' + LIBTOOL="$abs_top_builddir/libtool" + + # We want no optimization. +-CFLAGS="@O0CFLAGS@ -I$abs_top_builddir/src/include -I$abs_top_builddir/src/lib -I$abs_top_builddir/src/gtk-helpers -D_GNU_SOURCE @GLIB_CFLAGS@ @GTK_CFLAGS@" ++CFLAGS="@O0CFLAGS@ -I$abs_top_builddir/src/include -I$abs_top_builddir/src/lib -I$abs_top_builddir/src/gtk-helpers -D_GNU_SOURCE @GLIB_CFLAGS@ @GTK_CFLAGS@ -DDEFAULT_DUMP_DIR_MODE=@DEFAULT_DUMP_DIR_MODE@" + + # Are special link options needed? +-LDFLAGS="@LDFLAGS@ $abs_top_builddir/src/lib/libreport.la $abs_top_builddir/src/gtk-helpers/libreport-gtk.la" ++LDFLAGS="@LDFLAGS@" + + # Are special libraries needed? +-LIBS="@LIBS@" ++LIBS="@LIBS@ $abs_top_builddir/src/lib/libreport.la $abs_top_builddir/src/gtk-helpers/libreport-gtk.la $abs_top_builddir/src/lib/libreport-web.la" +-- +2.1.0 + diff --git a/0010-ureport-allow-multiple-cert-file-in-rhsm-entitlement.patch b/0010-ureport-allow-multiple-cert-file-in-rhsm-entitlement.patch new file mode 100644 index 0000000..9d94b01 --- /dev/null +++ b/0010-ureport-allow-multiple-cert-file-in-rhsm-entitlement.patch @@ -0,0 +1,100 @@ +From a9e2277e8c717db2ebef46db700806e40359a8c0 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 22 Oct 2014 08:00:39 +0200 +Subject: [PATCH] ureport: allow multiple cert file in rhsm-entitlement dir + +Thanks Martin Milata + +https://bugzilla.redhat.com/show_bug.cgi?id=1140224#c6 + +Related to #1140224 +Fixes #296 + +Signed-off-by: Jakub Filak +--- + src/lib/ureport.c | 54 +++++++++++++++++++++++------------------------------- + 1 file changed, 23 insertions(+), 31 deletions(-) + +diff --git a/src/lib/ureport.c b/src/lib/ureport.c +index 731b96c..3c7a935 100644 +--- a/src/lib/ureport.c ++++ b/src/lib/ureport.c +@@ -102,52 +102,44 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + ureport_server_config_set_url(config, xstrdup(RHSM_WEB_SERVICE_URL)); + + GList *certs = get_file_list(RHSMENT_PEM_DIR_PATH, "pem"); +- if (g_list_length(certs) != 2) ++ if (g_list_length(certs) < 2) + { ++ g_list_free_full(certs, (GDestroyNotify)free_file_obj); ++ + log_notice(RHSMENT_PEM_DIR_PATH" does not contain unique cert-key files pair"); + log_notice("Not using client authentication"); + return; + } + +- const char *cert = NULL; +- const char *key = NULL; +- +- file_obj_t *fst = (file_obj_t *)certs->data; +- file_obj_t *scn = (file_obj_t *)certs->next->data; +- +- if (strlen(fo_get_filename(fst)) < strlen(fo_get_filename(scn))) ++ /* Use the last non-key file found. */ ++ file_obj_t *cert = NULL; ++ for (GList *iter = certs; iter != NULL; iter = g_list_next(iter)) + { +- cert = fo_get_filename(fst); +- key = fo_get_filename(scn); ++ file_obj_t *tmp = (file_obj_t *)iter->data; ++ const char *file_name = fo_get_filename(tmp); + +- config->ur_client_cert = xstrdup(fo_get_fullpath(fst)); +- config->ur_client_key = xstrdup(fo_get_fullpath(scn)); ++ if (suffixcmp(file_name, "-key")) ++ cert = tmp; + } +- else ++ ++ if (cert == NULL) + { +- cert = fo_get_filename(scn); +- key = fo_get_filename(fst); ++ g_list_free_full(certs, (GDestroyNotify)free_file_obj); + +- config->ur_client_cert = xstrdup(fo_get_fullpath(scn)); +- config->ur_client_key = xstrdup(fo_get_fullpath(fst)); ++ log_notice(RHSMENT_PEM_DIR_PATH" contains only key files"); ++ log_notice("Not using client authentication"); ++ return; + } + +- const bool iscomplement = prefixcmp(key, cert) != 0 || strcmp("-key", key + strlen(cert)) != 0; +- g_list_free_full(certs, (GDestroyNotify)free_file_obj); ++ config->ur_client_cert = xstrdup(fo_get_fullpath(cert)); ++ /* Yes, the key file may not exists. I over took this code from ++ * sos-uploader and they are pretty happy with this approach, so why ++ * shouldn't we?. */ ++ config->ur_client_key = xasprintf("%s/%s-key.pem", RHSMENT_PEM_DIR_PATH, fo_get_filename(cert)); + +- if (iscomplement) +- { +- log_notice("Key file '%s' isn't complement to cert file '%s'", +- config->ur_client_key, config->ur_client_cert); +- log_notice("Not using client authentication"); +- +- free(config->ur_client_cert); +- free(config->ur_client_key); +- config->ur_client_cert = NULL; +- config->ur_client_key = NULL; ++ log_debug("Using cert files: '%s' : '%s'", config->ur_client_cert, config->ur_client_key); + +- return; +- } ++ g_list_free_full(certs, (GDestroyNotify)free_file_obj); + + char *certdata = xmalloc_open_read_close(config->ur_client_cert, /*no size limit*/NULL); + if (certdata != NULL) +-- +2.1.0 + diff --git a/0011-ureport-use-entit-certs-with-rhsm-and-drop-rhsm-enti.patch b/0011-ureport-use-entit-certs-with-rhsm-and-drop-rhsm-enti.patch new file mode 100644 index 0000000..080dc5b --- /dev/null +++ b/0011-ureport-use-entit-certs-with-rhsm-and-drop-rhsm-enti.patch @@ -0,0 +1,84 @@ +From c901c734ff5840ed3005f05af9711a7b20cc38fb Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 22 Oct 2014 08:12:44 +0200 +Subject: [PATCH] ureport: use entit certs with 'rhsm' and drop + 'rhsm-entitlement' + +/etc/pki/consumer certificates cannot be used for authentication in +Strata. Martin Milata has correctly pointed out that it does not make +sense to have both 'rhsm' and 'rhsm-entitlement' options. + +Related #1140224 + +Signed-off-by: Jakub Filak +--- + doc/reporter-ureport.txt | 6 ++---- + src/lib/ureport.c | 11 ----------- + src/plugins/ureport.conf | 4 +--- + 3 files changed, 3 insertions(+), 18 deletions(-) + +diff --git a/doc/reporter-ureport.txt b/doc/reporter-ureport.txt +index f31dd45..a69c7ae 100644 +--- a/doc/reporter-ureport.txt ++++ b/doc/reporter-ureport.txt +@@ -35,10 +35,8 @@ Configuration file lines should have 'PARAM = VALUE' format. The parameters are: + Possible values are: + + 'rhsm';; +- Uses the system certificate that is used for Red Hat subscription management. +- +- 'rhsm-entitlement';; +- Same as 'rhsm' but uses the V3 RHSM entitlement certificates. ++ Uses the system V3 entitlement certificate that is used for Red Hat ++ subscription management. + + 'puppet';; + Uses the certificate that is used by the Puppet configuration management tool. +diff --git a/src/lib/ureport.c b/src/lib/ureport.c +index 3c7a935..d6c3ead 100644 +--- a/src/lib/ureport.c ++++ b/src/lib/ureport.c +@@ -31,9 +31,6 @@ + + #define RHSM_WEB_SERVICE_URL "https://api.access.redhat.com/rs/telemetry/abrt" + +-#define RHSM_CERT_PATH "/etc/pki/consumer/cert.pem" +-#define RHSM_KEY_PATH "/etc/pki/consumer/key.pem" +- + #define RHSMENT_PEM_DIR_PATH "/etc/pki/entitlement" + #define RHSMENT_ENT_DATA_BEGIN_TAG "-----BEGIN ENTITLEMENT DATA-----" + #define RHSMENT_ENT_DATA_END_TAG "-----END ENTITLEMENT DATA-----" +@@ -93,14 +90,6 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + if (config->ur_url == NULL) + ureport_server_config_set_url(config, xstrdup(RHSM_WEB_SERVICE_URL)); + +- config->ur_client_cert = xstrdup(RHSM_CERT_PATH); +- config->ur_client_key = xstrdup(RHSM_KEY_PATH); +- } +- else if (strcmp(client_auth, "rhsm-entitlement") == 0) +- { +- if (config->ur_url == NULL) +- ureport_server_config_set_url(config, xstrdup(RHSM_WEB_SERVICE_URL)); +- + GList *certs = get_file_list(RHSMENT_PEM_DIR_PATH, "pem"); + if (g_list_length(certs) < 2) + { +diff --git a/src/plugins/ureport.conf b/src/plugins/ureport.conf +index a3aa456..da00990 100644 +--- a/src/plugins/ureport.conf ++++ b/src/plugins/ureport.conf +@@ -22,10 +22,8 @@ + # 'IncludeAuthData' to 'yes'. + # None (default): + # SSLClientAuth = +-# Using RH subscription management certificate: +-# SSLClientAuth = rhsm + # Using RH subscription management entitlement certificate: +-# SSLClientAuth = rhsm-entitlement ++# SSLClientAuth = rhsm + # Using Puppet certificate: + # SSLClientAuth = puppet + # Using custom certificate: +-- +2.1.0 + diff --git a/0012-ureport-get-rhsm-entitlement-cert-dir-from-rhsm-conf.patch b/0012-ureport-get-rhsm-entitlement-cert-dir-from-rhsm-conf.patch new file mode 100644 index 0000000..06d2b8a --- /dev/null +++ b/0012-ureport-get-rhsm-entitlement-cert-dir-from-rhsm-conf.patch @@ -0,0 +1,106 @@ +From 5abe5538f971ae33795e106af23b25e1d07ea1b0 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 22 Oct 2014 14:27:00 +0200 +Subject: [PATCH] ureport: get rhsm entitlement cert dir from rhsm conf + +Related #1140224 + +Signed-off-by: Jakub Filak +--- + src/lib/ureport.c | 46 +++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 41 insertions(+), 5 deletions(-) + +diff --git a/src/lib/ureport.c b/src/lib/ureport.c +index d6c3ead..83eb1b1 100644 +--- a/src/lib/ureport.c ++++ b/src/lib/ureport.c +@@ -31,7 +31,6 @@ + + #define RHSM_WEB_SERVICE_URL "https://api.access.redhat.com/rs/telemetry/abrt" + +-#define RHSMENT_PEM_DIR_PATH "/etc/pki/entitlement" + #define RHSMENT_ENT_DATA_BEGIN_TAG "-----BEGIN ENTITLEMENT DATA-----" + #define RHSMENT_ENT_DATA_END_TAG "-----END ENTITLEMENT DATA-----" + #define RHSMENT_SIG_DATA_BEGIN_TAG "-----BEGIN RSA SIGNATURE-----" +@@ -68,6 +67,33 @@ ureport_server_config_set_url(struct ureport_server_config *config, + config->ur_url = server_url; + } + ++static char * ++rhsm_config_get_entitlement_cert_dir(void) ++{ ++ char *result = getenv("LIBREPORT_DEBUG_RHSMENT_PEM_DIR_PATH"); ++ if (result != NULL) ++ return xstrdup(result); ++ ++ result = run_in_shell_and_save_output(0, ++ "python -c \"from rhsm.config import initConfig; print(initConfig().get('rhsm', 'entitlementCertDir'))\"", ++ NULL, NULL); ++ ++ /* run_in_shell_and_save_output always returns non-NULL */ ++ if (result[0] != '/') ++ goto error; ++ ++ char *newline = strchrnul(result, '\n'); ++ if (!newline) ++ goto error; ++ ++ *newline = '\0'; ++ return result; ++error: ++ error_msg("Failed to get 'rhsm':'entitlementCertDir' from rhsm.config python module."); ++ free(result); ++ return NULL; ++} ++ + void + ureport_server_config_set_client_auth(struct ureport_server_config *config, + const char *client_auth) +@@ -90,13 +116,21 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + if (config->ur_url == NULL) + ureport_server_config_set_url(config, xstrdup(RHSM_WEB_SERVICE_URL)); + +- GList *certs = get_file_list(RHSMENT_PEM_DIR_PATH, "pem"); ++ char *rhsm_dir = rhsm_config_get_entitlement_cert_dir(); ++ if (rhsm_dir == NULL) ++ { ++ log_notice("Not using client authentication"); ++ return; ++ } ++ ++ GList *certs = get_file_list(rhsm_dir, "pem"); + if (g_list_length(certs) < 2) + { + g_list_free_full(certs, (GDestroyNotify)free_file_obj); + +- log_notice(RHSMENT_PEM_DIR_PATH" does not contain unique cert-key files pair"); ++ log_notice("'%s' does not contain a cert-key files pair", rhsm_dir); + log_notice("Not using client authentication"); ++ free(rhsm_dir); + return; + } + +@@ -115,8 +149,9 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + { + g_list_free_full(certs, (GDestroyNotify)free_file_obj); + +- log_notice(RHSMENT_PEM_DIR_PATH" contains only key files"); ++ log_notice("'%s' does not contain a cert file (only keys)", rhsm_dir); + log_notice("Not using client authentication"); ++ free(rhsm_dir); + return; + } + +@@ -124,7 +159,8 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + /* Yes, the key file may not exists. I over took this code from + * sos-uploader and they are pretty happy with this approach, so why + * shouldn't we?. */ +- config->ur_client_key = xasprintf("%s/%s-key.pem", RHSMENT_PEM_DIR_PATH, fo_get_filename(cert)); ++ config->ur_client_key = xasprintf("%s/%s-key.pem", rhsm_dir, fo_get_filename(cert)); ++ free(rhsm_dir); + + log_debug("Using cert files: '%s' : '%s'", config->ur_client_cert, config->ur_client_key); + +-- +2.1.0 + diff --git a/0013-ureport-consistently-die-on-all-client-auth-errors.patch b/0013-ureport-consistently-die-on-all-client-auth-errors.patch new file mode 100644 index 0000000..72d20b4 --- /dev/null +++ b/0013-ureport-consistently-die-on-all-client-auth-errors.patch @@ -0,0 +1,78 @@ +From 3461f0e3d59e051da6507b1a1ac2530067c7f02b Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 22 Oct 2014 09:16:48 +0200 +Subject: [PATCH] ureport: consistently die on all client auth errors + +Related #1140224 + +Signed-off-by: Jakub Filak +--- + src/lib/ureport.c | 25 ++++--------------------- + 1 file changed, 4 insertions(+), 21 deletions(-) + +diff --git a/src/lib/ureport.c b/src/lib/ureport.c +index 83eb1b1..d39709d 100644 +--- a/src/lib/ureport.c ++++ b/src/lib/ureport.c +@@ -89,9 +89,8 @@ rhsm_config_get_entitlement_cert_dir(void) + *newline = '\0'; + return result; + error: +- error_msg("Failed to get 'rhsm':'entitlementCertDir' from rhsm.config python module."); + free(result); +- return NULL; ++ error_msg_and_die("Failed to get 'rhsm':'entitlementCertDir' from rhsm.config python module."); + } + + void +@@ -117,21 +116,12 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + ureport_server_config_set_url(config, xstrdup(RHSM_WEB_SERVICE_URL)); + + char *rhsm_dir = rhsm_config_get_entitlement_cert_dir(); +- if (rhsm_dir == NULL) +- { +- log_notice("Not using client authentication"); +- return; +- } + + GList *certs = get_file_list(rhsm_dir, "pem"); + if (g_list_length(certs) < 2) + { + g_list_free_full(certs, (GDestroyNotify)free_file_obj); +- +- log_notice("'%s' does not contain a cert-key files pair", rhsm_dir); +- log_notice("Not using client authentication"); +- free(rhsm_dir); +- return; ++ error_msg_and_die("'%s' does not contain a cert-key files pair", rhsm_dir); + } + + /* Use the last non-key file found. */ +@@ -148,11 +138,7 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + if (cert == NULL) + { + g_list_free_full(certs, (GDestroyNotify)free_file_obj); +- +- log_notice("'%s' does not contain a cert file (only keys)", rhsm_dir); +- log_notice("Not using client authentication"); +- free(rhsm_dir); +- return; ++ error_msg_and_die("'%s' does not contain a cert file (only keys)", rhsm_dir); + } + + config->ur_client_cert = xstrdup(fo_get_fullpath(cert)); +@@ -188,10 +174,7 @@ ureport_server_config_set_client_auth(struct ureport_server_config *config, + xasprintf(RHSMENT_SIG_DATA_BEGIN_TAG"%s"RHSMENT_SIG_DATA_END_TAG, sig_data)); + } + else +- { +- log_notice("Cert file '%s' doesn't contain Entitlement and RSA Signature sections", config->ur_client_cert); +- log_notice("Not using HTTP authentication headers"); +- } ++ error_msg_and_die("Cert file '%s' doesn't contain Entitlement and RSA Signature sections", config->ur_client_cert); + + free(sig_data); + free(ent_data); +-- +2.1.0 + diff --git a/0014-rhtsupport-never-use-uReport-URL-from-ureport.config.patch b/0014-rhtsupport-never-use-uReport-URL-from-ureport.config.patch new file mode 100644 index 0000000..7977868 --- /dev/null +++ b/0014-rhtsupport-never-use-uReport-URL-from-ureport.config.patch @@ -0,0 +1,57 @@ +From 7f97600ab8f814fb8446536b9708ddb90b576284 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 22 Oct 2014 10:21:07 +0200 +Subject: [PATCH] rhtsupport: never use uReport URL from ureport.config + +The GUI reporter always export uReport_URL, thus reporter-rhtsupport +never use the Strata URL. + +Moreover, usage of uReport_URL is really bad idea, because a reporter +thinks he is going to send data to the portal but the ureport might end +somewhere else. + +Related #1139987 + +Signed-off-by: Jakub Filak +--- + src/plugins/reporter-rhtsupport.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c +index 9a1f392..4b74c5c 100644 +--- a/src/plugins/reporter-rhtsupport.c ++++ b/src/plugins/reporter-rhtsupport.c +@@ -383,18 +383,18 @@ void prepare_ureport_configuration(const char *urcfile, + load_conf_file(urcfile, settings, false); + ureport_server_config_init(urconf); + +- char *url = NULL; +- UREPORT_OPTION_VALUE_FROM_CONF(settings, "URL", url, xstrdup); +- if (url == NULL) +- { +- ureport_server_config_set_url(urconf, concat_path_file(portal_url, "/telemetry/abrt")); +- urconf->ur_ssl_verify = ssl_verify; +- } +- else +- { +- ureport_server_config_set_url(urconf, url); +- UREPORT_OPTION_VALUE_FROM_CONF(settings, "SSLVerify", urconf->ur_ssl_verify, string_to_bool); +- } ++ /* The following lines cause that we always use URL from ureport's ++ * configuration becuase the GUI reporter always exports uReport_URL env ++ * var. ++ * ++ * char *url = NULL; ++ * UREPORT_OPTION_VALUE_FROM_CONF(settings, "URL", url, xstrdup); ++ * if (url != NULL) ++ * ureport_server_config_set_url(urconf, url); ++ */ ++ ++ ureport_server_config_set_url(urconf, concat_path_file(portal_url, "/telemetry/abrt")); ++ urconf->ur_ssl_verify = ssl_verify; + + ureport_server_config_set_basic_auth(urconf, login, password); + +-- +2.1.0 + diff --git a/0015-rhtsupport-do-not-leak-the-hints-results.patch b/0015-rhtsupport-do-not-leak-the-hints-results.patch new file mode 100644 index 0000000..dfc18d9 --- /dev/null +++ b/0015-rhtsupport-do-not-leak-the-hints-results.patch @@ -0,0 +1,53 @@ +From 256a8e48db14512357f8e1412018a88b3003bbce Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 22 Oct 2014 11:09:43 +0200 +Subject: [PATCH] rhtsupport: do not leak the hints results + +The leak was introduced in commit +5ff7f36c1a06f5317241b43999f4f03a21594c79 + +Related to rhbz#1139987 + +Signed-off-by: Jakub Filak +--- + src/plugins/reporter-rhtsupport.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c +index 4b74c5c..add0d6b 100644 +--- a/src/plugins/reporter-rhtsupport.c ++++ b/src/plugins/reporter-rhtsupport.c +@@ -275,6 +275,7 @@ void attach_to_ureport(struct ureport_server_config *conf, + static + bool check_for_hints(const char *url, char **login, char **password, bool ssl_verify, const char *tempfile) + { ++ bool retval = false; + rhts_result_t *result = NULL; + + INVALID_CREDENTIALS_LOOP((*login), (*password), +@@ -317,14 +318,18 @@ bool check_for_hints(const char *url, char **login, char **password, bool ssl_ve + hint = append_to_malloced_string(hint, + _("Do you still want to create a RHTSupport ticket?") + ); +- int create_ticket = ask_yes_no(hint); ++ ++ /* ++ * 'Yes' to the create ticket question means no hints were found. ++ */ ++ retval = !ask_yes_no(hint); ++ + free(hint); +- if (!create_ticket) +- return true; + } + } ++ + free_rhts_result(result); +- return false; ++ return retval; + } + + static +-- +2.1.0 + diff --git a/0017-ureport-fall-back-to-the-hardcoded-rhsm-cert-dir.patch b/0017-ureport-fall-back-to-the-hardcoded-rhsm-cert-dir.patch new file mode 100644 index 0000000..f70764f --- /dev/null +++ b/0017-ureport-fall-back-to-the-hardcoded-rhsm-cert-dir.patch @@ -0,0 +1,42 @@ +From 323ddb510c031a631ba294fc549b22a83d4159bb Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Thu, 23 Oct 2014 11:30:14 +0200 +Subject: [PATCH] ureport: fall back to the hardcoded rhsm cert dir + +This commit adds a fallback execution path for cases where getting the +rhsm entitlement dir path via an execution of python from the +librepor-web library fails for any reason. + +See commit 2b20c9f91342da7744ae40ee623735ab95f83219 +Related #1140224 + +Signed-off-by: Jakub Filak +--- + src/lib/ureport.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/lib/ureport.c b/src/lib/ureport.c +index d39709d..868bb4f 100644 +--- a/src/lib/ureport.c ++++ b/src/lib/ureport.c +@@ -31,6 +31,7 @@ + + #define RHSM_WEB_SERVICE_URL "https://api.access.redhat.com/rs/telemetry/abrt" + ++#define RHSMENT_PEM_DIR_PATH "/etc/pki/entitlement" + #define RHSMENT_ENT_DATA_BEGIN_TAG "-----BEGIN ENTITLEMENT DATA-----" + #define RHSMENT_ENT_DATA_END_TAG "-----END ENTITLEMENT DATA-----" + #define RHSMENT_SIG_DATA_BEGIN_TAG "-----BEGIN RSA SIGNATURE-----" +@@ -90,7 +91,8 @@ rhsm_config_get_entitlement_cert_dir(void) + return result; + error: + free(result); +- error_msg_and_die("Failed to get 'rhsm':'entitlementCertDir' from rhsm.config python module."); ++ error_msg("Failed to get 'rhsm':'entitlementCertDir' from rhsm.config python module. Using "RHSMENT_PEM_DIR_PATH); ++ return xstrdup(RHSMENT_PEM_DIR_PATH); + } + + void +-- +2.1.0 + diff --git a/0018-ureport-wrong-description-of-two-functions-in-urepor.patch b/0018-ureport-wrong-description-of-two-functions-in-urepor.patch new file mode 100644 index 0000000..1b5a7ef --- /dev/null +++ b/0018-ureport-wrong-description-of-two-functions-in-urepor.patch @@ -0,0 +1,41 @@ +From 49651673afe704d5911ba29404390958dbc7ee05 Mon Sep 17 00:00:00 2001 +From: Matej Habrnal +Date: Wed, 22 Oct 2014 01:32:33 +0200 +Subject: [PATCH] ureport: wrong description of two functions in ureport.h + +Changed wrong description of function ureport_attach_string and +ureport_attach_int. Both of these functions returns True in case of any error +(not False). + +fixes #298 + +Signed-off-by: Matej Habrnal +--- + src/include/ureport.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/include/ureport.h b/src/include/ureport.h +index 104e8d0..852ee0e 100644 +--- a/src/include/ureport.h ++++ b/src/include/ureport.h +@@ -233,7 +233,7 @@ ureport_json_attachment_new(const char *bthash, const char *type, const char *da + * @param type Type of attachment + * @param data Attached data + * @param config Configuration used in communication +- * @return False in case of any error; otherwise True ++ * @return True in case of any error; otherwise False + */ + #define ureport_attach_string libreport_ureport_attach_string + bool +@@ -247,7 +247,7 @@ ureport_attach_string(const char *bthash, const char *type, const char *data, + * @param type Type of attachment + * @param data Attached data + * @param config Configuration used in communication +- * @return False in case of any error; otherwise True ++ * @return True in case of any error; otherwise False + */ + #define ureport_attach_int libreport_ureport_attach_int + bool +-- +2.1.0 + diff --git a/0019-ureport-fix-a-memory-leak-related-to-AuthDataItems.patch b/0019-ureport-fix-a-memory-leak-related-to-AuthDataItems.patch new file mode 100644 index 0000000..0270c24 --- /dev/null +++ b/0019-ureport-fix-a-memory-leak-related-to-AuthDataItems.patch @@ -0,0 +1,27 @@ +From 70f0b9bbfb297cdcd1eb56162d9cbe9ca832f84f Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Fri, 31 Oct 2014 09:27:33 +0100 +Subject: [PATCH] ureport: fix a memory leak related to AuthDataItems + +Related to rhbz#1139557 + +Signed-off-by: Jakub Filak +--- + src/lib/ureport.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/lib/ureport.c b/src/lib/ureport.c +index 868bb4f..9c007fe 100644 +--- a/src/lib/ureport.c ++++ b/src/lib/ureport.c +@@ -640,6 +640,7 @@ ureport_from_dump_dir_ext(const char *dump_dir_path, const struct ureport_prefer + } + + sr_report_add_auth(report, key, value); ++ free(value); + } + + dd_close(dd); +-- +2.1.0 + diff --git a/0020-doc-fix-asciidoc-misrendering.patch b/0020-doc-fix-asciidoc-misrendering.patch new file mode 100644 index 0000000..dbd380c --- /dev/null +++ b/0020-doc-fix-asciidoc-misrendering.patch @@ -0,0 +1,31 @@ +From d4dfba834acb573a5040c0a26a07d59f59551214 Mon Sep 17 00:00:00 2001 +From: Martin Milata +Date: Mon, 3 Nov 2014 12:26:01 +0100 +Subject: [PATCH] doc: fix asciidoc misrendering + +http://www.methods.co.nz/asciidoc/chunked/ch21.html#X77 + +Signed-off-by: Martin Milata +--- + doc/reporter-upload.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/doc/reporter-upload.txt b/doc/reporter-upload.txt +index 40a8694..8acf798 100644 +--- a/doc/reporter-upload.txt ++++ b/doc/reporter-upload.txt +@@ -54,9 +54,9 @@ OPTIONS + + -u URL:: + The URL where tarball should be uploaded. +- URL should have form protocol://[user[:pass]@]host/dir/[file.tar.gz] ++ URL should have the form protocol://[user[:pass]@]host/dir/[file.tar.gz] + where protocol can be http(s), ftp, scp, or file. +- File protocol can't have user and host parts: file:///dir/[file.tar.gz]. ++ File protocol can't have user and host parts: pass:[file:///dir/[file.tar.gz]]. + If URL ends with a slash, the archive name will be generated and appended + to URL; otherwise, URL will be used as full file name. + +-- +2.1.0 + diff --git a/0021-testsuite-add-tests-ureport-to-EXTRA_DIST.patch b/0021-testsuite-add-tests-ureport-to-EXTRA_DIST.patch new file mode 100644 index 0000000..1636eac --- /dev/null +++ b/0021-testsuite-add-tests-ureport-to-EXTRA_DIST.patch @@ -0,0 +1,26 @@ +From 6ccff130d77158005128cbf6c00267f8a386a5a2 Mon Sep 17 00:00:00 2001 +From: Martin Milata +Date: Tue, 4 Nov 2014 16:22:41 +0100 +Subject: [PATCH] testsuite: add tests/ureport/ to EXTRA_DIST + +Otherwise make rpm fails. +--- + tests/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index cda9375..1cfc206 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -49,7 +49,7 @@ TESTSUITE = $(srcdir)/testsuite + MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) + check_DATA = atconfig atlocal $(TESTSUITE) + DISTCLEANFILES = atconfig +-EXTRA_DIST += atlocal.in conf ++EXTRA_DIST += atlocal.in conf ureport + + atconfig: $(top_builddir)/config.status + (cd ${top_builddir} && ./config.status ${subdir}/atconfig) +-- +2.1.0 + diff --git a/0022-ureport-use-rhsm-ssl-client-auth-by-default.patch b/0022-ureport-use-rhsm-ssl-client-auth-by-default.patch new file mode 100644 index 0000000..e2fabd4 --- /dev/null +++ b/0022-ureport-use-rhsm-ssl-client-auth-by-default.patch @@ -0,0 +1,32 @@ +From fb554038d9bc692d99fbd6eace61979dc48a8b93 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Mon, 3 Nov 2014 15:51:32 +0100 +Subject: [PATCH] ureport: use 'rhsm' ssl client auth by default + +libreport used to be configured to use 'rhsm' by default and I (Jakub +Filak ) inappropriately changed it to no ssl +client auth in commit 4f61f5d9eec75e471c8176dac0c21f4361e40ee6 + +Related to rhbz#1140224 + +Signed-off-by: Jakub Filak +--- + src/plugins/ureport.conf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/plugins/ureport.conf b/src/plugins/ureport.conf +index da00990..75c4893 100644 +--- a/src/plugins/ureport.conf ++++ b/src/plugins/ureport.conf +@@ -23,7 +23,7 @@ + # None (default): + # SSLClientAuth = + # Using RH subscription management entitlement certificate: +-# SSLClientAuth = rhsm ++SSLClientAuth = rhsm + # Using Puppet certificate: + # SSLClientAuth = puppet + # Using custom certificate: +-- +2.1.0 + diff --git a/0023-ureport-be-able-to-configure-ContactEmail-from-GUI.patch b/0023-ureport-be-able-to-configure-ContactEmail-from-GUI.patch new file mode 100644 index 0000000..5b65f91 --- /dev/null +++ b/0023-ureport-be-able-to-configure-ContactEmail-from-GUI.patch @@ -0,0 +1,35 @@ +From 07118b21e400670b91093cafc677395fc59b88b4 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Mon, 3 Nov 2014 15:59:26 +0100 +Subject: [PATCH] ureport: be able to configure ContactEmail from GUI + +reporter-rhtsupport reads uReport_ContactEmail configuration option +before attaching the contact email to uReport. It is likely that users +will run the reporter from the GUI, so they must be able to configure +the reporter from the GUI too. + +Related to rhbz#1150388 + +Signed-off-by: Jakub Filak +--- + src/plugins/report_uReport.xml.in | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/plugins/report_uReport.xml.in b/src/plugins/report_uReport.xml.in +index a02f484..1147880 100644 +--- a/src/plugins/report_uReport.xml.in ++++ b/src/plugins/report_uReport.xml.in +@@ -20,6 +20,10 @@ + <_note-html>Adds your Bugzilla login to CC List of already reported bugs. + yes + ++ + + ++ +