smb

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package smb implements the apply step that activates the Samba server: group and user membership, avahi, config validation, service enablement, and samba account passwords. It never writes config files — placement is mise's job (smb.conf and shares.conf are system dotfiles); this step only activates what is already placed.

Index

Constants

View Source
const DefaultGroup = "smb"

DefaultGroup is used when a module's smb spec declares no group.

Variables

This section is empty.

Functions

func PostBootstrap added in v0.10.0

func PostBootstrap(ctx context.Context, runner Runner, modules []resolve.SmbModuleSpec, out io.Writer) error

PostBootstrap runs the post-mise-bootstrap actions that can't be expressed declaratively: the testparm validation gate and interactive smbpasswd for each declared user missing from pdbedit -L. Group/user/service convergence is handled by mise bootstrap (bootstrap.groups/users/services); this function only does the interactive/validator parts.

Types

type ExecRunner

type ExecRunner struct {
	Verbose bool
	// Out/Err are the Verbose streaming destinations; nil defaults to
	// os.Stdout/os.Stderr.
	Out io.Writer
	Err io.Writer
}

ExecRunner is the real command runner. Verbose streams child stdout/stderr live to Out/Err while still capturing and echoes each command line set -x-style ("+ argv") to Err before it runs: Run callers parse (id -Gn, pdbedit -L) and append (testparm gate) the returned output, so streaming must never starve them.

func (ExecRunner) Run

func (r ExecRunner) Run(ctx context.Context, name string, args ...string) (string, error)

func (ExecRunner) RunInteractive

func (ExecRunner) RunInteractive(ctx context.Context, name string, args ...string) error

func (*ExecRunner) SetVerbose added in v0.5.0

func (r *ExecRunner) SetVerbose(v bool)

SetVerbose toggles live output streaming.

type Runner

type Runner interface {
	Run(ctx context.Context, name string, args ...string) (string, error)
	RunInteractive(ctx context.Context, name string, args ...string) error
}

Runner runs commands for the step. Run captures combined output (stdout and stderr merged, so validation errors like testparm's carry their diagnostics); cancelling ctx kills the child process. RunInteractive attaches the terminal so a command can prompt (smbpasswd password entry).

type Step

type Step struct {
	Runner Runner
	Plan   resolve.SmbStep
	Out    io.Writer
}

Step is the apply pipeline step for Samba server activation, consuming the resolved smb aggregate. Out receives intentional user-facing messages (the no-TTY smbpasswd skip warning); it defaults to os.Stdout.

func (*Step) Name

func (s *Step) Name() string

Name returns the step name.

func (*Step) Run

func (s *Step) Run(ctx context.Context) error

Run activates Samba in script order (mise-tasks/system/smb.sh): per module ensure the group, user membership, and avahi; then gate on testparm; then enable/restart the smb service; finally ensure each declared user has a samba password. An empty aggregate is a no-op.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL