°¢°¢ÀÇ µµ¸ÞÀÎÀº ÀڽŸ¸ÀÇ µð·ºÅ丮 ±¸Á¶¸¦ °¡Áø´Ù. µû¶ó¼ ¸¸¾à
chroot
¸¦ »ç¿ëÇÏ·Á°í ÇÑ´Ù¸é, ´ç½ÅÀº °øÀ¯ ¶óÀ̺귯¸®³ª ¹ÙÀ̳ʸ®
½ÇÇàÆÄÀϵé, ¼³Á¤ ÆÄÀÏ µîÀ» º¹Á¦ÇÏ´Â °úÁ¤ÀÌ ÇÊ¿äÇÏ´Ù. ³ª´Â ³»°¡ ¸¸µç
°¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ /virtual/domain1.comÀ» »ç¿ëÇÑ´Ù.
¹°·Ð ´õ ¸¹Àº µð½ºÅ©ÀÇ °ø°£ÀÌ ÇÊ¿äÇÏ°Ô µÇÁö¸¸, ±×°ÍÀÌ »õ·Î¿î ¸Ó½Å°ú ³×Æ®¿öÅ© Ä«µå¸¦ ¼³Ä¡ÇÏ´Â °Íº¸´Ù´Â °ªÀÌ Àú·ÅÇÏ´Ù. ¸¸¾à ´ç½ÅÀÌ °ø°£À» Àý¾àÇÏ°í ½Í´Ù¸é ÇÏµå ¸µÅ©¸¦ ÀÌ¿ëÇÒ ¼ö Àִµ¥, ³» °æ¿ì ÀÌ ¹æ¹ýÀ» »ç¿ëÇϸé 2M°¡ ¾à°£ ³Ñ´Â °ø°£¸¸À» »ç¿ëÇÏ°Ô µÈ´Ù. ÇÏÁö¸¸, ÀÌ ½ºÅ©¸³Æ®´Â °¡±ÞÀû ÀϹÝÀûÀÎ ½Ã½ºÅÛÀ» ¸¸µé±â À§ÇØ ¸ÞÀÎ ÆÄÀϽýºÅÛ¿¡¼ ¸ðµç ÆÄÀÏÀ» º¹»çÇÏ·Á ÇÒ °ÍÀÌ´Ù.
¿©±â °£´ÜÇÑ virtfs ½ºÅ©¸³Æ®°¡ ÀÖ´Ù:
#!/bin/sh echo '$Revision: 1.49 $' echo -n "Enter the domain name: " read domain if [ "$domain" = "" ] then echo Nothing entered: aborting exit 0 fi leadingdir=/virtual echo -n "Enter leading dir: (Enter for default: $leadingdir): " read ans if [ "$ans" != "" ] then leadingdir=$ans fi newdir=$leadingdir/$domain if [ -d "$newdir" ] then echo New directory: $newdir: ALREADY exists exit 0 else echo New directory: $newdir fi echo Create $newdir mkdir -p $newdir echo Create bin cp -pdR /bin $newdir echo Create dev cp -pdR /dev $newdir echo Create dev/log ln -f /virtual/log $newdir/dev/log echo Create etc mkdir -p $newdir/etc for i in /etc/* do if [ -d "$i" ] then continue fi cp -pd $i $newdir/etc done echo Create etc/skel mkdir -p $newdir/etc/skel echo Create home for i in a b c d e f g h i j k l m n o p q r s t u v w x y z do mkdir -p $newdir/home/$i done echo Create home/c/crc mkdir -p $newdir/home/c/crc chown crc.users $newdir/home/c/crc echo Create lib mkdir -p $newdir/lib for i in /lib/* do if [ -d "$i" ] then continue fi cp -pd $i $newdir/lib done echo Create proc mkdir -p $newdir/proc echo Create sbin cp -pdR /sbin $newdir echo Create tmp mkdir -p -m 0777 $newdir/tmp chmod +t $newdir/tmp echo Create usr mkdir -p $newdir/usr echo Create usr/bin cp -pdR /usr/bin $newdir/usr echo Create usr/lib mkdir -p $newdir/usr/lib echo Create usr/lib/locale cp -pdR /usr/lib/locale $newdir/usr/lib echo Create usr/lib/terminfo cp -pdR /usr/lib/terminfo $newdir/usr/lib echo Create usr/lib/zoneinfo cp -pdR /usr/lib/zoneinfo $newdir/usr/lib echo Create usr/lib/\*.so\* cp -pdR /usr/lib/*.so* $newdir/usr/lib echo Create usr/sbin cp -pdR /usr/sbin $newdir/usr echo Linking usr/tmp ln -s /tmp $newdir/usr/tmp echo Create var mkdir -p $newdir/var echo Create var/lock cp -pdR /var/lock $newdir/var echo Create var/log mkdir -p $newdir/var/log echo Create var/log/wtmp cp /dev/null $newdir/var/log/wtmp echo Create var/run cp -pdR /var/run $newdir/var echo Create var/run/utmp cp /dev/null $newdir/var/run/utmp echo Create var/spool cp -pdR /var/spool $newdir/var echo Linking var/tmp ln -s /tmp $newdir/var/tmp echo Create var/www/html mkdir -p $newdir/var/www/html chown webmast.www $newdir/var/www/html chmod g+s $newdir/var/www/html echo Create var/www/master mkdir -p $newdir/var/www/master chown webmast.www $newdir/var/www/master echo Create var/www/server mkdir -p $newdir/var/www/server chown webmast.www $newdir/var/www/server exit 0
°¡»ó ȯ°æ¿¡¼ ¸í·É¾î¸¦ ½ÇÇà½ÃÅ°±â À§Çؼ ´ç½ÅÀº chroot
¸¦
ÀÌ¿ëÇÏ¿© µð·ºÅ丮¸¦ º¯°æÇÑ µÚ ¸í·É¾î¸¦ ½ÇÇàÇؾ߸¸ ÇÑ´Ù. ¿©±â ¾î¶²
¸í·É¿¡ ´ëÇؼ ÀÌ·± ±â´ÉÀ» ¼öÇàÇÒ ¼ö Àִ Ưº°ÇÑ ¼Ð½ºÅ©¸³Æ®ÀÎ
virtexec¸¦ ¼Ò°³ÇÑ´Ù:
#!/bin/sh echo '$Revision: 1.49 $' BNAME=`basename $0` FIRST4CHAR=`echo $BNAME | cut -c1-4` REALBNAME=`echo $BNAME | cut -c5-` if [ "$BNAME" = "virtexec" ] then echo Cannot run virtexec directly: NEED a symlink exit 0 fi if [ "$FIRST4CHAR" != "virt" ] then echo Symlink not a virt function exit 0 fi list="" num=1 for i in /virtual/* do if [ ! -d "$i" ] then continue fi if [ "$i" = "/virtual/lost+found" ] then continue fi list="$list $i $num" num=`expr $num + 1` done if [ "$list" = "" ] then echo No virtual environments exist exit 0 fi dialog --clear --title 'Virtexec' --menu Pick 20 70 12 $list 2> /tmp/menu.$$ if [ "$?" = "0" ] then newdir=`cat /tmp/menu.$$` else newdir="" fi tput clear rm -f /tmp/menu.$$ echo '$Revision: 1.49 $' if [ ! -d "$newdir" ] then echo New directory: $newdir: NOT EXIST exit 0 else echo New directory: $newdir fi echo bname: $BNAME echo realbname: $REALBNAME if [ "$*" = "" ] then echo args: none else echo args: $* fi echo Changing to $newdir cd $newdir echo Running program $REALBNAME chroot $newdir $REALBNAME $* exit 0
ÀÌ ½ºÅ©¸³Æ®°¡ ½ÇÇàµÇ±â À§Çؼ ´ç½Å ½Ã½ºÅÛ¿¡ dialog
ÇÁ·Î±×·¥ÀÌ
¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù´Â °ÍÀ» ÁÖÀÇÇ϶ó. virtexec¸¦ »ç¿ëÇϱâ À§Çؼ´Â ´ÜÁö
½Éº¼¸¯ ¸µÅ©¸¦ ÇØÁÖ¸é µÈ´Ù. ¿¹¸¦ µé¸é ´ÙÀ½°ú °°´Ù.
ln -s /usr/local/bin/virtexec /usr/local/bin/virtpasswd ln -s /usr/local/bin/virtexec /usr/local/bin/virtvi ln -s /usr/local/bin/virtexec /usr/local/bin/virtpico ln -s /usr/local/bin/virtexec /usr/local/bin/virtemacs ln -s /usr/local/bin/virtexec /usr/local/bin/virtmailq
¸µÅ©¸¦ ½ÃŲ ÈÄ virtvi¸¦ ½ÇÇà½ÃÅ°¸é °¡»ó ½Ã½ºÅÛÀÇ vi¸¦ ½ÇÇà½Ãų °ÍÀÌ´Ù. ¸¶Âù°¡Áö·Î virtpasswd´Â °¡»ó ½Ã½ºÅÛÀÇ »ç¿ëÀÚ ºñ¹Ð¹øÈ£¸¦ ¹Ù²Ü °ÍÀÌ°í, virtmailq´Â °¡»ó °ø°£ÀÇ ¸ÞÀÏ Å¥(queue)¸¦ È®ÀÎÇÒ °ÍÀÌ´Ù. ´ç½ÅÀº ¿øÇÏ´Â ¸¸Å virtexec¸¦ ¸¸µé ¼ö ÀÖ´Ù. ¸¸¾à ´ç½ÅÀÇ ÇÁ·Î±×·¥ÀÌ °øÀ¯ ¶óÀ̺귯¸®¸¦ ÇÊ¿ä·Î ÇÑ´Ù¸é ¹ÙÀ̳ʸ®¿Í ¸¶Âù°¡Áö·Î °¡»ó ÆÄÀϽýºÅÛ¿¡ À§Ä¡½Ãų ¼ö ÀÖ´Ù.
³ª´Â ¸ðµç ½ºÅ©¸³Æ®µéÀ» /usr/local/bin¿¡ ¼³Ä¡Çß´Ù. ±× ÀÌ¿Ü¿¡ °¡»ó ÆÄÀϽýºÅÛ¿¡ ³Ö°í½ÍÁö ¾ÊÀº °ÍµéÀº /usr/local¿¡ µÎ¾ú´Ù. ½ºÅ©¸³Æ®´Â /usr/local¿¡ ÀÖ´Â ÆÄÀÏÀ» °¡»ó ÆÄÀϽýºÅÛÀ¸·Î º¹»çÇÏÁö ¾Ê´Â´Ù. °¡»ó ÆÄÀϽýºÅÛÀ¸·Î ³Ñ¾î¿À¸é ¾ÈµÇ´Â Áß¿äÇÑ ÆÄÀϵéÀº ¹Ýµå½Ã °¡»ó ½Ã½ºÅÛ¿¡¼ Á¦°ÅµÇ¾î¾ß ÇÑ´Ù. ÇÑ ¿¹·Î, ³» ½Ã½ºÅÛ¿¡´Â ssh°¡ ¼³Ä¡µÇ¾î Àִµ¥, ¸ðµç °¡»óÀÇ ÆÄÀÏ ½Ã½ºÅÛÀÇ ¼¹ö¿¡¼´Â °³ÀÎÅ°(private key)¸¦ ¿øÇÏÁö ¾Ê±â ¶§¹®¿¡, virtfs¸¦ ½ÇÇà½ÃŲ ÀÌÈÄ¿¡ °¢°¢ÀÇ °¡»ó ÆÄÀÏ ½Ã½ºÅÛ¿¡¼ ÀÌ°ÍÀ» Á¦°ÅÇß´Ù. ¶ÇÇÑ resolv.conf¸¦ ¹Ù²Ù°í, ±× ¾È¿¡ ÀÖ´ø ´Ù¸¥ µµ¸ÞÀεéÀÇ À̸§À» °¡Áø ¸ðµç °ÍµéÀ» »èÁ¦Çß´Ù. ÀÌ·± °Íµé·Î´Â /etc/hosts³ª /etc/HOSTNAME µîÀÌ ÀÖ´Ù.
³»°¡ virtexec·Î ½Éº¼¸¯ ¸µÅ©½ÃŲ ÇÁ·Î±×·¥µéÀÌ´Ù: