Return a closure that checks if the current user owns a path.
()
| 100 | |
| 101 | |
| 102 | def _check_user_owns_path(): |
| 103 | """Return a closure that checks if the current user owns a path.""" |
| 104 | |
| 105 | def fn(path): |
| 106 | import os |
| 107 | |
| 108 | try: |
| 109 | st = os.stat(path) |
| 110 | uid = os.getuid() |
| 111 | return f"owner:{st.st_uid} me:{uid} match:{st.st_uid == uid}" |
| 112 | except OSError as e: |
| 113 | return f"ERROR:{e}" |
| 114 | |
| 115 | return fn |
| 116 | |
| 117 | |
| 118 | # ============================================================================= |
no outgoing calls
no test coverage detected