Signed-off-by: Nikola Pajkovsky npajkovs@redhat.com --- inc/abrtlib.h | 6 +- lib/Utils/Makefile.am | 2 +- lib/Utils/abrt_packages.c | 44 ++++++++ lib/Utils/abrt_packages.cpp | 26 ----- lib/Utils/abrt_packages.h | 35 ++++++ src/CLI/report.cpp | 2 + src/Daemon/Daemon.cpp | 2 +- src/Daemon/Makefile.am | 2 +- src/Daemon/MiddleWare.cpp | 3 +- src/Daemon/RPM.cpp | 223 --------------------------------------- src/Daemon/RPM.h | 80 -------------- src/Daemon/rpm.c | 244 +++++++++++++++++++++++++++++++++++++++++++ src/Daemon/rpm.h | 90 ++++++++++++++++ 13 files changed, 421 insertions(+), 338 deletions(-) create mode 100644 lib/Utils/abrt_packages.c delete mode 100644 lib/Utils/abrt_packages.cpp create mode 100644 lib/Utils/abrt_packages.h delete mode 100644 src/Daemon/RPM.cpp delete mode 100644 src/Daemon/RPM.h create mode 100644 src/Daemon/rpm.c create mode 100644 src/Daemon/rpm.h
diff --git a/inc/abrtlib.h b/inc/abrtlib.h index c8025e7..57097ec 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -65,6 +65,7 @@ char* skip_non_whitespace(const char *s); #ifdef __cplusplus extern "C" { #endif + int prefixcmp(const char *str, const char *prefix); int suffixcmp(const char *str, const char *suffix); #ifdef __cplusplus @@ -116,11 +117,6 @@ char *run_in_shell_and_save_output(int flags, const char *dir, size_t *size_p);
-/* cuts the name from the NVR format: foo-1.2.3-1.el6 - returns a newly allocated string -*/ -char * get_package_name_from_NVR_or_NULL(const char* package_NVR); - unsigned long long monotonic_ns(void); unsigned long long monotonic_us(void); unsigned monotonic_sec(void); diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index 88aab4d..04211a7 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -28,7 +28,7 @@ libABRTUtils_la_SOURCES = \ backtrace.h backtrace.c \ backtrace_parser.y \ strbuf.h strbuf.c \ - abrt_packages.cpp \ + abrt_packages.c abrt_packages.h \ hooklib.h hooklib.cpp libABRTUtils_la_CPPFLAGS = \ -Wall -Werror \ diff --git a/lib/Utils/abrt_packages.c b/lib/Utils/abrt_packages.c new file mode 100644 index 0000000..d9ffe44 --- /dev/null +++ b/lib/Utils/abrt_packages.c @@ -0,0 +1,44 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "abrt_packages.h" + +/* cuts the name from the NVR format: foo-1.2.3-1.el6 + returns a newly allocated string +*/ +char* get_package_name_from_NVR_or_NULL(const char* packageNVR) +{ + char* package_name = NULL; + if (packageNVR != NULL) + { + VERB1 log("packageNVR %s", packageNVR); + package_name = xstrdup(packageNVR); + char *pos = strrchr(package_name, '-'); + if (pos != NULL) + { + *pos = 0; + pos = strrchr(package_name, '-'); + if (pos != NULL) + { + *pos = 0; + } + } + } + return package_name; +} diff --git a/lib/Utils/abrt_packages.cpp b/lib/Utils/abrt_packages.cpp deleted file mode 100644 index 4cb8724..0000000 --- a/lib/Utils/abrt_packages.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "abrtlib.h" - - -/* cuts the name from the NVR format: foo-1.2.3-1.el6 - returns a newly allocated string -*/ -char* get_package_name_from_NVR_or_NULL(const char* packageNVR) -{ - char* package_name = NULL; - if (packageNVR != NULL) - { - VERB1 log("packageNVR %s", packageNVR); - package_name = xstrdup(packageNVR); - char *pos = strrchr(package_name, '-'); - if (pos != NULL) - { - *pos = 0; - pos = strrchr(package_name, '-'); - if (pos != NULL) - { - *pos = 0; - } - } - } - return package_name; -} diff --git a/lib/Utils/abrt_packages.h b/lib/Utils/abrt_packages.h new file mode 100644 index 0000000..e6209d8 --- /dev/null +++ b/lib/Utils/abrt_packages.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef ABRT_PACKAGES_H +#define ABRT_PACKAGES_H + +#include "xfuncs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +char* get_package_name_from_NVR_or_NULL(const char* packageNVR); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp index f3b4378..96dec55 100644 --- a/src/CLI/report.cpp +++ b/src/CLI/report.cpp @@ -35,6 +35,8 @@ # define _(S) (S) #endif
+#include "abrt_packages.h" + /* Field separator for the crash report file that is edited by user. */ #define FIELD_SEP "%----"
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 86f0fce..735da5a 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -43,7 +43,7 @@ #include "debug_dump.h" #include "Daemon.h" #include "dumpsocket.h" -#include "RPM.h" +#include "rpm.h"
using namespace std;
diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index 34243b1..09f5eea 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -4,7 +4,7 @@ sbin_PROGRAMS = abrtd
abrtd_SOURCES = \ PluginManager.h PluginManager.cpp \ - RPM.h RPM.cpp \ + rpm.h rpm.c \ MiddleWare.h MiddleWare.cpp \ CrashWatcher.h CrashWatcher.cpp \ CommLayerServer.h CommLayerServer.cpp \ diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index e601038..c7ed4df 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -24,9 +24,10 @@ #include "abrt_types.h" #include "Daemon.h" #include "Settings.h" -#include "RPM.h" +#include "rpm.h" #include "debug_dump.h" #include "abrt_exception.h" +#include "abrt_packages.h" #include "comm_layer_inner.h" #include "MiddleWare.h"
diff --git a/src/Daemon/RPM.cpp b/src/Daemon/RPM.cpp deleted file mode 100644 index 976c706..0000000 --- a/src/Daemon/RPM.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - Copyright (C) 2010 ABRT team - Copyright (C) 2010 RedHat Inc - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#include "abrtlib.h" -#include "RPM.h" -#include <rpm/header.h> -#include <rpm/rpmts.h> -#include "comm_layer_inner.h" -#include <glib.h> - -/** -* A set, which contains finger prints. -*/ - -static GList *list_fingerprints = NULL; - -void rpm_init() -{ - int status = rpmReadConfigFiles((const char*)NULL, (const char*)NULL); - if (status != 0) - error_msg("error reading rc files"); - - list_fingerprints = g_list_alloc(); -} - -static void list_free(gpointer data, gpointer user_data) -{ - free(data); -} - -void rpm_destroy() -{ - rpmFreeRpmrc(); - rpmFreeCrypto(); - - g_list_foreach(list_fingerprints, list_free, NULL); - g_list_free(list_fingerprints); -} - -void rpm_load_gpgkey(const char* filename) -{ - uint8_t *pkt = NULL; - size_t pklen; - if (pgpReadPkts(filename, &pkt, &pklen) != PGPARMOR_PUBKEY) - { - free(pkt); - error_msg("Can't load public GPG key %s", filename); - return; - } - - uint8_t keyID[8]; - if (pgpPubkeyFingerprint(pkt, pklen, keyID) == 0) - { - char *fingerprint = pgpHexStr(keyID, sizeof(keyID)); - if (fingerprint != NULL) - g_list_append(list_fingerprints, fingerprint); - } - free(pkt); -} - -bool rpm_chk_fingerprint(const char* pkg) -{ - bool ret = false; - char *pgpsig = NULL; - const char *errmsg = NULL; - - rpmts ts = rpmtsCreate(); - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pkg, 0); - Header header = rpmdbNextIterator(iter); - - if (!header) - goto error; - - pgpsig = headerFormat(header, "%{SIGGPG:pgpsig}", &errmsg); - if (!pgpsig && errmsg) - { - VERB1 log("cannot get siggpg:pgpsig. reason: %s", errmsg); - goto error; - } - - { - char *pgpsig_tmp = strstr(pgpsig, " Key ID "); - if (pgpsig_tmp) - { - pgpsig_tmp += sizeof(" Key ID ") - 1; - ret = g_list_find(list_fingerprints, pgpsig_tmp) != NULL; - } - } - -error: - free(pgpsig); - rpmdbFreeIterator(iter); - rpmtsFree(ts); - return ret; -} - -/* - Checking the MD5 sum requires to run prelink to "un-prelink" the - binaries - this is considered potential security risk so we don't - use it, until we find some non-intrusive way -*/ - -/* - * Not woking, need to be rewriten - * -bool CheckHash(const char* pPackage, const char* pPath) -{ - bool ret = true; - rpmts ts = rpmtsCreate(); - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0); - Header header = rpmdbNextIterator(iter); - if (header == NULL) - goto error; - - rpmfi fi = rpmfiNew(ts, header, RPMTAG_BASENAMES, RPMFI_NOHEADER); - pgpHashAlgo hashAlgo; - std::string headerHash; - char computedHash[1024] = ""; - - while (rpmfiNext(fi) != -1) - { - if (strcmp(pPath, rpmfiFN(fi)) == 0) - { - headerHash = rpmfiFDigestHex(fi, &hashAlgo); - rpmDoDigest(hashAlgo, pPath, 1, (unsigned char*) computedHash, NULL); - ret = (headerHash != "" && headerHash == computedHash); - break; - } - } - rpmfiFree(fi); -error: - rpmdbFreeIterator(iter); - rpmtsFree(ts); - return ret; -} -*/ - -char* rpm_get_description(const char* pkg) -{ - char *dsc = NULL; - const char *errmsg = NULL; - rpmts ts = rpmtsCreate(); - - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pkg, 0); - Header header = rpmdbNextIterator(iter); - if (!header) - goto error; - - dsc = headerFormat(header, "%{SUMMARY}\n\n%{DESCRIPTION}", &errmsg); - if (!dsc && errmsg) - error_msg("cannot get summary and description. reason: %s", errmsg); - -error: - rpmdbFreeIterator(iter); - rpmtsFree(ts); - return dsc; -} - -char* rpm_get_component(const char* filename) -{ - char *ret = NULL; - char *srpm = NULL; - const char *errmsg = NULL; - - rpmts ts = rpmtsCreate(); - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, filename, 0); - Header header = rpmdbNextIterator(iter); - if (!header) - goto error; - - srpm = headerFormat(header, "%{SOURCERPM}", &errmsg); - if (!srpm && errmsg) - { - error_msg("cannot get srpm. reason: %s", errmsg); - goto error; - } - - ret = get_package_name_from_NVR_or_NULL(srpm); - free(srpm); - -error: - rpmdbFreeIterator(iter); - rpmtsFree(ts); - return ret; -} - -// caller is responsible to free returned value -char* rpm_get_package_nvr(const char* filename) -{ - char* nvr = NULL; - const char *errmsg = NULL; - - rpmts ts = rpmtsCreate(); - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, filename, 0); - Header header = rpmdbNextIterator(iter); - - if (!header) - goto error; - - nvr = headerFormat(header, "%{NAME}-%{VERSION}-%{RELEASE}", &errmsg); - if (!nvr && errmsg) - error_msg("cannot get nvr. reason: %s", errmsg); - -error: - rpmdbFreeIterator(iter); - rpmtsFree(ts); - return nvr; -} diff --git a/src/Daemon/RPM.h b/src/Daemon/RPM.h deleted file mode 100644 index 6e034d2..0000000 --- a/src/Daemon/RPM.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - RPM.h - header file for rpm database - - it implements query for local rpm database - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#ifndef RPM_H_ -#define RPM_H_ - -#include <rpm/rpmcli.h> -#include <rpm/rpmts.h> -#include <rpm/rpmdb.h> -#include <rpm/rpmpgp.h> -#include "abrt_types.h" - -/** - * Checks if an application is modified by third party. - * @param pPackage A package name. The package contains the application. - * @param pPath A path to the application. - * - * Not used. Delete? - */ -//bool CheckHash(const char* pPackage, const char* pPath); - - -void rpm_init(); - -void rpm_destroy(); - -/** - * A function, which loads one GPG public key. - * @param filename A path to the public key. - */ -void rpm_load_gpgkey(const char* filename); - -/** - * A function, which checks if package's finger print is valid. - * @param pkg A package name. - */ -bool rpm_chk_fingerprint(const char* pkg); - -/** - * Gets a package description. - * @param pkg A package name. - * @return A package description. - */ -char* rpm_get_description(const char* pkg); -/** - * Gets a package name. This package contains particular - * file. If the file doesn't belong to any package, empty string is - * returned. - * @param filename A file name. - * @return A package name (malloc'ed string) - */ -char* rpm_get_package_nvr(const char* filename); -/** - * Finds a main package for given file. This package contains particular - * file. If the file doesn't belong to any package, empty string is - * returned. - * @param filename A file name. - * @return a malloc'ed package name. Need to be freed. - */ -char* rpm_get_component(const char* filename); - -#endif diff --git a/src/Daemon/rpm.c b/src/Daemon/rpm.c new file mode 100644 index 0000000..0b1d208 --- /dev/null +++ b/src/Daemon/rpm.c @@ -0,0 +1,244 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +//#include "abrtlib.h" +#include "rpm.h" + +/** +* A set, which contains finger prints. +*/ + +static GList *list_fingerprints = NULL; + +//TODO: npajkovs: where to place it? Should it be sotred in value or query from rpm? +/* cuts the name from the NVR format: foo-1.2.3-1.el6 + returns a newly allocated string +*/ +char* get_package_name_from_NVR_or_NULL(const char* package_nvr) +{ + char* package_name = NULL; + if (package_nvr != NULL) + { + VERB1 log("package_nvr %s", package_nvr); + package_name = xstrdup(package_nvr); + char *pos = strrchr(package_name, '-'); + if (pos != NULL) + { + *pos = 0; + pos = strrchr(package_name, '-'); + if (pos != NULL) + { + *pos = 0; + } + } + } + return package_name; +} + +void rpm_init() +{ + int status = rpmReadConfigFiles((const char*)NULL, (const char*)NULL); + if (status != 0) + error_msg("error reading rc files"); + + list_fingerprints = g_list_alloc(); +} + +static void list_free(gpointer data, gpointer user_data) +{ + free(data); +} + +void rpm_destroy() +{ + rpmFreeRpmrc(); + rpmFreeCrypto(); + + g_list_foreach(list_fingerprints, list_free, NULL); + g_list_free(list_fingerprints); +} + +void rpm_load_gpgkey(const char* filename) +{ + uint8_t *pkt = NULL; + size_t pklen; + if (pgpReadPkts(filename, &pkt, &pklen) != PGPARMOR_PUBKEY) + { + free(pkt); + error_msg("Can't load public GPG key %s", filename); + return; + } + + uint8_t keyID[8]; + if (pgpPubkeyFingerprint(pkt, pklen, keyID) == 0) + { + char *fingerprint = pgpHexStr(keyID, sizeof(keyID)); + if (fingerprint != NULL) + list_fingerprints = g_list_append(list_fingerprints, fingerprint); + } + free(pkt); +} + +bool rpm_chk_fingerprint(const char* pkg) +{ + bool ret = false; + char *pgpsig = NULL; + const char *errmsg = NULL; + + rpmts ts = rpmtsCreate(); + rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pkg, 0); + Header header = rpmdbNextIterator(iter); + + if (!header) + goto error; + + pgpsig = headerFormat(header, "%{SIGGPG:pgpsig}", &errmsg); + if (!pgpsig && errmsg) + { + VERB1 log("cannot get siggpg:pgpsig. reason: %s", errmsg); + goto error; + } + + { + char *pgpsig_tmp = strstr(pgpsig, " Key ID "); + if (pgpsig_tmp) + { + pgpsig_tmp += sizeof(" Key ID ") - 1; + ret = g_list_find(list_fingerprints, pgpsig_tmp) != NULL; + } + } + +error: + free(pgpsig); + rpmdbFreeIterator(iter); + rpmtsFree(ts); + return ret; +} + +/* + Checking the MD5 sum requires to run prelink to "un-prelink" the + binaries - this is considered potential security risk so we don't + use it, until we find some non-intrusive way +*/ + +/* + * Not woking, need to be rewriten + * +bool CheckHash(const char* pPackage, const char* pPath) +{ + bool ret = true; + rpmts ts = rpmtsCreate(); + rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0); + Header header = rpmdbNextIterator(iter); + if (header == NULL) + goto error; + + rpmfi fi = rpmfiNew(ts, header, RPMTAG_BASENAMES, RPMFI_NOHEADER); + pgpHashAlgo hashAlgo; + std::string headerHash; + char computedHash[1024] = ""; + + while (rpmfiNext(fi) != -1) + { + if (strcmp(pPath, rpmfiFN(fi)) == 0) + { + headerHash = rpmfiFDigestHex(fi, &hashAlgo); + rpmDoDigest(hashAlgo, pPath, 1, (unsigned char*) computedHash, NULL); + ret = (headerHash != "" && headerHash == computedHash); + break; + } + } + rpmfiFree(fi); +error: + rpmdbFreeIterator(iter); + rpmtsFree(ts); + return ret; +} +*/ + +char* rpm_get_description(const char* pkg) +{ + char *dsc = NULL; + const char *errmsg = NULL; + rpmts ts = rpmtsCreate(); + + rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pkg, 0); + Header header = rpmdbNextIterator(iter); + if (!header) + goto error; + + dsc = headerFormat(header, "%{SUMMARY}\n\n%{DESCRIPTION}", &errmsg); + if (!dsc && errmsg) + error_msg("cannot get summary and description. reason: %s", errmsg); + +error: + rpmdbFreeIterator(iter); + rpmtsFree(ts); + return dsc; +} + +char* rpm_get_component(const char* filename) +{ + char *ret = NULL; + char *srpm = NULL; + const char *errmsg = NULL; + + rpmts ts = rpmtsCreate(); + rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, filename, 0); + Header header = rpmdbNextIterator(iter); + if (!header) + goto error; + + srpm = headerFormat(header, "%{SOURCERPM}", &errmsg); + if (!srpm && errmsg) + { + error_msg("cannot get srpm. reason: %s", errmsg); + goto error; + } + + ret = get_package_name_from_NVR_or_NULL(srpm); + free(srpm); + +error: + rpmdbFreeIterator(iter); + rpmtsFree(ts); + return ret; +} + +// caller is responsible to free returned value +char* rpm_get_package_nvr(const char* filename) +{ + char* nvr = NULL; + const char *errmsg = NULL; + + rpmts ts = rpmtsCreate(); + rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, filename, 0); + Header header = rpmdbNextIterator(iter); + + if (!header) + goto error; + + nvr = headerFormat(header, "%{NAME}-%{VERSION}-%{RELEASE}", &errmsg); + if (!nvr && errmsg) + error_msg("cannot get nvr. reason: %s", errmsg); + +error: + rpmdbFreeIterator(iter); + rpmtsFree(ts); + return nvr; +} diff --git a/src/Daemon/rpm.h b/src/Daemon/rpm.h new file mode 100644 index 0000000..9b6b339 --- /dev/null +++ b/src/Daemon/rpm.h @@ -0,0 +1,90 @@ +/* + RPM.h - header file for rpm database + - it implements query for local rpm database + + Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) + Copyright (C) 2009 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#ifndef RPM_H_ +#define RPM_H_ + +#include <rpm/rpmts.h> +#include <glib.h> +#include <rpm/rpmcli.h> +#include <rpm/rpmdb.h> +#include <rpm/rpmpgp.h> +#include <stdbool.h> + +#include "xfuncs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Checks if an application is modified by third party. + * @param pPackage A package name. The package contains the application. + * @param pPath A path to the application. + * + * Not used. Delete? + */ +//bool CheckHash(const char* pPackage, const char* pPath); + +void rpm_init(); + +void rpm_destroy(); + +/** + * A function, which loads one GPG public key. + * @param filename A path to the public key. + */ +void rpm_load_gpgkey(const char* filename); + +/** + * A function, which checks if package's finger print is valid. + * @param pkg A package name. + */ +bool rpm_chk_fingerprint(const char* pkg); + +/** + * Gets a package description. + * @param pkg A package name. + * @return A package description. + */ +char* rpm_get_description(const char* pkg); +/** + * Gets a package name. This package contains particular + * file. If the file doesn't belong to any package, empty string is + * returned. + * @param filename A file name. + * @return A package name (malloc'ed string) + */ +char* rpm_get_package_nvr(const char* filename); +/** + * Finds a main package for given file. This package contains particular + * file. If the file doesn't belong to any package, empty string is + * returned. + * @param filename A file name. + * @return a malloc'ed package name. Need to be freed. + */ +char* rpm_get_component(const char* filename); + +#ifdef __cplusplus +} +#endif + +#endif
crash-catcher@lists.fedorahosted.org