openssh/bugfix-openssh-add-option-check-username-splash.patch

107 lines
3.5 KiB
Diff
Raw Permalink Normal View History

2020-07-24 15:45:06 +08:00
From 74c1a37dfeab8e9cc39e5bc76891d1d9d66b7638 Mon Sep 17 00:00:00 2001
2019-09-30 11:10:51 -04:00
From: wangqiang <wangqiang62@huawei.com>
2020-07-24 15:45:06 +08:00
Date: Thu, 16 Apr 2020 15:58:30 +0800
2019-09-30 11:10:51 -04:00
Subject: [PATCH] openssh: add option check username splash
add a check to inhibit username contains splash
add an option 'CheckUserSplash' so that user can turn off
this check
---
2020-07-24 15:45:06 +08:00
auth2.c | 4 +++-
2019-09-30 11:10:51 -04:00
servconf.c | 8 ++++++++
2020-07-24 15:45:06 +08:00
servconf.h | 1 +
2019-09-30 11:10:51 -04:00
sshd_config | 2 ++
2020-07-24 15:45:06 +08:00
4 files changed, 14 insertions(+), 1 deletion(-)
2019-09-30 11:10:51 -04:00
diff --git a/auth2.c b/auth2.c
2023-07-24 21:42:50 +08:00
index 4d574bb..c480aab 100644
2019-09-30 11:10:51 -04:00
--- a/auth2.c
+++ b/auth2.c
2023-07-24 21:42:50 +08:00
@@ -278,11 +278,13 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh)
2019-09-30 11:10:51 -04:00
debug("userauth-request for user %s service %s method %s", user, service, method);
debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
+if (options.check_user_splash)
+{
#ifdef WITH_SELINUX
if ((role = strchr(user, '/')) != NULL)
*role++ = 0;
#endif
2020-07-24 15:45:06 +08:00
-
2019-09-30 11:10:51 -04:00
+}
if ((style = strchr(user, ':')) != NULL)
*style++ = 0;
2020-07-24 15:45:06 +08:00
2019-09-30 11:10:51 -04:00
diff --git a/servconf.c b/servconf.c
2023-07-24 21:42:50 +08:00
index bcf69fd..b8340d8 100644
2019-09-30 11:10:51 -04:00
--- a/servconf.c
+++ b/servconf.c
2023-07-24 21:42:50 +08:00
@@ -199,6 +199,7 @@ initialize_server_options(ServerOptions *options)
2019-09-30 11:10:51 -04:00
options->ip_qos_interactive = -1;
options->ip_qos_bulk = -1;
options->version_addendum = NULL;
+ options->check_user_splash = -1;
options->fingerprint_hash = -1;
options->disable_forwarding = -1;
options->expose_userauth_info = -1;
2023-07-24 21:42:50 +08:00
@@ -456,6 +457,8 @@ fill_default_server_options(ServerOptions *options)
2020-07-24 15:45:06 +08:00
options->ip_qos_bulk = IPTOS_DSCP_CS1;
if (options->version_addendum == NULL)
2019-09-30 11:10:51 -04:00
options->version_addendum = xstrdup("");
+ if (options->check_user_splash == -1)
+ options->check_user_splash = 1;
if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1)
options->fwd_opts.streamlocal_bind_mask = 0177;
if (options->fwd_opts.streamlocal_bind_unlink == -1)
2023-07-24 21:42:50 +08:00
@@ -557,6 +560,7 @@ typedef enum {
2019-09-30 11:10:51 -04:00
sAllowStreamLocalForwarding, sFingerprintHash, sDisableForwarding,
2020-07-24 15:45:06 +08:00
sExposeAuthInfo, sRDomain, sPubkeyAuthOptions, sSecurityKeyProvider,
2023-07-24 21:42:50 +08:00
sRequiredRSASize, sChannelTimeout, sUnusedConnectionTimeout,
+ sCheckUserSplash,
2019-09-30 11:10:51 -04:00
sDeprecated, sIgnore, sUnsupported
} ServerOpCodes;
2023-07-24 21:42:50 +08:00
@@ -730,6 +734,7 @@ static struct {
2019-09-30 11:10:51 -04:00
{ "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL },
{ "disableforwarding", sDisableForwarding, SSHCFG_ALL },
{ "exposeauthinfo", sExposeAuthInfo, SSHCFG_ALL },
+ { "checkusersplash", sCheckUserSplash, SSHCFG_GLOBAL },
{ "rdomain", sRDomain, SSHCFG_ALL },
2020-07-24 15:45:06 +08:00
{ "casignaturealgorithms", sCASignatureAlgorithms, SSHCFG_ALL },
{ "securitykeyprovider", sSecurityKeyProvider, SSHCFG_GLOBAL },
2023-07-24 21:42:50 +08:00
@@ -1443,6 +1448,9 @@ process_server_config_line_depth(ServerOptions *options, char *line,
2019-09-30 11:10:51 -04:00
case sUsePAM:
intptr = &options->use_pam;
goto parse_flag;
+ case sCheckUserSplash:
2020-07-24 15:45:06 +08:00
+ intptr = &options->check_user_splash;
+ goto parse_flag;
2019-09-30 11:10:51 -04:00
/* Standard Options */
case sBadOption:
diff --git a/servconf.h b/servconf.h
2023-07-24 21:42:50 +08:00
index ccc0181..cb57dac 100644
2019-09-30 11:10:51 -04:00
--- a/servconf.h
+++ b/servconf.h
2023-02-02 16:09:45 +08:00
@@ -237,6 +237,7 @@ typedef struct {
2019-09-30 11:10:51 -04:00
int fingerprint_hash;
int expose_userauth_info;
u_int64_t timing_secret;
2023-07-24 21:42:50 +08:00
+ int check_user_splash; /* check whether splash exists in username, if exist, disable login */
2020-07-24 15:45:06 +08:00
char *sk_provider;
2023-02-02 16:09:45 +08:00
int required_rsa_size; /* minimum size of RSA keys */
2023-07-24 21:42:50 +08:00
2019-09-30 11:10:51 -04:00
diff --git a/sshd_config b/sshd_config
2023-07-24 21:42:50 +08:00
index 9851748..d57f11d 100644
2019-09-30 11:10:51 -04:00
--- a/sshd_config
+++ b/sshd_config
2023-02-02 16:09:45 +08:00
@@ -128,3 +128,5 @@ Subsystem sftp /usr/libexec/sftp-server
2021-10-28 16:38:19 +08:00
# AllowTcpForwarding no
2019-09-30 11:10:51 -04:00
# PermitTTY no
# ForceCommand cvs server
+#CheckUserSplash yes
2020-07-24 15:45:06 +08:00
+
2019-09-30 11:10:51 -04:00
--
2023-07-24 21:42:50 +08:00
2.23.0
2019-09-30 11:10:51 -04:00