int Manager::createKrate(const std::string& name, const std::string& manifest)
{
- auto provisioningWorker = [name, manifest, this]() {
+ const std::string& pkgId = context.getPeerPackageId();
+
+ auto provisioningWorker = [name, manifest, pkgId, this]() {
std::unique_ptr<xml::Document> manifestFile;
try {
maskUserServices(user);
manifestFile.reset(xml::Parser::parseString(manifest));
+ //write container author info
+ if (!pkgId.empty()) {
+ std::cout << manifestFile->getRootNode().getName() << std::endl;
+ manifestFile->getRootNode().addNewChild("author").setContent(pkgId);
+ }
manifestFile->write(CONF_PATH "/" + name + ".xml", "UTF-8", true);
- //TODO: write container owner info
-
//unlock the user
setKrateState(user.getUid(), 1);
int Manager::removeKrate(const std::string& name)
{
+ const std::string& pkgId = context.getPeerPackageId();
+ std::unique_ptr<xml::Document> manifestFile;
+ bool canRemove = false;
+
+ manifestFile.reset(xml::Parser::parseFile(CONF_PATH "/" + name + ".xml"));
+ xml::Node::NodeList authors = manifestFile->evaluate("/manifest/author");
+ for (const xml::Node& author : authors) {
+ if (author.getContent() == pkgId) {
+ canRemove = true;
+ break;
+ }
+ }
+
+ if (!canRemove) {
+ return -1;
+ }
+
if (lockKrate(name) != 0) {
return -1;
}
*/
#include <functional>
+#include <aul.h>
#include <cynara-client.h>
#include <cynara-session.h>
service->stop();
}
+const std::string Server::getPeerPackageId() const
+{
+ char pkgid[PATH_MAX];
+
+ if (aul_app_get_pkgid_bypid_for_uid(getPeerPid(), pkgid, sizeof(pkgid), getPeerUid()) != AUL_R_OK) {
+ return "";
+ }
+
+ return pkgid;
+}
+
runtime::FileDescriptor Server::registerNotificationSubscriber(const std::string& name)
{
return runtime::FileDescriptor(service->subscribeNotification(name), true);