Compare commits

..

18 Commits

Author SHA1 Message Date
Matt Johnston
6766dfae26 merge of cc7d47b52fc39dc6940ea8fff5b782fbd44a2f6c
and f697d6be3bdf1a59bfd78dc1239ea417d52904a7

--HG--
extra : convert_revision : b1cb6d6bba496c942d1850d0f6ca5d71c0deaf1f
2004-09-16 06:19:39 +00:00
Matt Johnston
199b67a68c Added dropbear.8 and dropbearkey.8 back in
--HG--
extra : convert_revision : dda3a93a5b9fb3338ea7fc45c45da6b76e3850f0
2004-09-14 15:26:50 +00:00
Matt Johnston
644488a5f3 put the #ifdefs back in for authpam
--HG--
extra : convert_revision : 93ad501313c213d77753d57def15f2c8cf5db8d7
2004-09-14 14:36:42 +00:00
Matt Johnston
1ace08645a Oops, PAM was on by default in options.h
--HG--
extra : convert_revision : 8f9d07675e82e64ef083bbdb833d0b2dbfe4d187
2004-09-14 13:47:10 +00:00
Matt Johnston
636b041b9b 0.44test4 probably
also bumped the channel recv window sizing

--HG--
extra : convert_revision : 2ab172def950d852426cf2c2e066c29aa50e2de9
2004-09-14 13:22:32 +00:00
Matt Johnston
a41f9dc036 calloc memory rather than mallocing it - can't hurt too much, and is
probably a bit safer

--HG--
extra : convert_revision : bbd2edbb1410ea8fd7bee089f60154f76d2a0ab7
2004-09-14 13:18:16 +00:00
Matt Johnston
448a05ae2c propagate of f51a272341ee12268fe7028bc2f2bad66c603069 and ab35ee4292ea910d4871c3609d6100fe34300720 from branch 'matt.dbclient.rez' to 'matt.dbclient.work'
--HG--
branch : private-rez
extra : convert_revision : 23e9cf6a5b5e33f172b7b8505c0731ce9c0b93df
2004-09-14 13:09:29 +00:00
Matt Johnston
099c9a3232 PAM improvements
--HG--
branch : private-rez
extra : convert_revision : c8f9300c5d598fe6003fcf19c831f5982620ec98
2004-09-14 12:51:16 +00:00
Matt Johnston
2575e227a5 Don't need to burn the payload buffer since process-packet.c does it
--HG--
extra : convert_revision : 12619953d6d88a1b8b0afc4dd5f6e0e2f8b324a0
2004-09-12 05:53:48 +00:00
Matt Johnston
fa26b59b0c propagate of 08347df3bca787bd3621602fe2b466c85c9dc3e2 and 717950f4061f1123659ee87c7c168805af920ab7 from branch 'matt.dbclient.rez' to 'matt.dbclient.authpam'
--HG--
branch : private-rez
extra : convert_revision : 555c429bf4e557ea5fd0af9db3987166d8217d8b
2004-09-12 05:52:36 +00:00
Matt Johnston
c23ffe4bc1 propagate of 717950f4061f1123659ee87c7c168805af920ab7 and 839f98f136788cc1466e4641bf796f96040a085d from branch 'matt.dbclient.authpam' to 'matt.dbclient.rez'
--HG--
branch : private-rez
extra : convert_revision : d58a4ff37f9784978a07df6a944f7dbae8196f6d
2004-09-12 04:56:50 +00:00
Matt Johnston
7ed5870ed9 Read the last line of a file without a finishing '\n' correctly
--HG--
branch : private-rez
extra : convert_revision : f64591461a40d54a2bd2e12493253ec76eab1ff2
2004-09-02 18:36:11 +00:00
Matt Johnston
8559be015a Check for non-matching algos properly
--HG--
extra : convert_revision : 20ab9edd3f3f714ecc4630bb97912185d88aa376
2004-09-02 15:24:17 +00:00
Matt Johnston
cb0657bdf3 WCOREDUMP finally
--HG--
extra : convert_revision : 12aa4fdb328febedfd3fd50d1dae783d8a0dab14
2004-08-31 08:52:41 +00:00
Matt Johnston
15fb479e94 Leak found with MallocDebug - it's kinda useful
--HG--
extra : convert_revision : 43fdd8b10616b9d5e11f677d16763c7a876a5ec3
2004-08-30 15:02:45 +00:00
Matt Johnston
0378cffafc Load the hostkeys for inetd too - oops
--HG--
extra : convert_revision : 815f75b9a450396fd5a9cca286803a91f0edc1a9
2004-08-30 13:26:42 +00:00
Matt Johnston
51fb224ef8 options.h
--HG--
extra : convert_revision : 10b3693ebf2d3f713a16aedf214e26bc8a04b9e6
2004-08-27 17:01:18 +00:00
Matt Johnston
3238bed9c9 svr-authpam code merged and works. needs tidying a log
--HG--
branch : authpam
extra : convert_revision : abeb2807b88fbd8b95d92b760a209a0816cbaea9
2004-08-08 16:57:37 +00:00
18 changed files with 470 additions and 29 deletions

19
CHANGES
View File

@@ -1,3 +1,22 @@
0.44test4 - Tue Sept 14 21:15:54 +0800
- Fix inetd mode so it actually loads the hostkeys (oops)
- Changed DROPBEAR_DEFPORT properly everywhere
- Fix a small memory leak in the auth code
- WCOREDUMP is only used on systems which support it (ie not cygwin or AIX)
- Check (and fail for) cases when we can't negotiate algorithms with the
remote side successfully (rather than bombing out ungracefully)
- Handle authorized_keys files without a terminating newline
- Fiddle the channel receive window size for possibly better performance
- Added in the PAM authentication code (finally! thanks to Martin Carlsson)
0.44test3 - Fri Aug 27 22:20:54 +0800
- Fixed a bunch of warnings.

View File

@@ -24,7 +24,7 @@ COMMONOBJS=dbutil.o buffer.o \
SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
svr-authpasswd.o svr-authpubkey.o svr-session.o svr-service.o \
svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
svr-tcpfwd.o
svr-tcpfwd.o svr-authpam.o
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
cli-session.o cli-service.o cli-runopts.o cli-chansession.o \

1
auth.h
View File

@@ -36,6 +36,7 @@ void send_msg_userauth_failure(int partial, int incrfail);
void send_msg_userauth_success();
void svr_auth_password();
void svr_auth_pubkey();
void svr_auth_pam();
/* Client functions */
void recv_msg_userauth_failure();

View File

@@ -50,8 +50,8 @@
#define CHAN_EXTEND_SIZE 3 /* how many extra slots to add when we need more */
#define RECV_MAXWINDOW 4000 /* tweak */
#define RECV_WINDOWEXTEND 500 /* We send a "window extend" every
#define RECV_MAXWINDOW 8000 /* tweak */
#define RECV_WINDOWEXTEND 1000 /* We send a "window extend" every
RECV_WINDOWEXTEND bytes */
#define RECV_MAXPACKET RECV_MAXWINDOW /* tweak */

View File

@@ -169,6 +169,8 @@ void recv_msg_userauth_failure() {
}
}
m_free(methods);
cli_ses.state = USERAUTH_FAIL_RCVD;
TRACE(("leave recv_msg_userauth_failure"));

View File

@@ -634,42 +634,44 @@ static void read_kex_algos() {
/* encryption_algorithms_client_to_server */
c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess);
if (algo == NULL) {
if (c2s_cipher_algo == NULL) {
erralgo = "enc c->s";
goto error;
}
TRACE(("c2s is %s", c2s_cipher_algo->name));
/* encryption_algorithms_server_to_client */
s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess);
if (algo == NULL) {
if (s2c_cipher_algo == NULL) {
erralgo = "enc s->c";
goto error;
}
TRACE(("s2c is %s", s2c_cipher_algo->name));
/* mac_algorithms_client_to_server */
c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess);
if (algo == NULL) {
if (c2s_hash_algo == NULL) {
erralgo = "mac c->s";
goto error;
}
/* mac_algorithms_server_to_client */
s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess);
if (algo == NULL) {
if (s2c_hash_algo == NULL) {
erralgo = "mac s->c";
goto error;
}
/* compression_algorithms_client_to_server */
c2s_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess);
if (algo == NULL) {
if (c2s_comp_algo == NULL) {
erralgo = "comp c->s";
goto error;
}
/* compression_algorithms_server_to_client */
s2c_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess);
if (algo == NULL) {
if (s2c_comp_algo == NULL) {
erralgo = "comp s->c";
goto error;
}

View File

@@ -117,6 +117,43 @@ AC_ARG_ENABLE(zlib,
]
)
# Check if pam is needed
AC_ARG_WITH(pam,
[ --with-pam=PATH Use pam in PATH],
[
# option is given
if test -d "$withval/lib"; then
LDFLAGS="-L${withval}/lib ${LDFLAGS}"
else
LDFLAGS="-L${withval} ${LDFLAGS}"
fi
if test -d "$withval/include"; then
CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
else
CPPFLAGS="-I${withval} ${CPPFLAGS}"
fi
]
)
AC_ARG_ENABLE(pam,
[ --enable-pam Try to include PAM support],
[
if test "x$enableval" = "xyes"; then
AC_CHECK_LIB(pam, pam_authenticate, , AC_MSG_ERROR([*** PAM missing - install first or check config.log ***]))
AC_MSG_RESULT(Enabling PAM)
else
AC_DEFINE(DISABLE_PAM,, Use PAM)
AC_MSG_RESULT(Disabling PAM)
fi
],
[
# disable it by default
AC_DEFINE(DISABLE_PAM,, Use PAM)
AC_MSG_RESULT(Disabling PAM)
]
)
AC_ARG_ENABLE(openpty,
[ --disable-openpty Don't use openpty, use alternative method],
[
@@ -169,7 +206,7 @@ AC_ARG_ENABLE(shadow,
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h netinet/tcp.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h crypt.h pty.h ioctl.h libutil.h libgen.h inttypes.h stropts.h utmp.h utmpx.h lastlog.h paths.h util.h netdb.h])
AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h netinet/tcp.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h crypt.h pty.h ioctl.h libutil.h libgen.h inttypes.h stropts.h utmp.h utmpx.h lastlog.h paths.h util.h netdb.h security/pam_appl.h pam/pam_appl.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

View File

@@ -506,18 +506,17 @@ int buf_getline(buffer * line, FILE * authfile) {
out:
buf_setpos(line, 0);
/* if we didn't read anything before EOF or error, exit */
if (c == EOF && line->pos == 0) {
TRACE(("leave getauthline: failure"));
TRACE(("leave buf_getline: failure"));
return DROPBEAR_FAILURE;
} else {
TRACE(("leave getauthline: success"));
TRACE(("leave buf_getline: success"));
buf_setpos(line, 0);
return DROPBEAR_SUCCESS;
}
TRACE(("leave buf_getline"));
}
#endif
@@ -545,7 +544,7 @@ void * m_malloc(size_t size) {
if (size == 0) {
dropbear_exit("m_malloc failed");
}
ret = malloc(size);
ret = calloc(1, size);
if (ret == NULL) {
dropbear_exit("m_malloc failed");
}

6
debian/changelog vendored
View File

@@ -1,3 +1,9 @@
dropbear (0.44test4-1) unstable; urgency=medium
* New upstream beta, various useful fixes.
-- Matt Johnston <matt@ucc.asn.au> Tues, 14 September 2004 21:20:00 +0800
dropbear (0.44test3-1) unstable; urgency=medium
* New upstream beta, various useful fixes.

81
dropbear.8 Normal file
View File

@@ -0,0 +1,81 @@
.TH dropbear 8
.SH NAME
dropbear \- lightweight SSH2 server
.SH SYNOPSIS
.B dropbear
[\-FEmwsgjki] [\-b
.I banner\fR] [\-d
.I dsskey\fR] [\-r
.I rsakey\fR] [\-p
.IR port ]
.SH DESCRIPTION
.B dropbear
is a SSH 2 server designed to be small enough to be used in small memory
environments, while still being functional and secure enough for general use.
.SH OPTIONS
.TP
.B \-b \fIbanner
bannerfile.
Display the contents of the file
.I banner
before user login (default: none).
.TP
.B \-d \fIdsskey
dsskeyfile.
Use the contents of the file
.I dsskey
for the dss host key (default: /etc/dropbear/dropbear_dss_host_key).
This file is generated with
.BR dropbearkey (8).
.TP
.B \-r \fIrsakey
rsakeyfile.
Use the contents of the file
.I rsakey
for the rsa host key (default: /etc/dropbear/dropbear_rsa_host_key).
This file is generated with
.BR dropbearkey (8).
.TP
.B \-F
Don't fork into background.
.TP
.B \-E
Log to standard error rather than syslog.
.TP
.B \-m
Don't display the message of the day on login.
.TP
.B \-w
Disallow root logins.
.TP
.B \-s
Disable password logins.
.TP
.B \-g
Disable password logins for root.
.TP
.B \-j
Disable local port forwarding.
.TP
.B \-k
Disable remote port forwarding.
.TP
.B \-p \fIport
Listen on specified tcp port
.IR port ;
up to 10 can be specified (default 22 if none specified).
.TP
.B \-i
Service program mode.
Use this option to run
.B dropbear
under TCP/IP servers like inetd, tcpsvd, or tcpserver.
In program mode the \-F option is implied, and \-p options are ignored.
.SH AUTHOR
Matt Johnston (matt@ucc.asn.au).
.br
Gerrit Pape (pape@smarden.org) wrote this manual page.
.SH SEE ALSO
dropbearkey(8)
.P
http://matt.ucc.asn.au/dropbear/dropbear.html

47
dropbearkey.8 Normal file
View File

@@ -0,0 +1,47 @@
.TH dropbearkey 8
.SH NAME
dropbearkey \- create private keys for the use with dropbear(8)
.SH SYNOPSIS
.B dropbearkey
\-t
.I type
\-f
.I file
[\-s
.IR bits ]
.SH DESCRIPTION
.B dropbearkey
generates a type
.I rsa
or
.I dss
SSH private key, and saves it to a file for the use with the
.BR dropbear (8)
SSH 2 server.
.SH OPTIONS
.TP
.B \-t \fItype
Type of key to generate.
Must be one of
.I rsa
or
.IR dss .
.TP
.B \-f \fIfile
Write the secret key to the file
.IR file .
.TP
.B \-s \fIbits
Set the key size to
.I bits
bits, should be multiple of 8 (optional).
.SH EXAMPLE
# dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
.SH AUTHOR
Matt Johnston (matt@ucc.asn.au).
.br
Gerrit Pape (pape@smarden.org) wrote this manual page.
.SH SEE ALSO
dropbear(8)
.P
http://matt.ucc.asn.au/dropbear/dropbear.html

View File

@@ -10,7 +10,7 @@
* parts are to allow for commandline -DDROPBEAR_XXX options etc.
******************************************************************/
#ifndef DROPBEAR_PORT
#ifndef DROPBEAR_DEFPORT
#define DROPBEAR_DEFPORT "22"
#endif
@@ -110,9 +110,19 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */
#define MOTD_FILENAME "/etc/motd"
#endif
/* Authentication types to enable, at least one required.
/* Authentication Types - at least one required.
RFC Draft requires pubkey auth, and recommends password */
/* PAM auth is quite simple, and only works for PAM modules which just do a
* simple "Login: " "Password: " (or something like that - if your module is
* similar but not quite like that, edit the strings in svr-authpam.c).
* Basically, it's useful for systems like OS X where standard password crypts
* don't work, but there's and interface via a PAM module. You'll need to
* configure with --enable-pam as well, since it's off by default. And you
* should only enable either PASSWORD _or_ PAM auth, not both. */
#define ENABLE_SVR_PASSWORD_AUTH
/*#define ENABLE_SVR_PAM_AUTH*/
#define ENABLE_SVR_PUBKEY_AUTH
#define ENABLE_CLI_PASSWORD_AUTH
@@ -173,7 +183,7 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */
*******************************************************************/
#ifndef DROPBEAR_VERSION
#define DROPBEAR_VERSION "0.44test3"
#define DROPBEAR_VERSION "0.44test4"
#endif
#define LOCAL_IDENT "SSH-2.0-dropbear_" DROPBEAR_VERSION
@@ -322,6 +332,10 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */
#define DROPBEAR_KEY_LINES /* ie we're using authorized_keys or known_hosts */
#endif
#if defined(ENABLE_SVR_PASSWORD_AUTH) && defined(ENABLE_SVR_PAM_AUTH)
#error "You can't turn on PASSWORD and PAM auth both at once. Fix it in options.h"
#endif
/* We use dropbear_client and dropbear_server as shortcuts to avoid redundant
* code, if we're just compiling as client or server */
#if defined(DROPBEAR_SERVER) && defined(DROPBEAR_CLIENT)

View File

@@ -55,7 +55,7 @@ static void authclear() {
#ifdef ENABLE_SVR_PUBKEY_AUTH
ses.authstate.authtypes |= AUTH_TYPE_PUBKEY;
#endif
#ifdef ENABLE_SVR_PASSWORD_AUTH
#if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
if (!svr_opts.noauthpass) {
ses.authstate.authtypes |= AUTH_TYPE_PASSWORD;
}
@@ -154,6 +154,19 @@ void recv_msg_userauth_request() {
}
#endif
#ifdef ENABLE_SVR_PAM_AUTH
if (!svr_opts.noauthpass &&
!(svr_opts.norootpass && ses.authstate.pw->pw_uid == 0) ) {
/* user wants to try password auth */
if (methodlen == AUTH_METHOD_PASSWORD_LEN &&
strncmp(methodname, AUTH_METHOD_PASSWORD,
AUTH_METHOD_PASSWORD_LEN) == 0) {
svr_auth_pam();
goto out;
}
}
#endif
#ifdef ENABLE_SVR_PUBKEY_AUTH
/* user wants to try pubkey auth */
if (methodlen == AUTH_METHOD_PUBKEY_LEN &&

223
svr-authpam.c Normal file
View File

@@ -0,0 +1,223 @@
/*
* Dropbear SSH
*
* Copyright (c) 2004 Martin Carlsson
* Portions (c) 2004 Matt Johnston
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. */
/* Validates a user password using PAM */
#include "includes.h"
#include "session.h"
#include "buffer.h"
#include "dbutil.h"
#include "auth.h"
#if defined(HAVE_SECURITY_PAM_APPL_H)
#include <security/pam_appl.h>
#elif defined (HAVE_PAM_PAM_APPL_H)
#include <pam/pam_appl.h>
#endif
#ifdef ENABLE_SVR_PAM_AUTH
struct UserDataS {
char* user;
char* passwd;
};
/* PAM conversation function - for now we only handle one message */
int
pamConvFunc(int num_msg,
const struct pam_message **msg,
struct pam_response **respp,
void *appdata_ptr) {
int rc = PAM_SUCCESS;
struct pam_response* resp = NULL;
struct UserDataS* userDatap = (struct UserDataS*) appdata_ptr;
const char* message = (*msg)->msg;
TRACE(("enter pamConvFunc"));
if (num_msg != 1) {
/* If you're getting here - Dropbear probably can't support your pam
* modules. This whole file is a bit of a hack around lack of
* asynchronocity in PAM anyway */
dropbear_log(LOG_INFO, "pamConvFunc() called with >1 messages: not supported.");
return PAM_CONV_ERR;
}
TRACE(("msg_style is %d", (*msg)->msg_style));
if (message) {
TRACE(("message is '%s'", message));
} else {
TRACE(("null message"));
}
switch((*msg)->msg_style) {
case PAM_PROMPT_ECHO_OFF:
if (strcmp(message, "Password:") != 0) {
TRACE(("PAM_PROMPT_ECHO_OFF: unrecognized prompt"));
rc = PAM_CONV_ERR;
break;
}
/* This looks leaky, but the PAM module-writer docs
* assure us that the caller will free it... */
resp = (struct pam_response*) m_malloc(sizeof(struct pam_response));
memset(resp, 0, sizeof(struct pam_response));
/* Safe to just use the direct pointer (no strdup) since
* it shouldn't be getting munged at all */
resp->resp = userDatap->passwd;
(*respp) = resp;
break;
case PAM_PROMPT_ECHO_ON:
if ((strcmp(message, "login: " ) != 0)
&& (strcmp(message, "login:" ) != 0)
&& (strcmp(message, "Please enter username: " ) != 0)) {
TRACE(("PAM_PROMPT_ECHO_ON: unrecognized prompt"));
rc = PAM_CONV_ERR;
break;
}
/* This looks leaky, but the PAM module-writer docs
* assure us that the caller will free it... */
resp = (struct pam_response*) m_malloc(sizeof(struct pam_response));
memset(resp, 0, sizeof(struct pam_response));
/* Safe to just use the direct pointer (no strdup) since
* it shouldn't be getting munged at all */
resp->resp = userDatap->user;
TRACE(("userDatap->user='%s'", userDatap->user));
(*respp) = resp;
break;
default:
TRACE(("Unknown message type"));
rc = PAM_CONV_ERR;
break;
}
TRACE(("leave pamConvFunc, rc %d", rc));
return rc;
}
/* Process a password auth request, sending success or failure messages as
* appropriate. To the client it looks like it's doing normal password auth (as
* opposed to keyboard-interactive or something), so the pam module has to be
* fairly standard (ie just "what's your username, what's your password, OK").
*
* Keyboard interactive would be a lot nicer, but since PAM is synchronous, it
* gets very messy trying to send the interactive challenges, and read the
* interactive responses, over the network. */
void svr_auth_pam() {
struct UserDataS userData;
struct pam_conv pamConv = {
pamConvFunc,
&userData /* submitted to pamvConvFunc as appdata_ptr */
};
pam_handle_t* pamHandlep = NULL;
unsigned char * password = NULL;
unsigned int passwordlen;
int rc = PAM_SUCCESS;
unsigned char changepw;
/* check if client wants to change password */
changepw = buf_getbyte(ses.payload);
if (changepw) {
/* not implemented by this server */
send_msg_userauth_failure(0, 1);
goto cleanup;
}
password = buf_getstring(ses.payload, &passwordlen);
/* used to pass data to the PAM conversation function */
userData.user = ses.authstate.printableuser;
userData.passwd = password;
/* Init pam */
if ((rc = pam_start("sshd", NULL, &pamConv, &pamHandlep)) != PAM_SUCCESS) {
dropbear_log(LOG_WARNING, "pam_start() failed, rc=%d, %s\n",
rc, pam_strerror(pamHandlep, rc));
goto cleanup;
}
/* just to set it to something */
if ((rc = pam_set_item(pamHandlep, PAM_TTY, "ssh") != PAM_SUCCESS)) {
dropbear_log(LOG_WARNING, "pam_set_item() failed, rc=%d, %s\n",
rc, pam_strerror(pamHandlep, rc));
goto cleanup;
}
(void) pam_fail_delay(pamHandlep, 0 /* musec_delay */);
/* (void) pam_set_item(pamHandlep, PAM_FAIL_DELAY, (void*) pamDelayFunc); */
if ((rc = pam_authenticate(pamHandlep, 0)) != PAM_SUCCESS) {
dropbear_log(LOG_WARNING, "pam_authenticate() failed, rc=%d, %s\n",
rc, pam_strerror(pamHandlep, rc));
dropbear_log(LOG_WARNING,
"bad pam password attempt for '%s'",
ses.authstate.printableuser);
send_msg_userauth_failure(0, 1);
goto cleanup;
}
if ((rc = pam_acct_mgmt(pamHandlep, 0)) != PAM_SUCCESS) {
dropbear_log(LOG_WARNING, "pam_acct_mgmt() failed, rc=%d, %s\n",
rc, pam_strerror(pamHandlep, rc));
dropbear_log(LOG_WARNING,
"bad pam password attempt for '%s'",
ses.authstate.printableuser);
send_msg_userauth_failure(0, 1);
goto cleanup;
}
/* successful authentication */
dropbear_log(LOG_NOTICE, "pam password auth succeeded for '%s'",
ses.authstate.printableuser);
send_msg_userauth_success();
cleanup:
if (password != NULL) {
m_burn(password, passwordlen);
m_free(password);
}
if (pamHandlep != NULL) {
(void) pam_end(pamHandlep, 0 /* pam_status */);
}
}
#endif /* ENABLE_SVR_PAM_AUTH */

View File

@@ -80,10 +80,6 @@ void svr_auth_password() {
password = buf_getstring(ses.payload, &passwordlen);
/* clear the buffer containing the password */
buf_incrpos(ses.payload, -passwordlen - 4);
m_burn(buf_getptr(ses.payload, passwordlen + 4), passwordlen + 4);
/* the first bytes of passwdcrypt are the salt */
testcrypt = crypt((char*)password, passwdcrypt);
m_burn(password, passwordlen);

View File

@@ -93,7 +93,7 @@ static void sesssigchild_handler(int UNUSED(dummy)) {
}
if (WIFSIGNALED(status)) {
chansess->exitsignal = WTERMSIG(status);
#ifndef AIX
#if !defined(AIX) && defined(WCOREDUMP)
chansess->exitcore = WCOREDUMP(status);
#else
chansess->exitcore = 0;

View File

@@ -138,9 +138,6 @@ void main_noinetd() {
commonsetup();
/* Now we can setup the hostkeys - needs to be after logging is on,
* otherwise we might end up blatting error messages to the socket */
loadhostkeys();
/* should be done after syslog is working */
if (svr_opts.forkbg) {
@@ -355,6 +352,10 @@ static void commonsetup() {
if (signal(SIGSEGV, sigsegv_handler) == SIG_ERR) {
dropbear_exit("signal() error");
}
/* Now we can setup the hostkeys - needs to be after logging is on,
* otherwise we might end up blatting error messages to the socket */
loadhostkeys();
}
/* Set up listening sockets for all the requested ports */

View File

@@ -59,7 +59,7 @@ static void printhelp(const char * progname) {
"-m Don't display the motd on login\n"
#endif
"-w Disallow root logins\n"
#ifdef ENABLE_SVR_PASSWORD_AUTH
#if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
"-s Disable password logins\n"
"-g Disable password logins for root\n"
#endif
@@ -183,7 +183,7 @@ void svr_getopts(int argc, char ** argv) {
case 'w':
svr_opts.norootlogin = 1;
break;
#ifdef ENABLE_SVR_PASSWORD_AUTH
#if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
case 's':
svr_opts.noauthpass = 1;
break;