#include <malloc.h>
#include <stdio.h>
#include <sys/capability.h>
+#include <sys/smack.h>
#include <sys/types.h>
#include <unistd.h>
+#include <filesystem>
+#include <fstream>
+#include <iostream>
+#include <string>
#include <utility>
#include <exception.hh>
SetPid(peer_cred->GetPid());
prepared_ = true;
- if (listener_ != nullptr)
+ if (listener_ != nullptr) {
+ CreateReadyFile();
listener_->OnLoaderPrepared(this);
+ }
SECURE_LOGI("Type %d loader was connected. pid: %d", GetType(), pid_);
UserTracer::Print("Type " + std::to_string(GetType()) +
HandleLoaderClientEvent(condition);
}
+void LoaderContext::CreateReadyFile() {
+ std::string path = "/run/aul/daemons/" + std::to_string(getuid()) + "/." +
+ GetLoaderName() + ".ready";
+ std::filesystem::path file_path(path);
+ if (std::filesystem::exists(file_path))
+ return;
+
+ std::ofstream file_stream(file_path);
+ if (!file_stream.is_open()) {
+ _E("Failed to create the file. path(%s)", path.c_str());
+ return;
+ }
+
+ file_stream.close();
+
+ if (smack_setlabel(path.c_str(), "*", SMACK_LABEL_ACCESS) != 0)
+ _E("smack_setlabel() is failed. path: %s, errno: %d", path.c_str(), errno);
+
+ _W("File(%s) created successfully", path.c_str());
+}
+
} // namespace launchpad