Files
baby-nas/internal/db/models.go
T
darroyo 8003db49b3 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:17:32 -04:00

90 lines
2.6 KiB
Go

package db
import "time"
type User struct {
ID int64 `json:"id"`
Username string `json:"username"`
UID *int64 `json:"uid,omitempty"`
GID *int64 `json:"gid,omitempty"`
Groups []string `json:"groups"`
SMBEnabled bool `json:"smb_enabled"`
Disabled bool `json:"disabled"`
// PendingPassword holds a not-yet-applied password. Never serialized.
PendingPassword string `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Admin struct {
ID int64 `json:"id"`
Username string `json:"username"`
PasswordHash string `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SambaShare struct {
ID int64 `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Comment string `json:"comment"`
ReadOnly bool `json:"read_only"`
GuestOK bool `json:"guest_ok"`
ValidUsers []string `json:"valid_users"`
ValidGroups []string `json:"valid_groups"`
InvalidUsers []string `json:"invalid_users"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NFSClient struct {
Host string `json:"host"`
ReadOnly bool `json:"read_only"`
Async bool `json:"async"`
RootSquash bool `json:"root_squash"`
SubtreeCheck bool `json:"subtree_check"`
Advanced NFSAdvanced `json:"advanced"`
}
type NFSExport struct {
ID int64 `json:"id"`
Path string `json:"path"`
Clients []NFSClient `json:"clients"`
ReadOnly bool `json:"read_only"`
Async bool `json:"async"`
RootSquash bool `json:"root_squash"`
SubtreeCheck bool `json:"subtree_check"`
FSID int64 `json:"fsid"`
Advanced string `json:"advanced"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NFSAdvanced struct {
AllSquash bool `json:"all_squash"`
Secure bool `json:"secure"`
WDelay bool `json:"wdelay"`
Hide bool `json:"hide"`
Crossmnt bool `json:"crossmnt"`
}
type WatchedMount struct {
ID int64 `json:"id"`
Path string `json:"path"`
CreatedAt time.Time `json:"created_at"`
}
type DirtyModule struct {
Module string `json:"module"`
MarkedAt time.Time `json:"marked_at"`
}
type ApplyLogEntry struct {
ID int64 `json:"id"`
Module string `json:"module"`
Message string `json:"message"`
Success bool `json:"success"`
CreatedAt time.Time `json:"created_at"`
}