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
|
2020-07-24 15:45:06 +08:00
|
|
|
index 4adc502..956b9cf 100644
|
2019-09-30 11:10:51 -04:00
|
|
|
--- a/auth2.c
|
|
|
|
|
+++ b/auth2.c
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -282,11 +282,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
|
2020-07-24 15:45:06 +08:00
|
|
|
index 7001d56..76147f9 100644
|
2019-09-30 11:10:51 -04:00
|
|
|
--- a/servconf.c
|
|
|
|
|
+++ b/servconf.c
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -195,6 +195,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;
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -473,6 +474,8 @@ fill_default_server_options(ServerOptions *options)
|
|
|
|
|
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)
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -574,6 +577,7 @@ typedef enum {
|
2019-09-30 11:10:51 -04:00
|
|
|
sStreamLocalBindMask, sStreamLocalBindUnlink,
|
|
|
|
|
sAllowStreamLocalForwarding, sFingerprintHash, sDisableForwarding,
|
2020-07-24 15:45:06 +08:00
|
|
|
sExposeAuthInfo, sRDomain, sPubkeyAuthOptions, sSecurityKeyProvider,
|
2019-09-30 11:10:51 -04:00
|
|
|
+ sCheckUserSplash,
|
|
|
|
|
sDeprecated, sIgnore, sUnsupported
|
|
|
|
|
} ServerOpCodes;
|
|
|
|
|
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -740,6 +744,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 },
|
|
|
|
|
@@ -1360,6 +1365,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
|
2020-07-24 15:45:06 +08:00
|
|
|
index a3827e5..2c16b5a 100644
|
2019-09-30 11:10:51 -04:00
|
|
|
--- a/servconf.h
|
|
|
|
|
+++ b/servconf.h
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -226,6 +226,7 @@ typedef struct {
|
2019-09-30 11:10:51 -04:00
|
|
|
int fingerprint_hash;
|
|
|
|
|
int expose_userauth_info;
|
|
|
|
|
u_int64_t timing_secret;
|
|
|
|
|
+ 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;
|
2019-09-30 11:10:51 -04:00
|
|
|
} ServerOptions;
|
|
|
|
|
|
|
|
|
|
diff --git a/sshd_config b/sshd_config
|
2020-07-24 15:45:06 +08:00
|
|
|
index ebc28b3..b121450 100644
|
2019-09-30 11:10:51 -04:00
|
|
|
--- a/sshd_config
|
|
|
|
|
+++ b/sshd_config
|
2020-07-24 15:45:06 +08:00
|
|
|
@@ -125,6 +125,8 @@ Subsystem sftp /usr/libexec/sftp-server
|
2021-10-28 16:38:19 +08:00
|
|
|
# Example of overriding settings on a per-user basis
|
|
|
|
|
#Match User anoncvs
|
|
|
|
|
# X11Forwarding no
|
|
|
|
|
# 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
|
|
|
--
|
2020-07-24 15:45:06 +08:00
|
|
|
2.23.0
|
2019-09-30 11:10:51 -04:00
|
|
|
|