@@ -156,10 +156,10 @@ static int RunTest(const TEST_CASE* tc)
156156
157157 ret = tc -> func ();
158158 if (ret != 0 ) {
159- Log ( "%s FAILED.\n" , tc -> name );
159+ fprintf ( stderr , "%s FAILED (ret=%d) .\n" , tc -> name , ret );
160160 }
161161 else {
162- Log ( "%s PASSED.\n" , tc -> name );
162+ fprintf ( stderr , "%s PASSED.\n" , tc -> name );
163163 }
164164
165165 TestCleanup ();
@@ -173,6 +173,32 @@ typedef struct {
173173 int shouldFail ;
174174} CONFIG_LINE_VECTOR ;
175175
176+ static int test_ConfigDefaults (void )
177+ {
178+ int ret = WS_SUCCESS ;
179+ WOLFSSHD_CONFIG * conf ;
180+
181+ conf = wolfSSHD_ConfigNew (NULL );
182+ if (conf == NULL )
183+ ret = WS_MEMORY_E ;
184+
185+ if (ret == WS_SUCCESS ) {
186+ if (wolfSSHD_ConfigGetGraceTime (conf ) != 120 )
187+ ret = WS_FATAL_ERROR ;
188+ }
189+ if (ret == WS_SUCCESS ) {
190+ if (wolfSSHD_ConfigGetPort (conf ) != 22 )
191+ ret = WS_FATAL_ERROR ;
192+ }
193+ if (ret == WS_SUCCESS ) {
194+ if (wolfSSHD_ConfigGetPwAuth (conf ) == 0 )
195+ ret = WS_FATAL_ERROR ;
196+ }
197+
198+ wolfSSHD_ConfigFree (conf );
199+ return ret ;
200+ }
201+
176202static int test_ParseConfigLine (void )
177203{
178204 int ret = WS_SUCCESS ;
@@ -277,16 +303,16 @@ static int test_ConfigCopy(void)
277303 ret = wolfSSHD_ConfigSetHostCertFile (head , "/etc/ssh/host_cert.pub" );
278304 if (ret == WS_SUCCESS )
279305 ret = wolfSSHD_ConfigSetUserCAKeysFile (head , "/etc/ssh/ca.pub" );
280- if ( ret == WS_SUCCESS )
281- ret = wolfSSHD_ConfigSetAuthKeysFile ( head , " .ssh/authorized_keys" );
306+ /* AuthorizedKeysFile must go through PCL so authKeysFileSet flag is set */
307+ if ( ret == WS_SUCCESS ) ret = PCL ( "AuthorizedKeysFile .ssh/authorized_keys" );
282308
283309 /* scalar fields */
284310 if (ret == WS_SUCCESS ) ret = PCL ("Port 2222" );
285311 if (ret == WS_SUCCESS ) ret = PCL ("LoginGraceTime 30" );
286312 if (ret == WS_SUCCESS ) ret = PCL ("PasswordAuthentication yes" );
287313 if (ret == WS_SUCCESS ) ret = PCL ("PermitEmptyPasswords yes" );
288314 if (ret == WS_SUCCESS ) ret = PCL ("PermitRootLogin yes" );
289- if (ret == WS_SUCCESS ) ret = PCL ("UsePrivilegeSeparation yes " );
315+ if (ret == WS_SUCCESS ) ret = PCL ("UsePrivilegeSeparation sandbox " );
290316
291317 /* trigger ConfigCopy via Match; conf advances to the new node */
292318 if (ret == WS_SUCCESS ) ret = PCL ("Match User testuser" );
@@ -370,7 +396,7 @@ static int test_ConfigCopy(void)
370396 ret = WS_FATAL_ERROR ;
371397 }
372398 if (ret == WS_SUCCESS ) {
373- if (wolfSSHD_ConfigGetPrivilegeSeparation (match ) == 0 )
399+ if (wolfSSHD_ConfigGetPrivilegeSeparation (match ) != WOLFSSHD_PRIV_SANDBOX )
374400 ret = WS_FATAL_ERROR ;
375401 }
376402
@@ -467,6 +493,7 @@ static int test_CheckPasswordHashUnix(void)
467493#endif /* WOLFSSH_HAVE_LIBCRYPT || WOLFSSH_HAVE_LIBLOGIN */
468494
469495const TEST_CASE testCases [] = {
496+ TEST_DECL (test_ConfigDefaults ),
470497 TEST_DECL (test_ParseConfigLine ),
471498 TEST_DECL (test_ConfigCopy ),
472499 TEST_DECL (test_ConfigFree ),
0 commit comments