• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Virtual machine Management Terminal User Interface


Commit MetaInfo

Révisioncf859483163fcb8b4e3dbb3102ffb0e7de8ccbca (tree)
l'heure2022-06-06 20:18:50
AuteurKoine Yuusuke(koinec) <koinec@user...>
CommiterKoine Yuusuke(koinec)

Message de Log

Support ConfigFile.

Change Summary

Modification

--- a/src/Makefile
+++ b/src/Makefile
@@ -44,6 +44,7 @@ OBJS_PARTS = common.o \
4444 sshcmd.o \
4545 localcmd.o \
4646 localshell.o \
47+ configfile.o \
4748 tuisys.o \
4849 tuititle.o \
4950 tuistatus.o \
@@ -70,6 +71,7 @@ HEADER = vmtui.h \
7071 sshcmd.h \
7172 localcmd.h \
7273 localshell.h \
74+ configfile.h \
7375 tuisys.h \
7476 tuititle.h \
7577 tuistatus.h \
@@ -96,7 +98,8 @@ TEST_OBJS = test_vmtui.o \
9698 test_request.o \
9799 test_hvctl.o \
98100 test_errinfo.o \
99- test_guestctl.o
101+ test_guestctl.o \
102+ test_configfile.o
100103 TEST_RESULT = test_result.log
101104
102105 CALLGRAPH = CallGraph.txt
@@ -154,6 +157,9 @@ guestctl.o: guestctl.c $(HEADER)
154157 vmbhyve.o: vmbhyve.c $(HEADER)
155158 $(CC) -c -o vmbhyve.o $(FLAGS_COMPILE) $(FLAGS_DEBUG) \
156159 vmbhyve.c
160+configfile.o: configfile.c $(HEADER)
161+ $(CC) -c -o configfile.o $(FLAGS_COMPILE) $(FLAGS_DEBUG) \
162+ configfile.c
157163 tuisys.o: tuisys.c $(HEADER)
158164 $(CC) -c -o tuisys.o $(FLAGS_COMPILE) $(FLAGS_DEBUG) \
159165 tuisys.c
@@ -213,6 +219,9 @@ test_guestctl.o:test_guestctl.c
213219 test_errinfo.o: test_errinfo.c
214220 $(CC) -c -o test_errinfo.o $(TEST_FLAGS_COMPILE) $(FLAGS_DEBUG) \
215221 test_errinfo.c
222+test_configfile.o: test_configfile.c
223+ $(CC) -c -o test_configfile.o $(TEST_FLAGS_COMPILE) $(FLAGS_DEBUG) \
224+ test_configfile.c
216225
217226
218227 $(CALLGRAPH):
--- /dev/null
+++ b/src/configfile.c
@@ -0,0 +1,388 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+
29+#define VMTUI_SRC_CONFIGFILE
30+#include "vmtui.h"
31+
32+/* ===========================================================================*/
33+Word
34+ ConfigFile_Str2Word(
35+ char *pstr_src,
36+ int i_len )
37+{
38+ int i_pos;
39+ Word w_value = 0;
40+
41+ if( 4 < i_len )
42+ { i_len = 4; }
43+
44+ for( i_pos = 0; i_pos < i_len; i_pos++, pstr_src++ ) {
45+ if( !isdigit( *pstr_src ) )
46+ { return 0; }
47+ w_value = (w_value * 10) + (*pstr_src - '0');
48+ }
49+
50+ return w_value;
51+}
52+
53+/* ===========================================================================*/
54+VMTUI_CONFIGFILE_EXTERN
55+char *
56+ ConfigFile_GetFilePath(
57+ void )
58+{
59+ return gstr_configfile;
60+}
61+
62+/* ===========================================================================*/
63+VMTUI_CONFIGFILE_EXTERN
64+void
65+ ConfigFile_SetConfigFilePath(
66+ char *pstr_cfgpath,
67+ char *pstr_filename )
68+{
69+ struct stat t_buf;
70+ char str_curpath[256];
71+
72+ if( NULL == pstr_filename )
73+ { pstr_filename = CFG_FILENAME_DEFAULT; }
74+
75+ // Priority 1: Operand ---- for TestProgram
76+ if( NULL != pstr_cfgpath ) {
77+ strncpy( gstr_configfile, pstr_cfgpath, 255 );
78+ strncat( gstr_configfile, "/", 255 );
79+ strncat( gstr_configfile, pstr_filename, 255 );
80+ if( 0x00 == stat( gstr_configfile, &t_buf ))
81+ { return; }
82+ }
83+
84+ // Priority 2: Current Dir. --- for DebugMode
85+ getcwd( str_curpath, 255 );
86+ strncat( str_curpath, "/", 255 );
87+ strncat( str_curpath, pstr_filename, 255 );
88+
89+ if( 0x00 == stat( str_curpath, &t_buf ) ) {
90+ strncpy( gstr_configfile, str_curpath, 255 );
91+ return;
92+ }
93+
94+ // Priority 3: Home dir (.vmtui) ---
95+ strncpy( gstr_configfile, getenv("HOME"), 255 );
96+ strncat( gstr_configfile, "/" CFG_FILENAME_HOMEDIR, 255 );
97+ if( 0x00 == stat( gstr_configfile, &t_buf ))
98+ { return; }
99+
100+ // Priority 4: etc dir. ---
101+ strncpy( gstr_configfile, CFG_DIR_GLOBAL "/" CFG_FILENAME_DEFAULT, 255 );
102+
103+ return;
104+}
105+
106+
107+/* ===========================================================================*/
108+void
109+ ConfigFile_InitTempHvisor(
110+ HVisor *p_hvtmp )
111+{
112+ assert( NULL != p_hvtmp );
113+
114+ memset( p_hvtmp, 0x00, sizeof( HVisor ) );
115+
116+ // Default value
117+ p_hvtmp->dw_type = HVISOR_TYPE_BHYVE_VMBHYVE;
118+ p_hvtmp->dw_option = HVISOR_OPTION_NONE;
119+ p_hvtmp->b_connection = HVISOR_CON_LOCALHOST;
120+
121+ p_hvtmp->ssh.b_sshtype = HVISOR_SSH_AUTH_PASSWD;
122+ strncpy( p_hvtmp->ssh.str_pubkeypath, CFG_FILEPATH_DEFAULT_PUBKEY, VMTUI_MAXPATH );
123+ strncpy( p_hvtmp->ssh.str_seckeypath, CFG_FILEPATH_DEFAULT_SECKEY, VMTUI_MAXPATH );
124+
125+ return;
126+}
127+
128+/* ===========================================================================*/
129+int
130+ ConfigFile_ReadHyperVisor(
131+ HVisor *p_hvtmp,
132+ char *pstr_key, int i_keylen,
133+ char *pstr_val, int i_vallen )
134+{
135+ int i_ret = 0x00;
136+
137+ if( !strncmp( pstr_key, CFG_KEY_SERVER_CONNECTION, i_keylen )) {
138+ if( !strncmp( pstr_val, CFG_VAL_SERVER_CONNECTION_LOCAL, 32 ))
139+ { p_hvtmp->b_connection = HVISOR_CON_LOCALHOST; }
140+ else if( !strncmp( pstr_val, CFG_VAL_SERVER_CONNECTION_SSH, 32 ))
141+ { p_hvtmp->b_connection = HVISOR_CON_REMOTE_SSH; }
142+ i_ret++;
143+ }
144+
145+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_HYPERVISOR, i_keylen )) {
146+ if( !strncmp( pstr_val, CFG_VAL_SERVER_HYPERVISOR_VMBHYVE, 32 ))
147+ { p_hvtmp->dw_type = HVISOR_TYPE_BHYVE_VMBHYVE; }
148+ else if( !strncmp( pstr_val, CFG_VAL_SERVER_HYPERVISOR_BHYVEDIRECT, 32 ))
149+ { p_hvtmp->dw_type = HVISOR_TYPE_BHYVE_DIRECTBHYVE; }
150+ else if( !strncmp( pstr_val, CFG_VAL_SERVER_HYPERVISOR_BHYVE_LIBVIRT, 32 ))
151+ { p_hvtmp->dw_type = HVISOR_TYPE_BHYVE_LIBVIRT; }
152+ else if( !strncmp( pstr_val, CFG_VAL_SERVER_HYPERVISOR_QEMUKVM_LIBVIRT, 32 ))
153+ { p_hvtmp->dw_type = HVISOR_TYPE_QEMUKVM_LIBVIRT; }
154+ i_ret++;
155+ }
156+
157+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SERVERNAME, i_keylen )) {
158+ strncpy( p_hvtmp->str_name, pstr_val, HVISOR_MAXLEN_NAME );
159+ i_ret++;
160+ }
161+
162+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_HOSTNAME, i_keylen )) {
163+ strncpy( p_hvtmp->ssh.str_hostfqdn, pstr_val, HVISOR_MAXLEN_HOSTFQDN );
164+ i_ret++;
165+ }
166+
167+ // SSH Settings -----
168+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SSH_AUTHTYPE, i_keylen )) {
169+ if( !strncmp( pstr_val, CFG_KEY_SERVER_SSH_AUTHTYPE_PASSWD, 32 ))
170+ { p_hvtmp->ssh.b_sshtype = HVISOR_SSH_AUTH_PASSWD; }
171+ else if( !strncmp( pstr_val, CFG_KEY_SERVER_SSH_AUTHTYPE_PUBKEY, 32 ))
172+ { p_hvtmp->ssh.b_sshtype = HVISOR_SSH_AUTH_PUBKEY; }
173+ else if( !strncmp( pstr_val, CFG_KEY_SERVER_SSH_AUTHTYPE_HOSTBASED, 32 ))
174+ { p_hvtmp->ssh.b_sshtype = HVISOR_SSH_AUTH_HOSTBASED; }
175+ i_ret++;
176+ }
177+
178+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SSH_PORT, i_keylen )) {
179+ p_hvtmp->ssh.w_port = ConfigFile_Str2Word( pstr_val, i_vallen );
180+ i_ret++;
181+ }
182+
183+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SSH_USER, i_keylen )) {
184+ strncpy( p_hvtmp->ssh.str_user, pstr_val, HVISOR_SSH_MAXLEN_USER );
185+ i_ret++;
186+ }
187+
188+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SSH_PASSWORD, i_keylen )) {
189+ strncpy( p_hvtmp->ssh.str_password, pstr_val, HVISOR_SSH_MAXLEN_PASSWORD );
190+ i_ret++;
191+ }
192+
193+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SSH_PUBKEYPATH, i_keylen )) {
194+ strncpy( p_hvtmp->ssh.str_pubkeypath, pstr_val, VMTUI_MAXPATH );
195+ i_ret++;
196+ }
197+
198+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SSH_SECKEYPATH, i_keylen )) {
199+ strncpy( p_hvtmp->ssh.str_seckeypath, pstr_val, VMTUI_MAXPATH );
200+ i_ret++;
201+ }
202+
203+ // SuDo Settings ----
204+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SUDO_ENABLE, i_keylen )) {
205+ if( !strncmp( pstr_val, CFG_VAL_YES, 32 ))
206+ { p_hvtmp->dw_option = HVISOR_OPTION_SUDO; }
207+ i_ret++;
208+ }
209+
210+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SUDO_OPTION, i_keylen )) {
211+ strncpy( p_hvtmp->sudo.str_option, pstr_val, HVISOR_SUDO_MAXLEN_OPTION );
212+ i_ret++;
213+ }
214+
215+ else if( !strncmp( pstr_key, CFG_KEY_SERVER_SUDO_PASSWORD, i_keylen )) {
216+ strncpy( p_hvtmp->sudo.str_password, pstr_val, HVISOR_SUDO_MAXLEN_PASSWORD );
217+ i_ret++;
218+ }
219+
220+ return i_ret;
221+}
222+
223+/* ===========================================================================*/
224+int
225+ ConfigFile_RegistHVisor(
226+ HVisor *p_hvtmp )
227+{
228+ int i_err;
229+ int i_hvisor;
230+
231+ i_hvisor = HvCtl_CreateHVisor(
232+ p_hvtmp->dw_type, p_hvtmp->b_connection,
233+ p_hvtmp->str_name, p_hvtmp->dw_option );
234+ if( HVISOR_ID_NONE == i_hvisor ) {
235+ ErrInfo_Error( "Can't Regist HVisor", i_hvisor, 0x00, 0x00, 0x00, -0x01, p_hvtmp->str_name );
236+ return -0x01;
237+ }
238+
239+ if( HVISOR_CON_REMOTE_SSH == p_hvtmp->b_connection ) {
240+ i_err = HvCtl_SetSSHConnectionInfo(
241+ i_hvisor,
242+ p_hvtmp->ssh.b_sshtype,
243+ p_hvtmp->ssh.str_hostfqdn, p_hvtmp->ssh.w_port,
244+ p_hvtmp->ssh.str_user, p_hvtmp->ssh.str_password,
245+ p_hvtmp->ssh.str_pubkeypath, p_hvtmp->ssh.str_seckeypath );
246+ if( 0x00 != i_err ) {
247+ ErrInfo_Warn( "Can't Regist HVisor SSH Info.",
248+ i_hvisor, 0x00, 0x00, 0x00, -0x02, p_hvtmp->ssh.str_hostfqdn );
249+ return -0x02;
250+ }
251+ }
252+
253+ if( HVISOR_OPTION_SUDO & p_hvtmp->dw_option ) {
254+ i_err = HvCtl_SetSudoInfo(
255+ i_hvisor,
256+ p_hvtmp->sudo.str_option,
257+ p_hvtmp->sudo.str_password );
258+ if( 0x00 != i_err ) {
259+ ErrInfo_Warn( "Can't Regist HVisor Sudo Info.",
260+ i_hvisor, 0x00, 0x00, 0x00, -0x02, p_hvtmp->ssh.str_hostfqdn );
261+ return -0x03;
262+ }
263+ }
264+
265+ return 0x00;
266+}
267+
268+/* ===========================================================================*/
269+VMTUI_CONFIGFILE_EXTERN
270+int
271+ ConfigFile_ReadConfig(
272+ void )
273+{
274+ int i_ret = 0x00;
275+ int i_len;
276+ int i_keylen;
277+ int i_mode = 0x00;
278+ int i_err;
279+ char *pstr_val;
280+ char *pstr_key;
281+ FILE *fp;
282+ struct stat t_buf;
283+ char str_buf[1024];
284+
285+ HVisor *p_hvtmp;
286+
287+
288+ if( 0x00 != stat( gstr_configfile, &t_buf ) ) {
289+ ErrInfo_Warn( "Don't exist config file.",
290+ 0x00, 0x00, 0x00, 0x00, 0x00, gstr_configfile );
291+ return 0x00;
292+ }
293+
294+ p_hvtmp = (HVisor *)malloc( sizeof( HVisor ));
295+ if( NULL == p_hvtmp ) {
296+ ErrInfo_Error( "Can't alloc temp. HVisor memory.",
297+ 0x00, 0x00, 0x00, errno, -0x01, NULL );
298+ return -0x01;
299+ }
300+
301+ fp = fopen( gstr_configfile, "r" );
302+ if( NULL == fp ) {
303+ ErrInfo_Error( "Can't open confg file.",
304+ 0x00, 0x00, 0x00, errno, -0x02, gstr_configfile );
305+ i_ret = -0x02;
306+ goto goto_ConfigFile_ReadConfig_post;
307+ }
308+
309+ do {
310+ if( NULL == fgets( str_buf, 1024, fp )) { break; }
311+
312+ if(('\n' == str_buf[0]) || ('\r' == str_buf[0]) || ('#' == str_buf[0]))
313+ { continue; }
314+
315+ i_len = strnlen( str_buf, 1024 );
316+ if( 0 == i_len )
317+ { continue; }
318+
319+ // Cut LineEnd CR/LF ---
320+ if(( '\n' == str_buf[ i_len - 1 ]) || ( '\r' == str_buf[ i_len - 1] )) {
321+ str_buf[ i_len - 1 ] = '\0';
322+ i_len--;
323+ }
324+ if(( '\n' == str_buf[ i_len - 1 ]) || ( '\r' == str_buf[ i_len - 1] )) {
325+ str_buf[ i_len - 1 ] = '\0';
326+ i_len--;
327+ }
328+
329+ // Parse Section Name & Regist before Section Info -----
330+ if(( '[' == str_buf[0] ) && ( ']' == str_buf[ i_len - 1 ] )) {
331+
332+ if( 0x02 == i_mode ) {
333+ i_err = ConfigFile_RegistHVisor( p_hvtmp );
334+ if( 0x00 != i_err ) {
335+ ErrInfo_Error( "Failed call ConfigFile_Regist_HVisor()",
336+ 0x00, 0x00, 0x00, errno, i_err, NULL );
337+ // Ignore failed regist HVisor ---
338+ }
339+ }
340+
341+ // Section Name ---
342+ if( !strncmp( str_buf, CFG_SECTION_GLOBAL, 63 ) ) {
343+ i_mode = 0x01; // Global
344+ }
345+ if( !strncmp( str_buf, CFG_SECTION_HYPERVISOR, 63 ) ) {
346+ i_mode = 0x02; // HyperVisor
347+ str_buf[ i_len - 1 ] = '\0';
348+
349+ ConfigFile_InitTempHvisor( p_hvtmp );
350+ }
351+ }
352+
353+ // Separate Key & Value ---
354+ pstr_val = str_buf;
355+ pstr_key = strsep( &pstr_val, "=" );
356+ if(( NULL == pstr_key ) || ( NULL == pstr_val ))
357+ { continue; }
358+ i_keylen = (int)(pstr_val - pstr_key) - 1;
359+
360+ // Data Dispatch ---
361+ if( 0 == i_mode ) {
362+ // Global ---
363+
364+ }
365+ else {
366+ // Server ---
367+
368+ if( ConfigFile_ReadHyperVisor(
369+ p_hvtmp, pstr_key, i_keylen, pstr_val, i_len - i_keylen - 1 ))
370+ { continue; }
371+
372+ ErrInfo_Warn( "Unknown configfile Parameter.",
373+ 0x00, 0x00, 0x00, 0x00, 0x00, pstr_key );
374+ }
375+
376+ }while( !feof(fp) );
377+
378+ fclose( fp );
379+
380+goto_ConfigFile_ReadConfig_post:
381+ free( p_hvtmp );
382+
383+ return i_ret;
384+}
385+
386+
387+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
388+
--- /dev/null
+++ b/src/configfile.h
@@ -0,0 +1,106 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+#ifndef VMTUI_HEADER_CONFIGFILE
29+#define VMTUI_HEADER_CONFIGFILE
30+
31+#include "vmtui.h"
32+
33+#define CONFIGFILE_SECTION_GLOBAL "Global"
34+
35+#define CFG_FILENAME_DEFAULT "vmtui.conf"
36+#define CFG_FILENAME_HOMEDIR ".vmtui"
37+
38+#define CFG_FILEPATH_DEFAULT_PUBKEY "~/.ssh/id_rsa.pub"
39+#define CFG_FILEPATH_DEFAULT_SECKEY "~/.ssh/id_rsa"
40+
41+#define CFG_DIR_GLOBAL "/usr/local/etc"
42+
43+#define CFG_SECTION_GLOBAL "[Global]"
44+#define CFG_SECTION_HYPERVISOR "[HyperVisor]"
45+
46+#define CFG_KEY_SERVER_CONNECTION "Connection"
47+ #define CFG_VAL_SERVER_CONNECTION_LOCAL "Local"
48+ #define CFG_VAL_SERVER_CONNECTION_SSH "SSH"
49+
50+#define CFG_KEY_SERVER_SERVERNAME "ServerName"
51+#define CFG_KEY_SERVER_HOSTNAME "HostName"
52+#define CFG_KEY_SERVER_SSH_AUTHTYPE "SSH_AuthType"
53+ #define CFG_KEY_SERVER_SSH_AUTHTYPE_PASSWD "Password"
54+ #define CFG_KEY_SERVER_SSH_AUTHTYPE_PUBKEY "Pubkey"
55+ #define CFG_KEY_SERVER_SSH_AUTHTYPE_HOSTBASED "HostBased"
56+
57+#define CFG_KEY_SERVER_SSH_PORT "SSH_Port"
58+#define CFG_KEY_SERVER_SSH_USER "SSH_User"
59+#define CFG_KEY_SERVER_SSH_PASSWORD "SSH_Password"
60+#define CFG_KEY_SERVER_SSH_PUBKEYPATH "SSH_PubkeyPath"
61+#define CFG_KEY_SERVER_SSH_SECKEYPATH "SSH_SeckeyPath"
62+#define CFG_KEY_SERVER_HYPERVISOR "HyperVisor"
63+ #define CFG_VAL_SERVER_HYPERVISOR_VMBHYVE "VmBhyve"
64+ #define CFG_VAL_SERVER_HYPERVISOR_BHYVEDIRECT "BhyveDirect"
65+ #define CFG_VAL_SERVER_HYPERVISOR_BHYVE_LIBVIRT "Bhyve_libvirt"
66+ #define CFG_VAL_SERVER_HYPERVISOR_QEMUKVM_LIBVIRT "qemuKVM_libvirt"
67+
68+#define CFG_KEY_SERVER_SUDO_ENABLE "sudo_Enable"
69+#define CFG_KEY_SERVER_SUDO_OPTION "sudo_Option"
70+#define CFG_KEY_SERVER_SUDO_PASSWORD "sudo_Password"
71+
72+#define CFG_VAL_YES "Yes"
73+#define CFG_VAL_NO "No"
74+
75+
76+static char gstr_configfile[256];
77+
78+#ifdef VMTUI_SRC_CONFIGFILE
79+ #define VMTUI_CONFIGFILE_EXTERN
80+#else
81+ #define VMTUI_CONFIGFILE_EXTERN extern
82+#endif
83+VMTUI_CONFIGFILE_EXTERN char * ConfigFile_GetFilePath( void );
84+VMTUI_CONFIGFILE_EXTERN void ConfigFile_SetConfigFilePath( char *pstr_cfgpath, char *pstr_filename );
85+VMTUI_CONFIGFILE_EXTERN int ConfigFile_ReadConfig( void );
86+
87+
88+/*
89+LIBTODO_CONFIGFILE_EXTERN
90+ int ConfigFile_CreateConfig( char *pstr_code );
91+LIBTODO_CONFIGFILE_EXTERN
92+ int ConfigFile_ReadConfig( void );
93+LIBTODO_CONFIGFILE_EXTERN
94+ int ConfigFile_WriteConfig( Byte b_mode );
95+*/
96+
97+
98+#endif
99+
100+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
101+
102+
103+
104+
105+
106+/* EOF of main.c ******************************************************/
--- a/src/hvctl.c
+++ b/src/hvctl.c
@@ -282,6 +282,78 @@ int
282282 /* ===========================================================================*/
283283 VMTUI_HVCTL_EXTERN
284284 int
285+ HvCtl_SetSSHPassword(
286+ int i_hvid,
287+ char *pstr_password )
288+{
289+ HVisor *p_hv;
290+
291+ p_hv = HVisor_Use( i_hvid );
292+ if( NULL == p_hv ) {
293+ return -0x01;
294+ }
295+
296+ // Set Password
297+ if( NULL != pstr_password )
298+ { strncpy( p_hv->ssh.str_password, pstr_password, HVISOR_SSH_MAXLEN_PASSWORD ); }
299+
300+ HVisor_Release( p_hv );
301+
302+ return 0x00;
303+}
304+
305+/* ===========================================================================*/
306+VMTUI_HVCTL_EXTERN
307+int
308+ HvCtl_SetSudoInfo(
309+ int i_hvid,
310+ char *pstr_option,
311+ char *pstr_password )
312+{
313+ HVisor *p_hv;
314+
315+ p_hv = HVisor_Use( i_hvid );
316+ if( NULL == p_hv ) {
317+ return -0x01;
318+ }
319+
320+ // Set Operand
321+ if( NULL != pstr_option )
322+ { strncpy( p_hv->sudo.str_option, pstr_option, HVISOR_SUDO_MAXLEN_OPTION ); }
323+ if( NULL != pstr_password )
324+ { strncpy( p_hv->sudo.str_password, pstr_password, HVISOR_SUDO_MAXLEN_PASSWORD ); }
325+
326+ HVisor_Release( p_hv );
327+
328+ return 0x00;
329+}
330+
331+/* ===========================================================================*/
332+VMTUI_HVCTL_EXTERN
333+int
334+ HvCtl_SetSudoPassword(
335+ int i_hvid,
336+ char *pstr_password )
337+{
338+ HVisor *p_hv;
339+
340+ p_hv = HVisor_Use( i_hvid );
341+ if( NULL == p_hv ) {
342+ return -0x01;
343+ }
344+
345+ // Set Password
346+ if( NULL != pstr_password )
347+ { strncpy( p_hv->sudo.str_password, pstr_password, HVISOR_SUDO_MAXLEN_PASSWORD ); }
348+
349+ HVisor_Release( p_hv );
350+
351+ return 0x00;
352+}
353+
354+/* ===========================================================================*/
355+VMTUI_HVCTL_EXTERN
356+int
285357 HvCtl_CreateHVisor(
286358 DWord dw_type,
287359 Byte b_connection,
--- a/src/hvctl.h
+++ b/src/hvctl.h
@@ -46,6 +46,9 @@ VMTUI_HVCTL_EXTERN int HvCtl_SetSSHConnectionInfo(
4646 int i_hvid, Byte b_sshtype, char *pstr_host,
4747 Word w_port, char *pstr_user, char *pstr_password,
4848 char *pstr_pubkeypath, char *pstr_seckeypath );
49+VMTUI_HVCTL_EXTERN int HvCtl_SetSSHPassword( int i_hvid, char *pstr_password );
50+VMTUI_HVCTL_EXTERN int HvCtl_SetSudoInfo( int i_hvid, char *pstr_option, char *pstr_password );
51+VMTUI_HVCTL_EXTERN int HvCtl_SetSudoPassword( int i_hvid, char *pstr_password );
4952 VMTUI_HVCTL_EXTERN int HvCtl_CreateHVisor(
5053 DWord dw_type, Byte b_connection, char *pstr_name,
5154 DWord dw_option );
--- a/src/hvisor.h
+++ b/src/hvisor.h
@@ -102,6 +102,14 @@ typedef struct {
102102
103103 } SSH_Info;
104104
105+#define HVISOR_SUDO_MAXLEN_OPTION 64
106+#define HVISOR_SUDO_MAXLEN_PASSWORD 64
107+
108+typedef struct {
109+ char str_option[HVISOR_SUDO_MAXLEN_OPTION];
110+ char str_password[HVISOR_SUDO_MAXLEN_PASSWORD];
111+} Sudo_Info;
112+
105113 typedef struct {
106114 // System Data ----
107115 int i_id;
@@ -127,7 +135,7 @@ typedef struct {
127135 #define HVISOR_TYPE_BHYVE_DIRECTBHYVE 0x00000002|HVISOR_TYPE_BHYVE
128136 #define HVISOR_TYPE_BHYVE_LIBVIRT 0x00000004|HVISOR_TYPE_BHYVE
129137
130- #define HVISOR_TYPE_QEMUKVM_LIBVIRT 0x00000004
138+ #define HVISOR_TYPE_QEMUKVM_LIBVIRT 0x00000004|HVISOR_TYPE_QEMUKVM
131139
132140 Byte b_connection; // HVISOR_CON_***
133141
@@ -144,6 +152,7 @@ typedef struct {
144152 char str_name[HVISOR_MAXLEN_NAME];
145153
146154 SSH_Info ssh;
155+ Sudo_Info sudo;
147156
148157 HvConnect con;
149158
--- /dev/null
+++ b/src/test_configfile.c
@@ -0,0 +1,172 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+
29+#define VMTUI_SRC_TEST_CONFIGFILE
30+#include "vmtui.h"
31+#include "test_vmtui.h"
32+
33+
34+/* ===========================================================================*/
35+void
36+ Test_ConfigFile_SetConfigFilePath_Test001( void ) {
37+
38+ int i_err = 0x00;
39+
40+ i_err = ErrInfo_Init( 0x00, ERRINFO_FLAG_NONE );
41+ CU_ASSERT( 0x00 == i_err );
42+
43+ ConfigFile_SetConfigFilePath( "./testfile", NULL );
44+ CU_ASSERT( 0x00 ==
45+ strncmp( ConfigFile_GetFilePath(), "./testfile/vmtui.conf", 255) );
46+
47+ ConfigFile_SetConfigFilePath( NULL, NULL );
48+ CU_ASSERT( 0x00 ==
49+ strncmp( ConfigFile_GetFilePath(), "/usr/local/etc/vmtui.conf", 255) );
50+
51+ ErrInfo_Term();
52+
53+ return;
54+}
55+
56+
57+/* ===========================================================================*/
58+void
59+ Test_ConfigFile_ReadConfigFile_Test001( void ) {
60+
61+ int i_err = 0x00;
62+
63+ i_err = ErrInfo_Init( 0x00, ERRINFO_FLAG_NONE );
64+ CU_ASSERT( 0x00 == i_err );
65+
66+ i_err = HVisor_Init();
67+ CU_ASSERT( 0x00 == i_err );
68+
69+ ConfigFile_SetConfigFilePath( "./testfile", NULL );
70+ CU_ASSERT( 0x00 ==
71+ strncmp( ConfigFile_GetFilePath(), "./testfile/vmtui.conf", 255) );
72+
73+ ConfigFile_ReadConfig();
74+
75+ HVisor_Term();
76+
77+ ErrInfo_Term();
78+
79+ return;
80+}
81+
82+/* ===========================================================================*/
83+void
84+ Test_ConfigFile_ReadConfigFile_Test002( void ) {
85+
86+ int i_err = 0x00;
87+ int i_hvisor;
88+ HVisor *p_hvisor;
89+
90+ i_err = ErrInfo_Init( 0x00, ERRINFO_FLAG_NONE );
91+ CU_ASSERT( 0x00 == i_err );
92+
93+ i_err = HVisor_Init();
94+ CU_ASSERT( 0x00 == i_err );
95+
96+ ConfigFile_SetConfigFilePath( "./testfile", "test_vmtui.conf" );
97+ CU_ASSERT( 0x00 ==
98+ strncmp( ConfigFile_GetFilePath(), "./testfile/test_vmtui.conf", 255) );
99+
100+ ConfigFile_ReadConfig();
101+
102+ i_hvisor = HVisor_GetTopID();
103+ while( HVISOR_ID_NONE != i_hvisor ) {
104+ p_hvisor = HVisor_Ref( i_hvisor );
105+
106+ if( !strncmp( p_hvisor->str_name, "Local HyperVisor", HVISOR_MAXLEN_NAME ) ) {
107+ CU_ASSERT( p_hvisor->b_connection == HVISOR_CON_LOCALHOST );
108+ CU_ASSERT_STRING_EQUAL( p_hvisor->str_name, "Local HyperVisor" );
109+ CU_ASSERT_STRING_NOT_EQUAL( p_hvisor->ssh.str_hostfqdn, "localhost.localdomain" );
110+ CU_ASSERT( p_hvisor->dw_type == (HVISOR_TYPE_BHYVE_DIRECTBHYVE) );
111+ CU_ASSERT( p_hvisor->dw_option == HVISOR_OPTION_NONE );
112+ }
113+ else if( !strncmp( p_hvisor->str_name, "Remote HyperVisor1", HVISOR_MAXLEN_NAME ) ) {
114+ CU_ASSERT( p_hvisor->b_connection == HVISOR_CON_REMOTE_SSH );
115+ CU_ASSERT_STRING_EQUAL( p_hvisor->str_name, "Remote HyperVisor1" );
116+ CU_ASSERT_STRING_EQUAL( p_hvisor->ssh.str_hostfqdn, "hypervisor1.localdomain" );
117+ CU_ASSERT( p_hvisor->ssh.b_sshtype == HVISOR_SSH_AUTH_PASSWD );
118+ CU_ASSERT( p_hvisor->ssh.w_port == 22 );
119+ CU_ASSERT_STRING_EQUAL( p_hvisor->ssh.str_user, "testuser" );
120+ CU_ASSERT_STRING_EQUAL( p_hvisor->ssh.str_password, "password1" );
121+ CU_ASSERT( p_hvisor->dw_type == (HVISOR_TYPE_BHYVE_VMBHYVE) );
122+ CU_ASSERT( p_hvisor->dw_option == HVISOR_OPTION_SUDO );
123+ CU_ASSERT_STRING_EQUAL( p_hvisor->sudo.str_option, "-a -b" );
124+ CU_ASSERT_STRING_EQUAL( p_hvisor->sudo.str_password, "password2" );
125+ }
126+ else if( !strncmp( p_hvisor->str_name, "Remote HyperVisor2", HVISOR_MAXLEN_NAME ) ) {
127+ CU_ASSERT( p_hvisor->b_connection == HVISOR_CON_REMOTE_SSH );
128+ CU_ASSERT_STRING_EQUAL( p_hvisor->str_name, "Remote HyperVisor2" );
129+ CU_ASSERT_STRING_EQUAL( p_hvisor->ssh.str_hostfqdn, "hypervisor2.localdomain" );
130+ CU_ASSERT( p_hvisor->ssh.b_sshtype == HVISOR_SSH_AUTH_PUBKEY );
131+ CU_ASSERT( p_hvisor->ssh.w_port == 2222 );
132+ CU_ASSERT_STRING_EQUAL( p_hvisor->ssh.str_user, "testuser2" );
133+ CU_ASSERT_STRING_EQUAL( p_hvisor->ssh.str_password, "password3" );
134+ CU_ASSERT( p_hvisor->dw_type == (HVISOR_TYPE_BHYVE_LIBVIRT) );
135+ CU_ASSERT( p_hvisor->dw_option == HVISOR_OPTION_NONE );
136+ CU_ASSERT_STRING_EQUAL( p_hvisor->sudo.str_option, "" );
137+ CU_ASSERT_STRING_EQUAL( p_hvisor->sudo.str_password, "" );
138+ }
139+
140+ i_hvisor = HVisor_GetNextID( i_hvisor );
141+ }
142+
143+ HVisor_Term();
144+
145+ ErrInfo_Term();
146+
147+ return;
148+}
149+
150+/* ===========================================================================*/
151+VMTUI_TEST_CONFIGFILE_EXTERN
152+int
153+ Test_ConfigFile(
154+ void ) {
155+
156+ CU_pSuite pt_configfile;
157+
158+ pt_configfile = CU_add_suite( "VMTUI_Template", NULL, NULL );
159+
160+ CU_add_test( pt_configfile, "VMTUI_ConfigFile_SetConfigFilePath_test001",
161+ Test_ConfigFile_SetConfigFilePath_Test001 );
162+ CU_add_test( pt_configfile, "VMTUI_ConfigFile_ReadConfigFile_test001",
163+ Test_ConfigFile_ReadConfigFile_Test001 );
164+ CU_add_test( pt_configfile, "VMTUI_ConfigFile_ReadConfigFile_test002",
165+ Test_ConfigFile_ReadConfigFile_Test002 );
166+
167+ return 0x00;
168+}
169+
170+
171+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
172+
--- /dev/null
+++ b/src/test_template.c
@@ -0,0 +1,63 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+
29+#define VMTUI_SRC_TEST_TEMPLATE
30+#include "vmtui.h"
31+#include "test_vmtui.h"
32+
33+
34+/* ===========================================================================*/
35+void
36+ Test_Template_Function_OK001( void ) {
37+
38+ int i_err;
39+
40+ CU_ASSERT( 0x00 == i_err );
41+
42+ return;
43+}
44+
45+
46+/* ===========================================================================*/
47+VMTUI_TEST_TEMPLATE_EXTERN
48+int
49+ Test_Template(
50+ void ) {
51+
52+ CU_pSuite pt_template;
53+
54+ pt_template = CU_add_suite( "VMTUI_Template", NULL, NULL );
55+
56+ CU_add_test( pt_template, "VMTUI_Template_Function_OK001", Test_Template_Function_OK001 );
57+
58+ return 0x00;
59+}
60+
61+
62+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
63+
--- a/src/test_vmtui.c
+++ b/src/test_vmtui.c
@@ -45,6 +45,7 @@ int
4545 Test_HvCtl();
4646 Test_GuestCtl();
4747 Test_ErrInfo();
48+ Test_ConfigFile();
4849
4950 CU_basic_run_tests();
5051 CU_cleanup_registry();
--- a/src/test_vmtui.h
+++ b/src/test_vmtui.h
@@ -73,6 +73,13 @@ VMTUI_TEST_GUESTCTL_EXTERN int Test_GuestCtl( void );
7373 #endif
7474 VMTUI_TEST_ERRINFO_EXTERN int Test_ErrInfo( void );
7575
76+#ifdef VMTUI_SRC_TEST_CONFIGFILE
77+ #define VMTUI_TEST_CONFIGFILE_EXTERN
78+#else
79+ #define VMTUI_TEST_CONFIGFILE_EXTERN extern
80+#endif
81+VMTUI_TEST_CONFIGFILE_EXTERN int Test_ConfigFile( void );
82+
7683 #endif
7784
7885 /* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
--- /dev/null
+++ b/src/testfile/test_vmtui.conf
@@ -0,0 +1,84 @@
1+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+# VMTUI (Virtual machine Management Terminal User Interface)
3+#
4+# Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+#
6+# Redistribution and use in source and binary forms, with or without
7+# modification, are permitted provided that the following conditions are met:
8+#
9+# 1. Redistributions of source code must retain the above copyright notice,
10+# this list of conditions and the following disclaimer.
11+# 2. Redistributions in binary form must reproduce the above copyright
12+# notice, this list of conditions and the following disclaimer in the
13+# documentation and/or other materials provided with the distribution.
14+#
15+# THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+# IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+#
26+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
27+
28+[Global]
29+
30+
31+# [Server]
32+# Connection={Local, SSH}
33+# HostName=<Server FQDN>
34+# SSH_AuthType=<Pasword, PubKey, HostBased>
35+# SSH_Port=<SSH PortNumber> default:22
36+# SSH_User=<SSH User> default: vmtui Operation UserName
37+# SSH_Password=<SSH Password>
38+# HyperVisor={VmBhyve, BhyveDirect, Bhyve_libvirt, qemuKVM_libvirt}
39+# sudo_Enable={Yes, No}
40+# sudo_Option=
41+# sudo_Password=
42+
43+[HyperVisor]
44+Connection=Local
45+ServerName=Local HyperVisor
46+HostName=localhost.localdomain
47+SSH_AuthType=
48+SSH_Port=
49+SSH_User=
50+SSH_Password=
51+SSH_PubkeyPath=
52+SSH_SeckeyPath=
53+HyperVisor=BhyveDirect
54+sudo_Enable=No
55+sudo_Option=
56+sudo_Password=
57+
58+[HyperVisor]
59+Connection=SSH
60+ServerName=Remote HyperVisor1
61+HostName=hypervisor1.localdomain
62+SSH_AuthType=Pasword
63+SSH_Port=22
64+SSH_User=testuser
65+SSH_Password=password1
66+HyperVisor=VmBhyve
67+sudo_Enable=Yes
68+sudo_Option=-a -b
69+sudo_Password=password2
70+
71+[HyperVisor]
72+Connection=SSH
73+ServerName=Remote HyperVisor2
74+HostName=hypervisor2.localdomain
75+SSH_AuthType=PubKey
76+SSH_Port=2222
77+SSH_User=testuser2
78+SSH_Password=password3
79+HyperVisor=libvirt
80+sudo_Enable=no
81+sudo_Option=
82+sudo_Password=
83+
84+
--- /dev/null
+++ b/src/testfile/vmtui.conf
@@ -0,0 +1,71 @@
1+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+# VMTUI (Virtual machine Management Terminal User Interface)
3+#
4+# Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+#
6+# Redistribution and use in source and binary forms, with or without
7+# modification, are permitted provided that the following conditions are met:
8+#
9+# 1. Redistributions of source code must retain the above copyright notice,
10+# this list of conditions and the following disclaimer.
11+# 2. Redistributions in binary form must reproduce the above copyright
12+# notice, this list of conditions and the following disclaimer in the
13+# documentation and/or other materials provided with the distribution.
14+#
15+# THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+# IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+#
26+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
27+
28+[Global]
29+
30+
31+# [Server]
32+# Connection={Local, SSH}
33+# HostName=<Server FQDN>
34+# SSH_AuthType=<Pasword, PubKey, HostBased>
35+# SSH_Port=<SSH PortNumber> default:22
36+# SSH_User=<SSH User> default: vmtui Operation UserName
37+# SSH_Password=<SSH Password>
38+# HyperVisor={VmBhyve, BhyveDirect, libvirt}
39+# sudo_Enable={Yes, No}
40+# sudo_Option=
41+# sudo_Password=
42+
43+[HyperVisor]
44+Connection=Local
45+ServerName=Local HyperVisor
46+HostName=
47+SSH_AuthType=
48+SSH_Port=
49+SSH_User=
50+SSH_Password=
51+SSH_PubkeyPath=
52+SSH_SeckeyPath=
53+HyperVisor=VmBhyve
54+sudo_Enable=Yes
55+sudo_Option=
56+sudo_Password=
57+
58+[HyperVisor]
59+Connection=SSH
60+ServerName=Remote HyperVisor
61+HostName=hypervisor.localdomain
62+SSH_AuthType=Pasword
63+SSH_Port=22
64+SSH_User=
65+SSH_Password=
66+HyperVisor=VmBhyve
67+sudo_Enable=Yes
68+sudo_Option=
69+sudo_Password=
70+
71+
--- a/src/vmtui.h
+++ b/src/vmtui.h
@@ -86,6 +86,7 @@ typedef unsigned long QWord;
8686 #include "guestctl.h"
8787 #include "vmbhyve.h"
8888 #include "hvcmd.h"
89+#include "configfile.h"
8990 #include "tuititle.h"
9091 #include "tuistatus.h"
9192 #include "tuihvisor.h"