#2974 mysql errors not showing up in chroot jail

works-for-me
nobody
None
5
2013-06-11
2010-01-29
Marco Gatti
No

I use phpmyadmin in different web chroot jail environments. When trying to execute custom sql, for example, if its syntax is wrong phpmyadmin shows only mysql error number but no text describing the error. Removing the chroot environment it works normally. Custom php scripts connecting to mysql databases and executing the same sql displays error number and error text as usual even in chroot environment.
I tried versions 2.11.10, 3.2.5 and also 3.3.0-beta1 with same results.

Discussion

  • To be able to reproduce your problem I have several questions:
    Is the webserver that runs phpMyAdmin in the same chroot as the MySQL server or a different one?
    Are connecting via socket or tcp?
    Do you have the same problem when you use the mysql commandline client?

     
  • Marco Gatti
    Marco Gatti
    2010-02-03

    Apache chroot jail is implemented with a module, is not a full jail (i tried two different modules for chroot and the result is the same), so mysql is outside the jail. Mysql server is accessed via tcp and does not matter if it's in the same machine or in another.
    As you might guess there is no problem using mysql command line.

     
  • I have a hunch that the mysql client lib in PHP can not resolve the error number into a full error description.
    This might be due to something unaccessible from inside the chroot.

    You might be able to verify this with a small piece of php code like below. I assume u use the mysqli?
    What versions of PHP, webserver and MySQL are you using?

    <?php
    $link = mysqli_connect("localhost", "my_user", "my_password", "world");

    /* check connection */
    if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
    }

    $query = "SELECT * FROM `non_existing_table`";
    if (!mysqli_query($link, $query)) {
    printf("Errornumber: %s\n", mysqli_errno($link));
    printf("Errormessage: %s\n", mysqli_error($link));
    }

    /* close connection */
    mysqli_close($link);
    ?>

     
  • Marco Gatti
    Marco Gatti
    2010-02-04

    It's what i thought at the beginning (about mysql client libraries resolution in php), but every php application that we have works fine.
    I'm using debian stable 'lenny' packages, so apache is 2.2.9, php is 5.2.6 and mysql is 5.0.51a.
    Yes, i'm using mysqli but if i revert to mysql php extension it doesn't chage...

    I tried your code and this is the output:
    Errornumber: 1146 Errormessage: Table 'drupal.non_existing_table' doesn't exist

    Where drupal is a database.
    So php resolves both errornumber and errormessage, but not when using phpmyadmin!
    Why?

     
  • Could you check some values inside the PMA_DBI_getError() function in libraries/dbi/mysqli.dbi.lib.php?
    It would be interesting to see if $error_message gets a good value.

     
  • Marco Gatti
    Marco Gatti
    2010-02-19

    • status: open --> closed-works-for-me
     
  • Marco Gatti
    Marco Gatti
    2010-02-19

    I traced back the $error_message variable in libraries/database_interface.lib.php where in function PMA_DBI_convert_message() che charset conversion done by php internal function iconv() was givin errors or not working properly.
    It came out i just had to add a new directory inside the jail: /usr/lib/gconv (for debian) and now i got error messages right where they should be!
    So i wasn't having problems from other applications because they didn't use iconv function...
    Thank you for showing me where to investigate!

     
  • Michal Čihař
    Michal Čihař
    2013-06-11

    • Status: closed-works-for-me --> works-for-me