ret = cynara_creds_gdbus_get_client(conn, sender, CLIENT_METHOD_DEFAULT,
&client);
if (ret != CYNARA_API_SUCCESS) {
+ if (user)
+ free(user);
LOG(ERROR) << "cynara_creds_gdbus_get_client() failed: " << ret;
return SecurityManager::Credentials();
}
ret = cynara_creds_gdbus_get_pid(conn, sender, &pid);
if (ret != CYNARA_API_SUCCESS) {
+ if (user)
+ free(user);
+ if (client)
+ free(client);
LOG(ERROR) << "cynara_creds_gdbus_get_pid() failed: " << ret;
return SecurityManager::Credentials();
}
return SecurityManager::Credentials(pid, client, user);
}
-DBusService::DBusService() {
+DBusService::DBusService() : owner_id_(0), sid_(0) {
node_info_ = g_dbus_node_info_new_for_xml(kDBusInstropectionXml, nullptr);
if (node_info_) {
owner_id_ = g_bus_own_name(G_BUS_TYPE_SYSTEM, kDBusServiceName,
GDBusMethodInvocation* invocation, const gchar* sender,
GDBusConnection* connection) {
LOG(INFO) << "HandleSendFile ";
- gchar* device_id;
- gchar* file_path;
+ const gchar* device_id;
+ const gchar* file_path;
std::string file_path_str;
g_variant_get(params, "(&s&s)", &device_id, &file_path);
LOG(ERROR) << "Failed to create credentials";
return false;
}
-
if (!SecurityManager::CheckFilePermission(file_path_str, c)) {
LOG(ERROR) << "File permission error: " << file_path_str;
g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", -1));
reinterpret_cast<GDBusConnection*>(g_object_ref(connection)));
file_map_.emplace(handle->file_path, handle);
-
boost::optional<int> r =
EventHandler().send_file_event(handle->device_id, handle->file_path);
if (!r) {
LOG(ERROR) << "Failed to send file";
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", -1));
return false;
}
HandleSendRemoteAppControl(parameters, invocation);
return;
} else if (g_strcmp0("SendFile", method_name) == 0) {
- r = HandleSendFile(parameters, invocation, sender, connection);
+ HandleSendFile(parameters, invocation, sender, connection);
return;
}
namespace capmgr {\r
\r
\r
-SecurityManager::Credentials::Credentials(): init_(false) {}\r
+SecurityManager::Credentials::Credentials(): init_(false), pid_(0),\r
+ user_(nullptr), smack_label_(nullptr) {}\r
\r
SecurityManager::Credentials::Credentials(int pid, const char* user,\r
const char* smack_label) {\r
pid_ = pid;\r
init_ = false;\r
- smack_label_ = strdup(smack_label);\r
- if (!smack_label_) {\r
- return;\r
- }\r
-\r
user_ = strdup(user);\r
if (!user_) {\r
- free(smack_label_);\r
smack_label_ = nullptr;\r
return;\r
}\r
\r
+ smack_label_ = strdup(smack_label);\r
+ if (!smack_label_) {\r
+ free(user_);\r
+ return;\r
+ }\r
init_ = true;\r
}\r
\r
}\r
\r
bool SecurityManager::CheckFilePermission(const std::string& file_path,\r
- SecurityManager::Credentials c) {\r
+ const SecurityManager::Credentials& c) {\r
char* real_file_path = nullptr;\r
char* file_label = nullptr;\r
int ret;\r