diff options
author | 2022-01-13 15:43:38 +0000 | |
---|---|---|
committer | 2022-02-21 11:29:52 +0000 | |
commit | 4fd99fd4aff341e5f4d3975e6a7bedfac76d99f7 (patch) | |
tree | 5a74dc24b529968b93bb3bddb56505cb02579f18 /jni/node-inl.h | |
parent | 57758b43515a5542ca07837df8cb7b513983f5a4 (diff) |
Fix unnecessary redaction for videos in DCIM/Camera
The MediaMetadataRetriever (MMR) attempts to convert any legacy fds
obtained from a modern fd back to a modern fd. Access control is
implemented in the FuseDaemon by checking if the caller has an fd from
the FUSE fs and if so, it simply re-opens the associated file path and
returns the original (modern) fd to the caller.
The previous implementation was conservative and always opened a
redacted fd if an equivalent fd was found on the FUSE fs.
This breaks MMR location metadata access because location will always
be redacted when the data source is a file path or fd because the FUSE
fs will have an equivalent fd by the time convertToModernFd is called.
Now, we retrieve the redaction state of the equivalent opened FUSE fd
and use that to open the returned modern fd.
Test: atest TranscodeTest && atest fuse_node_test
Bug: 205749245
Change-Id: I45670dff4e5348a3b07bf423cd1465c328ad79ea
Diffstat (limited to 'jni/node-inl.h')
-rw-r--r-- | jni/node-inl.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/jni/node-inl.h b/jni/node-inl.h index c2bb2607b..15844e3c9 100644 --- a/jni/node-inl.h +++ b/jni/node-inl.h @@ -77,6 +77,15 @@ struct dirhandle { ~dirhandle() { closedir(d); } }; +/** Represents file open result from MediaProvider */ +struct FdAccessResult { + FdAccessResult(const std::string& file_path, const bool should_redact) + : file_path(file_path), should_redact(should_redact) {} + + const std::string file_path; + const bool should_redact; +}; + // Whether inode tracking is enabled or not. When enabled, we maintain a // separate mapping from inode numbers to "live" nodes so we can detect when // we receive a request to a node that has been deleted. @@ -332,6 +341,25 @@ class node { return false; } + std::unique_ptr<FdAccessResult> CheckHandleForUid(const uid_t uid) const { + std::lock_guard<std::recursive_mutex> guard(*lock_); + + bool found_handle = false; + bool redaction_not_needed = false; + for (const auto& handle : handles_) { + if (handle->uid == uid) { + found_handle = true; + redaction_not_needed |= !handle->ri->isRedactionNeeded(); + } + } + + if (found_handle) { + return std::make_unique<FdAccessResult>(BuildPath(), !redaction_not_needed); + } + + return std::make_unique<FdAccessResult>(std::string(), false); + } + void SetName(std::string name) { std::lock_guard<std::recursive_mutex> guard(*lock_); name_ = std::move(name); |