Skip to content

Commit 25a4ae6

Browse files
committed
Source snapshot from Powershell/openssh-portable:latestw_all
1 parent c168016 commit 25a4ae6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1747
-962
lines changed

.skipped-commit-ids

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ fe5b31f69a60d47171836911f144acff77810217 Makefile.inc bits
1919
ea80f445e819719ccdcb237022cacfac990fdc5c Makefile.inc warning flags
2020
b92c93266d8234d493857bb822260dacf4366157 moduli-gen.sh tweak
2121
b25bf747544265b39af74fe0716dc8d9f5b63b95 Updated moduli
22+
1bd41cba06a7752de4df304305a8153ebfb6b0ac rsa.[ch] already removed
23+
e39b3902fe1d6c4a7ba6a3c58e072219f3c1e604 Makefile changes

Makefile.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
8181
cipher-ctr.o cleanup.o \
8282
compat.o crc32.o fatal.o hostfile.o \
8383
log.o match.o moduli.o nchan.o packet.o opacket.o \
84-
readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \
84+
readpass.o ttymodes.o xmalloc.o addrmatch.o \
8585
atomicio.o key.o dispatch.o mac.o uidswap.o uuencode.o misc.o utf8.o \
8686
monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
8787
msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
@@ -92,7 +92,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
9292
kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
9393
kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \
9494
kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \
95-
platform-pledge.o platform-tracing.o
95+
platform-pledge.o platform-tracing.o platform-misc.o
9696

9797
SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
9898
sshconnect.o sshconnect2.o mux.o

README

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ The PAM support is now more functional than the popular packages of
3030
commercial ssh-1.2.x. It checks "account" and "session" modules for
3131
all logins, not just when using password authentication.
3232

33-
OpenSSH depends on Zlib[3], OpenSSL[4] and optionally PAM[5].
33+
OpenSSH depends on Zlib[3], OpenSSL[4], and optionally PAM[5] and
34+
libedit[6]
3435

3536
There is now several mailing lists for this port of OpenSSH. Please
3637
refer to https://www.openssh.com/list.html for details on how to join.
3738

3839
Please send bug reports and patches to the mailing list
3940
[email protected]. The list is open to posting by unsubscribed
4041
users. Code contribution are welcomed, but please follow the OpenBSD
41-
style guidelines[6].
42+
style guidelines[7].
4243

4344
Please refer to the INSTALL document for information on how to install
4445
OpenSSH on your system.
@@ -61,4 +62,5 @@ References -
6162
[5] http://www.openpam.org
6263
http://www.kernel.org/pub/linux/libs/pam/
6364
(PAM also is standard on Solaris and HP-UX 11)
64-
[6] http://man.openbsd.org/style.9
65+
[6] http://thrysoee.dk/editline/ (portable version)
66+
[7] http://man.openbsd.org/style.9

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 0.0.19.0.{build}
1+
version: 0.0.20.0.{build}
22
image: Visual Studio 2015
33

44
branches:

auth-pam.c

+26
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,36 @@ finish_pam(void)
926926
sshpam_cleanup();
927927
}
928928

929+
static void
930+
expose_authinfo(const char *caller)
931+
{
932+
char *auth_info;
933+
934+
/*
935+
* Expose authentication information to PAM.
936+
* The enviornment variable is versioned. Please increment the
937+
* version suffix if the format of session_info changes.
938+
*/
939+
if (sshpam_authctxt->session_info == NULL)
940+
auth_info = xstrdup("");
941+
else if ((auth_info = sshbuf_dup_string(
942+
sshpam_authctxt->session_info)) == NULL)
943+
fatal("%s: sshbuf_dup_string failed", __func__);
944+
945+
debug2("%s: auth information in SSH_AUTH_INFO_0", caller);
946+
do_pam_putenv("SSH_AUTH_INFO_0", auth_info);
947+
free(auth_info);
948+
}
949+
929950
u_int
930951
do_pam_account(void)
931952
{
932953
debug("%s: called", __func__);
933954
if (sshpam_account_status != -1)
934955
return (sshpam_account_status);
935956

957+
expose_authinfo(__func__);
958+
936959
sshpam_err = pam_acct_mgmt(sshpam_handle, 0);
937960
debug3("PAM: %s pam_acct_mgmt = %d (%s)", __func__, sshpam_err,
938961
pam_strerror(sshpam_handle, sshpam_err));
@@ -1057,6 +1080,9 @@ void
10571080
do_pam_session(void)
10581081
{
10591082
debug3("PAM: opening session");
1083+
1084+
expose_authinfo(__func__);
1085+
10601086
sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
10611087
(const void *)&store_conv);
10621088
if (sshpam_err != PAM_SUCCESS)

auth.c

+2-97
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth.c,v 1.122 2017/06/24 06:34:38 djm Exp $ */
1+
/* $OpenBSD: auth.c,v 1.123 2017/08/18 05:36:45 djm Exp $ */
22
/*
33
* Copyright (c) 2000 Markus Friedl. All rights reserved.
44
*
@@ -43,9 +43,6 @@
4343
#ifdef USE_SHADOW
4444
#include <shadow.h>
4545
#endif
46-
#ifdef HAVE_LIBGEN_H
47-
#include <libgen.h>
48-
#endif
4946
#include <stdarg.h>
5047
#include <stdio.h>
5148
#include <string.h>
@@ -508,98 +505,6 @@ check_key_in_hostfiles(struct passwd *pw, struct sshkey *key, const char *host,
508505
return host_status;
509506
}
510507

511-
/*
512-
* Check a given path for security. This is defined as all components
513-
* of the path to the file must be owned by either the owner of
514-
* of the file or root and no directories must be group or world writable.
515-
*
516-
* XXX Should any specific check be done for sym links ?
517-
*
518-
* Takes a file name, its stat information (preferably from fstat() to
519-
* avoid races), the uid of the expected owner, their home directory and an
520-
* error buffer plus max size as arguments.
521-
*
522-
* Returns 0 on success and -1 on failure
523-
*/
524-
int
525-
auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
526-
uid_t uid, char *err, size_t errlen)
527-
{
528-
char buf[PATH_MAX], homedir[PATH_MAX];
529-
char *cp;
530-
int comparehome = 0;
531-
struct stat st;
532-
533-
if (realpath(name, buf) == NULL) {
534-
snprintf(err, errlen, "realpath %s failed: %s", name,
535-
strerror(errno));
536-
return -1;
537-
}
538-
if (pw_dir != NULL && realpath(pw_dir, homedir) != NULL)
539-
comparehome = 1;
540-
541-
if (!S_ISREG(stp->st_mode)) {
542-
snprintf(err, errlen, "%s is not a regular file", buf);
543-
return -1;
544-
}
545-
if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) ||
546-
(stp->st_mode & 022) != 0) {
547-
snprintf(err, errlen, "bad ownership or modes for file %s",
548-
buf);
549-
return -1;
550-
}
551-
552-
/* for each component of the canonical path, walking upwards */
553-
for (;;) {
554-
if ((cp = dirname(buf)) == NULL) {
555-
snprintf(err, errlen, "dirname() failed");
556-
return -1;
557-
}
558-
strlcpy(buf, cp, sizeof(buf));
559-
560-
if (stat(buf, &st) < 0 ||
561-
(!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) ||
562-
(st.st_mode & 022) != 0) {
563-
snprintf(err, errlen,
564-
"bad ownership or modes for directory %s", buf);
565-
return -1;
566-
}
567-
568-
/* If are past the homedir then we can stop */
569-
if (comparehome && strcmp(homedir, buf) == 0)
570-
break;
571-
572-
/*
573-
* dirname should always complete with a "/" path,
574-
* but we can be paranoid and check for "." too
575-
*/
576-
if ((strcmp("/", buf) == 0) || (strcmp(".", buf) == 0))
577-
break;
578-
}
579-
return 0;
580-
}
581-
582-
/*
583-
* Version of secure_path() that accepts an open file descriptor to
584-
* avoid races.
585-
*
586-
* Returns 0 on success and -1 on failure
587-
*/
588-
static int
589-
secure_filename(FILE *f, const char *file, struct passwd *pw,
590-
char *err, size_t errlen)
591-
{
592-
struct stat st;
593-
594-
/* check the open file to avoid races */
595-
if (fstat(fileno(f), &st) < 0) {
596-
snprintf(err, errlen, "cannot stat file %s: %s",
597-
file, strerror(errno));
598-
return -1;
599-
}
600-
return auth_secure_path(file, &st, pw->pw_dir, pw->pw_uid, err, errlen);
601-
}
602-
603508
static FILE *
604509
auth_openfile(const char *file, struct passwd *pw, int strict_modes,
605510
int log_missing, char *file_type)
@@ -646,7 +551,7 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes,
646551
return NULL;
647552
}
648553
if (strict_modes &&
649-
secure_filename(f, file, pw, line, sizeof(line)) != 0) {
554+
safe_path_fd(fileno(f), file, pw, line, sizeof(line)) != 0) {
650555
fclose(f);
651556
logit("Authentication refused: %s", line);
652557
auth_debug_add("Ignored %s: %s", file_type, line);

auth.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth.h,v 1.92 2017/06/24 06:34:38 djm Exp $ */
1+
/* $OpenBSD: auth.h,v 1.93 2017/08/18 05:36:45 djm Exp $ */
22

33
/*
44
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -149,10 +149,6 @@ void auth2_record_info(Authctxt *authctxt, const char *, ...)
149149
__attribute__((__nonnull__ (2)));
150150
void auth2_update_session_info(Authctxt *, const char *, const char *);
151151

152-
struct stat;
153-
int auth_secure_path(const char *, struct stat *, const char *, uid_t,
154-
char *, size_t);
155-
156152
#ifdef KRB5
157153
int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *);
158154
int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt);

0 commit comments

Comments
 (0)