Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions scapy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@
def _probe_xdg_folder(var, default, *cf):
# type: (str, str, *str) -> Optional[pathlib.Path]
path = pathlib.Path(os.environ.get(var, default))
if not path.exists():
# ~ folder doesn't exist. Create according to spec
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
# "If, when attempting to write a file, the destination directory is
# non-existent an attempt should be made to create it with permission 0700."
try:
try:
if not path.exists():
# ~ folder doesn't exist. Create according to spec
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
# "If, when attempting to write a file, the destination directory is
# non-existent an attempt should be made to create it with permission 0700."
path.mkdir(mode=0o700, exist_ok=True)
except Exception:
# There is a gazillion ways this can fail. Most notably,
# a read-only fs.
return None
except Exception:
# There is a gazillion ways this can fail. Most notably, a read-only fs or no
# permissions to even check for folder to exist (e.x. privileges were dropped
# before scapy was started).
return None
return path.joinpath(*cf).resolve()


Expand Down
Loading