(path)
| 68 | """Return a closure that attempts to write a file and returns the result.""" |
| 69 | |
| 70 | def fn(path): |
| 71 | import os |
| 72 | |
| 73 | try: |
| 74 | with open(os.path.join(path, ".landlock-test"), "w") as f: |
| 75 | f.write("test") |
| 76 | return "OK" |
| 77 | except PermissionError: |
| 78 | return "EPERM" |
| 79 | except OSError as e: |
| 80 | return f"ERROR:{e.errno}" |
| 81 | |
| 82 | return fn |
| 83 |