- Change retrying count to 250.
- Check whether the stub is system daemon or not
- Fix a bug about delegate invocation
Change-Id: I49b36eb990957dabaa29d462b74e6c32df501c93
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
#include <aul.h>
#include <aul_rpc_port.h>
#include <aul_proc.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <memory>
namespace rpc_port {
namespace internal {
+const uid_t kRegularUidMin = 5000;
+
std::string Aul::GetName(int pid) {
char* name = nullptr;
if (aul_proc_get_name(pid, &name) != AUL_R_OK) return "";
}
std::string Aul::GetAppId(int pid) {
- char app_id[256] = { 0, };
- int ret = aul_app_get_appid_bypid(pid, app_id, sizeof(app_id));
- if (ret != AUL_R_OK) {
- // LCOV_EXCL_START
- _E("aul_app_get_appid_bypid() is failed. pid(%d), error(%d)", pid, ret);
- return GetName(pid);
- // LCOV_EXCL_STOP
+ if (getuid() >= kRegularUidMin) {
+ char app_id[256] = { 0, };
+ int ret = aul_app_get_appid_bypid(pid, app_id, sizeof(app_id));
+ if (ret == AUL_R_OK) return std::string(app_id);
}
- return std::string(app_id);
+ return GetName(pid);
}
std::string Aul::GetPortPath(const std::string& app_id,
bool Proxy::WaitUntilPortCreation() {
file_monitor_.reset(new FileMonitor(port_path_));
- int retry_count = rpc_port_get_timeout() / 1000;
+ int retry_count = rpc_port_get_timeout() / 100;
do {
if (file_monitor_->Exist()) return true;
IEvent* listener, bool is_delegate)
: Port(read_fd, write_fd, std::move(id)),
listener_(listener),
- is_delegate_(is_delegate) {}
+ is_delegate_(is_delegate) {
+ if (read_fd > -1)
+ Watch(read_fd);
+}
ProxyPort::~ProxyPort() { GLib::SourceDestroy(source_); }
}
int Stub::CreatePort() {
- if (getenv("AUL_APPID") == nullptr) {
- std::string name = Aul::GetName(getpid());
+ const char* appid = getenv("AUL_APPID");
+ if (getuid() < kRegularUidMin || appid == nullptr) {
+ std::string name = appid ? appid : Aul::GetName(getpid());
if (!name.empty()) {
port_path_ = Aul::GetPortPath(name, GetPortName(), getuid());
int fd = GetFdFromSystemd();
void Stub::CheckPermission(const std::shared_ptr<Request>& request,
const std::shared_ptr<ClientSocket>& client,
const std::shared_ptr<PeerCred>& cred) {
- std::string app_id = Aul::GetAppId(cred->GetPid());
+ std::string app_id;
+ if (cred->GetUid() >= kRegularUidMin) app_id = Aul::GetAppId(cred->GetPid());
auto response_func = [=](int res) -> void {
if (freed_stubs_.find(this) != freed_stubs_.end())
return; // LCOV_EXCL_LINE