Commit Graph

19 Commits

Author SHA1 Message Date
darroyo 03e9368a91 feat: add invalid_users directive for Samba shares
Samba shares now support an 'invalid users' list (deny list), written
as 'invalid users = u1,u2' in smb.conf. The UI shows a ChipPicker
for valid_users and invalid_users, mutually exclusive, sourced from
the system user list.

feat: add ImportSystemUsers for fresh installations

When NASCTL_IMPORT_ON_BOOT=true, nasctl now imports existing system
users from /etc/passwd (UID 1000-60000) and /etc/group (supplemental
groups), and detects which have Samba accounts via 'pdbedit -L'.
Imported users are marked dirty so the admin can review before applying.
New POST /api/import/users endpoint for manual re-import.

This mirrors the existing import-on-boot flow for smb.conf and /etc/exports.
2026-07-06 15:37:01 -04:00
darroyo 3e290164c5 fix(nfs): move fsid=N inside client parentheses in /etc/exports
exportfs parses 'path host(flags) fsid=N' as a separate fsid= token
without host or options, causing 'No options for path fsid=N' errors.
The correct format puts fsid=N inside the host parentheses:
  /path host(flags,fsid=N)

Changes:
- clientFlags(c, fsid) now appends fsid=N at the end
- buildExportFlags(e, fsid) same
- buildExportLine removed buildExportSuffix call; fsid is now per-client
- Removed now-unused buildExportSuffix function

Version: 0.5.3
2026-07-06 12:20:35 -04:00
darroyo d380cad36d fix(nfs): add migration 0006 to repair fsid=0 exports
Migration 0005 (MigrateNFSClients) only runs once when first applied,
so any fsid=0 rows present before 0005 was applied never get repaired.

Migration 0006 triggers FixZeroFSIDs() which:
- Queries all nfs_exports rows with fsid=0
- Generates a new random fsid per row
- Updates the row

Version: 0.5.2
2026-07-06 12:10:20 -04:00
darroyo 35ff23bf71 bump version to 0.5.1 2026-07-06 12:05:29 -04:00
darroyo 512feaffd7 feat(nfs): per-host NFS options (IP/CIDR with own ro/async/squash flags)
This is a backward-compatible MINOR bump (0.4.0 → 0.5.0).

BREAKING NOTES (for users upgrading from pre-0.5.0):
- The nfs_exports.clients column schema changed from []string to
  []NFSClient (per-host options). A migration (0005) transforms existing
  string arrays into object arrays, taking export-level options as
  defaults for each host.
- ValidateNFSClient now only accepts IPv4 (192.168.1.1) or IPv4/CIDR
  (192.168.1.0/24). Hostnames, wildcards, netgroups are rejected.
- If you use NASCTL_IMPORT_ON_BOOT, re-import your /etc/exports to pick
  up per-host options.

What changed:
- NFSClient type: {host, read_only, async, root_squash, subtree_check, advanced}
- NFSExport.Clients is now []NFSClient (was []string)
- export-level flags (ro/async/root_squash/subtree_check/advanced) are
  preserved as template defaults for newly added hosts in the UI.
- buildExportLine generates: path host1(ro,sync,...) host2(rw,async,...) fsid=N
- ValidateNFSClient: strict IPv4/CIDR only (0-255 octets, /0-32 prefix)
- parseExportLine now parses per-host options from /etc/exports (previously
  only the first host's options were kept, others were discarded)
- UI: per-host rows with toggles (ro/async/root_squash/subtree_check) and
  advanced options (all_squash, secure, wdelay, hide, crossmnt)
2026-07-06 11:30:27 -04:00
darroyo 50ed8abe95 feat: file manager with browse, search, upload, chmod/chown
- Full file browser page at /files with lazy-load, breadcrumbs, drag&drop
- FileBrowserModal component for path selection from Samba/NFS forms
- PathField component replaces bare inputs in share/export forms
- Backend: /api/files/* routes with List, Mkdir, Rename, Delete, Chmod, Chown, Upload, Download, Preview, Search
- Reuses NASCTL_ALLOWED_ROOTS for path validation
- NASCTL_UPLOAD_MAX_BYTES (100MB) and NASCTL_PREVIEW_MAX_BYTES (256KB) env vars
- Capabilities endpoint returns chmod/chown availability (requires root)
- Version bump: 0.3.2 -> 0.4.0
2026-07-06 01:56:40 -04:00
darroyo 0da789cd96 fix: populate fsid for legacy NFS exports on migration
Migration 0002 added fsid column with DEFAULT 0 but never
populated existing rows. Now PopulateLegacyFSIDs() runs after 0002
to extract fsid from legacy options string or generate random.

Also: move generateRandomFSID to internal/system to avoid import
cycles. Migration 0004 drops the legacy options column.

Version: 0.3.1 -> 0.3.2
2026-07-06 01:22:16 -04:00
darroyo b678c8e1a9 Bump version: 0.3.0 -> 0.3.1 2026-07-06 00:52:29 -04:00
darroyo 508890a232 feat: multi-source disk entries with chips display
diskUsage now carries Sources []string instead of a single Source.
collectDiskUsage accumulates all sources (samba, nfs, manual) per path.
NFS no longer adds a redundant label to used_by.

Dashboard and Settings render one chip per source. When a path
is shared via SMB and NFS, both chips appear.

API breaking: disks[].source replaced by disks[].sources[].
Version: 0.2.1 -> 0.3.0
2026-07-06 00:40:41 -04:00
darroyo a24145e07a Bump version: 0.2.0 -> 0.2.1 2026-07-06 00:34:09 -04:00
darroyo e3add68584 feat: structured NFS options with auto-fsid and manual watched mounts
NFS exports: replace plain-text options string with typed booleans
(read_only, async, root_squash, subtree_check) + advanced JSON blob.
fsid is auto-generated via crypto/rand with collision retry and is
never user-settable. Breaking API change (options field removed).

Dashboard: filter disks to manual+samba+nfs sources only; no more
auto-discovery of all /proc/mounts entries.

Settings: new 'Puntos de montaje vigilados' card with add/remove
for manual mount points. AllowedRoots validation applied.

Version bump: 0.1.10 -> 0.2.0
2026-07-06 00:23:49 -04:00
darroyo 63e0b5146a fix: tolerate duplicate column errors in migration runner
The previous SAVEPOINT approach failed because Go's tx.Exec() stops at
the first error and never reaches the ROLLBACK TO statements. This caused
every subsequent startup to re-run migration 0002, fail on the first
ALTER (column already exists from a prior partial run), and crash.

Fix runMigration() to:
- Execute migrations without a wrapping transaction (DDL in SQLite is
  auto-commit anyway)
- Treat "duplicate column name" / "already exists" errors as success
  and record the migration anyway, covering cases where a previous
  failed attempt already partially modified the schema

Also simplify 0002_nfs_structured.sql back to plain ALTER TABLE
statements (no SAVEPOINT needed with the new Go-level tolerance).

Bump VERSION 0.1.9 -> 0.1.10
2026-07-06 00:05:02 -04:00
darroyo 9a9d4cc753 fix: implement migration tracking and make 0002 idempotent
- Add schema_migrations table to track applied migrations
- Migrate() now checks if a migration was already applied before running
- 0002 rewritten to use SAVEPOINT+ROLLBACK per column, making it safe
  to run even if some columns were partially added previously
- Each migration runs in its own transaction; INSERT into schema_migrations
  only happens if the SQL executes without error
- Bump VERSION 0.1.8 -> 0.1.9
2026-07-05 23:54:14 -04:00
darroyo 3d956d43c2 fix: split ALTER TABLE into separate ADD COLUMN statements in migration 0002
SQLite does not support adding multiple columns in a single ALTER TABLE
statement. The previous migration tried to add 6 columns at once and
caused a syntax error, crashing the service at startup.

Bump VERSION 0.1.7 -> 0.1.8
2026-07-05 23:26:53 -04:00
darroyo a61ae04009 fix: use try-restart in postinst so .deb upgrade reloads the service
- Bump VERSION 0.1.6 -> 0.1.7
- Change systemctl start -> try-restart in postinst script so that
  upgrading the package actually restarts nasctl with the new binary
2026-07-05 23:14:31 -04:00
darroyo ac07499e8d feat: bake version into binary and display in UI sidebar
- Inject VERSION via ldflags (-X main=web.Version=) and git short SHA
- Add /api/version endpoint returning {version, commit}
- Display version in Layout sidebar footer (v0.1.6 · 8cfd405)
- Add AGENTS.md section documenting SemVer policy and bump-before-push rule
- Bump VERSION 0.1.5 -> 0.1.6 in Makefile
2026-07-05 23:07:20 -04:00
darroyo 8cfd405ffc cambios 2026-07-05 22:59:37 -04:00
darroyo d6b184d19b postinst: start nasctl service after install so it's immediately running 2026-07-05 21:21:33 -04:00
darroyo 4f0754ecc5 Add nasctl: Go NAS control plane with React frontend 2026-07-05 17:37:19 -04:00