Skip to content

Commit 5858e6d

Browse files
romanmichalvasko
authored andcommitted
session server ssh REFACTOR change local to system
1 parent 4a1dcdf commit 5858e6d

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/session_server_ssh.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ nc_server_ssh_get_pwd_hash(const char *username)
569569

570570
pwd = nc_server_ssh_getpwnam(username, &pwd_buf, &buf, &buf_size);
571571
if (!pwd) {
572-
VRB(NULL, "User \"%s\" not found locally.", username);
572+
VRB(NULL, "User \"%s\" not found in the system.", username);
573573
goto error;
574574
}
575575

@@ -906,7 +906,7 @@ nc_server_ssh_auth_kbdint_pam(struct nc_session *session, const char *username,
906906
#elif defined (HAVE_SHADOW)
907907

908908
/**
909-
* @brief Authenticate using locally stored credentials.
909+
* @brief Authenticate using credentials stored in the system.
910910
*
911911
* @param[in] session Session to authenticate on.
912912
* @param[in] username Username of the client to authenticate.
@@ -920,13 +920,12 @@ nc_server_ssh_auth_kbdint_system(struct nc_session *session, const char *usernam
920920
int ret = 0, n_answers;
921921
const char *name = "Keyboard-Interactive Authentication";
922922
const char *instruction = "Please enter your authentication token";
923-
char *prompt = NULL, *local_pw = NULL, *received_pw = NULL;
923+
char *prompt = NULL, *pw = NULL, *received_pw = NULL;
924924
char echo[] = {0};
925925

926-
/* try to get the client's locally stored pw hash */
927-
local_pw = nc_server_ssh_get_pwd_hash(username);
928-
if (!local_pw) {
929-
ERR(session, "Unable to get %s's credentials.", username);
926+
/* try to get the client's pw hash from the system */
927+
pw = nc_server_ssh_get_pwd_hash(username);
928+
if (!pw) {
930929
ret = 1;
931930
goto cleanup;
932931
}
@@ -957,10 +956,10 @@ nc_server_ssh_auth_kbdint_system(struct nc_session *session, const char *usernam
957956
NC_CHECK_ERRMEM_GOTO(!received_pw, ret = 1, cleanup);
958957

959958
/* cmp the passwords */
960-
ret = nc_server_ssh_compare_password(local_pw, received_pw);
959+
ret = nc_server_ssh_compare_password(pw, received_pw);
961960

962961
cleanup:
963-
free(local_pw);
962+
free(pw);
964963
free(received_pw);
965964
free(prompt);
966965
return ret;
@@ -1178,7 +1177,7 @@ nc_server_ssh_auth_none(int local_users_supported, struct nc_auth_client *auth_c
11781177
return 0;
11791178
}
11801179

1181-
/* reply and return -1 so that this does not get counted as an usuccessful authentication attempt */
1180+
/* reply and return -1 so that this does not get counted as an unsuccessful authentication attempt */
11821181
ssh_message_reply_default(msg);
11831182
return -1;
11841183
}
@@ -1312,7 +1311,7 @@ nc_server_ssh_auth_kbdint(struct nc_session *session, int local_users_supported,
13121311
/* authenticate using PAM */
13131312
rc = nc_server_ssh_auth_kbdint_pam(session, session->username, msg);
13141313
#elif defined (HAVE_SHADOW)
1315-
/* authenticate using locally configured users */
1314+
/* authenticate using the system */
13161315
rc = nc_server_ssh_auth_kbdint_system(session, session->username, msg);
13171316
#else
13181317
ERR(NULL, "Keyboard-interactive method not supported.");
@@ -1716,8 +1715,10 @@ nc_session_ssh_msg(struct nc_session *session, struct nc_server_ssh_opts *opts,
17161715
/* check if local-users-supported feature is enabled */
17171716
rc = lys_feature_value(mod, "local-users-supported");
17181717
if (!rc) {
1718+
/* using users from the YANG data */
17191719
local_users_supported = 1;
17201720
} else if (rc == LY_ENOT) {
1721+
/* using users from the system */
17211722
local_users_supported = 0;
17221723
} else {
17231724
ERRINT;

0 commit comments

Comments
 (0)