[Lldb-commits] [PATCH] D78712: [lldb/Host] Improve error messages on unowned read files

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 23 07:32:11 PDT 2020


mib created this revision.
mib added reviewers: JDevlieghere, labath.
mib added a project: LLDB.
Herald added subscribers: lldb-commits, emaste.
mib marked an inline comment as done.
mib added inline comments.
mib edited the summary of this revision.


================
Comment at: lldb/test/API/commands/target/basic/TestTargetCommand.py:343
+    def test_target_create_unowned_core_file(self):
+        self.expect("target create -c ~root", error=True,
+                    substrs=["core file '", "' is not readable"])
----------------
Currently, I try to open the root user home directory, since I sure it's not readable by other users on UNIX systems.

I went this route, because doing a `os.chown` requires privileges, and the test suites doesn't run in a privileged mode.

I'm open to suggestions on how I could test this on different platforms.


When trying to read a core file that is not owned by the user running lldb
and that doesn't have read permission on the file, we can a misleading
error message

  Unable to find process plug-in for core file

This is due to the fact that currently, lldb doesn't check the file
ownership. And when trying to to open and read a core file, the syscall
fails, which prevents a process to be created.

This patch introduces the `FileSystem::ReadableByCurrentUser` method
that checks if the file has readable permissions and its ownership.
This patch also changes the error messages to be more accurate.

rdar://42630030

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78712

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/test/API/commands/target/basic/TestTargetCommand.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78712.259557.patch
Type: text/x-patch
Size: 6137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200423/3a67eb0c/attachment-0001.bin>


More information about the lldb-commits mailing list