fix no obvious “secure_file_priv” prompt when load data error issue 981 (#1738)

This commit is contained in:
qiuyg3
2023-12-20 11:11:20 +08:00
committed by GitHub
parent daa119ab50
commit 178fca9e35

View File

@ -7784,6 +7784,7 @@ int ObResolverUtils::check_secure_path(const common::ObString &secure_file_priv,
if (secure_file_priv.empty() || 0 == secure_file_priv.case_compare(N_NULL)) { if (secure_file_priv.empty() || 0 == secure_file_priv.case_compare(N_NULL)) {
ret = OB_ERR_NO_PRIVILEGE; ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "Access denied, please set suitable variable 'secure-file-priv' first, such as: SET GLOBAL secure_file_priv = '/'");
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(full_path)); LOG_WARN("no priv", K(ret), K(secure_file_priv), K(full_path));
} else if (OB_UNLIKELY(secure_file_priv.length() >= DEFAULT_BUF_LENGTH)) { } else if (OB_UNLIKELY(secure_file_priv.length() >= DEFAULT_BUF_LENGTH)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
@ -7797,6 +7798,7 @@ int ObResolverUtils::check_secure_path(const common::ObString &secure_file_priv,
stat(buf, &path_stat); stat(buf, &path_stat);
if (0 == S_ISDIR(path_stat.st_mode)) { if (0 == S_ISDIR(path_stat.st_mode)) {
ret = OB_ERR_NO_PRIVILEGE; ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "Access denied, please set suitable variable 'secure-file-priv' first, such as: SET GLOBAL secure_file_priv = '/'");
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(full_path)); LOG_WARN("no priv", K(ret), K(secure_file_priv), K(full_path));
} else { } else {
MEMSET(buf, 0, sizeof(buf)); MEMSET(buf, 0, sizeof(buf));
@ -7808,13 +7810,16 @@ int ObResolverUtils::check_secure_path(const common::ObString &secure_file_priv,
const int64_t pos = secure_file_priv_tmp.length(); const int64_t pos = secure_file_priv_tmp.length();
if (full_path.length() < secure_file_priv_tmp.length()) { if (full_path.length() < secure_file_priv_tmp.length()) {
ret = OB_ERR_NO_PRIVILEGE; ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "Access denied, please set suitable variable 'secure-file-priv' first, such as: SET GLOBAL secure_file_priv = '/'");
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path)); LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path));
} else if (!full_path.prefix_match(secure_file_priv_tmp)) { } else if (!full_path.prefix_match(secure_file_priv_tmp)) {
ret = OB_ERR_NO_PRIVILEGE; ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "Access denied, please set suitable variable 'secure-file-priv' first, such as: SET GLOBAL secure_file_priv = '/'");
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path)); LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path));
} else if (full_path.length() > secure_file_priv_tmp.length() } else if (full_path.length() > secure_file_priv_tmp.length()
&& secure_file_priv_tmp != "/" && full_path[pos] != '/') { && secure_file_priv_tmp != "/" && full_path[pos] != '/') {
ret = OB_ERR_NO_PRIVILEGE; ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "Access denied, please set suitable variable 'secure-file-priv' first, such as: SET GLOBAL secure_file_priv = '/'");
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path)); LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path));
} }
} }