• R/O
  • HTTP
  • SSH
  • HTTPS

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Virtual machine Management Terminal User Interface


File Info

Rev. 50b2e09d722b08e7afe48c362605b0d1e89d6780
Tamaño 4,621 octetos
Tiempo 2023-05-06 22:05:00
Autor Koine Yuusuke(koinec)
Log Message

Fix build error on FreeBSD 13.2-RELEASE.

Content

/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
          VMTUI (Virtual machine Management Terminal User Interface)

         Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/


#define	VMTUI_SRC_
#include "vmtui.h"


/* ===========================================================================*/
VMTUI_HVCMD_EXTERN
int
	HvCmd_Connect(
		int		i_hvisor,
		Byte	b_phase,
		char	*pstr_passwd )
{
	int		i_ret		= 0x00;
	HVisor	*p_hvisor;
	DWord	dw_status;
	DWord	dw_hvoption;
	Byte	b_connection;
	Byte	b_nosshpasswd	= 0x00;
	Byte	b_nosudopasswd	= 0x00;

	// Get HyperVisor Status ---
	p_hvisor	= HVisor_Ref( i_hvisor );
	dw_status		= p_hvisor->dw_status;
	b_connection	= p_hvisor->b_connection;
	if(( HVISOR_OPTION_SSH_PASSWORD & p_hvisor->dw_option )
			&& ( p_hvisor->ssh.str_password[0] == '\0' ))
		{ b_nosshpasswd	= 0x01; }
	dw_hvoption		= p_hvisor->dw_option;
	if(( HVISOR_OPTION_SUDO_PASSWORD & dw_hvoption ) && ( '\0' == p_hvisor->sudo.str_password[0] ))
		{ b_nosudopasswd	= 0x01; }
	HVisor_Release( p_hvisor );

	// Check Connected? ---
	if(( HVISOR_STATUS_CONNECTED & dw_status ) || ( HVISOR_STATUS_CONNECTING & dw_status ))	{
		ErrInfo_Warn( "Don't connect Hypervisor because connected or connecting now.",
						i_hvisor, GUEST_ID_NONE, REQUEST_ID_NONE,
						0x00, -0x01, dw_status, NULL );
		return -0x01;
	}

	// Check LocalHost? ---
	if( HVISOR_CON_LOCALHOST == b_connection )
		{ b_phase	= HVCMD_CONNECT_PHASE_SUDOPASS_REQ; }

	if(( HVCMD_CONNECT_PHASE_SUDOPASS_SET > b_phase ) && ( 0x00 == b_nosshpasswd ))
		{ b_phase	= HVCMD_CONNECT_PHASE_SUDOPASS_REQ; }

	// Proc. SSH Connect Phase. ---
	if( HVCMD_CONNECT_PHASE_REQUEST == b_phase )	{
		if(( 0x01 == b_nosshpasswd ) && ( HVISOR_CON_LOCALHOST != b_connection ))	{
			TuiKey_ChangeMode( TUIKEY_MODE_INPUTPASSWD, REQUEST_CMD_HV_CONNECT,
								i_hvisor, GUEST_ID_NONE, HVCMD_CONNECT_PHASE_SSHPASS_SET,
								"Input SSH PassWord / PassPhrase ? " );
			return 0x00;
		}
	}

	if( HVCMD_CONNECT_PHASE_SSHPASS_SET == b_phase )	{
		HvCtl_SetSSHPassword( i_hvisor, pstr_passwd );

		b_phase	= HVCMD_CONNECT_PHASE_SUDOPASS_REQ;
	}

	if( HVCMD_CONNECT_PHASE_SUDOPASS_REQ == b_phase )	{
		if( 0x01 == b_nosudopasswd )	{
			TuiKey_ChangeMode( TUIKEY_MODE_INPUTPASSWD, REQUEST_CMD_HV_CONNECT,
								i_hvisor, GUEST_ID_NONE, HVCMD_CONNECT_PHASE_SUDOPASS_SET,
								"Input Login User's Password for sudo cmd. ? " );
			return 0x00;
		}

		b_phase	= HVCMD_CONNECT_PHASE_CONNECTSTART;
	}

	if( HVCMD_CONNECT_PHASE_SUDOPASS_SET == b_phase )	{
		HvCtl_SetSudoPassword( i_hvisor, pstr_passwd );
		b_phase	= HVCMD_CONNECT_PHASE_CONNECTSTART;
	}

	TuiKey_ChangeMode( TUIKEY_MODE_VMLIST, REQUEST_CMD_NONE, 0x00, 0x00, 0x00, NULL );
	i_ret	= ReqCtl_CreateRequest( REQUEST_CMD_HV_CONNECT, i_hvisor, GUEST_ID_NONE, NULL );

	return i_ret;
}

/* ===========================================================================*/
VMTUI_HVCMD_EXTERN
int
	HvCmd_Update_All(
		void )
{
	int		i_hvisor;

	i_hvisor	= HVisor_GetTopID();
	while( HVISOR_ID_NONE != i_hvisor )	{

		ReqCtl_CreateRequest( REQUEST_CMD_VMLIST, i_hvisor, GUEST_ID_NONE, NULL );

		i_hvisor	= HVisor_GetNextID( i_hvisor );
	}

	return 0x00;
}


/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/