init: apply settings to context in iscsi_parse_url

if iscsi_context is not NULL we apply the parsed settings
to the context.

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2015-03-26 10:32:19 +01:00
parent a45094b7a7
commit 2955b2c616
9 changed files with 20 additions and 88 deletions

View File

@@ -172,12 +172,8 @@ void list_luns(struct client_state *clnt, const char *target, const char *portal
printf("Failed to create context\n");
exit(10);
}
if (clnt->username != NULL) {
if (iscsi_set_initiator_username_pwd(iscsi, clnt->username, clnt->password) != 0) {
fprintf(stderr, "Failed to set initiator username and password\n");
exit(10);
}
}
iscsi_set_initiator_username_pwd(iscsi, clnt->username, clnt->password);
if (iscsi_set_targetname(iscsi, target)) {
fprintf(stderr, "Failed to set target name\n");
exit(10);
@@ -430,14 +426,9 @@ int main(int argc, char *argv[])
iscsi_set_session_type(iscsi, ISCSI_SESSION_DISCOVERY);
if (iscsi_url->user[0]) {
state.username = iscsi_url->user;
state.password = iscsi_url->passwd;
if (iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user, iscsi_url->passwd) != 0) {
fprintf(stderr, "Failed to set initiator username and password\n");
exit(10);
}
}
state.username = iscsi_url->user;
state.password = iscsi_url->passwd;
if (iscsi_connect_async(iscsi, iscsi_url->portal, discoveryconnect_cb, &state) != 0) {
fprintf(stderr, "iscsi_connect failed. %s\n", iscsi_get_error(iscsi));
exit(10);