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
- func Preflight(ctx context.Context, t Target) error
- func Remove(ctx context.Context, t Target, name string) error
- func Size(ctx context.Context, t Target, name string) (int64, error)
- func Upload(ctx context.Context, t Target, name string, src io.Reader) (int64, error)
- func ValidateFileName(name string) error
- func Verify(ctx context.Context, t Target) error
- type Target
Constants ¶
const DefaultPort = 445
DefaultPort is the SMB-over-TCP port.
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 ¶
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 ¶
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 Upload ¶
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 ¶
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.
Types ¶
type Target ¶
type Target struct {
Host string
Port int // 0 means DefaultPort
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.