patrickpr / trapdirector

Icingaweb2 module for receiving and handling snmp traps
GNU General Public License v3.0
53 stars 15 forks source link

Error handling installer.sh #46

Closed Pio84 closed 4 years ago

Pio84 commented 4 years ago

In the function add_schema_mysql() ist the output: Connecting...ERROR 1698 (28000): Access denied for user 'root'@'localhost' somewhat misleading. Because the input was... Enter database host [set to 127.0.0.1 if you don't enter anything] : 127.0.0.1 in my mysql database is root@localhost and root@127.0.0.1 not the same.

the right Error should be: Connecting...ERROR 1698 (28000): Access denied for user 'root'@'127.0.0.1' because thats the input i gave to the script.

I think its in Line 383 of the script.

Enter database host [set to 127.0.0.1 if you don't enter anything] : ive tested with no input and with 127.0.0.1 and this is leading to the error. If i write "localhost" as input it works as it should.

patrickpr commented 4 years ago

The script uses the following command for user testing :

mysql -h <IP or hostname> -P <TCP Port> -u <user> -p<pass> -e 'show databases;' 

with IP set to 127.0.0.1 if you enter nothing.

The error message comes from mysql not from the script : there is nothing I can do about it.

Example on my test server :

[root@icinga ~]# mysql -h 127.0.0.1 -P 3306 -u root -ptest -e 'show databases;'
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
manfredw commented 4 years ago

I think the default host value for local databases should be localhost instead of 127.0.0.1 within the installer script.

Also check if there is an mysql user entry for root@localhost in your database.

Pio84 commented 4 years ago

The error message comes from mysql not from the script : there is nothing I can do about it.

perhaps some kind of stringmanipulation at stderr?

But you are right, the wrong Errormsg comes from sql.

patrickpr commented 4 years ago

@Pio84 : string manipulation on error messages is a bad idea as some users may be used to (and expect) the 'incorrect' one.

@manfredw : at this stage, the script tries to login the database so there can't be any queries. About default values, I didn't see any guidelines or good practice for this : do you have any references on this ?

patrickpr commented 4 years ago

Added command display on error :

Enter username : root
Enter password (or press enter if no password is required) :
Connecting...ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Command sent was : mysql  -h 127.0.0.1 -P 3306 -u root  -ptest   -e 'show databases;'