#include <cynara-creds-gdbus.h>
#include "ac-internal.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RPC_PORT"
+#include "log-private.hh"
namespace rpc_port {
namespace internal {
appid_ = appid;
}
- LOGD("CheckCertificate : %s :: %s", appid_.c_str(), sender_appid);
+ _D("CheckCertificate : %s :: %s", appid_.c_str(), sender_appid);
pkgmgrinfo_cert_compare_result_type_e res;
int ret = pkgmgrinfo_pkginfo_compare_usr_app_cert_info(appid_.c_str(),
sender_appid, getuid(), &res);
if (ret < 0) {
- LOGE("CheckCertificate() Failed");
+ _E("CheckCertificate() Failed");
return -1;
}
if (res != PMINFO_CERT_COMPARE_MATCH) {
- LOGE("CheckCertificate() Failed : Certificate Not Matched");
+ _E("CheckCertificate() Failed : Certificate Not Matched");
return -1;
}
cynara* cynara_inst = nullptr;
if (cynara_initialize(&cynara_inst, NULL) != CYNARA_API_SUCCESS) {
- LOGE("cynara_initialize() is failed"); // LCOV_EXL_LINE
+ _E("cynara_initialize() is failed"); // LCOV_EXL_LINE
} else {
cynara_.reset(cynara_inst);
}
int ret = cynara_creds_gdbus_get_user(connection, sender, USER_METHOD_DEFAULT,
&user);
if (ret != CYNARA_API_SUCCESS) {
- LOGE("cynara_creds_gdbus_get_user() is failed : %d", ret); // LCOV_EXCL_LINE
+ _E("cynara_creds_gdbus_get_user() is failed : %d", ret); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
user_.reset(user);
ret = cynara_creds_gdbus_get_client(connection, sender, CLIENT_METHOD_DEFAULT,
&client);
if (ret != CYNARA_API_SUCCESS) {
- LOGE("cynara_creds_gdbus_get_client() is failed : %d", ret); // LCOV_EXCL_LINE
+ _E("cynara_creds_gdbus_get_client() is failed : %d", ret); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
client_.reset(client);
- LOGD("cred client : %s, cred user : %s", client_.get(), user_.get());
+ _D("cred client : %s, cred user : %s", client_.get(), user_.get());
return 0;
}
int AccessController::Cynara::Check(const std::string& privilege) const {
- LOGD("check privilege %s", privilege.c_str());
+ _D("check privilege %s", privilege.c_str());
if (cynara_check(cynara_.get(), client_.get(), "", user_.get(),
privilege.c_str()) != CYNARA_API_ACCESS_ALLOWED) {
- LOGE("cynara_check() is not allowed : %s", privilege.c_str());
+ _E("cynara_check() is not allowed : %s", privilege.c_str());
return -1;
}
#include <algorithm>
#include "fdbroker-internal.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RPC_PORT"
+#include "log-private.hh"
#define EILLEGALACCESS 127
if (gdbus_conn_ == nullptr) {
// LCOV_EXCL_START
if (error != nullptr) {
- LOGE("Failed to get dbus [%s]", error->message);
+ _E("Failed to get dbus [%s]", error->message);
g_error_free(error);
}
if (aul_rpc_port_create_socket_pair(target_appid.c_str(),
port_name.c_str(), &socks_) != AUL_R_OK) {
- LOGE("error create socket pair"); // LCOV_EXCL_LINE
+ _E("error create socket pair"); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
close(fd);
if (err != NULL) {
- LOGE("g_unix_fd_list_append [%s]", err->message); // LCOV_EXCL_LINE
+ _E("g_unix_fd_list_append [%s]", err->message); // LCOV_EXCL_LINE
g_error_free(err); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
LOGI("FdBroker::Cancel!");
if (cancellable_) {
- LOGW("Cancel the send request");
+ _W("Cancel the send request");
g_cancellable_cancel(cancellable_);
g_object_unref(cancellable_);
cancellable_ = nullptr;
if (!mock_ && aul_app_get_appid_bypid(getpid(),
sender_appid, sizeof(sender_appid)) < 0) {
- LOGE("Can't get appid"); // LCOV_EXCL_LINE
+ _E("Can't get appid"); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
RPC_PORT_OBJECT_PATH,
interface_name.c_str(), "send_message");
if (!msg) {
- LOGE("Can't allocate new method call"); // LCOV_EXCL_LINE
+ _E("Can't allocate new method call"); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
cancellable_ = g_cancellable_new();
if (!cancellable_) {
- LOGE("Failed to create GCancellable"); // LCOV_EXCL_LINE
+ _E("Failed to create GCancellable"); // LCOV_EXCL_LINE
g_object_unref(msg); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
res_data_ = CreateWeakPtr();
if (res_data_ == nullptr) {
- LOGE("Failed to create weak ptr");
+ _E("Failed to create weak ptr");
g_object_unref(msg);
return -1;
}
if (!mock_) {
ret = aul_app_get_appid_bypid(getpid(), sender_appid, sizeof(sender_appid));
if (ret != AUL_R_OK) {
- LOGE("Failed to get application ID. ret(%d)", ret);
+ _E("Failed to get application ID. ret(%d)", ret);
return -1;
}
}
GDBusMessage* msg = g_dbus_message_new_method_call(interface_name.c_str(),
RPC_PORT_OBJECT_PATH, interface_name.c_str(), "send_message");
if (msg == nullptr) {
- LOGE("g_dbus_message_new_method_call() is failed");
+ _E("g_dbus_message_new_method_call() is failed");
return -1;
}
break;
if (reply == nullptr) {
- LOGE("g_dbus_connection_send_message_with_reply_sync() is failed");
+ _E("g_dbus_connection_send_message_with_reply_sync() is failed");
if (err) {
- LOGE("error(%s)", err->message);
+ _E("error(%s)", err->message);
g_error_free(err);
}
} else if (g_dbus_message_to_gerror(reply, &err)) {
- LOGE("error(%s) was set", err->message);
+ _E("error(%s) was set", err->message);
g_error_free(err);
g_object_unref(reply);
}
if (try_sleep_time.tv_nsec > (MAX_SLEEP * BASE_SLEEP))
try_sleep_time.tv_nsec = MAX_SLEEP * BASE_SLEEP;
- LOGD("Retry");
+ _D("Retry");
} while (max_timeout > 0);
if (max_timeout <= 0) {
- LOGE("Timed out");
+ _E("Timed out");
return -1;
}
GVariant* reply_body = g_dbus_message_get_body(reply);
if (reply_body == nullptr) {
- LOGE("g_dbus_message_get_body() is failed");
+ _E("g_dbus_message_get_body() is failed");
g_object_unref(reply);
return -1;
}
g_variant_get(reply_body, "(i)", &ret);
if (ret != 0) {
- LOGE("Access Denied[sender_appid: %s, result: %d]", sender_appid, ret);
+ _E("Access Denied[sender_appid: %s, result: %d]", sender_appid, ret);
g_object_unref(reply);
return -EILLEGALACCESS;
}
- LOGD("[Reply: %d]", ret);
+ _D("[Reply: %d]", ret);
(*fds)[0] = main_sock_pair.Detach(SocketPair::SENDER);
(*fds)[1] = delegate_sock_pair.Detach(SocketPair::SENDER);
returned_fds = g_unix_fd_list_steal_fds(fd_list, &fd_len);
if (returned_fds == nullptr || fd_len != 2) {
- LOGE("fail to get fds. fd_len(%d)", fd_len); // LCOV_EXCL_LINE
+ _E("fail to get fds. fd_len(%d)", fd_len); // LCOV_EXCL_LINE
return; // LCOV_EXCL_LINE
}
auto* ptr = static_cast<std::weak_ptr<FdBroker>*>(user_data);
auto broker = ptr->lock();
if (broker == nullptr) {
- LOGE("broker is nullptr");
+ _E("broker is nullptr");
return;
}
std::lock_guard<std::recursive_mutex> lock(broker->GetMutex());
if (broker->registration_id_ == 0) {
- LOGE("Invalid context. FdBroker(%p)", broker.get());
+ _E("Invalid context. FdBroker(%p)", broker.get());
return;
}
&error);
if (error) {
- LOGE("RequestName fail : %s", error->message); // LCOV_EXCL_LINE
+ _E("RequestName fail : %s", error->message); // LCOV_EXCL_LINE
g_error_free(error); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
if (result == nullptr) {
- LOGE("fail to get name NULL"); // LCOV_EXCL_LINE
+ _E("fail to get name NULL"); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
g_variant_get(result, "(u)", &owner_id);
if (owner_id == 0) {
- LOGE("Acquiring the own name is failed"); // LCOV_EXCL_LINE
+ _E("Acquiring the own name is failed"); // LCOV_EXCL_LINE
g_variant_unref(result); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}
- LOGD("Acquiring the own name : %d", owner_id);
+ _D("Acquiring the own name : %d", owner_id);
g_variant_unref(result);
return owner_id;
"/org/freedesktop/DBus", "org.freedesktop.DBus",
"GetConnectionUnixProcessID");
if (!msg) {
- LOGE("Can't allocate new method call"); // LCOV_EXCL_LINE
+ _E("Can't allocate new method call"); // LCOV_EXCL_LINE
goto out; // LCOV_EXCL_LINE
}
if (!reply) {
// LCOV_EXCL_START
if (err != NULL) {
- LOGE("Failed to get pid [%s]", err->message);
+ _E("Failed to get pid [%s]", err->message);
g_error_free(err);
}
goto out;
GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(
introspection_xml.c_str(), nullptr);
if (!introspection_data) {
- LOGE("g_dbus_node_info_new_for_xml() is failed.");
+ _E("g_dbus_node_info_new_for_xml() is failed.");
return -1;
}
auto broker = CreateWeakPtr();
if (broker == nullptr) {
- LOGE("Failed to create weak ptr");
+ _E("Failed to create weak ptr");
return -1;
}
g_dbus_node_info_unref(introspection_data);
if (registration_id_ == 0) {
- LOGE("Failed to g_dbus_connection_register_object");
+ _E("Failed to g_dbus_connection_register_object");
return -1;
}
if (GetOwnerId(interface_name) < 0) {
- LOGE("Failed to get owner id");
+ _E("Failed to get owner id");
return -1;
}
int FdBroker::Listen(IEventListener* ev, const std::string& port_name) {
if (listener_ != nullptr) {
- LOGE("listener_ is not NULL"); // LCOV_EXCL_LINE
+ _E("listener_ is not NULL"); // LCOV_EXCL_LINE
return RPC_PORT_ERROR_INVALID_PARAMETER; // LCOV_EXCL_LINE
}
if (ev == nullptr) {
- LOGE("ev is NULL"); // LCOV_EXCL_LINE
+ _E("ev is NULL"); // LCOV_EXCL_LINE
return RPC_PORT_ERROR_INVALID_PARAMETER; // LCOV_EXCL_LINE
}
int ret = RegisterDbusInterface(port_name);
if (ret != 0) {
- LOGE("Failed to register dbus interface"); // LCOV_EXCL_LINE
+ _E("Failed to register dbus interface"); // LCOV_EXCL_LINE
return RPC_PORT_ERROR_IO_ERROR; // LCOV_EXCL_LINE
}
auto* ptr = static_cast<std::weak_ptr<FdBroker>*>(user_data);
auto broker = ptr->lock();
if (broker == nullptr) {
- LOGE("broker is nullptr");
+ _E("broker is nullptr");
return;
}
std::lock_guard<std::recursive_mutex> lock(broker->GetMutex());
if (broker->watcher_id_ == 0) {
- LOGE("Invalid context. FdBroker(%p)", broker.get());
+ _E("Invalid context. FdBroker(%p)", broker.get());
return;
}
if (aul_app_get_appid_bypid(pid, owner_appid, sizeof(owner_appid)) < 0) {
// LCOV_EXCL_START
- LOGE("aul_app_get_appid_bypid failed %d", pid);
+ _E("aul_app_get_appid_bypid failed %d", pid);
broker->watcher_->OnPortRejected(RPC_PORT_ERROR_IO_ERROR);
return;
// LCOV_EXCL_STOP
if (broker->watch_appid_ != owner_appid) {
// LCOV_EXCL_START
- LOGE("invalid appid %s", owner_appid);
+ _E("invalid appid %s", owner_appid);
broker->watcher_->OnPortRejected(RPC_PORT_ERROR_IO_ERROR);
return;
// LCOV_EXCL_STOP
auto* ptr = static_cast<std::weak_ptr<FdBroker>*>(user_data);
auto broker = ptr->lock();
if (broker == nullptr) {
- LOGE("broker is nullptr");
+ _E("broker is nullptr");
return;
}
std::lock_guard<std::recursive_mutex> lock(broker->GetMutex());
if (broker->watcher_id_ == 0) {
- LOGE("Invalid context. FdBroker(%p)", broker.get());
+ _E("Invalid context. FdBroker(%p)", broker.get());
return;
}
if (watcher_id_ > 0) {
// LCOV_EXCL_START
g_bus_unwatch_name(watcher_id_);
- LOGD("Retry to watch name. stub %s:%s",
+ _D("Retry to watch name. stub %s:%s",
target_appid.c_str(), port_name.c_str());
// LCOV_EXCL_STOP
}
auto broker = CreateWeakPtr();
if (broker == nullptr) {
- LOGE("Failed to create weak ptr");
+ _E("Failed to create weak ptr");
return -1;
}
DestroyWeakPtr);
if (watcher_id_ == 0) {
// LCOV_EXCL_START
- LOGE("Failed to watch connection(%s)", interface_name.c_str());
+ _E("Failed to watch connection(%s)", interface_name.c_str());
watcher_ = nullptr;
return -1;
// LCOV_EXCL_STOP
port_name.c_str());
if (ret != AUL_R_OK) {
// LCOV_EXCL_START
- LOGE("Failed to prepare stub %s:%s [ret : %d]",
+ _E("Failed to prepare stub %s:%s [ret : %d]",
target_appid.c_str(), port_name.c_str(), ret);
if (ret == AUL_R_EILLACC)
return -EILLEGALACCESS;
void FdBroker::OnResultReceived(GObject* source_object,
GAsyncResult* res,
gpointer user_data) {
- LOGW("OnResultReceived()");
+ _W("OnResultReceived()");
GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(source_object);
GError* err = nullptr;
GDBusMessage* reply = g_dbus_connection_send_message_with_reply_finish(conn,
if (err && err->code == G_IO_ERROR_CANCELLED) {
g_error_free(err);
- LOGE("IO error cancelled");
+ _E("IO error cancelled");
return;
}
auto* ptr = static_cast<std::weak_ptr<FdBroker>*>(user_data);
auto broker = ptr->lock();
if (broker == nullptr) {
- LOGE("broker is nullptr");
+ _E("broker is nullptr");
return;
}
std::lock_guard<std::recursive_mutex> lock(broker->GetMutex());
if (broker->cancellable_ == nullptr) {
- LOGE("Invalid context. Fdbroker(%p)", broker.get());
+ _E("Invalid context. Fdbroker(%p)", broker.get());
return;
}
watcher->OnPortDisconnected(true);
g_error_free(err);
if (broker->cancellable_) {
- LOGW("Cancel the send request");
+ _W("Cancel the send request");
g_cancellable_cancel(broker->cancellable_);
g_object_unref(broker->cancellable_);
broker->cancellable_ = nullptr;
}
if (reply == nullptr) {
- LOGW("Null reply"); // LCOV_EXCL_LINE
+ _W("Null reply"); // LCOV_EXCL_LINE
return; // LCOV_EXCL_LINE
}
GVariant* reply_body = g_dbus_message_get_body(reply);
if (reply_body == nullptr) {
// LCOV_EXCL_START
- LOGE("g_dbus_message_get_body() is failed");
+ _E("g_dbus_message_get_body() is failed");
watcher->OnPortDisconnected();
g_object_unref(reply);
return;
g_variant_get(reply_body, "(i)", &ret);
g_object_unref(reply);
if (ret != 0) {
- LOGE("Access Denied[sender_appid : %s]", broker->watch_appid_.c_str());
+ _E("Access Denied[sender_appid : %s]", broker->watch_appid_.c_str());
watcher->OnPortRejected(RPC_PORT_ERROR_PERMISSION_DENIED);
return;
}
watcher->OnPortConnected();
- LOGD("[Reply : %d]", ret);
+ _D("[Reply : %d]", ret);
}
gboolean FdBroker::OnDbusNameTimeout(gpointer user_data) {
auto* ptr = static_cast<std::weak_ptr<FdBroker>*>(user_data);
auto broker = ptr->lock();
if (broker == nullptr) {
- LOGE("broker is nullptr");
+ _E("broker is nullptr");
return G_SOURCE_REMOVE;
}
std::lock_guard<std::recursive_mutex> lock(broker->GetMutex());
if (broker->conn_data_ == nullptr) {
- LOGE("Invalid context. FdBroker(%p)", broker.get());
+ _E("Invalid context. FdBroker(%p)", broker.get());
return G_SOURCE_REMOVE;
}
void FdBroker::SetConnTimer() {
if (conn_data_) {
- LOGW("Already exists");
+ _W("Already exists");
return;
}
conn_data_ = CreateWeakPtr();
if (conn_data_ == nullptr)
- LOGE("Out of memory");
+ _E("Out of memory");
g_timeout_add(10 * 1000, OnDbusNameTimeout, conn_data_);
}
#include <aul_rpc_port.h>
#include <glib-unix.h>
-#include "rpc-port.h"
+#include "log-private.hh"
#include "port-internal.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RPC_PORT"
+#include "rpc-port.h"
#define MAX_CNT 100
#define MAX_SLEEP 100
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (fd_ < 0 || fd_ >= sysconf(_SC_OPEN_MAX)) {
- LOGE("Invalid fd(%d)", fd_);
+ _E("Invalid fd(%d)", fd_);
return RPC_PORT_ERROR_IO_ERROR;
}
while (left) {
nb = read(fd_, buffer, left);
if (nb == 0) {
- LOGE("read_socket: ...read EOF, socket closed %d: nb %zd\n", fd_, nb);
+ _E("read_socket: ...read EOF, socket closed %d: nb %zd\n", fd_, nb);
return RPC_PORT_ERROR_IO_ERROR;
} else if (nb == -1) {
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
nanosleep(&TRY_SLEEP_TIME, 0);
max_timeout -= (TRY_SLEEP_TIME.tv_nsec / (BASE_SLEEP));
if (max_timeout <= 0) {
- LOGE("read_socket: ...timed out fd %d: errno %d", fd_, errno);
+ _E("read_socket: ...timed out fd %d: errno %d", fd_, errno);
return RPC_PORT_ERROR_IO_ERROR;
}
TRY_SLEEP_TIME.tv_nsec *= 2;
continue;
}
- LOGE("read_socket: ...error fd %d: errno %d\n", fd_, errno);
+ _E("read_socket: ...error fd %d: errno %d\n", fd_, errno);
return RPC_PORT_ERROR_IO_ERROR;
}
}
if (delayed_message_size_ > QUEUE_SIZE_MAX) {
- LOGE("cache fail : delayed_message_size (%d), count(%zu)",
+ _E("cache fail : delayed_message_size (%d), count(%zu)",
delayed_message_size_, queue_.size());
return RPC_PORT_ERROR_IO_ERROR;
}
const char* buffer = static_cast<const char*>(buf);
if (fd_ < 0 || fd_ >= sysconf(_SC_OPEN_MAX)) {
- LOGE("Invalid fd(%d)", fd_);
+ _E("Invalid fd(%d)", fd_);
return PORT_STATUS_ERROR_IO_ERROR;
}
if (errno == EAGAIN || errno == EWOULDBLOCK)
return PORT_STATUS_ERROR_RESOURCE_UNAVAILABLE;
- LOGE("write_socket: ...error fd %d: errno %d\n", fd_, errno);
+ _E("write_socket: ...error fd %d: errno %d\n", fd_, errno);
return PORT_STATUS_ERROR_IO_ERROR;
}
}
if (left != 0) {
- LOGE("error fd %d: retry_cnt %d", fd_, retry_cnt);
+ _E("error fd %d: retry_cnt %d", fd_, retry_cnt);
return PORT_STATUS_ERROR_IO_ERROR;
}
queue_.pop();
}
- LOGW("cache : count(%zu), delayed_message_size (%d), ret(%d)",
+ _W("cache : count(%zu), delayed_message_size (%d), ret(%d)",
queue_.size(), delayed_message_size_, ret);
return ret;
}
if (queue_.empty()) {
delay_src_id_ = g_unix_fd_add(fd_, G_IO_OUT, OnEventReceived, this);
if (delay_src_id_ == 0) {
- LOGE("Failed to add watch on socket");
+ _E("Failed to add watch on socket");
return RPC_PORT_ERROR_IO_ERROR;
}
}
delayed_message_size_ += dm->GetOriginalSize();
queue_.push(dm);
- LOGW("cache : count(%zu), delayed_message_size (%d)",
+ _W("cache : count(%zu), delayed_message_size (%d)",
queue_.size(), delayed_message_size_);
return RPC_PORT_ERROR_NONE;
}