- if (conf.loglevel_arg <= NOTICE)
- cmdline_parser_print_version();
- PARA_INFO_LOG(
- "current loglevel: %d\n"
- "using config_file: %s\n"
- "using key_file: %s\n"
- "connecting to %s:%d\n",
- conf.loglevel_arg,
- config_file,
- key_file,
- conf.hostname_arg,
- conf.server_port_arg
- );
- ret = - E_CLIENT_SYNTAX;
- if (!conf.inputs_num)
- goto out;
- /* concat args */
- for (i = 0; i < conf.inputs_num; i++)
- append_str(&command, conf.inputs[i]);
- crypt_function_recv = NULL;
- crypt_function_send = NULL;
- /* get the host info */
- PARA_NOTICE_LOG("getting host info of %s\n",
- conf.hostname_arg);
- ret = get_host_info(conf.hostname_arg, &he);
- if (ret < 0)
- goto out;
- /* get new socket */
- ret = get_socket();
- if (ret < 0)
- goto out;
- sockfd = ret;
- /* init their_addr */
- init_sockaddr(&their_addr, conf.server_port_arg, he);
- /* connect */
- PARA_NOTICE_LOG("connecting to %s\n", conf.hostname_arg);
- ret = para_connect(sockfd, &their_addr);
- if (ret < 0)
- goto out;
- /* receive welcome message */
- ret = recv_buffer(sockfd, buf, sizeof(buf));
- if (ret < 0)
- goto out;
- /* send auth command */
- auth_str = make_message("auth %s%s", conf.plain_given? "" : "rc4 ",
- conf.user_arg);
- PARA_INFO_LOG("<-- %s--> %s\n", buf, auth_str);
- ret = send_buffer(sockfd, auth_str);
- if (ret < 0)
- goto out;
- /* receive challenge number */
- ret = recv_buffer(sockfd, buf, sizeof(buf));
- if (ret < 0)
- goto out;
- if (ret != 64) {
- ret = -E_INVALID_CHALLENGE;
- PARA_ERROR_LOG("received the following: %s\n", buf);
- goto out;
- }
- PARA_INFO_LOG("%s", "<-- [challenge]\n");
- /* decrypt challenge number */
- ret = para_decrypt_challenge(key_file, &challenge_nr, (unsigned char *) buf, 64);
- if (ret < 0)
- goto out;
- /* send decrypted challenge */
- PARA_INFO_LOG("--> %lu\n", challenge_nr);
- ret = send_va_buffer(sockfd, "%s%lu", CHALLENGE_RESPONSE_MSG, challenge_nr);