eznfs 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
eznfs-1.0.0/AGENTS.md ADDED
@@ -0,0 +1,644 @@
1
+ # AGENTS.md — eznfs contributor guide
2
+
3
+ This document is the technical map for humans and AI agents working on `eznfs`. It describes the implemented architecture, safety invariants, command behavior, testing expectations, and the reasons behind important design decisions.
4
+
5
+ For installation and end-user usage, see [README.md](README.md). When user-facing behavior and this document disagree, investigate the code and update both as appropriate.
6
+
7
+ ## 1. Project overview
8
+
9
+ `eznfs` is a Linux-only Python 3 CLI and interactive wizard for managing NFS entries in `/etc/fstab`. It can:
10
+
11
+ - Add a share and mount it immediately.
12
+ - Edit an existing NFS connection source.
13
+ - List NFS/NFSv4 entries.
14
+ - Remove an entry, optionally unmounting it first.
15
+ - Explain client UID/GID values that must be compatible with server-side NFS permissions.
16
+
17
+ The project keeps runtime dependencies minimal and pins Rich at `15.0.0` for its terminal UI. PyInstaller `6.22.3` is an optional build-only dependency for standalone binaries. It does not configure NFS servers, modify `/etc/exports`, install system packages, or remap client UID/GID ownership.
18
+
19
+ ### Runtime requirements
20
+
21
+ - Linux
22
+ - Python 3.10 or newer for source installs and builds
23
+ - Rich `15.0.0` for source installs; bundled in standalone binaries
24
+ - PyInstaller `6.22.3` only when building standalone binaries
25
+ - Build `1.6.1` and Twine `7.0.0` only when publishing to PyPI
26
+ - `mount.nfs` for applying NFS entries
27
+ - systemd for the preferred mount path, with a bounded direct-mount fallback for non-systemd hosts
28
+
29
+ ## 2. Repository map
30
+
31
+ ```text
32
+ eznfs.py Application logic and CLI entry point
33
+ eznfs_ui.py Rich presentation, prompts, tables, panels, and progress
34
+ eznfs.spec PyInstaller one-file console specification
35
+ build.sh Local standalone build entry point
36
+ publish.sh TestPyPI/PyPI build, check, and upload wrapper
37
+ MANIFEST.in Source-distribution file manifest
38
+ tools/build_dist.py Build, metadata, smoke tests, staging, and archive
39
+ tools/release_notes.py Changelog extraction, checksums, and release notes
40
+ tools/publish_pypi.py Isolated package builds, Twine checks, and uploads
41
+ tests/test_eznfs.py Unit, CLI, wizard, and transaction tests
42
+ tests/test_eznfs_ui.py Rich rendering and prompt tests
43
+ tests/test_release_tools.py Build/release utility tests
44
+ tests/test_publish_tools.py PyPI artifact and credential-handling tests
45
+ pyproject.toml Package metadata, entry point, and pinned dependencies
46
+ CHANGELOG.md Curated release highlights
47
+ LICENSE MIT license
48
+ screenshot-wizard.png Interactive wizard screenshot
49
+ screenshot-list.png List-command screenshot
50
+ README.md End-user installation and usage
51
+ AGENTS.md Architecture, invariants, decisions, and contributor guidance
52
+ .gitignore Generated-file and virtual-environment exclusions
53
+ ```
54
+
55
+ The project is installed into a virtual environment in editable mode:
56
+
57
+ ```bash
58
+ .venv/bin/python -m pip install -e .
59
+ .venv/bin/eznfs --help
60
+ ```
61
+
62
+ For standalone builds, install the optional build extra and run `./build.sh`. Build artifacts are host-specific and must not be committed.
63
+
64
+ ## 3. Current CLI surface
65
+
66
+ ```text
67
+ eznfs
68
+ eznfs add --server SERVER --share EXPORT --mountpoint MOUNTPOINT [options]
69
+ eznfs edit
70
+ eznfs list
71
+ eznfs remove MOUNTPOINT [options]
72
+ ```
73
+
74
+ ### `add` options
75
+
76
+ - `--type {auto,nfs,nfs4}` — defaults to `auto`, which is stored as `nfs`.
77
+ - `--profile {hard,soft}` — defaults to `hard`.
78
+ - `--user USERNAME` — selects the local account used for UID/GID guidance.
79
+ - `--allow-unresolved` — explicitly permits an unresolved hostname for offline provisioning.
80
+ - `--no-mount` — saves the entry without mounting it.
81
+ - `--dry-run` — prints the proposed configuration without changing anything.
82
+
83
+ ### `list` options
84
+
85
+ - `--no-latency` — skip TCP probes and omit the latency column.
86
+ - `--latency-timeout SECONDS` — per-attempt timeout, default `1.0`.
87
+
88
+ ### `remove` options
89
+
90
+ - `--unmount` — unmount the share before removing its fstab entry.
91
+ - `--yes` — skip interactive confirmation.
92
+ - `--dry-run` — preview removal without changing anything.
93
+
94
+ ### Root requirements
95
+
96
+ | Command | Root required? | Notes |
97
+ |---|---:|---|
98
+ | Bare `eznfs` wizard | Yes | Checked before any prompt. |
99
+ | `eznfs add` | Yes, except dry-run | Dry-run is unprivileged. |
100
+ | `eznfs edit` | Yes | Checked before the numbered menu. |
101
+ | `eznfs list` | No | Read-only. |
102
+ | `eznfs remove` | Yes to apply | Confirmation may occur before the root check. |
103
+
104
+ ## 4. Code map
105
+
106
+ Use symbol names rather than line numbers when referring to code; line numbers drift.
107
+
108
+ | Area | Key symbols | Responsibility |
109
+ |---|---|---|
110
+ | CLI parsing and dispatch | `build_parser()`, `main()` | Define commands, route arguments, translate expected errors into exit codes. |
111
+ | Terminal UI | `EznfsUI`, `ui` | Rich console, prompts, panels, tables, syntax, Markdown, status, and progress. |
112
+ | Add wizard | `run_wizard()` | Collect server, export, mount point, type, profile, and local user; preview and confirm. |
113
+ | Add transaction | `AddRequest`, `create_spec()`, `add_share()` | Validate input, modify fstab, create the mount point, reload systemd, and mount. |
114
+ | Edit wizard | `run_edit()`, `_select_edit_entry()` | Numbered NFS menu and replacement-source prompt. |
115
+ | Edit transaction | `edit_share_source()`, `_rollback_source_edit()` | Replace only `fs_spec`, mount the new source, and restore the old source on failure. |
116
+ | Listing | `list_shares()` | Display NFS entries, mount state, management marker, and optional TCP latency. |
117
+ | Network diagnostics | `LatencyResult`, `probe_tcp_latency()`, `probe_server_latencies()` | Resolve servers once, run six bounded TCP probes, cache unique hosts, and format color-coded results. |
118
+ | Removal | `remove_share()` | Confirm, optionally unmount, remove one entry, and clean up. |
119
+ | Desired configuration | `MountSpec` | Immutable representation of a generated NFS entry. |
120
+ | Parsed fstab entry | `FstabEntry` | Snapshot of raw fields plus decoded convenience properties. |
121
+ | Mutable fstab document | `FstabDocument` | Preserve original bytes and lines while adding, removing, or updating entries. |
122
+ | Validation | `normalize_server()`, `normalize_absolute_path()`, `normalize_nfs_source()`, `ensure_server_resolution()` | Validate hosts, paths, `server:/export` sources, and pre-write DNS resolution. |
123
+ | Fstab escaping | `escape_fstab_field()`, `unescape_fstab_field()` | Encode/decode fstab octal escapes, including UTF-8 byte sequences. |
124
+ | Source replacement | `replace_fstab_source_token()` | Replace only the first field while preserving spacing and inline comments. |
125
+ | Persistence | `fstab_lock()`, `_create_backup()`, `write_fstab_atomic()` | Serialize eznfs writes, back up fstab, and atomically replace it. |
126
+ | Mount/systemd | `refresh_systemd()`, `start_mount()`, `stop_mount()` | Reload units and mount/unmount with bounded execution. |
127
+ | Command execution | `run_command()`, `run_bounded()` | Run subprocesses without a shell; terminate bounded process groups on timeout. |
128
+ | User guidance | `get_invoking_user()`, `lookup_local_user()`, `print_uid_gid_checkpoint()` | Detect the invoking user and explain numeric UID/GID requirements. |
129
+ | Errors | `EznfsError`, `MountOperationError` | Expected user-facing failures and post-write mount failures. |
130
+ | Build/release | `build_distribution()`, `smoke_test_binary()`, `generate()` | PyInstaller builds, metadata, smoke tests, archives, checksums, and release notes. |
131
+ | PyPI publishing | `build_packages()`, `check_artifacts()`, `upload_artifacts()` | Isolated sdist/wheel builds, Twine validation, checksums, and token-based uploads. |
132
+
133
+ ## 5. Terminal UI architecture
134
+
135
+ `eznfs_ui.py` owns presentation only. It must not contain fstab parsing, validation, filesystem writes, or mount logic.
136
+
137
+ `EznfsUI` provides:
138
+
139
+ - A shared themed `Console` and stderr console.
140
+ - Adaptive light/dark themes selected from `EZNFS_COLOR_THEME` or `COLORFGBG`, with a dark fallback.
141
+ - Matching light/dark syntax palettes (`friendly`/`ansi_dark`).
142
+ - Plain-text fallback when stdout is not a terminal or `TERM=dumb`.
143
+ - Prompt and confirmation wrappers around Rich `Prompt` and `Confirm`.
144
+ - Panels, key/value grids, Markdown panels, and syntax blocks.
145
+ - Rich tables for list/edit views and aligned plain tables for redirected output.
146
+ - Step-based progress for known operations and spinners for indeterminate work.
147
+ - Animation only when the console is attached to a terminal.
148
+
149
+ Dynamic values must be passed as `Text` objects or otherwise escaped. Never interpolate hostnames, IPv6 addresses, paths, usernames, or fstab content into Rich markup strings. Rich markup is permitted only for static, developer-controlled labels.
150
+
151
+ The global `ui` instance is used by `eznfs.py`. Tests may mock its methods or inject in-memory consoles.
152
+
153
+ ## 6. Core data model
154
+
155
+ ### `AddRequest`
156
+
157
+ Immutable input from the CLI or wizard:
158
+
159
+ - server
160
+ - export path
161
+ - mount point
162
+ - filesystem type
163
+ - retry profile
164
+ - mount-now choice
165
+ - optional local username for guidance
166
+
167
+ The username is guidance-only. It is not written into fstab and does not change ownership.
168
+
169
+ ### `LatencyResult`
170
+
171
+ Immutable TCP probe result containing the server, successful latency samples, attempt count, and optional error. Formatting and color selection are derived from average latency and success count.
172
+
173
+ ### `MountSpec`
174
+
175
+ Immutable desired fstab configuration. It owns:
176
+
177
+ - Source construction.
178
+ - Hard/soft option selection.
179
+ - fstab field escaping.
180
+ - Generated entry rendering.
181
+
182
+ ### `FstabEntry`
183
+
184
+ A parsed entry containing:
185
+
186
+ - `line_index`
187
+ - `raw_fields`
188
+
189
+ Convenience properties decode `fs_spec` and mount point and expose type/options. Treat `raw_fields` as the authoritative snapshot when checking whether an entry changed.
190
+
191
+ ### `FstabDocument`
192
+
193
+ A mutable representation of fstab containing:
194
+
195
+ - `path`
196
+ - `original_bytes`
197
+ - `lines`
198
+
199
+ It preserves unrelated content and supports:
200
+
201
+ - `add()`
202
+ - `remove()`
203
+ - `update_source()`
204
+ - `update_raw_source()`
205
+ - `render()`
206
+
207
+ `update_raw_source()` exists so rollback can restore the exact original source token rather than re-canonicalizing it.
208
+
209
+ ## 7. Command flows
210
+
211
+ ### Add flow
212
+
213
+ ```text
214
+ parse CLI or wizard input
215
+ → create and validate MountSpec
216
+ → load fstab
217
+ → reject duplicate mount point
218
+ → resolve hostname or require explicit offline override
219
+ → dry-run: print preview and exit
220
+ → require root
221
+ → preflight NFS helper and mount backend
222
+ → print UID/GID checkpoint unless already shown by wizard
223
+ → acquire fstab lock
224
+ → reload fstab and recheck duplicates
225
+ → create mount point if needed
226
+ → add entry to FstabDocument
227
+ → create timestamped backup
228
+ → atomically replace fstab
229
+ → release lock
230
+ → systemctl daemon-reload
231
+ → start generated mount unit, or bounded mount fallback
232
+ → report success or post-write failure
233
+ ```
234
+
235
+ If mounting fails after fstab is written, the entry remains in place. The command exits nonzero and explains that `nofail` and the configured timeouts protect future boots. If the hostname no longer resolves, the error includes a DNS diagnosis and remediation guidance.
236
+
237
+ ### Edit flow
238
+
239
+ ```text
240
+ require root
241
+ → load fstab and display numbered NFS menu
242
+ → validate replacement fs_spec
243
+ → resolve replacement hostname before any unmount or write
244
+ → show exact old and new lines
245
+ → confirm
246
+ → reload and compare selected entry
247
+ → detect current mount state
248
+ → preflight requirements
249
+ → unmount old share if mounted
250
+ → lock and reload fstab
251
+ → verify entry still matches the selected snapshot
252
+ → replace only fs_spec
253
+ → back up and atomically write fstab
254
+ → daemon-reload
255
+ → mount the new source
256
+ → on failure: restore old source when safe and remount old share if appropriate
257
+ ```
258
+
259
+ Important edit rules:
260
+
261
+ - Only the source field changes.
262
+ - Mount point, type, options, dump/pass values, comments, spacing, and marker are preserved.
263
+ - An externally changed source is never overwritten during rollback.
264
+ - Externally changed non-source fields are preserved; rollback may still remount the old source.
265
+ - `edit` always mounts after a successful source change, even if the share was previously unmounted.
266
+
267
+ ### Remove flow
268
+
269
+ ```text
270
+ validate mount point
271
+ → load fstab and find exactly one matching entry
272
+ → reject mounted share unless --unmount is supplied
273
+ → dry-run: preview and exit
274
+ → confirm unless --yes
275
+ → require root
276
+ → lock and reload fstab
277
+ → optionally unmount
278
+ → remove entry and its eznfs marker when present
279
+ → back up and atomically write fstab
280
+ → daemon-reload
281
+ → report result
282
+ ```
283
+
284
+ ### List flow
285
+
286
+ ```text
287
+ load fstab and select NFS/NFSv4 entries
288
+ → optionally resolve each unique server once
289
+ → run six bounded TCP connections to port 2049 per server
290
+ → probe unique servers concurrently and cache results
291
+ → render table with average, range, success count, and threshold color
292
+ ```
293
+
294
+ `--no-latency` skips all network probes and omits the column. TCP latency is a responsiveness indicator, not NFS RPC latency.
295
+
296
+ ## 8. Fstab parsing and persistence
297
+
298
+ ### Why a custom document model exists
299
+
300
+ Generic INI-style parsers do not preserve fstab comments, whitespace, octal escapes, or unknown fields correctly. `FstabDocument` therefore keeps the original lines and modifies only what is necessary.
301
+
302
+ Contributors must preserve:
303
+
304
+ - Unrelated entries.
305
+ - Blank lines and comments.
306
+ - Existing spacing where practical.
307
+ - Inline comments during source edits.
308
+ - Original source spelling during rollback.
309
+ - File ownership and mode.
310
+
311
+ ### Escaping
312
+
313
+ fstab fields escape:
314
+
315
+ - Space as `\040`
316
+ - Tab as `\011`
317
+ - Backslash as `\134`
318
+
319
+ Decoding operates through bytes so octal-escaped UTF-8 paths round-trip correctly.
320
+
321
+ ### Locking
322
+
323
+ - Real `/etc/fstab` writes use `/run/lock/eznfs-fstab.lock`.
324
+ - Tests and alternate paths use an adjacent lock file.
325
+ - The lock covers the final reload-check-write sequence.
326
+
327
+ External editors do not necessarily honor this lock. Stale-entry checks in `edit` provide an additional safeguard.
328
+
329
+ ### Atomic writes
330
+
331
+ `write_fstab_atomic()`:
332
+
333
+ 1. Rejects symlink and non-regular targets.
334
+ 2. Reads target ownership and mode.
335
+ 3. Creates a timestamped backup with exclusive creation.
336
+ 4. Writes a temporary file in the same directory.
337
+ 5. Applies ownership and mode.
338
+ 6. Flushes and fsyncs the temporary file.
339
+ 7. Uses `os.replace()`.
340
+ 8. Fsyncs the parent directory where supported.
341
+
342
+ Backup naming:
343
+
344
+ ```text
345
+ /etc/fstab.eznfs-YYYYMMDDTHHMMSS.ffffff.bak
346
+ ```
347
+
348
+ ## 9. Mount and systemd behavior
349
+
350
+ ### Generated safety options
351
+
352
+ Hard profile:
353
+
354
+ ```text
355
+ rw,hard,timeo=600,retrans=2,_netdev,nofail,x-systemd.device-timeout=10s,x-systemd.mount-timeout=15s
356
+ ```
357
+
358
+ Soft profile:
359
+
360
+ ```text
361
+ rw,soft,timeo=100,retrans=2,_netdev,nofail,x-systemd.device-timeout=10s,x-systemd.mount-timeout=15s
362
+ ```
363
+
364
+ Key behavior:
365
+
366
+ - `_netdev` marks the mount as network-dependent.
367
+ - `nofail` prevents an offline share from failing boot.
368
+ - Device and mount timeouts bound systemd waiting.
369
+ - `hard` favors data integrity but can block active I/O if a server disappears.
370
+ - `soft` returns errors sooner but failed writes can risk data inconsistency.
371
+
372
+ Do not silently change these defaults.
373
+
374
+ ### systemd path
375
+
376
+ On systemd hosts, eznfs:
377
+
378
+ 1. Runs `systemctl daemon-reload`.
379
+ 2. Computes the path-escaped `.mount` unit name.
380
+ 3. Runs `systemctl start UNIT`.
381
+
382
+ Starting the generated unit allows `x-systemd.mount-timeout` to govern the mount operation.
383
+
384
+ `systemd_unit_name()` mirrors `systemd-escape --path --suffix=mount` without shelling out.
385
+
386
+ ### Non-systemd fallback
387
+
388
+ When systemd is not running, `run_bounded()` starts `mount` or `umount` in a new process group and terminates the group after a timeout.
389
+
390
+ Never replace this with an unbounded `subprocess.run()` for network mounts.
391
+
392
+ ## 10. Validation and path safety
393
+
394
+ ### Server and source validation
395
+
396
+ Supported server forms:
397
+
398
+ - Hostname
399
+ - IPv4 address
400
+ - IPv6 address, stored in brackets when used in `fs_spec`
401
+
402
+ NFS sources use:
403
+
404
+ ```text
405
+ server:/absolute/export/path
406
+ [2001:db8::1]:/absolute/export/path
407
+ ```
408
+
409
+ Invalid control characters, relative export paths, malformed hosts, and ambiguous unbracketed IPv6 sources are rejected.
410
+
411
+ ### Hostname resolution
412
+
413
+ Before any add or edit write, hostnames are checked with `getent ahosts` and a five-second timeout. Literal IP addresses bypass the lookup. This honors `/etc/hosts`, NSS, and DNS through the system resolver.
414
+
415
+ Unresolved hostnames abort before mount-point creation, unmounting, or fstab modification. `--allow-unresolved` is the explicit CLI override for offline provisioning; the wizard and editor offer retry, save-anyway, and cancel choices. Resolution success does not imply that the NFS service is online.
416
+
417
+ If DNS fails between the pre-write check and mounting, post-write errors include a DNS diagnosis while preserving the existing saved-entry or rollback behavior.
418
+
419
+ ### Mount-point safety
420
+
421
+ Add and removal flows reject:
422
+
423
+ - `/`
424
+ - Paths inside `/boot`, `/etc`, `/proc`, `/run`, `/sys`, and `/dev`
425
+ - Duplicate mount points
426
+
427
+ The add flow additionally refuses symbolic-link or regular-file targets. New mount points are created root-owned with mode `0755`. Existing directory permissions are not changed.
428
+
429
+ ## 11. UID/GID guidance
430
+
431
+ The wizard and noninteractive add flow print a permission checkpoint.
432
+
433
+ User detection order:
434
+
435
+ 1. `SUDO_USER`
436
+ 2. `SUDO_UID`
437
+ 3. Current effective UID
438
+
439
+ The checkpoint displays:
440
+
441
+ - Local username.
442
+ - Numeric UID and primary GID.
443
+ - A server-side `stat` command.
444
+ - A reminder that numeric IDs and permission bits must allow access.
445
+ - A brief `root_squash` explanation.
446
+
447
+ This is guidance, not enforcement. eznfs does not currently verify mounted ownership, test write access, modify server ownership, or add `uid=`/`gid=` mount options.
448
+
449
+ Server-side NFS policy is authoritative. Client mount-point ownership does not control ownership inside a mounted NFS share.
450
+
451
+ ## 12. Error handling and exit codes
452
+
453
+ Expected failures should raise `EznfsError` with a useful message rather than producing a traceback.
454
+
455
+ | Exit code | Meaning |
456
+ |---:|---|
457
+ | `0` | Success, cancellation, or broken pipe handled cleanly. |
458
+ | `1` | Validation, permission, fstab, or other expected failure. |
459
+ | `2` | Post-write systemd/mount failure. |
460
+ | `130` | Ctrl-C or EOF cancellation. |
461
+
462
+ `MountOperationError` is an `EznfsError` with exit code `2`.
463
+
464
+ ## 13. Safety invariants
465
+
466
+ Contributors must not casually change these rules:
467
+
468
+ 1. Never use `shell=True` or interpolate user input into shell command strings.
469
+ 2. Never run tests against the real `/etc/fstab`.
470
+ 3. Never require tests to contact an NFS server or perform real mounts.
471
+ 4. Preserve unrelated fstab content.
472
+ 5. Keep backups, locking, atomic replacement, and ownership/mode preservation.
473
+ 6. Keep `_netdev`, `nofail`, and bounded timeouts in generated entries.
474
+ 7. Do not add a global `network-online.target` dependency.
475
+ 8. Do not silently switch between hard and soft mount semantics.
476
+ 9. Keep root checks before interactive wizard/edit prompts.
477
+ 10. Keep transactional source-edit rollback.
478
+ 11. Do not overwrite externally changed sources during rollback.
479
+ 12. Do not present client-side `uid=`/`gid=` or mount-point `chown` as an NFS permission fix.
480
+ 13. Do not modify NFS server configuration from this project.
481
+ 14. Do not interpolate dynamic values into Rich markup; use `Text` or escaped output.
482
+ 15. Do not write an unresolved hostname without the explicit offline-provisioning override.
483
+ 16. Keep latency probes read-only, bounded, concurrent across unique servers, and disabled by `--no-latency`.
484
+ 17. Do not generate release notes for artifacts without passed smoke tests, and do not commit host-specific `build/` or `dist/` output.
485
+ 18. Never place API tokens in command arguments, logs, tests, or committed files; publishing tests must not perform real uploads.
486
+
487
+ If a change requires weakening one of these invariants, discuss it explicitly and update this document.
488
+
489
+ ## 14. Technical decision log
490
+
491
+ | ID | Decision | Justification | Consequences |
492
+ |---|---|---|---|
493
+ | D-001 | Core script plus presentation module | Keeps fstab/mount logic separate from terminal rendering while remaining easy to package. | UI changes belong in `eznfs_ui.py`; core behavior stays in `eznfs.py`. |
494
+ | D-002 | Python 3.10+ | Enables modern type syntax and standard-library APIs. | Older Python releases are unsupported. |
495
+ | D-003 | Minimal pinned dependency | Rich provides accessible, consistent terminal UI without a large dependency surface. | Rich is pinned to `15.0.0`; upgrades require explicit review. |
496
+ | D-004 | Custom fstab document model | Preserves comments, spacing, escapes, and unknown fields. | Parser and writer require careful tests. |
497
+ | D-005 | Octal escaping through bytes | Correctly round-trips escaped UTF-8 paths. | Do not replace with naïve Unicode-only decoding. |
498
+ | D-006 | Root-owned `0755` mount points | Safe for privileged/systemd mounting. | Does not grant NFS file access; server permissions still apply. |
499
+ | D-007 | Immediate mount by default | Matches the tool's purpose and gives immediate feedback. | `--no-mount` remains available. |
500
+ | D-008 | Hard profile by default | Favors read/write data integrity. | Users must understand possible active-I/O hangs. |
501
+ | D-009 | `_netdev,nofail` plus timeouts | Prevents an offline nonessential share from failing or hanging boot. | `nofail` does not prevent active-I/O hangs. |
502
+ | D-010 | Start systemd mount units | Honors `x-systemd.mount-timeout`. | Requires `systemctl` and `daemon-reload` on systemd hosts. |
503
+ | D-011 | Bounded non-systemd fallback | Avoids indefinite `mount`/`umount` waits. | Requires process-group termination logic. |
504
+ | D-012 | Backup plus atomic replace | Protects against interrupted or invalid fstab writes. | Creates backup files that users may need to clean up. |
505
+ | D-013 | Lock plus stale-entry checks | Reduces lost updates and edit races. | External editors may still race; checks are essential. |
506
+ | D-014 | Transactional source edit | Restores a working source when a replacement cannot mount. | Rollback has explicit failure reporting. |
507
+ | D-015 | Early root checks | Avoids wasting time entering wizard data without privileges. | Dry-run and list remain unprivileged. |
508
+ | D-016 | UID/GID checkpoint only | Server-side NFS policy is authoritative; client remapping is misleading. | Post-mount verification remains future work. |
509
+ | D-017 | Detect sudo invoking user | The process runs as root but the intended user is usually `SUDO_USER`. | Guidance must not default to root when sudo metadata exists. |
510
+ | D-018 | `unittest` with temp files and mocks | Tests stay fast, rootless, and safe. | Real systemd/NFS integration requires separate manual testing. |
511
+ | D-019 | Rich 15.0.0 terminal UI | Provides panels, tables, Markdown, syntax highlighting, prompts, and progress with a plain-output fallback. | Dynamic values must use `Text`; tests cover TTY and non-TTY rendering. |
512
+ | D-020 | Strict pre-write hostname resolution with offline override | Catches DNS typos before fstab changes while preserving intentional offline provisioning. | Unresolved names require `--allow-unresolved` or explicit wizard/editor confirmation. |
513
+ | D-021 | Six-attempt TCP latency column | Gives an immediate responsiveness signal without ICMP privileges or NFS RPC instrumentation. | Label as TCP latency; cache unique hosts, probe concurrently, and allow `--no-latency`. |
514
+ | D-022 | Local one-file PyInstaller release build | Removes Python/pip requirements for target users while keeping builds manual and host-specific. | Pin PyInstaller `6.22.3`; require smoke tests; generate neutral notes and checksums without publishing. |
515
+ | D-023 | Adaptive light/dark terminal themes | Bright yellow and cyan variants have poor contrast on light backgrounds, while Rich does not detect background brightness itself. | Parse `COLORFGBG`, support `EZNFS_COLOR_THEME`, use dark light-background colors, and switch syntax palettes. |
516
+ | D-024 | Isolated Twine publishing workflow | PyPI uploads require validated, reproducible artifacts and safe token handling. | Pin Build/Twine, use `dist/pypi/`, run `twine check`, keep tokens in environment variables, and test on TestPyPI first. |
517
+
518
+ ## 15. Testing
519
+
520
+ ### Required checks
521
+
522
+ ```bash
523
+ .venv/bin/python -m unittest discover -s tests -v
524
+ .venv/bin/python -m py_compile eznfs.py eznfs_ui.py tools/build_dist.py tools/release_notes.py tools/publish_pypi.py tests/test_eznfs.py tests/test_eznfs_ui.py tests/test_release_tools.py tests/test_publish_tools.py
525
+ git diff --check
526
+ ```
527
+
528
+ ### Safe manual checks
529
+
530
+ ```bash
531
+ .venv/bin/eznfs --help
532
+ .venv/bin/eznfs add --server nas.lan --share /export \
533
+ --mountpoint /mnt/media --dry-run
534
+ .venv/bin/eznfs list --no-latency
535
+ ```
536
+
537
+ To simulate sudo-user detection without changing the system:
538
+
539
+ ```bash
540
+ SUDO_USER=mrkmntal SUDO_UID=1000 \
541
+ ./eznfs.py add --server nas.lan --share /export \
542
+ --mountpoint /mnt/media --dry-run
543
+ ```
544
+
545
+ Do not run applying commands against the development host merely to test them.
546
+
547
+ ### Test map
548
+
549
+ | Test class | Focus |
550
+ |---|---|
551
+ | `ValidationTests` | Hosts, paths, sources, mount-point safety, escaping. |
552
+ | `DNSValidationTests` | Resolution checks, timeout, strict abort, override, and DNS diagnostics. |
553
+ | `LatencyTests` | TCP sampling, thresholds, partial failure, formatting, and host caching. |
554
+ | `MountSpecTests` | Option profiles and generated sources. |
555
+ | `FstabDocumentTests` | Parsing, add/remove/update, backups, atomic writes. |
556
+ | `SystemdTests` | Path-escaped mount unit names. |
557
+ | `CommandTests` | Add/list/remove behavior and mocked mount operations. |
558
+ | `EditCommandTests` | Menu, source edits, rollback, stale and external changes. |
559
+ | `UserGuidanceTests` | Sudo-user detection and UID/GID checkpoint output. |
560
+ | `CliAndWizardTests` | Argument dispatch and wizard flows. |
561
+ | `EznfsUITests` | Plain/Rich rendering, markup safety, prompts, progress, and stderr. |
562
+ | `ThemeTests` | Background detection, theme overrides, light/dark palettes, and syntax selection. |
563
+ | `ReleaseToolTests` | Changelog extraction, metadata validation, smoke status, checksums, and release notes. |
564
+ | `PublishToolTests` | Artifact selection, Twine commands, checksums, and token-safe upload handling. |
565
+
566
+ When changing behavior, add or update the closest test class. Tests must not require root, network access, or a real NFS server.
567
+
568
+ ## 16. Standalone build and release
569
+
570
+ Install the optional build dependency and run the local build:
571
+
572
+ ```bash
573
+ .venv/bin/python -m pip install -e '.[build]'
574
+ ./build.sh
575
+ ```
576
+
577
+ `tools/build_dist.py` uses `eznfs.spec` to produce `dist/eznfs`, stages a versioned binary with `build-info.json`, runs unprivileged smoke tests, and creates a `.tar.gz` archive. Smoke tests cover version/help output, local listing, and an IP-based dry run.
578
+
579
+ `tools/release_notes.py` validates the staged metadata and passed smoke status, extracts the matching `CHANGELOG.md` section, and generates SHA-256 checksums plus forge-neutral Markdown notes. It does not publish releases.
580
+
581
+ Builds are manual, host-specific, and not bit-for-bit reproducible. PyInstaller does not cross-compile. Never commit `build/` or `dist/` artifacts.
582
+
583
+ ### PyPI publishing
584
+
585
+ Install the optional publishing dependencies and run:
586
+
587
+ ```bash
588
+ .venv/bin/python -m pip install -e '.[publish]'
589
+ ./publish.sh testpypi --check-only
590
+ ./publish.sh testpypi
591
+ ./publish.sh pypi --skip-build
592
+ ```
593
+
594
+ `tools/publish_pypi.py` builds an sdist and wheel into `dist/pypi/`, runs `twine check`, writes SHA-256 checksums, and uploads only distribution artifacts. API tokens are read from `TWINE_PASSWORD` or `getpass` and passed only through the child process environment. Tests must mock all subprocesses and never upload.
595
+
596
+ ## 17. Contribution workflow
597
+
598
+ 1. Read this document and `README.md`.
599
+ 2. Inspect the working tree before editing; preserve unrelated user changes.
600
+ 3. Keep dependencies minimal and retain the exact Rich `15.0.0`, PyInstaller `6.22.3`, Build `1.6.1`, and Twine `7.0.0` pins unless upgrades are explicitly approved.
601
+ 4. Add tests for behavior changes.
602
+ 5. Run all required checks.
603
+ 6. Update `README.md` for user-visible changes.
604
+ 7. Update this code map and decision log for architectural changes.
605
+ 8. Do not commit generated files such as `__pycache__/`, `build/`, or `dist/`.
606
+
607
+ When adding a command, update all of the following:
608
+
609
+ - `build_parser()`
610
+ - `main()`
611
+ - Relevant transaction or interactive function
612
+ - `eznfs_ui.py` when presentation changes
613
+ - Tests
614
+ - `README.md`
615
+ - The CLI and code-map sections in this document
616
+
617
+ ## 18. Deferred ideas — not implemented
618
+
619
+ The following concepts have been discussed but are **not current behavior**. Do not document or code against them as though they already exist without an explicit implementation task:
620
+
621
+ - Selected-user-only passwordless mounting through sudoers.
622
+ - Root-owned `/mnt/eznfs/...` mounts exposed through home-directory symlinks.
623
+ - Migration of existing home-directory mounts to a secure mount location.
624
+ - Post-mount UID/GID verification.
625
+ - Dropped-privilege read/write/traverse checks.
626
+ - An `access` command for existing shares.
627
+ - fstab metadata recording a selected local user.
628
+
629
+ If one of these is implemented, move it out of this section and record the decision and tests.
630
+
631
+ ## 19. Agent working rules
632
+
633
+ AI agents contributing to this repository should:
634
+
635
+ - Inspect relevant code and tests before modifying files.
636
+ - Avoid destructive operations and unrelated refactors.
637
+ - Never modify the real `/etc/fstab`, sudoers, systemd units, or NFS exports during development.
638
+ - Use dry-run mode for manual CLI exploration.
639
+ - Preserve the safety invariants in section 13.
640
+ - Keep dynamic values out of Rich markup; use `Text` or escaped output.
641
+ - Ask before changing mount defaults, boot behavior, root requirements, persistence semantics, or dependency pins.
642
+ - Treat PyInstaller output as host-specific; never commit `build/` or `dist/` artifacts.
643
+ - Keep user-facing errors concise and actionable.
644
+ - Update tests and documentation in the same change as behavior.
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to eznfs will be documented in this file.
4
+
5
+ ## [1.0.0] - 2026-11-28
6
+
7
+ ### Added
8
+
9
+ - Interactive setup wizard and noninteractive `add` command.
10
+ - Safe fstab generation with `_netdev`, `nofail`, hard/soft profiles, and bounded systemd timeouts.
11
+ - Transactional NFS source editing with rollback.
12
+ - NFS listing, removal, duplicate protection, and optional unmounting.
13
+ - Atomic fstab writes with locking and timestamped backups.
14
+ - Strict hostname validation with an explicit offline-provisioning override.
15
+ - UID/GID guidance based on the invoking sudo user.
16
+ - Rich 15.0.0 terminal interface with tables, panels, Markdown, prompts, and progress.
17
+ - Adaptive light/dark terminal palettes with `COLORFGBG` detection and `EZNFS_COLOR_THEME` overrides.
18
+ - Six-attempt TCP latency probes for `list`, with color-coded responsiveness thresholds.
19
+ - Standalone one-file PyInstaller builds and forge-neutral release-note tooling.
20
+ - MIT licensing and README screenshots captured in kitty on KDE Plasma 6.
21
+ - Reproducible TestPyPI/PyPI publishing with isolated builds, Twine validation, checksums, and token-safe uploads.
eznfs-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 markmental
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.