auth1.c   auth1.c 
skipping to change at line 24 skipping to change at line 24
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILI TY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILI TY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details. * License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to * along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA. * MA 02111-1307, USA.
*/ */
#include "config.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "libssh/priv.h" #include "libssh/priv.h"
#include "libssh/ssh1.h" #include "libssh/ssh1.h"
#include "libssh/buffer.h"
#include "libssh/packet.h"
#include "libssh/session.h"
#include "libssh/string.h"
#ifdef WITH_SSH1 #ifdef WITH_SSH1
static int wait_auth1_status(SSH_SESSION *session) { static int wait_auth1_status(ssh_session session) {
/* wait for a packet */ /* wait for a packet */
if (packet_read(session) != SSH_OK) { if (packet_read(session) != SSH_OK) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
if(packet_translate(session) != SSH_OK) { if(packet_translate(session) != SSH_OK) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
switch(session->in_packet.type) { switch(session->in_packet.type) {
skipping to change at line 54 skipping to change at line 60
case SSH_SMSG_FAILURE: case SSH_SMSG_FAILURE:
return SSH_AUTH_DENIED; return SSH_AUTH_DENIED;
} }
ssh_set_error(session, SSH_FATAL, "Was waiting for a SUCCESS or " ssh_set_error(session, SSH_FATAL, "Was waiting for a SUCCESS or "
"FAILURE, got %d", session->in_packet.type); "FAILURE, got %d", session->in_packet.type);
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
static int send_username(SSH_SESSION *session, const char *username) { static int send_username(ssh_session session, const char *username) {
STRING *user = NULL; ssh_string user = NULL;
/* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */ /* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */
if(session->auth_service_asked) { if(session->auth_service_asked) {
return session->auth_service_asked; return session->auth_service_asked;
} }
if (!username) { if (!username) {
if(!(username = session->options->username)) { if(!(username = session->username)) {
if(ssh_options_default_username(session->options)) { if (ssh_options_set(session, SSH_OPTIONS_USER, NULL) < 0) {
return session->auth_service_asked = SSH_AUTH_ERROR; return session->auth_service_asked = SSH_AUTH_ERROR;
} else { } else {
username = session->options->username; username = session->username;
} }
} }
} }
user = string_from_char(username); user = string_from_char(username);
if (user == NULL) { if (user == NULL) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
if (buffer_add_u8(session->out_buffer, SSH_CMSG_USER) < 0) { if (buffer_add_u8(session->out_buffer, SSH_CMSG_USER) < 0) {
string_free(user); string_free(user);
skipping to change at line 94 skipping to change at line 100
if (packet_send(session) != SSH_OK) { if (packet_send(session) != SSH_OK) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
session->auth_service_asked = wait_auth1_status(session); session->auth_service_asked = wait_auth1_status(session);
return session->auth_service_asked; return session->auth_service_asked;
} }
/* use the "none" authentication question */ /* use the "none" authentication question */
int ssh_userauth1_none(SSH_SESSION *session, const char *username){ int ssh_userauth1_none(ssh_session session, const char *username){
return send_username(session, username); return send_username(session, username);
} }
/* /*
int ssh_userauth_offer_pubkey(SSH_SESSION *session, char *username,int type int ssh_userauth_offer_pubkey(ssh_session session, char *username,int type,
, STRING *publickey){ ssh_string publickey){
STRING *user; ssh_string user;
STRING *service; ssh_string service;
STRING *method; ssh_string method;
STRING *algo; ssh_string algo;
int err=SSH_AUTH_ERROR; int err=SSH_AUTH_ERROR;
if(!username) if(!username)
if(!(username=session->options->username)){ if(!(username=session->options->username)){
if(options_default_username(session->options)) if(options_default_username(session->options))
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
else else
username=session->options->username; username=session->options->username;
} }
if(ask_userauth(session)) if(ask_userauth(session))
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
skipping to change at line 139 skipping to change at line 145
free(user); free(user);
free(method); free(method);
free(service); free(service);
free(algo); free(algo);
return err; return err;
} }
*/ */
/** \internal /** \internal
* \todo implement ssh1 public key * \todo implement ssh1 public key
*/ */
int ssh_userauth1_offer_pubkey(SSH_SESSION *session, const char *username, int ssh_userauth1_offer_pubkey(ssh_session session, const char *username,
int type, STRING *pubkey) { int type, ssh_string pubkey) {
(void) session; (void) session;
(void) username; (void) username;
(void) type; (void) type;
(void) pubkey; (void) pubkey;
return SSH_AUTH_DENIED; return SSH_AUTH_DENIED;
} }
/* /*
int ssh_userauth_pubkey(SSH_SESSION *session, char *username, STRING *publi int ssh_userauth_pubkey(ssh_session session, char *username, ssh_string pub
ckey, PRIVATE_KEY *privatekey){ lickey, ssh_private_key privatekey){
STRING *user; ssh_string user;
STRING *service; ssh_string service;
STRING *method; ssh_string method;
STRING *algo; ssh_string algo;
STRING *sign; ssh_string sign;
int err=SSH_AUTH_ERROR; int err=SSH_AUTH_ERROR;
if(!username) if(!username)
if(!(username=session->options->username)){ if(!(username=session->options->username)){
if(options_default_username(session->options)) if(options_default_username(session->options))
return err; return err;
else else
username=session->options->username; username=session->options->username;
} }
if(ask_userauth(session)) if(ask_userauth(session))
return err; return err;
skipping to change at line 194 skipping to change at line 200
err=wait_auth_status(session,0); err=wait_auth_status(session,0);
} }
free(user); free(user);
free(service); free(service);
free(method); free(method);
free(algo); free(algo);
return err; return err;
} }
*/ */
int ssh_userauth1_password(SSH_SESSION *session, const char *username, int ssh_userauth1_password(ssh_session session, const char *username,
const char *password) { const char *password) {
STRING *pwd = NULL; ssh_string pwd = NULL;
int rc; int rc;
rc = send_username(session, username); rc = send_username(session, username);
if (rc != SSH_AUTH_DENIED) { if (rc != SSH_AUTH_DENIED) {
return rc; return rc;
} }
/* we trick a bit here. A known flaw in SSH1 protocol is that it's /* we trick a bit here. A known flaw in SSH1 protocol is that it's
* easy to guess password sizes. * easy to guess password sizes.
* not that sure ... * not that sure ...
 End of changes. 12 change blocks. 
24 lines changed or deleted 30 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/