Howto add programes to chroot users?

Discussion in 'Server Operation' started by badgerbox76, Apr 5, 2008.

  1. badgerbox76

    badgerbox76 Member

    I fallowed falko's Howto guild and got Chroot working. Now I want to add/give more programs to chroot users

    So I added a few programs to the script that was in the howto guild and ran it. Clear, nano to name a few

    Code:
    #!/bin/bash
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    
    APPS="/bin/sh /bin/bash /bin/nano /bin/cp /bin/ls /bin/mkdir /bin/mv /bin/pwd /bin/rm /bin/rmdir /usr/bin/id /usr/bin/ssh /bin/ping /usr/bin/clear /usr/bin/dircolors /usr/bin/cmatrix /usr/bin/raggle /usr/bi$
    for prog in $APPS;  do
            mkdir -p ./`dirname $prog` > /dev/null 2>&1
            cp $prog ./$prog
    
            # obtain a list of related libraries
            ldd $prog > /dev/null
            if [ "$?" = 0 ] ; then
                    LIBS=`ldd $prog | awk '{ print $3 }'`
                    for l in $LIBS; do
                            mkdir -p ./`dirname $l` > /dev/null 2>&1
                            cp $l ./$l  > /dev/null 2>&1
                    done
            fi
    done
    
    After running the script then having the chroot user get disconnected I reconnected to the server again to test things out.

    Code:
    login as: david
    [email protected]'s password:
    Last login: Fri Apr  4 18:35:43 2008 from 192.168.0.104
    [email protected]:~$ ls
    [email protected]:~$ clear
    'xterm': unknown terminal type.
    [email protected]:~$ nano
    Error opening terminal: xterm.
    [email protected]:~$
    Not working, I thought the script above grabbed all the necessary library files along with the program. I checked the chroot directory's and the programs are present.
     
  2. falko

    falko Super Moderator ISPConfig Developer

  3. badgerbox76

    badgerbox76 Member

    Yes /usr/share/terminfo so I copied it over to /home/chroot/usr/share/terminfo and re-ran the script

    Whats wrong with the script? Am I doing something wrong here?

    Code:
    [email protected]:/$ sudo /usr/local/sbin/create_chroot_env
    cp: `/bin/sh' and `.//bin/sh' are the same file
    cp: `/bin/bash' and `.//bin/bash' are the same file
    cp: `/bin/nano' and `.//bin/nano' are the same file
    cp: `/bin/cp' and `.//bin/cp' are the same file
    cp: `/bin/ls' and `.//bin/ls' are the same file
    cp: `/bin/mkdir' and `.//bin/mkdir' are the same file
    cp: `/bin/mv' and `.//bin/mv' are the same file
    cp: `/bin/pwd' and `.//bin/pwd' are the same file
    cp: `/bin/rm' and `.//bin/rm' are the same file
    cp: `/bin/rmdir' and `.//bin/rmdir' are the same file
    cp: `/usr/bin/id' and `.//usr/bin/id' are the same file
    cp: `/usr/bin/ssh' and `.//usr/bin/ssh' are the same file
    cp: `/bin/ping' and `.//bin/ping' are the same file
    cp: `/usr/bin/clear' and `.//usr/bin/clear' are the same file
    cp: `/usr/bin/dircolors' and `.//usr/bin/dircolors' are the same file
    cp: `/usr/bin/cmatrix' and `.//usr/bin/cmatrix' are the same file
    cp: `/usr/bin/raggle' and `.//usr/bin/raggle' are the same file
    cp: `/usr/bin/vi' and `.//usr/bin/vi' are the same file
    cp: `/usr/bin/sftp' and `.//usr/bin/sftp' are the same file
    cp: `/usr/lib/openssh/sftp-server' and `.//usr/lib/openssh/sftp-server' are the same file
    [email protected]:/$
    I don't know why I need this file but because all my terminal programs run fine under a regular user login I am just having a hard time getting them to work under chroot users.
    Code:
    [email protected]:/$ sudo apt-get install ncurses
    Reading package lists... Done
    Building dependency tree... Done
    Package ncurses is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    E: Package ncurses has no installation candidate
    [email protected]:/$
    
    Still no working, um
     
  4. badgerbox76

    badgerbox76 Member

    bump for a solution :rolleyes:
     
  5. falko

    falko Super Moderator ISPConfig Developer

    Try
    Code:
    apt-get install ncurses-base
     
  6. badgerbox76

    badgerbox76 Member

    Code:
    [email protected]:~$ sudo apt-get install ncurses-base                      Reading package lists... Done
    Building dependency tree... Done
    ncurses-base is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
    [email protected]:~$
    
    :confused:
     
  7. falko

    falko Super Moderator ISPConfig Developer

  8. badgerbox76

    badgerbox76 Member

    ok after copying over /lib/terminfo into /home/chroot/lib/terminfo the programs now run. Thanks much
     

Share This Page