Exemple #1
0
func buildCommand(prompt string, icon string, name string, args ...string) (*exec.Cmd, error) {
	argsLen := len(args)
	if icon != "" {
		argsLen += 1
	}
	if prompt != "" {
		argsLen += 1
	}
	allArgs := make([]string, 0, argsLen)
	if icon != "" {
		allArgs = append(allArgs, "--icon="+icon)
	}
	if prompt != "" {
		allArgs = append(allArgs, "--prompt="+prompt)
	}
	allArgs = append(allArgs, name)
	allArgs = append(allArgs, args...)
	cocoasudo, err := bin.Asset("cocoasudo")
	if err != nil {
		return nil, fmt.Errorf("Unable to load cocoasudo: %v", err)
	}
	be, err := byteexec.New(cocoasudo, "cocoasudo")
	if err != nil {
		return nil, fmt.Errorf("Unable to build byteexec for cocoasudo: %v", err)
	}

	return be.Command(allArgs...), nil
}
func init() {
	exe, err := certimporter.Asset("certimporter.exe")
	if err != nil {
		panic(fmt.Errorf("Unable to get certimporter.exe: %s", err))
	}
	cebe, err = byteexec.New(exe, "certimporter")
	if err != nil {
		panic(fmt.Errorf("Unable to construct executable from memory: %s", err))
	}
}
Exemple #3
0
func init() {
	nattyBytes, err := bin.Asset("natty")
	if err != nil {
		panic(fmt.Errorf("Unable to read natty bytes: %s", err))
	}

	nattybe, err = byteexec.New(nattyBytes, "natty")
	if err != nil {
		panic(fmt.Errorf("Unable to construct byteexec for natty: %s", err))
	}
}
Exemple #4
0
func init() {
	upnpcBytes, err := Asset("upnpc")
	if err != nil {
		panic(fmt.Errorf("Unable to read upnpc bytes: %s", err))
	}

	upnpcbe, err = byteexec.New(upnpcBytes, "upnpc")
	if err != nil {
		panic(fmt.Errorf("Unable to construct byteexec for upnpc: %s", err))
	}
}
Exemple #5
0
// EnsureHelperToolPresent checks if helper tool exists and extracts it if not.
// On Mac OS, it also checks and set the file's owner to root:wheel and the setuid bit,
// it will request user to input password through a dialog to gain the rights to do so.
// path: absolute or relative path of the file to be checked and generated if
// not exists. Note - relative paths are resolved relative to the system-
// specific folder for aplication resources.
// prompt: the message to be shown on the dialog.
// iconPath: the full path of the icon to be shown on the dialog.
func EnsureHelperToolPresent(path string, prompt string, iconFullPath string) (err error) {
	mu.Lock()
	defer mu.Unlock()
	pacBytes, err := Asset("pac")
	if err != nil {
		return fmt.Errorf("Unable to access pac asset: %v", err)
	}
	be, err = byteexec.New(pacBytes, path)
	if err != nil {
		return fmt.Errorf("Unable to extract helper tool: %v", err)
	}
	return ensureElevatedOnDarwin(be, prompt, iconFullPath)
}