Loading init/property_service.cpp +25 −11 Original line number Diff line number Diff line Loading @@ -346,18 +346,20 @@ class SocketConnection { return result == sizeof(value); } bool GetSourceContext(std::string* source_context) const { char* c_source_context = nullptr; if (getpeercon(socket_, &c_source_context) != 0) { return false; } *source_context = c_source_context; freecon(c_source_context); return true; } int socket() { return socket_; } const ucred& cred() { return cred_; } std::string source_context() const { char* source_context = nullptr; getpeercon(socket_, &source_context); std::string result = source_context; freecon(source_context); return result; } private: bool PollIn(uint32_t* timeout_ms) { struct pollfd ufds[1]; Loading Loading @@ -570,10 +572,15 @@ static void handle_property_set_fd() { prop_name[PROP_NAME_MAX-1] = 0; prop_value[PROP_VALUE_MAX-1] = 0; std::string source_context; if (!socket.GetSourceContext(&source_context)) { PLOG(ERROR) << "Unable to set property '" << prop_name << "': getpeercon() failed"; return; } const auto& cr = socket.cred(); std::string error; uint32_t result = HandlePropertySet(prop_name, prop_value, socket.source_context(), cr, &error); uint32_t result = HandlePropertySet(prop_name, prop_value, source_context, cr, &error); if (result != PROP_SUCCESS) { LOG(ERROR) << "Unable to set property '" << prop_name << "' from uid:" << cr.uid << " gid:" << cr.gid << " pid:" << cr.pid << ": " << error; Loading @@ -592,9 +599,16 @@ static void handle_property_set_fd() { return; } std::string source_context; if (!socket.GetSourceContext(&source_context)) { PLOG(ERROR) << "Unable to set property '" << name << "': getpeercon() failed"; socket.SendUint32(PROP_ERROR_PERMISSION_DENIED); return; } const auto& cr = socket.cred(); std::string error; uint32_t result = HandlePropertySet(name, value, socket.source_context(), cr, &error); uint32_t result = HandlePropertySet(name, value, source_context, cr, &error); if (result != PROP_SUCCESS) { LOG(ERROR) << "Unable to set property '" << name << "' from uid:" << cr.uid << " gid:" << cr.gid << " pid:" << cr.pid << ": " << error; Loading Loading
init/property_service.cpp +25 −11 Original line number Diff line number Diff line Loading @@ -346,18 +346,20 @@ class SocketConnection { return result == sizeof(value); } bool GetSourceContext(std::string* source_context) const { char* c_source_context = nullptr; if (getpeercon(socket_, &c_source_context) != 0) { return false; } *source_context = c_source_context; freecon(c_source_context); return true; } int socket() { return socket_; } const ucred& cred() { return cred_; } std::string source_context() const { char* source_context = nullptr; getpeercon(socket_, &source_context); std::string result = source_context; freecon(source_context); return result; } private: bool PollIn(uint32_t* timeout_ms) { struct pollfd ufds[1]; Loading Loading @@ -570,10 +572,15 @@ static void handle_property_set_fd() { prop_name[PROP_NAME_MAX-1] = 0; prop_value[PROP_VALUE_MAX-1] = 0; std::string source_context; if (!socket.GetSourceContext(&source_context)) { PLOG(ERROR) << "Unable to set property '" << prop_name << "': getpeercon() failed"; return; } const auto& cr = socket.cred(); std::string error; uint32_t result = HandlePropertySet(prop_name, prop_value, socket.source_context(), cr, &error); uint32_t result = HandlePropertySet(prop_name, prop_value, source_context, cr, &error); if (result != PROP_SUCCESS) { LOG(ERROR) << "Unable to set property '" << prop_name << "' from uid:" << cr.uid << " gid:" << cr.gid << " pid:" << cr.pid << ": " << error; Loading @@ -592,9 +599,16 @@ static void handle_property_set_fd() { return; } std::string source_context; if (!socket.GetSourceContext(&source_context)) { PLOG(ERROR) << "Unable to set property '" << name << "': getpeercon() failed"; socket.SendUint32(PROP_ERROR_PERMISSION_DENIED); return; } const auto& cr = socket.cred(); std::string error; uint32_t result = HandlePropertySet(name, value, socket.source_context(), cr, &error); uint32_t result = HandlePropertySet(name, value, source_context, cr, &error); if (result != PROP_SUCCESS) { LOG(ERROR) << "Unable to set property '" << name << "' from uid:" << cr.uid << " gid:" << cr.gid << " pid:" << cr.pid << ": " << error; Loading