Chroot - Mysql command line tool - /var/run/mysqld

  • Hello ;

    I've a library which allow to create jailed shell environments (chroot) using makejail.
    I want make the mysql command-line tool (/usr/bin/mysql) available inside the chroot and thus, I must mount the /var/run/mysqld directory inside the chroot. This is the directory holding the mysql socket.

    To do so, I've added the path /var/run/mysqld directory in the makejail configuration file but because /var/run is a symlink to /run which is a tmpfs (flushed on any reboot), I've the following problems:

    • When mounting /var/run/mysqld on <chroot_path>/var/run/mysqld, the mount is done on /var/run/mysqld (/run/mysqld) instead of <chroot_path>/var/run/mysqld (<chroot_path>/run/mysqld). It's normal because makejail create <chroot_path>/var/run that is an absolute symlink to /run which is only resolved correctly in the context of the chroot. This problem can be solved by forcing makejail to create relative symlink in place (I must patch the code) or maybe by using libpam-mount...
    • When adding the fstab entry for this mount point, this doesn't works because the /run tmpfs is cleaned on every boot (the mysqld directory is created only when the MySQL server is started, after that the fstab entries were processed).

    To resume here, since Debian Wheezy, it's not longer possible to re-mount a specific part of /var/run inside a chroot.

    Does anyone faced with such a problem and does anyone know a solution?


    • An hard link is not a solution because on reboot, it is broken.
    • A symlink is not a solution because it is not resolved in chroot context.
    • Forcing TCP connection using an /etc/mysql/my.cnf file within the chroot (see below) can be a solution but I would prefer stay with socket.

    File which allow to force TCP connection:

    1. root@wheezy:/# cat /var/chroot/InstantSSH/shared_jail/etc/mysql/my.cnf
    2. [client]
    3. protocol=tcp
    4. root@wheezy:/#

    Thank you for your advises.


  • badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @biologist