Chroot user home

/etc/fstab

/tmp/chroot/user_tmp    /usr/local/chroot.user/tmp          none    bind,noauto

/home/user              /usr/local/chroot.user/home/user    none    bind

userpts                 /usr/local/chroot.user/dev/pts      devpts  gid=5,mode=0620         0       0

Change the shell in /etc/passwd to chroot_user.sh

chroot_user.sh

#!/bin/bash

if [ "$1" = "-c" ]; then
        i=0;
        PARAMS="";
        for param in $*; do
            if [ $i -gt 0 ]; then
                PARAMS="$PARAMS $param";
            fi
            let i++;
        done;
        /usr/bin/sudo /usr/sbin/chroot /usr/local/chroot.user /bin/su - user -c "$PARAMS"
    else
        /usr/bin/sudo /usr/sbin/chroot /usr/local/chroot.user /bin/su - user
fi;

exit 0

Chroot environment in /usr/local/chroot.user:

/bin/bash
     chmod
     chown
     cp
     false
     ln
     ls
     mkdir
     mv
     pwd
     rm
     rmdir
     su
     touch
     true
/dev/log
     null
     ptmx
     pts/
     random
     tty
     tty1
     tty2
     tty3
     tty4
     tty5
     tty6
     urandom
     zero
/etc/group
     hosts
     localtime
     mc/
     passwd
     services
     ssh/
/home/user/
/lib/ld-2.7.so
     ld-linux.so.2 -> ld-2.7.so
     libc-2.7.so
     libc.so.6 -> libc-2.7.so
     libnss_files-2.7.so
     libnss_files.so.2 -> libnss_files-2.7.so
     terminfo/
/tmp/
/usr/bin/bunzip2
         bzip2
         ftp
         gunzip
         gzip
         mc
         mysql
         scp
         sftp
         ssh
         tar
    /lib/locale/en_US.utf8
                hu_HU
                hu_HU.utf8
    /local/mc/share/mc/extfs
    /share/locale/hu/
           /mc/syntax
           /terminfo
/var/
 
Logged in as: Oszkár Kmetti
linux/chroot_user.txt · Last modified: 2009.01.13 20:07 by oszi
 
Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki