The API is defined in the header file sysroot-*-kos/include/component/package_manager/i_package_control.h
from the KasperskyOS SDK.
The API lets you do the following:
Information about API functions is provided in the table below.
Installing a KPA package
To install a KPA package, call the InstallPackage()
function. Using the pkgInfo
input parameter, this function receives data to verify the certificates of an installed KPA package in the InstallPackageInfo
structure. All fields of this structure are optional.
struct InstallPackageInfo {
// Full name of the KPA package external signature file.
std::filesystem::path signaturePath = "";
// Full name of the KPA package index file.
std::filesystem::path indexPath = "";
// Indicates whether to verify certificates of the installed KPA package.
bool signatureVerify = false
};
If the signatureVerify
parameter is set to true
(verify certificates of the installed KPA package) but the file names are not specified, the following default values will be used during installation of the KPA package: <package_name>.kcat
for the KPA package external signature file and <package_name>.kidx
for the KPA package index file.
Deleting a KPA package
To remove a KPA package, call the UninstallPackage()
function.
Getting information about installed KPA packages
To get the unique IDs of installed KPA packages, call the ListInstalledPackages()
function. Using the pkgUIDs
output parameter, the function returns a list of unique IDs of installed packages.
To get data on the KPA package manifest, call the GetManifest()
function. Using the manifest
output parameter, the function returns the pointer of the instance of the IPackageManifest
interface that can be used to access the KPA package manifest key values. For more details, refer to IPackageManifest interface.
Notifications about the statuses of KPA packages in a KasperskyOS-based solution
The PackageManager component implements a mechanism for notifications about the statuses of KPA packages in a KasperskyOS-based solution, thereby enabling you to track changes to their statuses. To receive notifications, you must create a notification queue by using the CreateEventQueue()
function.
To extract notifications from this queue, you must use the GetEvents()
function. Using the pkgEvents
output parameter, the function returns the status of KPA packages (since the moment when the queue was created) in the PackageEvent
structure.
struct PackageEvent
{
enum class Type
{
// KPA package was installed.
INSTALL,
// KPA package was removed.
UNINSTALL,
// Notification queue
overflowed.
OVERFLOWED,
};
// KPA package status.
Type type;
// Unique ID of the KPA package.
std::string uid;
};
To delete the notification queue, call the DestroyEventQueue()
function.
i_package_control.h functions
Function |
Information about the function |
---|---|
|
Purpose Installs a KPA package. Parameters
Returned values If successful, the function returns |
|
Purpose Removes a KPA package. Parameters
Returned values If successful, the function returns |
|
Purpose Gets the unique IDs of installed KPA packages. Parameters
Returned values If successful, the function returns |
|
Purpose Gets the pointer to the instance of the Parameters
Returned values If successful, the function returns |
|
Purpose Gets the checksum of the KPA package component file from the PackageManager component database. Parameters
Returned values If successful, the function returns |
|
Purpose Gets the contents of a KPA package component. Parameters
Returned values If successful, the function returns |
|
Purpose Creates a queue for notifications about the statuses of KPA packages. Parameters
Returned values If successful, the function returns |
|
Purpose Deletes the queue for notifications about the statuses of KPA packages. Parameters
Returned values If successful, the function returns |
|
Purpose Gets the statuses of KPA packages from the notification queue. Parameters
Returned values If successful, the function returns |
Usage example:
client.cpp
#include <component/package_manager/kos_ipc/package_manager_proxy.h>
namespace pkgmgr = package_manager;
int main(int argc, const char *argv[])
{
// ...
// Create a queue for notifications about the statuses of KPA packages.
Handle eventQueue;
if (pkgc->CreateEventQueue(eventQueue) != kos::rtl::Ok)
return EXIT_FAILURE;
// Install the KPA package named test1.
std::string uid1;
const std::string pkgName1{"test1"};
const package_manager::InstallPackageInfo pkgInfo1{"", "", true};
if (pkgc->InstallPackage(pkgName1, uid1, pkgInfo1) != kos::rtl::Ok)
return EXIT_FAILURE;
// Install the KPA package named test2.
std::string uid2;
const std::string pkgName2{"test2"};
const package_manager::InstallPackageInfo pkgInfo2{"/test2.kcat", "/test2.kidx", true};
if (pkgc->InstallPackage(pkgName2, uid2, pkgInfo2) != kos::rtl::Ok)
return EXIT_FAILURE;
// Get the pointer to the instance of the IPackageManifest
interface
// for the KPA package
named test1.
pkgmgr::IPackageManifestPtr manifest;
if (pkgc->GetManifest(uid1, manifest) != kos::rtl::Ok)
return EXIT_FAILURE;
// Get the unique IDs of installed KPA packages.
std::vector<std::string> pkgUIDs
if (pkgc->ListInstalledPackages(pkgUIDs) != kos::rtl::Ok)
return EXIT_FAILURE;
// Remove the KPA package named test1.
if (pkgc->UninstallPackage(uid1) != kos::rtl::Ok)
return EXIT_FAILURE;
// Remove the KPA package named test2.
if (pkgc->UninstallPackage(uid2) != kos::rtl::Ok)
return EXIT_FAILURE;
// Get the statuses of KPA packages from the notification queue.
std::vector<package_manager::PackageEvent> pkgEvents;
if (pkgc->GetEvents(eventQueue, pkgEvents) != kos::rtl::Ok)
return EXIT_FAILURE;
// Delete the notification queue.
if (pkgc->DestroyEventQueue(eventQueue) != kos::rtl::Ok)
return EXIT_FAILURE;
if (KnHandleClose(eventQueue) != rcOk)
return EXIT_FAILURE;
// ...
}
Page top