Ejemplo n.º 1
0
func (provisioner *WindowsProvisioner) enableBasicAuthForWinRM() bool {
	log.Debug("Enabling basic auth for WinRM")

	ip, err := provisioner.Driver.GetIP()
	if err != nil {
		return false
	}

	d := provisioner.Driver
	stdout, stderr, exit, err := drivers.WinRMRunCmdWithNTLM(ip,
		d.GetSSHUsername(),
		d.GetSSHPassword(),
		enableBasicAuthCmd)
	if (err != nil) || (exit != 0) {
		log.Warn("Error getting WinRM command to enable basic auth:", err)
		log.Debug("Enable basic auth output:", stdout, ", err:", stderr, ", exit:", exit)
		return false
	}

	stdout, stderr, exit, err = drivers.WinRMRunCmdWithNTLM(ip,
		d.GetSSHUsername(),
		d.GetSSHPassword(),
		enableUnencryptedCmd)
	if (err != nil) || (exit != 0) {
		log.Warn("Error getting WinRM command to enable unencrypted comm:", err)
		log.Debug("Enable unencrypted comm output:", stdout, ", err:", stderr, ", exit:", exit)
		return false
	}

	// The daemon is up if the command worked.  Carry on.
	log.Debug("Successfully enabled basic auth for WinRM")
	return true
}
Ejemplo n.º 2
0
func (provisioner *WindowsProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	ip, err := provisioner.Driver.GetIP()
	if err != nil {
		return err
	}
	d := provisioner.Driver
	out, stderr, exit, err := drivers.WinRMRunCmdWithNTLM(ip, d.GetSSHUsername(), d.GetSSHPassword(), fmt.Sprintf("net %s %s", action.String(), name))
	if (err != nil) || (exit != 0) {
		log.Error("service stdout:", out, ", stderr:", stderr, ", err:", err, ", exit:", exit)
		return err
	}
	return nil
}