rpm: Add support for SQLite RPM databases (#6939)

This commit is contained in:
Teddy Reed 2021-02-06 08:48:04 -05:00 committed by GitHub
parent fedc90225f
commit 1699adc387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 2 deletions

3
Vagrantfile vendored
View File

@ -54,6 +54,9 @@ targets = {
"archlinux" => { "archlinux" => {
"box" => "archlinux/archlinux" "box" => "archlinux/archlinux"
}, },
"fedora33" => {
"box" => "fedora/33-cloud-base"
},
"suse11" => { "suse11" => {
"box" => "elastic/sles-11-x86_64" "box" => "elastic/sles-11-x86_64"
}, },

View File

@ -10,6 +10,7 @@ function(librpmMain)
set(rpm_library_srcs set(rpm_library_srcs
"${library_root}/lib/backend/bdb_ro.c" "${library_root}/lib/backend/bdb_ro.c"
"${library_root}/lib/backend/sqlite.c"
"${library_root}/lib/backend/dbi.c" "${library_root}/lib/backend/dbi.c"
"${library_root}/lib/backend/dummydb.c" "${library_root}/lib/backend/dummydb.c"
"${library_root}/lib/backend/dbiset.c" "${library_root}/lib/backend/dbiset.c"
@ -161,6 +162,7 @@ function(librpmMain)
endif() endif()
target_link_libraries(thirdparty_librpm PUBLIC target_link_libraries(thirdparty_librpm PUBLIC
thirdparty_sqlite
thirdparty_openssl thirdparty_openssl
thirdparty_zlib thirdparty_zlib
thirdparty_libmagic thirdparty_libmagic

View File

@ -36,7 +36,7 @@ export LDFLAGS="${CFLAGS} -L$OPENSSL_LINK -L$LIBMAGIC_LINK -L$POPT_LINK"
export CC=clang export CC=clang
./autogen.sh ./autogen.sh
./configure --enable-static --with-crypto=openssl --without-archive --enable-bdb --enable-bdb-ro --without-lua --disable-plugins --disable-openmp ./configure --enable-static --with-crypto=openssl --without-archive --enable-bdb --enable-bdb-ro --enable_sqlite --without-lua --disable-plugins --disable-openmp
``` ```
Then copy Then copy

View File

@ -407,7 +407,7 @@
/* #undef WITH_SELINUX */ /* #undef WITH_SELINUX */
/* Define if SQLITE is available */ /* Define if SQLITE is available */
/* #undef WITH_SQLITE */ #define WITH_SQLITE 1
/* Enable large inode numbers on Mac OS X 10.5. */ /* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE #ifndef _DARWIN_USE_64_BIT_INODE

View File

@ -158,5 +158,43 @@ TEST_F(RpmTests, test_bdb_packages) {
EXPECT_EQ(expected, packages); EXPECT_EQ(expected, packages);
}; };
TEST_F(RpmTests, test_sqlite_packages) {
auto dropper = DropPrivileges::get();
if (isUserAdmin()) {
ASSERT_TRUE(dropper->dropTo("nobody"));
}
auto sqlite_config = getTestConfigDirectory() / "rpm" / "rpm-sqlite";
sqlite_config = boost::filesystem::absolute(sqlite_config);
this->setConfig(sqlite_config.string());
std::vector<struct PackageDetails> packages;
auto getPackage = [&packages](struct PackageDetails& pd) {
packages.push_back(pd);
};
ASSERT_TRUE(queryRpmDb(getPackage).ok());
std::vector<struct PackageDetails> expected = {
{"deltarpm", "3.6.2", "b94aeacccb128594c1c385a19a36b7237fd7bd55"},
{"python3-rpm", "4.16.0", "cb4fd19975ffb22a6c67fa1ced0dd98cf039e2c3"},
{"rpm", "4.16.0", "f1b7a4ad5d2497a44039ba20a2e83e7e60d52472"},
{"rpm-build-libs", "4.16.0", "0e964be137e7489228e91d16d16ade7a38474bce"},
{"rpm-libs", "4.16.0", "4eb167bef01b1c0684f870ef791ec4de3db96ca2"},
{"rpm-plugin-selinux",
"4.16.0",
"2118e44fbdbdcd7bbf8306630bf03c289a6401cc"},
{"rpm-plugin-systemd-inhibit",
"4.16.0",
"74890e714d68b144750b5529617361b4a4f64430"},
{"rpm-sign-libs", "4.16.0", "01c6d988e05b320c9620e66b8bda57b8dd1749fe"},
{"systemd-rpm-macros",
"246.6",
"50805b7fdfeef333d918a0da76c636e7ef182e36"},
};
EXPECT_EQ(expected, packages);
};
} // namespace tables } // namespace tables
} // namespace osquery } // namespace osquery

Binary file not shown.

Binary file not shown.