forked from openssh/openssh-portable
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: switch over to the new authorized_keys options API and
remove the legacy one. Includes a fairly big refactor of auth2-pubkey.c to retain less state between key file lines. feedback and ok markus@ OpenBSD-Commit-ID: dece6cae0f47751b9892080eb13d6625599573df
- Loading branch information
Showing
19 changed files
with
767 additions
and
984 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
/* $OpenBSD: auth-options.h,v 1.24 2018/03/03 03:06:02 djm Exp $ */ | ||
/* $OpenBSD: auth-options.h,v 1.25 2018/03/03 03:15:51 djm Exp $ */ | ||
|
||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
* All rights reserved | ||
* Copyright (c) 2018 Damien Miller <[email protected]> | ||
* | ||
* As far as I am concerned, the code I have written for this software | ||
* can be used freely for any purpose. Any derived versions of this | ||
* software must be clearly marked as such, and if the derived work is | ||
* incompatible with the protocol description in the RFC file, it must be | ||
* called by a name other than "ssh" or "Secure Shell". | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#ifndef AUTH_OPTIONS_H | ||
|
@@ -18,30 +22,6 @@ | |
struct passwd; | ||
struct sshkey; | ||
|
||
/* Linked list of custom environment strings */ | ||
struct envstring { | ||
struct envstring *next; | ||
char *s; | ||
}; | ||
|
||
/* Flags that may be set in authorized_keys options. */ | ||
extern int no_port_forwarding_flag; | ||
extern int no_agent_forwarding_flag; | ||
extern int no_x11_forwarding_flag; | ||
extern int no_pty_flag; | ||
extern int no_user_rc; | ||
extern char *forced_command; | ||
extern struct envstring *custom_environment; | ||
extern int forced_tun_device; | ||
extern int key_is_cert_authority; | ||
extern char *authorized_principals; | ||
|
||
int auth_parse_options(struct passwd *, char *, const char *, u_long); | ||
void auth_clear_options(void); | ||
int auth_cert_options(struct sshkey *, struct passwd *, const char **); | ||
|
||
/* authorized_keys options handling */ | ||
|
||
/* | ||
* sshauthopt represents key options parsed from authorized_keys or | ||
* from certificate extensions/options. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: auth-passwd.c,v 1.45 2016/07/21 01:39:35 dtucker Exp $ */ | ||
/* $OpenBSD: auth-passwd.c,v 1.46 2018/03/03 03:15:51 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -68,22 +68,15 @@ extern login_cap_t *lc; | |
|
||
#define MAX_PASSWORD_LEN 1024 | ||
|
||
void | ||
disable_forwarding(void) | ||
{ | ||
no_port_forwarding_flag = 1; | ||
no_agent_forwarding_flag = 1; | ||
no_x11_forwarding_flag = 1; | ||
} | ||
|
||
/* | ||
* Tries to authenticate the user using password. Returns true if | ||
* authentication succeeds. | ||
*/ | ||
int | ||
auth_password(Authctxt *authctxt, const char *password) | ||
auth_password(struct ssh *ssh, const char *password) | ||
{ | ||
struct passwd * pw = authctxt->pw; | ||
Authctxt *authctxt = ssh->authctxt; | ||
struct passwd *pw = authctxt->pw; | ||
int result, ok = authctxt->valid; | ||
#if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE) | ||
static int expire_checked = 0; | ||
|
@@ -128,9 +121,9 @@ auth_password(Authctxt *authctxt, const char *password) | |
authctxt->force_pwchange = 1; | ||
} | ||
#endif | ||
result = sys_auth_passwd(authctxt, password); | ||
result = sys_auth_passwd(ssh, password); | ||
if (authctxt->force_pwchange) | ||
disable_forwarding(); | ||
auth_restrict_session(ssh); | ||
return (result && ok); | ||
} | ||
|
||
|
@@ -170,19 +163,19 @@ warn_expiry(Authctxt *authctxt, auth_session_t *as) | |
} | ||
|
||
int | ||
sys_auth_passwd(Authctxt *authctxt, const char *password) | ||
sys_auth_passwd(struct ssh *ssh, const char *password) | ||
{ | ||
struct passwd *pw = authctxt->pw; | ||
Authctxt *authctxt = ssh->authctxt; | ||
auth_session_t *as; | ||
static int expire_checked = 0; | ||
|
||
as = auth_usercheck(pw->pw_name, authctxt->style, "auth-ssh", | ||
as = auth_usercheck(authctxt->pw->pw_name, authctxt->style, "auth-ssh", | ||
(char *)password); | ||
if (as == NULL) | ||
return (0); | ||
if (auth_getstate(as) & AUTH_PWEXPIRED) { | ||
auth_close(as); | ||
disable_forwarding(); | ||
auth_restrict_session(ssh); | ||
authctxt->force_pwchange = 1; | ||
return (1); | ||
} else { | ||
|
@@ -195,8 +188,9 @@ sys_auth_passwd(Authctxt *authctxt, const char *password) | |
} | ||
#elif !defined(CUSTOM_SYS_AUTH_PASSWD) | ||
int | ||
sys_auth_passwd(Authctxt *authctxt, const char *password) | ||
sys_auth_passwd(struct ssh *ssh, const char *password) | ||
{ | ||
Authctxt *authctxt = ssh->authctxt; | ||
struct passwd *pw = authctxt->pw; | ||
char *encrypted_password, *salt = NULL; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.