util

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREDUI_MAX_CAPTION_LENGTH        = 128
	CREDUI_MAX_MESSAGE_LENGTH        = 32767
	CREDUI_MAX_USERNAME_LENGTH       = 256
	CREDUI_MAX_PASSWORD_LENGTH       = 256
	CREDUI_MAX_GENERIC_TARGET_LENGTH = 32767
	CREDUI_MAX_DOMAIN_TARGET_LENGTH  = 256 + 1 + 80

	CREDUIWIN_GENERIC      = 0x1  // Return the user name and password in plain text.
	CREDUIWIN_CHECKBOX     = 0x2  // The Save check box is displayed in the dialog box.
	CREDUIWIN_IN_CRED_ONLY = 0x20 // Only the credentials specified by the pvInAuthBuffer parameter

)
View Source
const (
	// How it will look.
	MB_OK                = 0x00000000
	MB_OKCANCEL          = 0x00000001
	MB_ABORTRETRYIGNORE  = 0x00000002
	MB_YESNOCANCEL       = 0x00000003
	MB_YESNO             = 0x00000004
	MB_RETRYCANCEL       = 0x00000005
	MB_CANCELTRYCONTINUE = 0x00000006
	MB_ICONHAND          = 0x00000010
	MB_ICONQUESTION      = 0x00000020
	MB_ICONEXCLAMATION   = 0x00000030
	MB_ICONASTERISK      = 0x00000040
	MB_USERICON          = 0x00000080
	MB_ICONWARNING       = MB_ICONEXCLAMATION
	MB_ICONERROR         = MB_ICONHAND
	MB_ICONINFORMATION   = MB_ICONASTERISK
	MB_ICONSTOP          = MB_ICONHAND
	// And behave.
	MB_DEFBUTTON1    = 0x00000000
	MB_DEFBUTTON2    = 0x00000100
	MB_DEFBUTTON3    = 0x00000200
	MB_DEFBUTTON4    = 0x00000300
	MB_SETFOREGROUND = 0x00010000
	// Return values.
	IDOK     = 1
	IDCANCEL = 2
	IDABORT  = 3
	IDRETRY  = 4
	IDIGNORE = 5
	IDYES    = 6
	IDNO     = 7
)

Windows SDK constants.

View Source
const (
	SSHAgentPipeName = "\\\\.\\pipe\\openssh-ssh-agent"
	MaxNameLen       = windows.UNIX_PATH_MAX

	// openssh-portable has it at 256 * 1024.
	// gpg-agent is using 16 * 1024.
	// Putty seems to have it at 8 + 1024.
	MaxAgentMsgLen = 256 * 1024

	GPGAgentName             = "gpg-agent"
	WinAgentName             = "agent-gui"
	SocketAgentName          = "S." + GPGAgentName
	SocketAgentBrowserName   = "S." + GPGAgentName + ".browser"
	SocketAgentExtraName     = "S." + GPGAgentName + ".extra"
	SocketAgentSSHName       = "S." + GPGAgentName + ".ssh"
	SocketAgentSSHCygwinName = "S." + GPGAgentName + ".ssh.cyg"
)

Shared names.

Variables

This section is empty.

Functions

func CleanUserEnvironmentVariable

func CleanUserEnvironmentVariable(name string, wslenv bool) error

CleanUserEnvironmentVariable will reverse settings done by PrepareUserEnvironmentVariable.

func CygwinCreateSocketFile added in v1.2.0

func CygwinCreateSocketFile(fname string, port int) (nonce [16]byte, err error)

CygwinCreateSocketFile creates CygWin socket file with proper content and attributes.

func CygwinNonceString added in v1.2.0

func CygwinNonceString(nonce [16]byte) string

CygwinNonceString converts binary nonce to printable string in net order.

func CygwinPerformHandshake added in v1.2.0

func CygwinPerformHandshake(conn io.ReadWriter, nonce [16]byte) error

CygwinPerformHandshake exchanges handshake data.

func FileExists

func FileExists(filename string) bool

FileExists check if file exists.

func GetIntOption added in v1.6.0

func GetIntOption(name string, def uint64) uint64

GetIntOption reads named integer value from registry. If value does not exist or there is a problem - default is returned.

func IsNetClosing

func IsNetClosing(err error) bool

IsNetClosing exists because ErrNetClosing is not exported. This is probably going to change in 1.16.

func IsProperWindowsVer added in v1.3.1

func IsProperWindowsVer() (bool, error)

IsProperWindowsVer checks if program is running on supported WIndows.

func KillRunningAgent

func KillRunningAgent() error

KillRunningAgent uses Os functions to terminate gpg-agent ungracefully.

func MessageBox added in v1.3.1

func MessageBox(title, text string, style uintptr) int

MessageBox full native implementation.

func NewLogWriter added in v1.3.1

func NewLogWriter(title string, flags int, debug bool)

NewLogWriter redirects all log output depending on debug parameetr. When true all output goes to OutputDebugString and you could use debugger or Sysinternals dbgview.exe to collect it. When false - everything is discarded.

func PrepareUserEnvironmentVariable

func PrepareUserEnvironmentVariable(name, value string, wslenv, translate bool) error

PrepareUserEnvironmentVariable modifies user environment. if wslenv is true - its name is added to WSLENV/up list for path translation.

func PrepareWindowsPath

func PrepareWindowsPath(path string) string

PrepareWindowsPath prepares Windows path for use on unix shell line without quoting.

func PromptForConfirmaion added in v1.3.1

func PromptForConfirmaion(_ DlgDetails, description, prompt string, onebutton bool) bool

func PromptForWindowsCredentials added in v1.3.1

func PromptForWindowsCredentials(details DlgDetails, errorMessage, description, prompt string, save bool) (bool, string, bool)

PromptForWindowsCredentials calls Windows CredUI.dll to pupup "standard" Windows security dialog using provided description, prompt and a flag, indicating that user could make a choice to save the result in Windows Credential manager. It returns canceled flag (indicating error or user's refusal to complete operation) and when false string with entered password/pin and flag indicating that user checked "Remember me" checkbox.

func SetIntOption added in v1.6.0

func SetIntOption(name string, val uint64)

SetIntOption stores named integer value to registry. Key must exist. Errors are ignored.

func ShowOKMessage added in v1.3.1

func ShowOKMessage(t MsgType, title, text string)

ShowOKMessage shows simple MB_OK message box.

func WaitForFileArrival

func WaitForFileArrival(period time.Duration, filenames ...string) bool

WaitForFileArrival checks for files existence once a second for requested waiting period.

func WaitForFileDeparture

func WaitForFileDeparture(period time.Duration, filenames ...string)

WaitForFileDeparture attempts to remove files once a second for requested waiting period.

func XAgentCookieString added in v1.5.0

func XAgentCookieString(n int) string

func XAgentPerformHandshake added in v1.5.0

func XAgentPerformHandshake(conn io.ReadWriter, cookie string) error

XAgentPerformHandshake exchanges handshake data with client.

Types

type DlgDetails added in v1.3.1

type DlgDetails struct {
	Delay    time.Duration `yaml:"delay,omitempty"`
	WndName  string        `yaml:"name,omitempty"`
	WndClass string        `yaml:"class,omitempty"`
}

type MsgType added in v1.3.1

type MsgType uint32

MsgType specifies how message box will look and behave.

const (
	MsgError       MsgType = MB_ICONHAND
	MsgExclamation MsgType = MB_ICONEXCLAMATION
	MsgInformation MsgType = MB_ICONASTERISK
)

Actual values.

type XAgentAdvertiser added in v1.5.0

type XAgentAdvertiser struct {
	// contains filtered or unexported fields
}

func AdvertiseXAgent added in v1.5.0

func AdvertiseXAgent(cookie string, port int) (xa *XAgentAdvertiser, err error)

AdvertiseXAgent() sets up server side part of XAgent protocol.

func (*XAgentAdvertiser) Close added in v1.5.0

func (xa *XAgentAdvertiser) Close() error

Close implements io.Closer.

Jump to

Keyboard shortcuts

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