Adopt to new pcp command usage
authorNozomi Anzai <[email protected]>
Fri, 4 Dec 2015 07:18:46 +0000 (16:18 +0900)
committerNozomi Anzai <[email protected]>
Fri, 4 Dec 2015 07:18:46 +0000 (16:18 +0900)
command.php
install/checkDirectory.php
install/checkParameter.php
lang/en.lang.php
lang/ja.lang.php
libs/plugins/function.custom_select.php
procInfo.php
screen.css
templates/innerError.tpl

index 5f0837166f7ca87b994b28947a3763f20d92d0cf..bf78c30540a4d189937614984dea59196c3f98b8 100644 (file)
@@ -19,7 +19,7 @@
  * is" without express or implied warranty.
  *
  * @author     Ryuma Ando <[email protected]>
- * @copyright  2003-2013 PgPool Global Development Group
+ * @copyright  2003-2015 PgPool Global Development Group
  * @version    CVS: $Id$
  */
 
@@ -32,7 +32,7 @@ require_once('common.php');
  * @param srgs $num
  * @return array
  */
-function execPcp($command, $num = '')
+function execPcp($command, $extra_args)
 {
     $pcpStatus = array (
         '0'   => 'SUCCESS',
@@ -55,12 +55,27 @@ function execPcp($command, $num = '')
     $param = readPcpInfo();
     $param['hostname'] = _PGPOOL2_PCP_HOSTNAME;
 
-    $args = " " . PCP_TIMEOUT.
-            " " . $param['hostname'] .
-            " " . $param['pcp_port'] .
-            " ". $_SESSION[SESSION_LOGIN_USER] .
-            " '" . $_SESSION[SESSION_LOGIN_USER_PASSWORD] . "' " .
-            $num;
+    if (3.5 <= _PGPOOL2_VERSION) {
+        // Check /home/apache/.pcppass (If error, exit here)
+        checkPcppass();
+
+        $args = sprintf(' -w -h %s -p %d -U %s',
+            $param['hostname'], $param['pcp_port'],
+            $_SESSION[SESSION_LOGIN_USER]
+        );
+
+        foreach ($extra_args as $arg_name => $val) {
+            $args .= " -{$arg_name} {$val}";
+        }
+
+    } else {
+        $args = " " . PCP_TIMEOUT.
+                " " . $param['hostname'] .
+                " " . $param['pcp_port'] .
+                " ". $_SESSION[SESSION_LOGIN_USER] .
+                " '" . $_SESSION[SESSION_LOGIN_USER_PASSWORD] . "' " .
+                implode($extra_args, ' ');
+    }
 
     switch ($command) {
         case 'PCP_NODE_COUNT':
@@ -158,6 +173,7 @@ function execPcp($command, $num = '')
         default:
             return array($pspStatus[1] => $pspStatus[1]);
     }
+
     return array($pcpStatus[$return_var] => $ret);
 }
 
@@ -195,12 +211,11 @@ function getNodeInfo($i)
     global $tpl;
 
     // execute "pcp_node_info" command
-    // ex) host1 5432 1 1073741823.500000
-    $result = execPcp('PCP_NODE_INFO', $i);
+    $result = execPcp('PCP_NODE_INFO', array('n' => $i));
 
     if (!array_key_exists('SUCCESS', $result)) {
-        $errorCode = 'e1003';
-        $tpl->assign('errorCode', $errorCode);
+        $tpl->assign('errorCode', 'e1003');
+        $tpl->assign('result', $result);
         $tpl->display('innerError.tpl');
         exit();
     }
@@ -238,4 +253,28 @@ function getWatchdogInfo($i = '')
 
     return $rtn;
 }
+
+function checkPcppass()
+{
+    global $message, $tpl;
+
+    $proc_user_info = posix_getpwuid(posix_geteuid());
+    $pcppass_file = "{$proc_user_info['dir']}/.pcppass";
+
+    $detail = NULL;
+    if (! is_file($pcppass_file)) {
+        $detail = $message['errFileNotFound'];
+    } elseif (fileowner($pcppass_file) != $proc_user_info['uid']) {
+        $detail = $message['errInvalidOwner'];
+    } elseif (substr(sprintf('%o', fileperms($pcppass_file)), -4) != '0600') {
+        $detail = $message['errInvalidPermission'];
+    }
+
+    if ($detail) {
+        $tpl->assign('errorCode', 'e1014');
+        $tpl->assign('detail', $detail);
+        $tpl->display('innerError.tpl');
+        exit();
+    }
+}
 ?>
index cfe9514d65aa6f25e6c3d8f4ba0d014af760d080..647dbe68e9d6e55cab8e566f4a890ca4b2056df7 100644 (file)
@@ -19,7 +19,7 @@
  * is" without express or implied warranty.
  *
  * @author     Ryuma Ando <[email protected]>
- * @copyright  2003-2013 PgPool Global Development Group
+ * @copyright  2003-2015 PgPool Global Development Group
  * @version    CVS: $Id$
  */
 
@@ -37,6 +37,7 @@ if (isset($_POST['action'])) {
     $action = $_POST['action'];
 }
 
+// Check templates_c
 $templates_c = dirname(dirname(__FILE__) . '/') . '/templates_c';
 if (!is_writable($templates_c)) {
     $templates_c = $templates_c . '  write denied';
@@ -44,6 +45,8 @@ if (!is_writable($templates_c)) {
 } else {
     unset($templates_c);
 }
+
+// Chech pgmgt.conf
 $conf = dirname(dirname(__FILE__) . '/') . '/conf/pgmgt.conf.php';
 if (!is_writable($conf)) {
     $conf = $conf . '  write denied';
@@ -70,7 +73,7 @@ if (!$error && $action == 'next') {
     </div>
       <div id="content">
   <h2>Welcome to pgpool-II Administration Tool</h2>
-  <h3><? echo $message['strDirectoryCheck'] ?></h3>
+  <h3><?php echo $message['strDirectoryCheck'] ?></h3>
   <form action="checkDirectory.php" method="post" name="CheckPath" id="CheckPath">
     <?php
     if($error) {
index e5a3b3aeb59e4c9f6d3804d02e448df7ad62ccbc..fb190318ffb79ada03494beac538403622f762e7 100644 (file)
@@ -19,7 +19,7 @@
  * is" without express or implied warranty.
  *
  * @author     Ryuma Ando <[email protected]>
- * @copyright  2003-2013 PgPool Global Development Group
+ * @copyright  2003-2015 PgPool Global Development Group
  * @version    CVS: $Id$
  */
 
@@ -56,7 +56,7 @@ if (isset($_POST['pgpool2_config_file']) && $_POST['pgpool2_config_file']) {
 }
 
 $msgPgpoolConfigFile = '';
-if (!@is_file($pgpool2_config_file)) {
+if (! @is_file($pgpool2_config_file)) {
     $msgPgpoolConfigFile = 'File not found';
     $error = TRUE;
 } else {
@@ -78,7 +78,7 @@ if (isset($_POST['password_file']) && $_POST['password_file']) {
 }
 
 $msgPasswordFile = '';
-if (!@is_file($password_file)) {
+if (! @is_file($password_file)) {
     $msgPasswordFile = 'File not found';
     $error = TRUE;
 } else {
@@ -100,7 +100,7 @@ if (isset($_POST['pgpool_command']) && $_POST['pgpool_command']) {
 }
 
 $msgPgpoolCommand = '';
-if (!@is_file($pgpool_command)) {
+if (! @is_file($pgpool_command)) {
     $msgPgpoolCommand = 'pgpool command not found';
     $error = TRUE;
 } elseif (!is_executable($pgpool_command)) {
@@ -108,7 +108,7 @@ if (!@is_file($pgpool_command)) {
     $error = TRUE;
 }
 
-// check args of pgpool comand
+// check args of pgpool command
 $msgCmdC = '';
 $msgCmdLargeD = '';
 $msgCmdD = '';
@@ -164,7 +164,7 @@ if (!is_dir($pcp_client_dir)) {
                      'pcp_systemdb_info');
 
     for ($i = 0; $i < count($command); $i++) {
-        if (!@is_file($pcp_client_dir . "/" . $command[$i])) {
+        if (! @is_file($pcp_client_dir . "/" . $command[$i])) {
             $msgPcpClientDir = $command[$i] . ' command not found';
             $error = TRUE;
         } elseif (!is_executable($pcp_client_dir . "/" . $command[$i] )) {
@@ -181,6 +181,19 @@ if (isset($_POST['pcp_hostname']) && $_POST['pcp_hostname']) {
     $pcp_hostname =  _PGPOOL2_PCP_HOSTNAME;
 }
 
+if (3.5 <= $version) {
+    $msgPcpPassFile = '';
+    $proc_user_info = posix_getpwuid(posix_geteuid());
+    $pcppass_file = "{$proc_user_info['dir']}/.pcppass";
+    if (! is_file($pcppass_file)) {
+        $msgPcpPassFile = 'File not found';
+    } elseif (fileowner($pcppass_file) != $proc_user_info['uid']) {
+        $msgPcpPassFile = 'Invalid owner';
+    } elseif (substr(sprintf('%o', fileperms($pcppass_file)), -4) != '0600') {
+        $msgPcpPassFile = 'Invalid permission';
+    }
+}
+
 $msgPcpTimeout = '';
 if (isset($_POST['pcp_timeout']) && $_POST['pcp_timeout']) {
     $pcp_timeout= $_POST['pcp_timeout'];
@@ -354,37 +367,37 @@ if (!$error && $action == 'next') {
 
   <table>
   <tr>
-    <th><label><?php echo $message['strCmdC'] ?></label></th>
+    <th><label><?php echo $message['strCmdC'] ?> (-c)</label></th>
     <td><input type="checkbox" name="c" />
     <?php showResult($msgCmdC); ?>
     </td>
   </tr>
   <tr>
-    <th><label><?php echo $message['strCmdLargeD'] ?></label></th>
+    <th><label><?php echo $message['strCmdLargeD'] ?> (-D)</label></th>
     <td><input type="checkbox" name="D" />
     <?php showResult($msgCmdLargeD); ?>
     </td>
   </tr>
   <tr>
-    <th><label><?php echo $message['strCmdN'] ?></label></th>
+    <th><label><?php echo $message['strCmdN'] ?> (-n)</label></th>
     <td><input type="checkbox" name="n" />
     <?php showResult($msgCmdN); ?>
     </td>
   </tr>
   <tr>
-    <th><label><?php echo $message['strCmdLargeC'] ?></label></th>
+    <th><label><?php echo $message['strCmdLargeC'] ?> (-C)</label></th>
     <td><input type="checkbox" name="D" />
     <?php showResult($msgCmdLargeC); ?>
     </td>
   </tr>
   <tr>
-    <th><label><?php echo $message['strCmdD'] ?></label></th>
+    <th><label><?php echo $message['strCmdD'] ?> (-d)</label></th>
     <td><input type="checkbox" name="d" />
     <?php showResult($msgCmdD); ?>
     </td>
   </tr>
   <tr>
-    <th><label><?php echo $message['strCmdM'] ?></label></th>
+    <th><label><?php echo $message['strCmdM'] ?> (-m)</label></th>
     <td><select  name="m" />
           <option value="s" selected="selected">smart</optgroup>
           <option value="f">fast</optgroup>
@@ -412,6 +425,10 @@ if (!$error && $action == 'next') {
     <?php showResult($msgPcpHostname); ?>
     </td>
   </tr>
+  <tr id="tr_pcppass">
+    <th><label>.pcppass [V3.5 - ]</label></th>
+    <td><?php echo $pcppass_file; ?>
+    <?php showResult($msgPcpPassFile); ?>
   <tr>
     <th><label><?php echo $message['strPcpTimeout'] ?></label></th>
     <td><input name="pcp_timeout" type="text" value="<?php echo $pcp_timeout?>" size="50" />
@@ -453,7 +470,7 @@ else {
 
 function versions()
 {
-    return array('3.4', '3.3', '3.2', '3.1', '3.0',
+    return array('3.5', '3.4', '3.3', '3.2', '3.1', '3.0',
                  '2.3', '2.2', '2.1', '2.0');
 }
 
index f78f4d527dc3091452e6b935e6042f25cd035058..6225ee65a6179eccb15f3485bb63bdf099930ee8 100644 (file)
@@ -200,6 +200,8 @@ $message = array(
     'errIllegalHostname' => 'Illegal hostname',
     'errIllegalPipe' => 'Pipe destination is invalid',
     'errInputEverything' => 'Please input all items',
+    'errInvalidOwner' => 'Invalid owner',
+    'errInvalidPermission' => 'Invalid permission',
     'errNoDefined' => 'No defined parameter',
     'errNotSameLength' => 'The array length of col_list is not corresponding to that of type_list. '.
                           'It should be the same number of elements.',
@@ -406,6 +408,7 @@ $message = array(
     'e1011' => 'Log file not found.',
     'e1012' => 'pcp_recovery_node command error occurred.',
     'e1013' => 'pcp_watchdog_info command error occurred.',
+    'e1014' => 'Could not read .pcppass file'
     'e2001' => 'Database connection error occurred.',
     'e2002' => 'The error occurred when SELECT was executed',
     'e2003' => 'pgpool.conf not found.',
index 409aa836647d50118a0dcc1922d211ec301320df..31475b93ab5d9a7e12eca6cb89e885d0e2cf5aea 100644 (file)
@@ -184,6 +184,8 @@ $message = array(
     'errIllegalHostname' => '不正なホスト名です',
     'errIllegalPipe' => 'パイプの指定が不正です',
     'errInputEverything' => 'すべてを入力してください',
+    'errInvalidOwner' => '所有者が正しくありません',
+    'errInvalidPermission' => 'パーミッションが正しくありません',
     'errNoDefined' => 'パラメータが設定されていません',
     'errNotSameLength' => '列名リストと列データ型リストの配列の長さが一致しません。'.
                           '同じ要素数である必要があります。',
@@ -393,6 +395,7 @@ $message = array(
     'e1011' => 'ログファイルが見つかりません',
     'e1012' => 'pcp_recovery_nodeコマンドでエラーが発生しました',
     'e1013' => 'pcp_watchdog_infoコマンドでエラーが発生しました',
+    'e1014' => '.pcppass ファイルの読み込みに失敗しました',
     'e2001' => 'データベースに接続できません',
     'e2002' => 'レコード取得時にエラーが発生しました',
     'e2003' => 'pgpool.confが見つかりません',
index e08f48a662ec4c6735be16b8451486148fd28128..868c0d68addf0fc48d9d4dfe0bff623ca2ac76a8 100644 (file)
@@ -13,7 +13,7 @@ function smarty_function_custom_select($args)
     foreach ($select_options[$param] as $key => $val) {
         $rtn .= sprintf(
             '<option value="%s" %s>%s</option>',
-            $key, ($val == $user_val) ? 'selected' : NULL, $val
+            $key, ($key === $user_val || $val === $user_val) ? 'selected' : NULL, $val
         );
     }
     $rtn .= '</select>';
index df81bc36365a32fafbd028f2af2391823999412c..c6258f0ac30c9aa3998d14f2622e800151333a86 100644 (file)
@@ -19,7 +19,7 @@
  * is" without express or implied warranty.
  *
  * @author     Ryuma Ando <[email protected]>
- * @copyright  2003-2011 PgPool Global Development Group
+ * @copyright  2003-2015 PgPool Global Development Group
  * @version    CVS: $Id$
  */
 
@@ -31,7 +31,9 @@ if (!isset($_SESSION[SESSION_LOGIN_USER])) {
 
 $ret = execPcp('PCP_PROC_COUNT');
 if (!array_key_exists('SUCCESS', $ret)) {
-    $errorCode = 'e1004';
+    if (! isset($ret['errorCode'])) {
+        $errorCode = 'e1004';
+    }
     $tpl->assign('errorCode', $errorCode);
     $tpl->display('innerError.tpl');
     exit();
@@ -42,10 +44,12 @@ if (!array_key_exists('SUCCESS', $ret)) {
 
 for ($i = 0; $i < count($procPids); $i++) {
     $procPid = $procPids[$i];
-    $ret = execPcp('PCP_PROC_INFO', $procPid);
+    $ret = execPcp('PCP_PROC_INFO', array('P' => $procPid));
 
     if (!array_key_exists('SUCCESS', $ret)) {
-        $errorCode = 'e1005';
+        if (! isset($ret['errorCode'])) {
+            $errorCode = 'e1005';
+        }
         $tpl->assign('errorCode', $errorCode);
         $tpl->display('innerError.tpl');
         exit();
index 6572142678e086e34099b45822850b05703bf377..b03d7e1f7867def959d2601724e3addd92936b6e 100644 (file)
@@ -50,6 +50,11 @@ tbody th.category {
   color: #709CD1;
   font-size: small;
 }
+tbody th.category_2 span {
+  font-weight: bold;
+  color: #7CC9E2;
+  font-size: small;
+}
 
 table#complete_msg
 {
@@ -67,7 +72,7 @@ td.pgconfig_msg img {
 /* --------------------------------------------------------------------- */
 
 a:link {
-  color: red; 
+  color: red;
   text-decoration: none;
 }
 a:visited {
@@ -95,64 +100,78 @@ input {
   font: x-small Verdana, Arial, Helvetica, sans-serif;
 }
 input[type=button], input[type=submit] {
-  border-radius: 3px;
-  padding: 2px 5px;
+  background: #cfcfcf;
 
+  padding: 5px 7px;
   vertical-align: middle;
 
-  border-top: 1px solid #aaa;
-  border-right: 1px solid #666;
-  border-bottom: 1px solid #666;
-  border-left: 1px solid #aaa;
-
+  border-width: 0px;
   -webkit-border-radius: 3px;
   -moz-border-radius:    3px;
   border-radius:         3px;
-
-  background: #ffffff;
-  background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#eeeeee));
-  background: -moz-linear-gradient(top, #ffffff, #eeeeee);
 }
-
 input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
-  border-top: 1px solid #666;
-  border-right: 1px solid #aaa;
-  border-bottom: 1px solid #aaa;
-  border-left: 1px solid #666;
-
-  background: #f3f3f3;
-  background: -webkit-gradient(linear, left top, left bottom, from(#eeeeee), to(#ffffff));
-  background: -moz-linear-gradient(top, #eeeeee, #ffffff);
+  background: #dddddd;
   color: #5f5f5f;
 }
 input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
-  border-top: 1px solid #666;
-  border-right: 1px solid #aaa;
-  border-bottom: 1px solid #aaa;
-  border-left: 1px solid #666;
-
-  background: #cccccc;
+  background: #bbbbbb;
   color: #000000;
 }
 input[type=button].command_active {
   background: yellow;
-  background: -webkit-gradient(linear, left top, left bottom, from(yellow), to(#FCE114));
-  background: -moz-linear-gradient(top, yellow, #FCE114);
   border-color: #BC4B00;
 }
 
 input[type=button][disabled], input[type=button][disabled]:hover {
-  border-top: 1px solid #aaa;
-  border-right: 1px solid #666;
-  border-bottom: 1px solid #666;
-  border-left: 1px solid #aaa;
-
-  background: #dedede;
+  background: #cfcfcf;
   color: #777777;
   text-shadow: #eeeeee 0 1px 0;
 }
-input[type=button][disabled]:hover {
-  background: #f0f0f0;
+
+/* --------------------------------------------------------------------- */
+/* radio                                                                 */
+/* --------------------------------------------------------------------- */
+
+div.radio_bool {
+    margin-bottom: 20px;
+    padding: 0px;
+}
+div.radio_bool input{
+    display: none;
+}
+div.radio_bool label{
+    background: #bdc3c7;
+    border-right: 1px solid #abb2b7;
+    color: #555e64;
+    cursor: pointer;
+    display: block;
+    float: left;
+    line-height: 1;
+    margin: 0;
+    padding: 5px 12px;
+    text-align: center;
+    transition: .2s;
+}
+div.radio_bool label:first-of-type{
+    border-radius: 3px 0 0 3px;
+}
+div.radio_bool label:last-of-type{
+    border-right: 0px;
+    border-radius: 0 3px 3px 0;
+}
+div.radio_bool input[type="radio"]:checked + label {
+    background-color: #a1b91d;
+    color: #fff;
+    font-weight: bold;
+}
+div.radio_bool input[type="radio"]:disabled:checked + label {
+    background-color: #e1e1e1;
+    color: #999999;
+}
+div.radio_bool input[type="radio"]:disabled + label {
+    background-color: #cfcfcf;
+    color: #aaaaaa;
 }
 
 /* --------------------------------------------------------------------- */
@@ -185,7 +204,6 @@ ul {
 
 /* menu */
 #menu {
-  padding-bottom: 40px;
   border-top: 1px solid lightsteelblue;
   border-right: 1px solid lightsteelblue;
   float: left;
@@ -220,27 +238,21 @@ ul {
   background: white url("images/background.gif") repeat-y left;
 }
 
-/* submenu */
+/* submenu in pgconfig */
 #submenu {
-  border: 1px solid lightsteelblue;
-  float: right;
+  padding: 0px 30px 30px 10px;
   background: ghostwhite;
   font-size: x-small;
+  border-bottom: 1px solid lightsteelblue;
 }
 #submenu h3 {
-  margin: 0px;
-  padding: 4px 8px;
-  border: 0px solid black;
-  border-bottom: 4px solid white;
-  color: white;
-  background: steelblue;
-  text-align: center;
+  border: 0px;
 }
-#submenu ul {
-  margin: 0px;
-  padding: 8px;
-  border-top: 1px solid lightsteelblue;
-  list-style: square inside;
+#submenu ul li {
+  border: 0px;
+}
+#submenu ul li a:link {
+  padding: 3px;
 }
 
 /* footer */
@@ -314,6 +326,23 @@ ul {
     border-radius: 3px;
     color: white;
 }
+p.check_error {
+    color: red;
+    font-weight: bold;
+}
+p.check_error span.error {
+    background: red;
+    color: white;
+    font-weight: bold;
+    padding: 1px 5px;
+
+    -webkit-border-radius: 3px;
+    -moz-border-radius:    3px;
+    border-radius:         3px;
+}
+td.command_option {
+    padding-left: 30px;
+}
 
 /* --------------------------------------------------------------------- */
 /* Refresh info                                                          */
@@ -332,3 +361,17 @@ div.auto_reloading span {
   margin: 5px;
   color: #2D1D00;
 }
+
+
+form.pgconfig table {
+    width: 800px;
+}
+form.pgconfig table tr:hover {
+    background: #f6f6f6;
+}
+form.pgconfig th.colname {
+    width: 500px;
+}
+form.pgconfig tr.group th {
+    padding-left: 30px;
+}
index 2cb07e7ae79c7ab0d5bdcca2751d5199c12d52c6..97f404e8c9f8994033f4d3167b767e6922680391 100644 (file)
@@ -13,7 +13,7 @@
     </tr>
     <tr>
       <th><label>{$message.strErrorMessage|escape}</label></th>
-      <td>{$message.$errorCode|escape}</td>
+      <td>{$message.$errorCode|escape}<br>{$detail|escape}</td>
     </tr>
     </td>
     </tr>