-
Notifications
You must be signed in to change notification settings - Fork 240
fix(install) Get the ip address of an existing connection to set the permission correctly #7347
Conversation
Co-Authored-By: lgcosta <luizgustavo@luizgustavo.pro.br>
is it possible that "SELECT host FROM information_schema.processlist WHERE ID = connection_id()" does not return anything ? |
As it takes advantage of an active match from the [1] https://dev.mysql.com/doc/refman/8.0/en/processlist-table.html |
Ok thanks for reply. Then you can merge it ;) |
Pull Request Template
Description
When an installation of the Centreon is done using the database server (MySQL) on an external server and it is on another network being accessed only via NAT, an ip address is mistakenly assigned in the user permission
centreon
of MySQL.Currently it uses a server variable to get the client ip (
$_SERVER['SERVER_ADDR']
). however, when the server is in another network location, the ip that needs to be allocated in the user's permission is the network gateway (which does the NAT).As for getting to this
centreon
user creation function, it is necessary to have the connection using validroot
, I am taking into account that there is a valid connection and functioning asroot
.So, I have a attribute available in the PDO connection object and with that, I use an attribute availablePDO::ATTR_CONNECTION_STATUS
in the object to get the valid ip address of the client for the connection.Using mysql directly is more effective, the PDO was returning me the ip of the server.
This way, I use the Mysql information table and I can capture the ip of the current session.
Type of change
Target serie
How this pull request can be tested ?
I came up with this problem using environments where I used MariaDB on docker instances in networks other than the Centreon installation. For example, I have the MariaDB docker on the 172.17.0.0/24 network and the Centreon installation on a Vagrant on the 10.1.0.0/24 network.
Checklist
Community contributors & Centreon team
Centreon team only