little flaw in create_chroot_env

Discussion in 'Developers' Forum' started by vogelor, May 2, 2008.

  1. vogelor

    vogelor ISPConfig Developer ISPConfig Developer

    i found a little flaws in and i post it here so that anyone of the developer with write access to the source-file can change (fix) it.

    at the end of the file BEVORE ln /var/run/mysqld/mysqld.soc ${HOMEDIR}... we have to add

    #delete the old one, because it changes if the server (or mysql) is restarted
    rm ${HOMEDIR}/var/run/mysqld/mysqld.sock
    because the problem is, that this file is regenerated every time the mysql database is (re)started. Maybe anyone has a better idea (maybe a "other" link which worked if the "original" file was removed and new generated or anything else...)

    if something is unclear, please fell free to ask...
  2. falko

    falko Super Moderator ISPConfig Developer

    I've added this to the bugtracker for review.
  3. flipkick

    flipkick ISPConfig Developer ISPConfig Developer

    i've reproduced the problem. a hard link like ${HOMEDIR}/var/run/mysqld/mysqld.sock uses the same inode as the original file. so if the original is modified, the hard linked file will also change because both are technically identical. but if you delete the original (when you stop mysqld), the linked file stays and gets the only one using the inode. there's no more link to another file then. so if you start mysqld again, the socket in the home dir is still the old one, but /var/run/mysqld/mysqld.sock is the new one.

    in my case, the creation of the hard link also failed because of an "invalid cross-device link" error. reason: hardlinking between different filesystems is not possible (because both files have to use the same inode on the same filesystem).

    bugfix for both problems is to use a symbolic link. it will stay, even if the original is removed, but won't work anymore. if the original is back, the link to the original works again. symbolic links also don't care about linking between different filesystems.

    fixed it in the ispconfig2-dev trunk. or simply change the following line at the end of

    ln /var/run/mysqld/mysqld.sock ${HOMEDIR}/var/run/mysqld/mysqld.sock

    ln -s /var/run/mysqld/mysqld.sock ${HOMEDIR}/var/run/mysqld/mysqld.sock
    Last edited: May 7, 2008
  4. vogelor

    vogelor ISPConfig Developer ISPConfig Developer

    can you please also add

    rm ${HOMEDIR}/var/run/mysqld/mysqld.sock
    before the creation of the symlink (in the SVN).
    (because the OLD "wrong" hard links exists and so the creation of the NEW "right" symlink fails
  5. vogelor

    vogelor ISPConfig Developer ISPConfig Developer


    i am using chrooted environment per user.

    so the symlink will not work, because you can't escape a chrooted-env with a symlink. a hardlink works, but will not refresh. this means after a restart of mysql the hardlink was unusable!

    any idea?

Share This Page