* (c) 2007-2008 Mandriva, http://www.mandriva.com * * $Id$ * * This file is part of Mandriva Management Console (MMC). * * MMC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MMC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MMC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ?> <?php $x1 = _T("Please make sure that"); $x2 = _T("The DHCP service is running", "network"); $x3 = _T("The path to the DHCP leases file is correctly configured in the network module configuration."); $errItem = new ErrorHandlingItem("No such file or directory:.*\\.leases'"); $errItem->setMsg(_T("Can't find the dhcpd.leases file", "network")); $errItem->setAdvice(sprintf("%s : <ul><li>%s</li><li>%s</li></ul>", $x1, $x2, $x3)); $errItem->setTraceBackDisplay(False); $errObj->add($errItem);
/** * Make a XML-RPC call * If the global variable $errorStatus is not zero, the XML-RPC call is not * done, and this function returns nothing. * * @param $method name of the method * @param $params array with param * @return the XML-RPC call result */ function xmlCall($method, $params = null) { global $errorStatus; global $errorDesc; global $conf; if (isXMLRPCError()) { // Don't do a XML-RPC call if a previous one failed return; } /* Set defaut login/pass if not set. The credentials are used to authenticate the web interface to the XML-RPC server. */ if (!isset($conf["global"]["login"])) { $conf["global"]["login"] = "******"; $conf["global"]["password"] = "******"; } $output_options = array("output_type" => "xml", "verbosity" => "pretty", "escaping" => array("markup"), "version" => "xmlrpc", "encoding" => "UTF-8"); $request = xmlrpc_encode_request($method, $params, $output_options); /* We build the HTTP POST that will be sent */ $host = $_SESSION["XMLRPC_agent"]["host"] . ":" . $_SESSION["XMLRPC_agent"]["port"]; $url = "/"; $httpQuery = "POST " . $url . " HTTP/1.0\r\n"; $httpQuery .= "User-Agent: MMC web interface\r\n"; $httpQuery .= "Host: " . $host . "\r\n"; $httpQuery .= "Content-Type: text/xml\r\n"; $httpQuery .= "Content-Length: " . strlen($request) . "\r\n"; /* Don't set the RPC session cookie if the user is on the login page */ if ($method == "base.ldapAuth" || $method == "base.tokenAuthenticate") { unset($_SESSION["RPCSESSION"]); $httpQuery .= "X-Browser-IP: " . $_SERVER["REMOTE_ADDR"] . "\r\n"; $httpQuery .= "X-Browser-HOSTNAME: " . gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\r\n"; } else { $httpQuery .= "Cookie: " . $_SESSION["RPCSESSION"] . "\r\n"; } $httpQuery .= "Authorization: Basic " . base64_encode($conf["global"]["login"] . ":" . $conf["global"]["password"]) . "\r\n\r\n"; $httpQuery .= $request; $sock = null; /* Connect to the XML-RPC server */ if ($_SESSION["XMLRPC_agent"]["scheme"] == "https") { $prot = "ssl://"; } else { $prot = ""; } list($sock, $errNo, $errString) = openSocket($prot, $conf); if (!$sock) { /* Connection failure */ $errObj = new ErrorHandlingItem(''); $errObj->setMsg(_("Can't connect to MMC agent")); $errObj->setAdvice(_("MMC agent seems to be down or not correctly configured.") . '<br/> Error: ' . $errNo . ' - ' . $errString); $errObj->setTraceBackDisplay(false); $errObj->setSize(400); $errObj->process(''); $errorStatus = 1; return FALSE; } /* Send the HTTP POST */ if (!fwrite($sock, $httpQuery, strlen($httpQuery))) { /* Failure */ $errObj = new ErrorHandlingItem(''); $errObj->setMsg(_("Can't send XML-RPC request to MMC agent")); $errObj->setAdvice(_("MMC agent seems to be not correctly configured.")); $errObj->setTraceBackDisplay(false); $errObj->setSize(400); $errObj->process(''); $errorStatus = 1; return FALSE; } fflush($sock); /* Get the response from the server */ $xmlResponse = ''; while (!feof($sock)) { $ret = fread($sock, 8192); $info = stream_get_meta_data($sock); if ($info['timed_out']) { $errObj = new ErrorHandlingItem(''); $errObj->setMsg(_('MMC agent communication problem')); $errObj->setAdvice(_('Timeout when reading data from the MMC agent. Please check network connectivity and server load.')); $errObj->setTraceBackDisplay(false); $errObj->setSize(400); $errObj->process(''); $errorStatus = 1; return FALSE; } if ($ret === False) { $errObj = new ErrorHandlingItem(''); $errObj->setMsg(_("Error while reading MMC agent XML-RPC response.")); $errObj->setAdvice(_("Please check network connectivity.")); $errObj->setTraceBackDisplay(false); $errObj->setSize(400); $errObj->process(''); $errorStatus = 1; return FALSE; } $xmlResponse .= $ret; } fclose($sock); /* Process the response */ if (!strlen($xmlResponse)) { $errObj = new ErrorHandlingItem(''); $errObj->setMsg(_("MMC agent communication problem")); $errObj->setAdvice(_("Can't communicate with MMC agent. Please check you're using the right TCP port and the right protocol.")); $errObj->setTraceBackDisplay(false); $errObj->setSize(400); $errObj->process(''); $errorStatus = 1; return FALSE; } /* Process the received HTTP header */ $pos = strpos($xmlResponse, "\r\n\r\n"); $httpHeader = substr($xmlResponse, 0, $pos); if ($method == "base.ldapAuth" || $method == "base.tokenAuthenticate") { if ($method == "base.tokenAuthenticate") { $_SESSION["AUTH_METHOD"] = "token"; } else { $_SESSION["AUTH_METHOD"] = "login"; } /* The RPC server must send us a session cookie */ if (preg_match("/(TWISTED_SESSION=[0-9a-f]+);/", $httpHeader, $match) > 0) { $_SESSION["RPCSESSION"] = $match[1]; } else { /* Can't get a session from the Twisted XML-RPC server */ $errObj = new ErrorHandlingItem(''); $errObj->setMsg(_("MMC agent communication problem")); $errObj->setAdvice(_("The MMC agent didn't give us a session number. Please check the MMC agent version.")); $errObj->setTraceBackDisplay(false); $errObj->setSize(400); $errObj->process(''); $errorStatus = 1; return False; } } /* Process the XML response */ $xmlResponse = substr($xmlResponse, $pos + 4); /* Test if the XMLRPC result is a boolean value set to False. If it is the case, xmlrpc_decode will return an empty string. So we need to test this special case. Looks like this bug is fixed in latest PHP version. At least it works with PHP 5.2.0. */ $booleanFalse = "<?xml version='1.0' ?>\n<methodResponse>\n<params>\n<param>\n<value><boolean>0</boolean></value>\n</param>\n</params>\n</methodResponse>\n"; if ($xmlResponse == $booleanFalse) { $xmlResponse = False; } else { $xmlResponseTmp = xmlrpc_decode($xmlResponse, "UTF-8"); /* if we cannot decode in UTF-8 */ if (!$xmlResponseTmp) { /* Maybe we received data encoded in ISO latin 1, so convert them to UTF8 first*/ $xmlResponse = iconv("ISO-8859-1", "UTF-8", $xmlResponse); $xmlResponse = xmlrpc_decode($xmlResponse, "UTF-8"); } else { $xmlResponse = $xmlResponseTmp; } } /* If debug is on, print the XML-RPC call and result */ if ($conf["debug"]["level"] != 0) { $str = '<div class="alert alert-info">'; $str .= "XML RPC CALL FUNCTION: {$method}("; if (!$params) { $params = "null"; } else { if (is_array($params)) { $str .= var_export($params, True); } else { $str .= $params; } } $str .= ')'; if (is_array($xmlResponse)) { $str .= "<pre>"; $str .= "result : "; $str .= var_export($xmlResponse, True); $str .= "</pre>"; } else { $str .= "result : " . $xmlResponse; } $str .= '</div>'; echo $str; } /* If the XML-RPC server sent a fault, display an error */ if (is_array($xmlResponse) && isset($xmlResponse["faultCode"])) { if ($xmlResponse["faultCode"] == "8003") { /* Fault 8003 means the session with the XML-RPC server has expired. So we make the current PHP session expire, so that the user is redirected to the login page. */ require_once 'modules/base/includes/users-xmlrpc.inc.php'; // Create a template array to store important session vars $temp = array(); // Session keys to keep $keys = array('ip_addr', 'XMLRPC_agent', 'agent', 'XMLRPC_server_description', 'AUTH_METHOD', 'login', 'pass', 'expire', 'lang', 'RPCSESSION', 'aclattr', 'acltab', 'acl', 'supportModList', 'modListVersion', 'doeffect', 'modulesList'); // Saving session params foreach ($keys as $key) { if (isset($_SESSION[$key])) { $temp[$key] = $_SESSION[$key]; } } // Destroy and recreate session to eliminate // modules session params session_destroy(); session_start(); // Restoring session params foreach ($keys as $key) { if (isset($temp[$key])) { $_SESSION[$key] = $temp[$key]; } } if (auth_user($temp['login'], $temp['pass'])) { // If login succeed, retry call after relogin return xmlCall($method, $params); } else { // Logout and request a new login unset($_SESSION["expire"]); $_SESSION["agentsessionexpired"] = 1; $root = $conf["global"]["root"]; header("Location: {$root}" . "main.php"); exit; } } /* Try to find an error handler */ $result = findErrorHandling($xmlResponse["faultCode"]); if (!is_object($result) and $result == -1) { /* We didn't find one */ $result = new ErrorHandlingItem(''); $result->setMsg(_("unknown error")); $result->setAdvice(_("This exception is unknown. Please contact us to add an error handling on this error.")); } $result->process($xmlResponse); $errorStatus = 1; $errorDesc = $xmlResponse["faultCode"]; return False; } /* Return the result of the remote procedure call */ return $xmlResponse; }
$errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid port range"); $errItem->setMsg(_T("Invalid port range", "shorewall")); $errItem->setAdvice(_T("Ports should be between 0 and 65535 and the left side port must be lower that the right side port.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid IP"); $errItem->setMsg(_T("Invalid IP", "shorewall")); $errItem->setAdvice(_T("The IP address is not correct.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid IP range"); $errItem->setMsg(_T("Invalid IP range", "shorewall")); $errItem->setAdvice(_T("The IP range is not correct.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid network"); $errItem->setMsg(_T("Invalid network", "shorewall")); $errItem->setAdvice(_T("The network is not correct.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid network masq"); $errItem->setMsg(_T("Invalid network masq", "shorewall")); $errItem->setAdvice(_T("The network masq is not correct.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem);
$errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must contain at least one lower.*'"); $errItem->setMsg(_("The password must contain at least one lower case character")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must contain at least one special.*'"); $errItem->setMsg(_("The password must contain at least one special character: #\$%&+./:=?@{}")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must not contain the same character.*'"); $errItem->setMsgFromError("/'info': '(.*)',/"); $dummyMsg = _("The password must not contain the same character %s times"); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'Password not accepted.*'"); $errItem->setMsgFromError("/'info': '(.*)',/"); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password length must be.*'"); $errItem->setMsgFromError("/'info': '(.*)',/"); $dummyMsg = _("The password length must be %s or longer"); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password is too short.*'"); $errItem->setMsg(_("The password is too short.")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Phone number is already taken"); $errItem->setMsg(_T("This phone number is already used.")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem);
# ACL support missing on partition containing /home/samba/ $errItem = new ErrorHandlingItem('\\[Errno 95\\] Operation not supported'); $errItem->setMsg(_T("ACLs are not supported in your partition containing /home/samba/")); $errItem->setAdvice(_T("Try to remount your partition with ACLs support\n\t\t\t<ul>\n\t\t\t<li>You could use XFS which support ACLs natively</li>\n\t\t\t<li>For ext3 filesystem, add \"acl\" to mount options in /etc/fstab<br/>\n\t\t\t <pre>ie: /dev/hda6 /home ext3 defaults,acl 1 2</pre></li>\n\t\t\t</ul>\n\t\t\t")); $errObj->add($errItem); $errItem = new ErrorHandlingItem('share "([A-Za-z0-9]*)" does not exist'); $errItem->setMsg(_T("This share does not exist")); $errItem->setAdvice(_T("Verify specified share exist.")); $errObj->add($errItem); $errItem = new ErrorHandlingItem('This share already exists'); $errItem->setMsg(_T("This share already exist")); $errItem->setAdvice(_T("<ul>\n <li>Delete this share before recreate it.</li>\n <li>Choose another share name</li>\n </ul>")); $errItem->setLevel(0); $errItem->setSize(450); $errItem->setTraceBackDisplay(false); $errObj->add($errItem); $errItem = new ErrorHandlingItem("No such file or directory"); $errItem->setMsg(_T("The share directory does not exist.")); $errItem->setAdvice(_T("Please delete this share, and then create it again.")); $errItem->setTraceBackDisplay(false); $errObj->add($errItem); $errItem = new ErrorHandlingItem('smb.conf file is not valid'); $errItem->setMsg(_("Some options are not valid")); $errItem->setAdvice(_("Check your custom parameters.")); $errItem->setTraceBackDisplay(false); $errObj->add($errItem); $errItem = new ErrorHandlingItem('invalid samba parameter format'); $errItem->setMsg(_("A custom parameter has an invalid format.")); $errItem->setAdvice(_("Use the 'option = value' format.")); $errItem->setTraceBackDisplay(false); $errObj->add($errItem);
$errItem = new ErrorHandlingItem('(ldap.ALREADY_EXISTS|Already exist)'); $errItem->setMsg(_("This item already exists in your LDAP directory")); $errItem->setAdvice(_("Solve the problem by:\n <ul>\n <li>change this entry name</li>\n <li>delete this entry before recreate it</li>\n </ul>")); $errItem->setTraceBackDisplay(false); $errItem->setSize(300); $errItem->setLevel(0); $errObj->add($errItem); $errItem = new ErrorHandlingItem('Can\'t contact LDAP server'); $errItem->setMsg(_("MMC Agent can't contact your LDAP server")); $errItem->setAdvice(_("Solve the problem by:\n <ul>\n <li>Verify your LDAP server is correctly configured in /etc/mmc/plugins/base/ini </li>\n <li>Verify you LDAP server is up</li>\n </ul>")); $errObj->add($errItem); $errItem = new ErrorHandlingItem("AuthenticationError"); $errItem->setMsg(_("Error during authentication process")); $errItem->setAdvice(_("Please contact your administrator.")); $errObj->add($errItem); $errItem = new ErrorHandlingItem("ProvisioningError"); $errItem->setMsg(_("Error while provisioning your account")); $errItem->setAdvice(_("Please contact your administrator.")); $errObj->add($errItem); $errItem = new ErrorHandlingItem('(exceptions.IndexError: list index out of range|ldap.NO_SUCH_OBJECT)'); // FIXME : isn't the regex too wide ? $errItem->setMsg(_("This item do not seems to be in the index")); $errItem->setAdvice(_("This problem can appear if:\n <ul>\n <li>This item no longer exists.</li>\n <li>You misspelled it.</li>\n </ul>")); //$errItem->setTraceBackDisplay(false); $errItem->setSize(800); $errItem->setLevel(0); $errObj->add($errItem); $errItem = new ErrorHandlingItem('Failed to modify password entry'); $errItem->setMsg(_("smbpasswd failed to change your password entry")); $errItem->setAdvice(_("Verify that your smbpasswd is correctly configured:\n <ul>\n <li> Your Ldap server can be down</li>\n <li> Your Samba server is not properly configured</li>\n </ul>")); $errObj->add($errItem);
$errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must contain at least one upper.*'"); $errItem->setMsg(_("The password must contain at least one upper case character")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must contain at least one lower.*'"); $errItem->setMsg(_("The password must contain at least one lower case character")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must contain at least one special.*'"); $errItem->setMsg(_("The password must contain at least one special character: #\$%&+./:=?@{}")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password must not contain the same character.*'"); $errItem->setMsgFromError("/'info': '(.*)',/"); $dummyMsg = _("The password must not contain the same character %s times"); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'Password not accepted.*'"); $errItem->setMsgFromError("/'info': '(.*)',/"); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password length must be.*'"); $errItem->setMsgFromError("/'info': '(.*)',/"); $dummyMsg = _("The password length must be %s or longer"); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": {'info': 'The password is too short.*'"); $errItem->setMsg(_("The password is too short.")); $errItem->setTraceBackDisplay(False); $errObj->add($errItem);
* MMC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MMC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MMC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ $errItem = new ErrorHandlingItem(": Invalid shorewall line"); $errItem->setMsg(_T("The rule is invalid", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid port number"); $errItem->setMsg(_T("Invalid port number", "shorewall")); $errItem->setAdvice(_T("Port should be between 0 and 65535.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem); $errItem = new ErrorHandlingItem(": Invalid port range"); $errItem->setMsg(_T("Invalid port range", "shorewall")); $errItem->setAdvice(_T("Ports should be between 0 and 65535 and the left side port must be lower that the right side port.", "shorewall")); $errItem->setLevel(1); $errItem->setTraceBackDisplay(False); $errObj->add($errItem);