From 2cbcf730fe71c246419cebd87c931a1559a9a925 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 14 Sep 2015 14:07:14 +1000 Subject: [PATCH] Simplify require SSL Signed-off-by: Madhura Jayaratne --- libraries/server_privileges.lib.php | 171 ++++++++++++++-------------- 1 file changed, 88 insertions(+), 83 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 7ca7e05285..d7badbbe79 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -718,33 +718,77 @@ function PMA_getHtmlToDisplayPrivilegesTable($db = '*', function PMA_getHtmlForRequires($row) { $html_output = '
'; + $html_output .= 'SSL'; - $html_output .= ''; - $html_output .= ''; + + // REQUIRE NONE + $html_output .= '
'; + $html_output .= ''; + + $html_output .= ''; + $html_output .= '
'; + + // REQUIRE SSL + $html_output .= '
'; + $html_output .= ''; - $html_output .= __('Require SSL') . ''; - $html_output .= '
'; + + $html_output .= ''; + $html_output .= '
'; + + // REQUIRE X509 + $html_output .= '
'; + $html_output .= ''; + + $html_output .= ''; + $html_output .= '
'; // Specified + $specified = (isset($row['ssl_type']) && $row['ssl_type'] == 'SPECIFIED'); $html_output .= '
'; $html_output .= ''; + . ' value="specified"' . ($specified ? ' checked="checked"' : '') . '/>'; - $html_output .= '
'; @@ -766,8 +810,9 @@ function PMA_getHtmlForRequires($row) . 'size=80" title="' . __( 'Requires that a specific cipher method be used for a connection.' - ) - . '" />'; + ) . '"' + . (! $specified ? ' disabled' : '') + . ' />'; $html_output .= '
'; // REQUIRE ISSUER @@ -785,8 +830,9 @@ function PMA_getHtmlForRequires($row) . 'size=80" title="' . __( 'Requires that a valid X509 certificate issued by this CA be presented.' - ) - . '" />'; + ) .'"' + . (! $specified ? ' disabled' : '') + . ' />'; $html_output .= ''; // REQUIRE SUBJECT @@ -804,52 +850,13 @@ function PMA_getHtmlForRequires($row) . '" size=80" title="' . __( 'Requires that a valid X509 certificate with this subject be presented.' - ) - . '" />'; + ) . '"' + . (! $specified ? ' disabled' : '') + . ' />'; $html_output .= ''; $html_output .= ''; - // REQUIRE X509 - $html_output .= '
'; - $html_output .= ''; - - $html_output .= ''; - $html_output .= '
'; - - // REQUIRE SSL - $html_output .= '
'; - $html_output .= ''; - - $html_output .= ''; - $html_output .= '
'; - $html_output .= ''; $html_output .= '
'; @@ -1986,31 +1993,29 @@ function PMA_getMessageAndSqlQueryForPrivilegesRevoke($dbname, function PMA_getRequireClause() { $require_clause = ""; - if (isset($_POST['SSL_priv']) && $_POST['SSL_priv'] == 'Y') { - if (isset($_POST['ssl_type']) && $_POST['ssl_type'] == 'specified') { - $require = array(); - if (! empty($_POST['ssl_cipher'])) { - $require[] = "CIPHER '" - . PMA_Util::sqlAddSlashes($_POST['ssl_cipher']) . "'"; - } - if (! empty($_POST['x509_issuer'])) { - $require[] = "ISSUER '" - . PMA_Util::sqlAddSlashes($_POST['x509_issuer']) . "'"; - } - if (! empty($_POST['x509_subject'])) { - $require[] = "SUBJECT '" - . PMA_Util::sqlAddSlashes($_POST['x509_subject']) . "'"; - } - if (count($require)) { - $require_clause = " REQUIRE " . implode(" AND ", $require); - } else { - $require_clause = " REQUIRE NONE"; - } - } elseif (isset($_POST['ssl_type']) && $_POST['ssl_type'] == 'X509') { - $require_clause = " REQUIRE X509"; - } elseif (isset($_POST['ssl_type']) && $_POST['ssl_type'] == 'ANY') { - $require_clause = " REQUIRE SSL"; + if (isset($_POST['ssl_type']) && $_POST['ssl_type'] == 'specified') { + $require = array(); + if (! empty($_POST['ssl_cipher'])) { + $require[] = "CIPHER '" + . PMA_Util::sqlAddSlashes($_POST['ssl_cipher']) . "'"; } + if (! empty($_POST['x509_issuer'])) { + $require[] = "ISSUER '" + . PMA_Util::sqlAddSlashes($_POST['x509_issuer']) . "'"; + } + if (! empty($_POST['x509_subject'])) { + $require[] = "SUBJECT '" + . PMA_Util::sqlAddSlashes($_POST['x509_subject']) . "'"; + } + if (count($require)) { + $require_clause = " REQUIRE " . implode(" AND ", $require); + } else { + $require_clause = " REQUIRE NONE"; + } + } elseif (isset($_POST['ssl_type']) && $_POST['ssl_type'] == 'X509') { + $require_clause = " REQUIRE X509"; + } elseif (isset($_POST['ssl_type']) && $_POST['ssl_type'] == 'ANY') { + $require_clause = " REQUIRE SSL"; } else { $require_clause = " REQUIRE NONE"; }