mirror of
https://github.com/clearml/dropbear
synced 2025-06-26 18:17:32 +00:00
Compare commits
18 Commits
DROPBEAR_0
...
DROPBEAR_0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6766dfae26 | ||
|
|
199b67a68c | ||
|
|
644488a5f3 | ||
|
|
1ace08645a | ||
|
|
636b041b9b | ||
|
|
a41f9dc036 | ||
|
|
448a05ae2c | ||
|
|
099c9a3232 | ||
|
|
2575e227a5 | ||
|
|
fa26b59b0c | ||
|
|
c23ffe4bc1 | ||
|
|
7ed5870ed9 | ||
|
|
8559be015a | ||
|
|
cb0657bdf3 | ||
|
|
15fb479e94 | ||
|
|
0378cffafc | ||
|
|
51fb224ef8 | ||
|
|
3238bed9c9 |
19
CHANGES
19
CHANGES
@@ -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.
|
||||
|
||||
@@ -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
1
auth.h
@@ -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();
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -169,6 +169,8 @@ void recv_msg_userauth_failure() {
|
||||
}
|
||||
}
|
||||
|
||||
m_free(methods);
|
||||
|
||||
cli_ses.state = USERAUTH_FAIL_RCVD;
|
||||
|
||||
TRACE(("leave recv_msg_userauth_failure"));
|
||||
|
||||
14
common-kex.c
14
common-kex.c
@@ -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;
|
||||
}
|
||||
|
||||
39
configure.in
39
configure.in
@@ -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
|
||||
|
||||
9
dbutil.c
9
dbutil.c
@@ -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
6
debian/changelog
vendored
@@ -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
81
dropbear.8
Normal 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
47
dropbearkey.8
Normal 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
|
||||
20
options.h
20
options.h
@@ -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)
|
||||
|
||||
15
svr-auth.c
15
svr-auth.c
@@ -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
223
svr-authpam.c
Normal 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 */
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user