≡ Menu

nginx Chroot Helper Bash Shell Script To Copy Libs To /lib64 and /usr/lib64

{ 2 comments… add one }
  • Debrah April 21, 2011, 11:29 am

    I’m imerpssed! You’ve managed the almost impossible.

  • Rahul Panwar July 22, 2010, 10:55 am


    I am using this script to prepare the jail root for SSH users. It is working fine if any given command’s lib does not already exist in the BASE dir. But if any file already exist it does not accept the multiple commands as argument, it exit after existing command.

    For example, if i execute this script as follows:
    n2chroot /bin/bash # It works fine
    n2chroot /bin/bash /bin/ls # It exit after /bin/bash as it was already exist there.

    Actually it exit from the function “sync_suppot_libs” when it found the any file already exist.

    When i change the last condition in function “sync_suppot_libs”
    [ ! -f ${d}${sldl} ] && ${_cp} -f ${sldl} ${d}${sldlsubdir}
    if [ ! -f ${d}${sldl} ]; then
    ${_cp} -f ${sldl} ${d}${sldlsubdir}
    It start working properly.
    May be you want to change in your script also. I also add few more lines at the end of function “sync_suppot_libs” as follows:
    #Copy the given file to the base directory
    dcc=”${pFILE%/*}” #get dirname for given file

    [ ! -d ${d}${dcc} ] && mkdir -p ${d}${dcc}
    # [ ! -f ${d}${pFILE} ] && ${_cp} -f ${pFILE} ${d}${pFILE}

    if [ ! -f ${d}${pFILE} ]; then
    ${_cp} -f ${pFILE} ${d}${pFILE}

    Thanks & Regards,
    Rahul Panwar

Security: Are you a robot or human?

Leave a Comment