From db84e8208db19b8a93cd49bd87dd83b544ef99b6 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Tue, 10 May 2022 19:13:27 +0200 Subject: [PATCH] fix(util): support shells passing subshell fd as /dev/fd This adds support orthogonal to shells that pass subshell fd as /proc/self/fd. --- libkeyringctl/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libkeyringctl/util.py b/libkeyringctl/util.py index 4ecdd1f..79b95d0 100644 --- a/libkeyringctl/util.py +++ b/libkeyringctl/util.py @@ -162,7 +162,8 @@ def transform_fd_to_tmpfile(working_dir: Path, sources: List[Path]) -> None: sources: Paths that should be iterated and all fd's transformed to tmpfiles """ for index, source in enumerate(sources): - if str(source).startswith("/proc/self/fd"): + source_str = str(source) + if source_str.startswith("/proc/self/fd/") or source_str.startswith("/dev/fd/"): file = mkstemp(dir=working_dir, prefix=f"{source.name}", suffix=".fd")[1] with open(file, mode="wb") as f: f.write(source.read_bytes())