Skip to content

Commit

Permalink
Fixes #4294
Browse files Browse the repository at this point in the history
Use os.stat to ensure directory exists and pulp has read-access
return any errors received from os.stat to the user

(cherry picked from commit b552eed)
  • Loading branch information
jpasqualetto authored and patchback[bot] committed Aug 21, 2023
1 parent 9347d8a commit 9c721b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/4294.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed bug where incorrect error message presented in relation to content-import
11 changes: 7 additions & 4 deletions pulpcore/app/views/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ def _validate_file(in_param, data):
return rc, [msg]

# check directory-sanity, leave if failed
# use os.stat to ensure directory exists and pulp has read-access
# return any errors received from os.stat to the user

owning_dir = os.path.dirname(real_file)
if not os.path.exists(owning_dir):
return False, [_("directory {} does not exist").format(owning_dir)]
if not os.access(owning_dir, os.R_OK):
return False, [_("directory {} does not allow read-access").format(owning_dir)]
try:
os.stat(owning_dir)
except OSError as e:
return False, [_("{}").format(e)]

# check file-exists, leave if failed
if not os.path.exists(real_file):
Expand Down

0 comments on commit 9c721b5

Please sign in to comment.