smbupload

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package smbupload writes a package file to an SMB file share distribution point. It speaks SMB2/3 only, through a pure-Go client, so the release pipeline's CGO_ENABLED=0 cross-compile is unaffected. AFP and SMB1 are not supported and never will be.

Index

Constants

View Source
const DefaultPort = 445

DefaultPort is the SMB-over-TCP port.

View Source
const PackagesDir = "Packages"

PackagesDir is the folder inside the share that holds packages. Jamf's distribution point setup says to "always use a folder named Packages to avoid issues with Jamf Pro being able to locate packages", and Jamf Pro and Jamf Admin both read and write it there: the share is the parent. It is never created here: a share without it is the wrong share, and creating the folder would hide that.

Variables

This section is empty.

Functions

func Preflight

func Preflight(ctx context.Context, t Target) error

Preflight proves the target before anything is written: the account signs in, the share mounts and holds a Packages folder. A caller that creates a package record first runs this, so a wrong share or account leaves nothing behind.

func Remove

func Remove(ctx context.Context, t Target, name string) error

Remove deletes name from the share's Packages folder. A file already absent is reported as an error wrapping fs.ErrNotExist so the caller can treat it as the state it wanted. A directory is refused: this removes a package file and nothing else.

func Size

func Size(ctx context.Context, t Target, name string) (int64, error)

Size reports the size of name on the share, for a post-upload check.

func Upload

func Upload(ctx context.Context, t Target, name string, src io.Reader) (int64, error)

Upload copies src into the share's Packages folder as name, replacing a file of the same name. It reports the bytes written. A write that has started is never retried: the caller sees the error and decides.

func ValidateFileName

func ValidateFileName(name string) error

ValidateFileName refuses a name that is not a bare file name valid on every server. A share root is a flat package directory and nothing here may step out of it. The Windows-reserved characters are refused for Samba too, so one rule holds for both: a colon on Windows names an alternate data stream, so "x.pkg:evil" would write a hidden stream rather than a package, and the others are not legal in an NTFS name at all.

func Verify

func Verify(ctx context.Context, t Target) error

Verify proves the account signs in and the share mounts, and nothing more. It is what setup runs before saving a credential: a share that has no Packages folder yet is not a wrong password.

Types

type Target

type Target struct {
	Host     string
	Port     int // 0 means DefaultPort
	Share    string
	Domain   string
	Username string
	Password string

	// CCacheFile, when set, authenticates with Kerberos from this FILE
	// credential cache and Username/Password are not used. KrbConfigFile is the
	// krb5.conf naming the realm's KDC. Kerberos needs the server's DNS name:
	// the service principal is cifs/<Host>, which an IP address cannot form.
	CCacheFile    string
	KrbConfigFile string
}

Target is one share on one file server, with the account to write it as. Password is never formatted into an error or a log line.

func (Target) Addr

func (t Target) Addr() string

Addr is host:port for dialing.

func (Target) Kerberos

func (t Target) Kerberos() bool

Kerberos reports whether the target authenticates with a ticket.

func (Target) UNC

func (t Target) UNC() string

UNC is the share as an operator would write it, for messages.

func (Target) Validate

func (t Target) Validate() error

Validate refuses a target that cannot work, before any connection.

Jump to

Keyboard shortcuts

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