Documentation
¶
Overview ¶
Package automount mounts an SMB share in the operating system's file manager without any password dialog, and unmounts it.
The credentials are handed to the platform's own mount service as values: NetFS with NoUI on macOS (github.com/go-macos/netfs), GVfs answering its own AskPassword call on Linux/GNOME (github.com/go-freedesktop/gvfs), and MSFT_SmbMapping.Create on Windows (github.com/go-mswin/win32). The password is never placed in an argument vector, the environment, a URL, an error message or a log. Every other GOOS answers ErrUnsupported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadURL: the URL is not smb://host[:port]/share. ErrBadURL = errors.New("automount: URL must be smb://host[:port]/share") // ErrCredentialsInURL: user information in the URL; pass Share.User and // Share.Password instead, so that a secret is never part of a URL. ErrCredentialsInURL = errors.New("automount: credentials must be passed in Share, not in the URL") // ErrBadDrive: Options.Drive is not a drive letter and a colon ("X:"). ErrBadDrive = errors.New("automount: Drive must be a letter and a colon, like \"X:\"") // ErrDriveInUse: Options.Drive is already a logical drive. ErrDriveInUse = errors.New("automount: drive letter already in use") // ErrNoFreeDrive: every drive letter from D: to Z: is taken. ErrNoFreeDrive = errors.New("automount: no free drive letter") // ErrReadOnlyUnsupported: Options.ReadOnly on a platform whose backend has // no read-only mount. ErrReadOnlyUnsupported = errors.New("automount: read-only mounts are not supported on this platform") )
var ErrNotMounted = errors.New("automount: the share is no longer mounted")
ErrNotMounted: Reveal on a share that was already unmounted.
var ErrUnsupported = errors.ErrUnsupported
ErrUnsupported is returned by Mount on a GOOS without a backend.
Functions ¶
This section is empty.
Types ¶
type Mounted ¶
type Mounted struct {
// contains filtered or unexported fields
}
Mounted is one mounted share. (The type cannot be called Mount: Go has one namespace for the function and the type.)
func Mount ¶
Mount mounts the share in the user's file manager: a volume under /Volumes on macOS, a gvfs location on Linux, a drive letter on Windows. No dialog appears; when the credentials are wrong the error says so (errors.Is reaches the backend's sentinel: netfs.ErrAuth, gvfs.ErrAuthFailed, or a *win32.SMBPortError).
func (*Mounted) Path ¶
Path is where the share is reachable: a directory on macOS and Linux, a drive root such as `Z:\` on Windows. On Linux, when gvfs-fuse is not serving the session, it is the smb:// URI, which GIO opens and os calls do not.
func (*Mounted) Reveal ¶ added in v0.2.0
Reveal opens the mount's Path in the operating system's file manager: Finder on macOS (open(1)), the default handler through xdg-open (or gio open) on Linux, Explorer on Windows. It returns once the helper is started, without waiting for the window. A missing helper is an error, never a panic.
The path is passed as one argument of an argument vector, never through a shell, so spaces and quotes are inert; a path that could be read as an option is made unambiguous first.
type Options ¶
type Options struct {
// Drive is the Windows drive letter ("X:"). Empty means the highest free
// letter from Z: down. It is ignored off Windows.
Drive string
// ReadOnly mounts read-only. Only macOS supports it; elsewhere Mount fails
// with ErrReadOnlyUnsupported rather than mounting read-write silently.
ReadOnly bool
}
Options tunes a mount.