sbpp / sourcebans-pp

Admin, ban, and comms management system for the Source engine
https://sbpp.github.io/
Creative Commons Attribution Share Alike 4.0 International
336 stars 174 forks source link

Wrong hostname used in user config (not an SourceBans Issue) #204

Closed hznovich closed 7 years ago

hznovich commented 7 years ago

Hello. After update to php 7.1 sourceban breaks:

`Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/sban/includes/adodb/drivers/adodb-mysqli.inc.php on line 124

Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/sban/includes/adodb/drivers/adodb-mysqli.inc.php on line 124

Fatal error: mysqli error: [2002: php_network_getaddresses: getaddrinfo failed: Name or service not known] in CONNECT(sbanuser, '', '', ) in /www/sban/includes/adodb/adodb-errorhandler.inc.php on line 79`

Whats wrong, help please... PS: Ubuntu 16.04

galexrt commented 7 years ago

@hznovich This issue is not related to SourceBans or SourceBans++.

What address are you using to connect to the database server? The issue is that the hostname you are using is invalid and can't be resolved to an IP address.

hznovich commented 7 years ago

Localhost. I tried 127.0.0.1 and etc, doesn't work. Other websites work at the same system normally now.

galexrt commented 7 years ago

Run the following command on the webserver and post the output:

cat /etc/hosts
hznovich commented 7 years ago
127.0.0.1       localhost
127.0.1.1       gs-vlv-02

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
galexrt commented 7 years ago

Do the "other websites" also use PHP 7.1?

hznovich commented 7 years ago

yes. Now i remove php7.1 and all modules, but doesn't work (((

$ php -v
PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.6, Copyright (c) 2002-2016, by ionCube Ltd.
    with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
galexrt commented 7 years ago

Post the content of the /etc/resolv.conf.

hznovich commented 7 years ago
nameserver 95.154.113.10
nameserver 95.154.112.75
nameserver 172.17.0.79
search inetvl.ru vladlink.ru
galexrt commented 7 years ago

Please post your sourceBans config (without password).

hznovich commented 7 years ago
<?php
/**
 * config.php
 *
 * This file contains all of the configuration for the db
 * that will
 * @author SteamFriends Development Team
 * @version 1.0.0
 * @copyright SteamFriends (www.SteamFriends.com)
 * @package SourceBans
 */
if(!defined('IN_SB')){echo 'You should not be here. Only follow links!';die();}

define('DB_HOST', 'localhost');                         // The host/ip to your SQL server
define('DB_USER', 'sbanuser');                                  // The username to connect with
define('DB_PASS', '');                                              // The password
define('DB_NAME', 'sbans');                                             // Database name
define('DB_PREFIX', 'sb');                                      // The table prefix for SourceBans
define('DB_PORT','3306');                                                       // The SQL port (Default: 3306)
define('SB_WP_URL','http://sban.example.com');

//define('DEVELOPER_MODE', true);                       // Use if you want to show debugmessages
define('SB_MEM', '128M');                               // Override php memory limit, if isn't enough (Banlist is just a blank page)
?>
hznovich commented 7 years ago

config hlstatsx

if ( !defined('IN_HLSTATS') ) { die('Do not access this file directly'); }

// DB_ADDR - The address of the database server, in host:port format.
//           (You might also try setting this to e.g. ":/tmp/mysql.sock" to
//           use a Unix domain socket, if your mysqld is on the same box as
//           your web server.)
define("DB_ADDR", "localhost");

// DB_USER - The username to connect to the database as
define("DB_USER", "hlstuser");

// DB_PASS - The password for DB_USER
define("DB_PASS", "");

// DB_NAME - The name of the database
define("DB_NAME", "stats");

// DB_TYPE - The database server type. Only "mysql" is supported currently
define("DB_TYPE", "mysql");

// DB_PCONNECT - Set to 1 to use persistent database connections. Persistent
//               connections can give better performance, but may overload
//               the database server. Set to 0 to use non-persistent
//               connections.
define("DB_PCONNECT", 0);

// INCLUDE_PATH - Filesystem path to the includes directory, relative to hlstats.php. This must be specified
//              as a relative path.
//
//                Under Windows, make sure you use forward slash (/) instead
//                of back slash (\) and use absolute paths if you are having any issue.
define("INCLUDE_PATH", "./includes");

// PAGE_PATH - Filesystem path to the pages directory, relative to hlstats.php. This must be specified
//              as a relative path.
//
//                Under Windows, make sure you use forward slash (/) instead
//                of back slash (\) and use absolute paths if you are having any issue.
define("PAGE_PATH", "./pages");

// PAGE_PATH - Filesystem path to the hlstatsimg directory, relative to hlstats.php. This must be specified
//              as a relative path.
//
//                Under Windows, make sure you use forward slash (/) instead
//                of back slash (\) and use absolute paths if you are having any issue.
//
//              Note: the progress directory under hlstatsimg must be writable!!
define("IMAGE_PATH", "./hlstatsimg");

// How often dynamicly generated images are updated (in seconds)
define("IMAGE_UPDATE_INTERVAL", 300);

//define("DB_DEBUG", true);
Groruk commented 7 years ago

@hznovich which version of SourceBans++ are you currently using?

hznovich commented 7 years ago

1.5.4.7

galexrt commented 7 years ago

Add this to the config.php. before the ?>, go to your sourcebans page and post the output:

print_r('mysqli://'.DB_USER.':'.DB_PASS.'@'.DB_HOST.':'.DB_PORT.'/'.DB_NAME);

Replace your password with the word PASSWORD in the output.

hznovich commented 7 years ago
mysqli://sbanuser:PASSWORD@localhost:3306/sbans
galexrt commented 7 years ago

Are the following commands working on the webserver?

ping -c 2 localhost
ping -c 2 127.0.0.1
hznovich commented 7 years ago
$ ping -c 2 localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.011 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.014 ms

--- localhost ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.011/0.012/0.014/0.003 ms

$ ping -c 2 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.010 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.013 ms

--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.010/0.011/0.013/0.003 ms
galexrt commented 7 years ago

Can you reinstall SourceBans++ and check if the issue continues to exist? (Please note: This is not an issue of SourceBans or SourceBans++! This seems to an issue on with your server configuration.)

hznovich commented 7 years ago

Ok, i do it tomorrow. Thanks

kalkafox commented 7 years ago

I'm appearing to be having the same issue with this as well. Of course, I've done every diagnostic suggested in this issue, to no avail.

64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.034 ms
^C
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.030/0.031/0.034/0.005 ms

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.035 ms
^C
--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.029/0.031/0.035/0.005 ms

I've even switched to the server's external IP address, and so far nothing. Performing a fresh install of SourceBans++ poses the same problem while performing the install:

image

I'm currently running PHP 5.6.30. After updating to 7.1, the issue continued.

phpinfo

I'll post any other diagnostic results to help with this issue.

EDIT: This issue was fixed for me. After some toying about, no matter what entry you place in any of the configuration parameters (even if the password is correct), this same exact error is outputted if your password contains a '#' character in DB_PASS. I've also tried other similar characters, such as '@', '%', '$', '^', and '&'. All of them worked. My MySQL password coincidentally has that character. The way I troubleshooted this was by entering a random username, password, and database name despite it existing. This was the result:


Fatal error: mysqli error: [1045: Access denied for user 'kalka_sbans'@'localhost' (using password: YES)] in CONNECT(localhost, '****', '****', kalka_sbans) in /home/kalka/subdomains/sbans/web/includes/adodb/adodb-errorhandler.inc.php on line 79

This verifies that the server does indeed connect to the MySQL server. I assume the '#' character caused DB_PASS to escape wrongly or something. I'm not a PHP expert, so I'm not sure.