Virtual Services Howto Brian Ackerman, (brian@nycrc.net) v2.1, 15 August 1998 ±ÇÅÂÁØ, (linusben@bawi.org) 06 April 1999 ÀÌ ¹®¼­´Â ½Ã½ºÅÛ¿¡¼­ °¡»ó ¼­ºñ½º(virtualize)¸¦ Á¦°øÇÏ´Â °Í¿¡ ´ëÇÑ ¸¹Àº ¿äûµéÀ» À§ÇØ ¸¸µé¾îÁ³´Ù. ______________________________________________________________________ ¸ñÂ÷ 1. ¼Ò°³ 1.1 ÇÊ¿äÇÑ Áö½Äµé 1.2 ¸ñÀû 1.3 Çǵå¹é(Feedback) 1.4 °»½Å ±â·Ï (Revision History) 1.5 ÀúÀÛ±Ç/¹èÆ÷ 2. IP ¾Ù¸®¾î½Ì(IP Aliasing) 3. Virtuald 3.1 ¼Ò°³ 3.2 Inetd 3.3 ¼³Á¤ ÆÄÀÏ 3.4 ¼Ò½ºÄÚµå 4. ¼Ð ½ºÅ©¸³Æ® 4.1 Virtfs 4.2 Virtexec 4.3 °ø°í(Note) 5. DNS 6. Syslogd 6.1 ¹®Á¦µé 6.2 Solution 6.2.1 Setup Links 6.2.2 Syslogd.init 6.3 ¿©·¯°³ÀÇ Syslogd 6.3.1 ÇϳªÀÇ µð½ºÅ©¿¡ ÇÑ°³ÀÇ syslogd 6.3.2 ÇϳªÀÇ µµ¸ÞÀο¡ ÇϳªÀÇ syslogd 7. °¡»ó FTP 7.1 Inetd 7.2 À͸íÀÇ FTP(Anonymous FTP) 7.3 °¡»óÀÇ FTP »ç¿ëÀÚµé 8. °¡»óÀÇ À¥ 8.1 Virtuald¿Í ½ÇÇàÇϱâ 8.1.1 ±ÇÇÏÁö ¾ÊÀ½!(Not recommended) 8.1.2 Inetd 8.1.3 Httpd.conf 8.1.4 ¼³Á¤ 8.1.5 Httpd.init 8.2 Apache VirtualHost¿Í °°ÀÌ ½ÇÇàÇϱâ 8.2.1 Access.conf 8.2.2 Httpd.conf 8.2.3 Srm.conf 8.2.4 Httpd.init 8.3 ÆÄÀÏ ¼­¼úÀÚ ¿À¹öÇ÷οì(File Descriptor Overflow) 8.3.1 °æ°í 8.3.2 ¿©·¯°³ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö 8.4 ÇϳªÀÇ IP¿¡¼­ ¼­¹ö °øÀ¯ 8.4.1 IP Àý¾àÇϱâ 8.4.2 °áÁ¡ 8.5 ´õ ¸¹Àº Á¤º¸ 9. °¡»ó ¸ÞÀÏ/POP ¼­¹ö 9.1 ¹®Á¦ 9.2 ÇØ°áÃ¥ 9.3 SendmailÀ» ÀÌ¿ëÇÑ ÇØ°áÃ¥ 9.3.1 ¼Ò°³ 9.3.2 Sendmail ¼³Á¤ ÆÄÀÏ ¸¸µé±â 9.3.3 Sendmail ¼³Á¤ÆÄÀÏ ÆíÁýÇϱâ 9.3.4 Sendmail Áö¿ª ¹è´Þ 9.3.5 °¡»ó µµ¸ÞÀÎ »çÀÌÀÇ Sendmail : The Hack (PRE8.8.6) 9.3.6 °¡»ó µµ¸ÞÀÎ »çÀÌÀÇ Sendmail : SendmailÀÇ »õ·Î¿î ±â´É (POST8.8.6) 9.3.7 Sendmail.init 9.3.8 Inetd ¼³Á¤ 9.4 QmailÀ» ÀÌ¿ëÇÑ ¹æ¹ý 9.4.1 ¼Ò°³ 9.4.2 °¡»ó µµ¸ÞÀÎ ¼³Á¤ 9.4.3 µµ¸ÞÀÎÀÇ ÁÖÀÎ(Domain Master User) ¼³Á¤ 9.4.4 Tcpserver 9.4.5 Qmail.init 9.4.6 ¼Ò½º(Source) 9.4.7 ¼Ò½º(Source) 9.5 °¨»ç (Acknowledgement) 10. °¡»ó »ï¹Ù (Virtual Samba) 10.1 ¼³Á¤ 10.2 Inetd 10.3 Smb.init 11. ´Ù¸¥ °¡»ó ¼­ºñ½º 12. °á·Ð 13. ÀÚÁÖ Áú¹®µÇ´Â »çÇ×µé(FAQ) ______________________________________________________________________ 1. ¼Ò°³ 1.1. ÇÊ¿äÇÑ Áö½Äµé ½Ã½ºÅÛÀÇ °¡»ó ¼­ºñ½º¸¦ Á¦°øÇÏ´Â ÀÏÀº ¾î·Á¿î ÀÏÀÌ ¾Æ´ÏÁö¸¸, ±âÃÊÀûÀÎ Áö½Ä ÀÌ»óÀ» ¿ä±¸ÇÑ´Ù. ÀÌ ¹®¼­°¡ ¸®´ª½º ¸Ó½ÅÀ» ÀüüÀûÀ¸·Î ¼³Á¤ÇÏ´Â ¹æ¹ý¿¡ ´ëÇÑ ÀÔ¹®¼­(primer)´Â ¾Æ´Ï´Ù. ÀÌ ÇÏ¿ìÅõ ¹®¼­´Â ´ç½ÅÀÌ ¾Æ·¡ÀÇ ³»¿ëµé¿¡ ´ëÇؼ­ ¾î´ÀÁ¤µµ ÀÌÇظ¦ ÇÏ°í ÀÖ´Ù´Â °¡Á¤ÇÏ¿¡ ÀÌ·ç¾îÁø °ÍÀÌ´Ù:(ÇÑ±Û ÀÚ·á´Â ¿øº»¿¡ ¾ø´Â °ÍÀÔ´Ï´Ù. ´ç¿¬ÇÏÁÒ?-¿ªÀÚÁÖ) o ¸®´ª½º Ä¿³Î ÄÄÆÄÀÏ°ú IP ¾Ù¸®¾î½Ì(aliasing) Áö¿ø IP Alias mini-HOWTO ¸®´ª½º¿¡¼­ IP Aliasing ¼¼ÆÃÇϱâ mini-HOWTO o ³×Æ®¿öÅ© ÀåºñÀÇ ¼³Á¤ NET-3 HOWTO o inetd ¼³Á¤ NET-3 HOWTO o ¾Æ·¡¿Í °°Àº ¿©·¯°¡Áö ³×Æ®¿þÅ© ÆÐÅ°Áö »÷µå¸ÞÀÏ(Sendmail) Çѱ۰ú »÷µå¸ÞÀÏ ¾ÆÆÄÄ¡(Apache) ¾ÆÆÄÄ¡(Apache)-ÇѱۻçÀÌÆ® Qmail »ï¹Ù(SAMBA) o DNS ¼³Á¤ DNS HOWTO DNS °ü·Ã¹®¼­ o ±âÃÊÀûÀÎ ½Ã½ºÅÛ °ü¸®¿¡ ´ëÇÑ ÀÌÇØ Linux Systems Administrators's Guide KLDPÀÇ ½Ã½ºÅÛ °ü¸® ÆäÀÌÁö o À¥¼­¹ö ¼³Á¤¿¡ ´ëÇÑ ÀÌÇØ WWW ÇÏ¿ìÅõ ¸¸¾à ´ç½ÅÀÌ À§ÀÇ ¾î¶² °Í¿¡ ´ëÇØ È®½ÅÀÌ ¾ø´Ù¸é, ¸µÅ©¸¦ ÂѾư¡¼­ ³»¿ëÀ» ¸ÕÀú È®½ÇÇÏ°Ô ÀÌÇØÇϱ⠹ٶõ´Ù. À§ÀÇ »çÇ׿¡ ´ëÇؼ­´Â ³­ ¸ÞÀÏ¿¡ ´ëÇØ °áÄÚ ´äÀåÀ» º¸³»Áö ¾ÊÀ» °ÍÀÌ´Ù. °ü·ÃµÈ HOWTOÀÇ ÀúÀÚ¿¡°Ô Á÷Á¢ Áú¹®À» ÇÏ´Â °ÍÀÌ ÁÁÀ» °ÍÀÌ´Ù. 1.2. ¸ñÀû °¡»ó(virtual) ¼­ºñ½ºÀÇ ¸ñÀûÀº ÇϳªÀÇ ¸Ó½Å¿¡ ¿©·¯°³ÀÇ ³×Æ®¿öÅ© Ä«µå ¾øÀ̵µ ¿©·¯°³ÀÇ IP ÁÖ¼Ò¸¦ ÀνÄÇϵµ·Ï ÇÏ´Â µ¥ ÀÖ´Ù. IP ¾Ù¸®¾î½Ì(aliasing)Àº ¿©·¯°³ÀÇ ³×Æ®¿öÅ© Ä«µå°¡ ÀÖÀ» ¶§ °¢°¢ÀÇ Àåºñ¿¡¼­ Çϳª ÀÌ»óÀÇ IP ÁÖ¼Ò¸¦ Çã¿ëÇÏ´Â Ä¿³Î ¿É¼ÇÀÌ´Ù. ÀÌ ¶§ Ä¿³ÎÀº µÚ¿¡¼­ ´ÙÁßÀÇ Á¤º¸±³È¯ÀÌ ÀÌ·ç¾îÁö°í(ÀÌ°ÍÀº ¸Å¿ì ºü¸£°Ô ÀÌ·ç¾îÁø´Ù) »ç¿ëÀÚ´Â ¸¶Ä¡ Çϳª ÀÌ»óÀÇ ¼­¹ö¸¦ °¡Áö°í ÀÖ´Â °Íó·³ ÀνÄÇÏ°Ô µÈ´Ù. ÀÌ·± ´ÙÁß Á¤º¸±³È¯(multiplexing)Àº ÇϳªÀÇ µµ¸ÞÀÎÀ» È£½ºÆÃÇÏ´Â °Í°ú °°Àº ºñ¿ëÀ¸·Î ¿©·¯°³ÀÇ µµ¸ÞÀÎ(www.domain1.com www.domain2.com µî)À» È£½ºÆÃÇÒ ¼ö ÀÖ´Ù. ºÒÇàÇÏ°Ôµµ ´ëºÎºÐÀÇ ¼­ºñ½º(FTP, web, mail)´Â ´ÙÁß µµ¸ÞÀÎÀ» ´Ù·ê ¼ö ÀÖµµ·Ï ¼³°èµÇ¾îÀÖÁö ¾Ê´Ù. À̵éÀ» Àû´çÇÏ°Ô ÀÛµ¿½ÃÅ°±â À§Çؼ­´Â ¼³Á¤ »Ó¸¸ ¾Æ´Ï¶ó ¼Ò½º Äڵ嵵 º¯Çü½ÃÄÑ¾ß ÇÑ´Ù. ÀÌ ¹®¼­´Â ¾î¶»°Ô ÀÌ·± º¯ÇüÀ» ½ÃÄѼ­ °¡»ó ¸Ó½ÅÀ» ¼³Á¤ÇÒ °ÍÀÎÁö¿¡ ´ëÇØ ±â¼úÇÑ´Ù. °¡»ó ¼­ºñ½º ±â´ÉÀ» À§Çؼ­´Â µ¥¸ó ¿ª½Ã ÇÊ¿äÇÏ´Ù. ÀÌ µ¥¸ó(virtuald) ¿ª½Ã ÀÌ ¹®¼­ÀÇ ÈĹݿ¡¼­ ´Ù·ê °ÍÀÌ´Ù. 1.3. Çǵå¹é(Feedback) ÀÌ ¹®¼­´Â ÆÐÅ°ÁöµéÀÌ ¾÷µ¥ÀÌÆ®µÇ°í ¼Ò½ºÄڵ峪 ¼³Á¤ ³»¿ëµéÀÌ º¯°æµÉ ¶§¸¶´Ù È®ÀåµÉ °ÍÀÌ´Ù. ¸¸¾à ÀÌ ¹®¼­ÀÇ Æ¯Á¤ºÎºÐÀÌ ºÒºÐ¸íÇÏ´Ù°í »ý°¢µÇ¸é °Å¸®³¦¾øÀÌ ³ª¿¡°Ô ´ç½ÅÀÇ Á¦¾ÈÀ̳ª Áú¹®À» email·Î º¸³»¶ó. ³»°¡ ÀÌ ÇÏ¿ìÅõ ¹®¼­ÀÇ ¸ðµç ºÎºÐÀ» µÚÁöÁö ¾Êµµ·Ï °¡±ÞÀûÀ̸é ƯÁ¤ÇÑ(specific) ºÎºÐÀ» Áý¾î¼­ È®½ÇÇÏ°Ô ÇØÁÖ°í, ºÒºÐ¸íÇÑ ºÎºÐÀÌ À§Ä¡ÇÑ ¼½¼ÇÀ» °°ÀÌ Ç¥½ÃÇØ Áֱ⠹ٶõ´Ù. ¶ÇÇϳª Áß¿äÇÑ Á¡Àº Á¦¸ñ¿¡ VIRTSERVICES HOWTO¶ó´Â ¹®ÀåÀ» ³Ö¾î ¸ÞÀÏÀ» º¸³»¶ó´Â Á¡ÀÌ´Ù. ±×·¸Áö ¾ÊÀº ´Ù¸¥ ¸ÞÀϵéÀº °³ÀÎÀûÀÎ ¸ÞÀÏ·Î Ãë±ÞµÉ °ÍÀ̱⠶§¹®¿¡ ¹«½ÃµÉ ¼öµµ ÀÖ´Ù. (³» Ä£±¸µé ¿ª½Ã ³»°¡ °³ÀÎÀûÀÎ ¸ÞÀÏÀ» ´Ù ÀÐÁö ¾Ê´Â´Ù´Â »ç½ÇÀ» ¾Ë°í ÀÖ´Ù.) ³ªÀÇ ¿¹Á¦µéÀº ´ÜÁö ¿¹Á¦ÀÏ »ÓÀ̹ǷΠ±×´ë·Î º¹»çÇؼ­ »ç¿ëÇÏÁö´Â ¸»±â ¹Ù¶õ´Ù. ´ç½ÅÀÌ ÀÌ ¿¹Á¦¸¦ »ç¿ëÇÏ°íÀÚ ÇÑ´Ù¸é, ´ç½Å ½Ã½ºÅÛ¿¡ ¸Â´Â °ªÀ» ³Ö¾î¾ß ÇÒ °ÍÀÌ´Ù. ¸¸¾à ¾î¶² ¹®Á¦°¡ »ý±ä´Ù¸é ³ª¿¡°Ô ¸ÞÀÏÀ» º¸³»¶ó. ¼³Ä¡¿¡ »ç¿ëÇÑ ¼³Á¤ ÆÄÀÏ°ú ¼³Ä¡¿¡ ¹ß»ýÇÑ ¿¡·¯ ¸Þ¼¼ÁöµéÀ» ¸ðµÎ ³ª¿¡°Ô º¸³»ÁØ´Ù¸é ³»°¡ ±×°ÍÀ» º» µÚ ³ªÀÇ ÀÇ°ßÀ» ´äÀå¿¡ ½á¼­ º¸³»ÁÙ °ÍÀÌ´Ù. 1.4. °»½Å ±â·Ï (Revision History) V1.0 ÃÖÃÊÀÇ ¹öÀü V1.1 ¹öÃß¾ó À¥ ¼³Á¤ ºÎºÐÀÇ ¿¡·¯ ¼öÁ¤ V1.2 ³¯Â¥ ¼öÁ¤ V2.0 HTML ¸µÅ© °»½Å À¥ °»½Å »õ·Î¿î ¼¾µå¸ÞÀÏ ¿É¼Ç »õ·Î¿î Qmail ¼½¼Ç Syslogd °»½Å FTP °»½Å Virtuald ±âº» ¿É¼Ç »õ·Î¿î »ï¹Ù(SAMBA) ¼½¼Ç FAQ °»½Å V2.1 ¸ðµç Æнº(path)¸¦ /usr/local·Î ¼öÁ¤ Changed all paths to /usr/local. VirtualdÀÇ VERBOSELOG ÄÄÆÄÀÏ ¿É¼Ç Ãß°¡ VirtualmailfilterÀÇ setuid/setgid ¹ö±× ¼öÁ¤ VirtualmailfilterÀÇ excel ¹ö±× ¼öÁ¤ VirtualmailfilterÀÇ ´ë¼Ò¹®ÀÚ ¹ö±× ¼öÁ¤. VirtualmailfilterÀÇ È¯°æ º¯¼ö È®ÀÎ ¼öÁ¤ Virtualmailfilter/virtmaildelivery¿¡¼­ mbox ÄÚµå Á¦°Å Qmail¿¡¼­ tcpserver.init pop ¼½¼Ç Ãß°¡ FAQ¿¡ ¾Ù¸®¾î½º µµ¸ÞÀγ×ÀÓ Áú¹® Ãß°¡ Virtmailfilter°¡ Ȩ µð·ºÅ丮¸¦ virtmaildelivery·Î º¸³»´Â ºÎºÐ ¼öÁ¤ 1.5. ÀúÀÛ±Ç/¹èÆ÷ ÀÌ ¹®¼­ÀÇ ÀúÀÛ±ÇÀº Copyright (c) 1997 by The Computer Resource Center Inc. ¿¡ ÀÖ´Ù. ÀÌ ¹®¼­ÀÇ º¹»çº»Àº ÀúÀÚÀÇ µ¿ÀÇ ¾øÀÌ ¾î¶² ¸Åü(¹°¸®Àû, ÀüÀÚÀû)¸¦ ÅëÇؼ­µµ ¹èÆ÷ ¹× Àç»ý»êÀÌ °¡´ÉÇÏ´Ù. ¹ø¿ª ¿ª½Ã ºñ½ÁÇÏ°Ô Çã¿ëµÇ´Âµ¥, ´Ù¸¸ ¹ø¿ªÀÚ¸¦ ¹®¼­¿¡ ¸í½ÃÇÑ´Ù´Â °ÍÀ» °¡Á¤ÇÑ´Ù. »ó¾÷ÀûÀÎ Àç¹èÆ÷ ¿ª½Ã Çã¿ëµÇ¸ç Àå·ÁµÇÁö¸¸ ÀÌ·± Á¾·ùÀÇ ¹èÆ÷¿¡ ´ëÇؼ­´Â Computer Resource Center ¿¡°Ô ¾Ë·ÁÁֱ⠹ٶõ´Ù. ÀÌ ¹®¼­ÀÇ ¹ßÃé ¿ª½Ã »çÀü µ¿ÀÇ ¾øÀÌ ÀÌ·ç¾îÁú ¼ö ÀÖ´Ù. ÀÌ ¹®¼­ÀÇ º¹»çº» Á¦ÀÛ ¹× ¹èÆ÷´Â ÀúÀ۱ǿ¡ ´ëÇÑ ¸í½Ã¿Í Çã°¡¿¡ ´ëÇÑ ÀÌ ±Ç°í°¡ ¸ðµç ¹èÆ÷º»¿¡ Æ÷Ç﵃ ¶§¿¡¸¸ ÀÎÁ¤µÈ´Ù. ¿ä¾àÇϸé, ¿ì¸®´Â °¡´ÉÇÑ ¸¹Àº °æ·Î¸¦ ÅëÇؼ­ ÀÌ ¹®¼­°¡ ³Î¸® ÆÛÁö±â¸¦ ¹Ù¶õ´Ù. ÇÏÁö¸¸, ¿ì¸®´Â ¶ÇÇÑ ÀÌ ¹®¼­ÀÇ ÀúÀÛ±Ç ¿ª½Ã °è¼Ó °®°íÀֱ⸦ ¿øÇϹǷÎ, ÀÌ ¹®¼­ÀÇ Àç¹èÆ÷¿¡ ´ëÇÑ °ÍÀ» ¾Ë±â¸¦ ¹Ù¶õ´Ù. 2. IP ¾Ù¸®¾î½Ì(IP Aliasing) IP ¾Ù¸®¾î½ÌÀº °¡»ó È£½ºÆà ¸Ó½ÅÀ» ½ÇÇà½ÃÅ°±â À§ÇÑ ¼³Á¤À¸·Î ÇÊ¿äÇÑ Ä¿³Î ¿É¼ÇÀÌ´Ù. ÀÌ¹Ì ÀÌ°Í¿¡ ´ëÇÑ ¹Ì´Ï-ÇÏ¿ìÅõ°¡ ³ª¿ÍÀÖ´Ù. IP aliasing ¸®´ª½º¿¡¼­ IP Aliasing ¼¼ÆÃÇϱâ mini-HOWTO ÀÌ°ÍÀ» ¾î¶»°Ô ¼³Á¤ÇÏ´ÂÁö ¾Ë°í ½Í´Ù¸é ÀÌ ¹®¼­¸¦ Âü°íÇ϶ó. 3. Virtuald 3.1. ¼Ò°³ ¸ðµç ³×Æ®¿öÅ© ¿¬°áÀº 2°³ÀÇ IP ¾îµå·¹½º/Æ÷Æ® ½ÖÀ¸·Î ÀÌ·ç¾îÁø´Ù. ³×Æ®¿öÅ© ÇÁ·Î±×·¡¹ÖÀ» À§ÇÑ API(Applications Program Interface)´Â ¼ÒÄÏ API·Î ºÒ¸°´Ù. ¼ÒÄÏÀº ¸¶Ä¡ ¿­·ÁÀÖ´Â ÆÄÀÏ°ú °°ÀÌ ÀÛµ¿Çϱ⠶§¹®¿¡ ³×Æ®¿öÅ© ¿¬°áÀ» ÅëÇØ µ¥ÀÌÅ͸¦ ÁÖ°í¹Þ´Â °ÍÀº ¼ÒÄÏ¿¡ ¾²°íÀд °úÁ¤À¸·Î ÀÌÇصȴÙ. ·ÎÄà ¼ÒÄÏÀÇ ÁÖ¼Ò¸¦ µ¹·ÁÁÖ´Â ÇÔ¼ö´Â getsocknameÀÌ´Ù. Virtuald´Â getsocknameÀ» »ç¿ëÇÏ¿© ·ÎÄà ½Ã½ºÅÛÀÇ ¾î¶² IP°¡ Á¢±Ù °¡´ÉÇÑÁö¸¦ ÆÇ´ÜÇÑ´Ù. Virtuald´Â ¼³Á¤ ÆÄÀÏÀ» Àо ÇØ´ç IP¿¡ ÇÒ´çµÈ µð·ºÅ丮¸¦ µ¹·Á¹Þ´Â´Ù. ±×¸®°í´Â chroot¸¦ ÅëÇؼ­ ¸ðµç ¼­ºñ½º¿¡ ´ëÇÑ Á¦¾î±ÇÀ» ³Ñ°ÜÁØ´Ù. ChrootÀº ·çÆ® µð·ºÅ丮¸¦ Àç¼³Á¤ÇÏ¿© »õ·Ó°Ô ÁöÁ¤¹ÞÀº Æ÷ÀÎÆ®¸¦ ·çÆ®·Î ¼³Á¤Çϱ⠶§¹®¿¡ »óÀ§ µð·ºÅ丮´Â ½ÇÇà ÇÁ·Î±×·¥µé¿¡ ÀÇÇØ ¹«½ÃµÈ´Ù. ³×Æ®¿öÅ© ÇÁ·Î±×·¥¿¡ ´ëÇؼ­´Â ÀÌ °úÁ¤Àº ¸¶Ä¡ ¾Æ¹«Àϵµ ÀϾÁö ¾ÊÀº °Íó·³ Åõ¸íÇÏ°Ô º¸ÀÏ °ÍÀÌ´Ù. Virtuald´Â inetd¿Í °°Àº ÇÁ·Î±×·¥°ú ¿¬°áµÇ¾î ¾î¶² ¼­ºñ½º¶óµµ °¡»óÀûÀ¸·Î ¸¸µé ¼ö ÀÖ´Ù. 3.2. Inetd Inetd´Â ¿ÜºÎ¿¡¼­ ³×Æ®¿öÅ©¸¦ ÅëÇØ ¿¬°áÀ» ½ÃµµÇÒ ¶§(¿¹¸¦ µé¸é POP¼­¹öÀÇ ¿äû) ¿©·¯ °³ÀÇ Æ÷Æ®¸¦ °¨½ÃÇÏ°í ÀÖ´Ù°¡ ¿äû¿¡ ´ëÇÑ Àû´çÇÑ ¿¬°áÀ» ±¸ÇöÇØÁÖ´Â ³×Æ®¿öÅ© super serverÀÌ´Ù. Inetd´Â ³×Æ®¿öÅ©¸¦ Àü¹ÝÀûÀ¸·Î °ü¸®Çϸ鼭 ƯÁ¤ ÇÁ·Î±×·¥¿¡ ´ëÇØ ³×Æ®¿öÅ©¸¦ ¿¬°áÇØ ÁÖ´Â ÀÏÀ» ÇÑ´Ù. ÀÌ·± °úÁ¤À» ÅëÇØ ¾î¶² ¼­ºñ½º°¡ ³×Æ®¿öÅ© ¿¬°áÀÌ ÇÊ¿ä ¾øÀ» ¶§ ºÒÇÊ¿äÇÏ°Ô ½ÇÇàµÇ´Â °ÍÀ» ¸·À» ¼ö ÀÖ´Ù. Ç¥ÁØÀûÀÎ /etc/inetd.conf ÆÄÀÏÀº ´ÙÀ½°ú °°´Ù: ftp stream tcp nowait root /usr/sbin/tcpd \ wu.ftpd -l -a pop-3 stream tcp nowait root /usr/sbin/tcpd \ in.qpop -s °¡»ó ¼­ºñ½º¸¦ ÇÒ ¶§ /etc/inetd.conf ÆÄÀÏÀº ´ÙÀ½°ú °°ÀÌ µÈ´Ù: ftp stream tcp nowait root /usr/local/bin/virtuald \ virtuald /virtual/conf.ftp wu.ftpd -l -a pop-3 stream tcp nowait root /usr/local/bin/virtuald \ virtuald /virtual/conf.pop in.qpop -s 3.3. ¼³Á¤ ÆÄÀÏ °¢°¢ÀÇ ¼­ºñ½ºµéÀº ¾î¶² IPµé°ú µð·ºÅ丮µéÀ» »ç¿ëÇÏ°í °ü¸®ÇÒ °ÍÀÎÁö¿¡ ´ëÇÑ Á¤º¸¸¦ ¼³Á¤ ÆÄÀÏ¿¡¼­ ¾ò°Ô µÈ´Ù. ´ç½ÅÀº ÇϳªÀÇ Àüü ¼³Á¤ ÆÄÀÏ (master config file)À» °®´øÁö ¾Æ´Ï¸é ¸î¸îÀÇ ¼³Á¤ ÆÄÀϵéÀ» ÅëÇؼ­ °¢°¢ÀÇ ¼­ºñ½º¿¡¼­ µµ¸ÞÀÎÀÇ ´Ù¸¥ ¸®½ºÆ®¸¦ ¾ò°Ô ÇÒ ¼ö ÀÖ´Ù. ¼³Á¤ ÆÄÀÏÀº ´ÙÀ½°ú °°´Ù: # This is a comment and so are blank lines # Format IP SPACE dir NOSPACES 10.10.10.129 /virtual/domain1.com 10.10.10.130 /virtual/domain2.com 10.10.10.157 /virtual/domain3.com # Default option for all other IPs default / 3.4. ¼Ò½ºÄÚµå ¾Æ·¡´Â virtuald ÇÁ·Î±×·¥¿¡ ´ëÇÑ C ¼Ò½º ÄÚµåÀÌ´Ù. ÀÌ°ÍÀ» ÄÄÆÄÀÏÇÏ°í /usr/local/bin ¾Æ·¡¿¡ 0755ÀÇ Æ۹̼ÇÀ¸·Î ¼³Ä¡Ç϶ó.(¼ÒÀ¯ÀÚ¿Í ±×·ìÀº ¸ðµÎ root·Î ÇÑ´Ù.) ÄÄÆÄÀϽÿ¡´Â VERBOSELOG°¡ ¿É¼ÇÀ¸·Î »ç¿ëµÉ ¼ö Àִµ¥ (¿ÀÁ÷ ÀÌ ¿É¼Ç¸¸ÀÌ Á¸ÀçÇÑ´Ù), ÀÌ°ÍÀº ¿¬°á½Ã ±â·ÏÀ» ³²±æ°ÍÀÎÁö¸¦ Á¤ÇÑ´Ù. #include #include #include #include #include #include #include #include #undef VERBOSELOG #define BUFSIZE 8192 int getipaddr(char **ipaddr) { struct sockaddr_in virtual_addr; static char ipaddrbuf[BUFSIZE]; int virtual_len; char *ipptr; virtual_len=sizeof(virtual_addr); if (getsockname(0,(struct sockaddr *)&virtual_addr,&virtual_len)<0) { syslog(LOG_ERR,"getipaddr: getsockname failed: %m"); return -1; } if (!(ipptr=inet_ntoa(virtual_addr.sin_addr))) { syslog(LOG_ERR,"getipaddr: inet_ntoa failed: %m"); return -1; } strncpy(ipaddrbuf,ipptr,sizeof(ipaddrbuf)-1); *ipaddr=ipaddrbuf; return 0; } int iptodir(char **dir,char *ipaddr,char *filename) { char buffer[BUFSIZE],*bufptr; static char dirbuf[BUFSIZE]; FILE *fp; if (!(fp=fopen(filename,"r"))) { syslog(LOG_ERR,"iptodir: fopen failed: %m"); return -1; } *dir=NULL; while(fgets(buffer,BUFSIZE,fp)) { buffer[strlen(buffer)-1]=0; if (*buffer=='#' || *buffer==0) continue; if (!(bufptr=strchr(buffer,' '))) { syslog(LOG_ERR,"iptodir: strchr failed"); return -1; } *bufptr++=0; if (!strcmp(buffer,ipaddr)) { strncpy(dirbuf,bufptr,sizeof(dirbuf)-1); *dir=dirbuf; break; } if (!strcmp(buffer,"default")) { strncpy(dirbuf,bufptr,sizeof(dirbuf)-1); *dir=dirbuf; break; } } if (fclose(fp)==EOF) { syslog(LOG_ERR,"iptodir: fclose failed: %m"); return -1; } if (!*dir) { syslog(LOG_ERR,"iptodir: ip not found in conf file"); return -1; } return 0; } int main(int argc,char **argv) { char *ipaddr,*dir; openlog("virtuald",LOG_PID,LOG_DAEMON); #ifdef VERBOSELOG syslog(LOG_ERR,"Virtuald Starting: $Revision: 1.49 $"); #endif if (!argv[1]) { syslog(LOG_ERR,"invalid arguments: no conf file"); exit(0); } if (!argv[2]) { syslog(LOG_ERR,"invalid arguments: no program to run"); exit(0); } if (getipaddr(&ipaddr)) { syslog(LOG_ERR,"getipaddr failed"); exit(0); } #ifdef VERBOSELOG syslog(LOG_ERR,"Incoming ip: %s",ipaddr); #endif if (iptodir(&dir,ipaddr,argv[1])) { syslog(LOG_ERR,"iptodir failed"); exit(0); } if (chroot(dir)<0) { syslog(LOG_ERR,"chroot failed: %m"); exit(0); } #ifdef VERBOSELOG syslog(LOG_ERR,"Chroot dir: %s",dir); #endif if (chdir("/")<0) { syslog(LOG_ERR,"chdir failed: %m"); exit(0); } if (execvp(argv[2],argv+2)<0) { syslog(LOG_ERR,"execvp failed: %m"); exit(0); } closelog(); exit(0); } 4. ¼Ð ½ºÅ©¸³Æ® 4.1. Virtfs °¢°¢ÀÇ µµ¸ÞÀÎÀº ÀڽŸ¸ÀÇ µð·ºÅ丮 ±¸Á¶¸¦ °¡Áø´Ù. µû¶ó¼­ ¸¸¾à 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 4.2. Virtexec °¡»ó ȯ°æ¿¡¼­ ¸í·É¾î¸¦ ½ÇÇà½ÃÅ°±â À§Çؼ­ ´ç½ÅÀº 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¸¦ ¸¸µé ¼ö ÀÖ´Ù. ¸¸¾à ´ç½ÅÀÇ ÇÁ·Î±×·¥ÀÌ °øÀ¯ ¶óÀ̺귯¸®¸¦ ÇÊ¿ä·Î ÇÑ´Ù¸é ¹ÙÀ̳ʸ®¿Í ¸¶Âù°¡Áö·Î °¡»ó ÆÄÀϽýºÅÛ¿¡ À§Ä¡½Ãų ¼ö ÀÖ´Ù. 4.3. °ø°í(Note) ³ª´Â ¸ðµç ½ºÅ©¸³Æ®µéÀ» /usr/local/bin¿¡ ¼³Ä¡Çß´Ù. ±× ÀÌ¿Ü¿¡ °¡»ó ÆÄÀϽýºÅÛ¿¡ ³Ö°í½ÍÁö ¾ÊÀº °ÍµéÀº /usr/local¿¡ µÎ¾ú´Ù. ½ºÅ©¸³Æ®´Â /usr/local¿¡ ÀÖ´Â ÆÄÀÏÀ» °¡»ó ÆÄÀϽýºÅÛÀ¸·Î º¹»çÇÏÁö ¾Ê´Â´Ù. °¡»ó ÆÄÀϽýºÅÛÀ¸·Î ³Ñ¾î¿À¸é ¾ÈµÇ´Â Áß¿äÇÑ ÆÄÀϵéÀº ¹Ýµå½Ã °¡»ó ½Ã½ºÅÛ¿¡¼­ Á¦°ÅµÇ¾î¾ß ÇÑ´Ù. ÇÑ ¿¹·Î, ³» ½Ã½ºÅÛ¿¡´Â ssh°¡ ¼³Ä¡µÇ¾î Àִµ¥, ¸ðµç °¡»óÀÇ ÆÄÀÏ ½Ã½ºÅÛÀÇ ¼­¹ö¿¡¼­´Â °³ÀÎÅ°(private key)¸¦ ¿øÇÏÁö ¾Ê±â ¶§¹®¿¡, virtfs¸¦ ½ÇÇà½ÃŲ ÀÌÈÄ¿¡ °¢°¢ÀÇ °¡»ó ÆÄÀÏ ½Ã½ºÅÛ¿¡¼­ ÀÌ°ÍÀ» Á¦°ÅÇß´Ù. ¶ÇÇÑ resolv.conf¸¦ ¹Ù²Ù°í, ±× ¾È¿¡ ÀÖ´ø ´Ù¸¥ µµ¸ÞÀεéÀÇ À̸§À» °¡Áø ¸ðµç °ÍµéÀ» »èÁ¦Çß´Ù. ÀÌ·± °Íµé·Î´Â /etc/hosts³ª /etc/HOSTNAME µîÀÌ ÀÖ´Ù. ³»°¡ virtexec·Î ½Éº¼¸¯ ¸µÅ©½ÃŲ ÇÁ·Î±×·¥µéÀÌ´Ù: o virtpasswd -- »ç¿ëÀÚ ºñ¹Ð¹øÈ£ º¯°æ o virtadduser -- »ç¿ëÀÚ Ãß°¡ o virtdeluser -- »ç¿ëÀÚ »èÁ¦ o virtsmbstatus -- »ï¹Ù(SAMBA) »óÅ º¸±â o virtvi -- ÆÄÀÏ ÆíÁý o virtmailq -- ¸ÞÀÏÅ¥ È®ÀÎ o virtnewaliases -- ¾Ù¸®¾î½º Å×ÀÌºí »õ·Î ±¸Ãà 5. DNS DNS ¿ª½Ã Á¤»óÀûÀ¸·Î ¼³Á¤µÉ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº DNS HOWTO. ¸¦ ÂüÁ¶Ç϶ó. 6. Syslogd 6.1. ¹®Á¦µé Syslogd´Â ÀϹÝÀûÀÎ À¯´Ð½º ½Ã½ºÅÛ¿¡¼­ »ç¿ëµÇ´Â ½Ã½ºÅÛ ±â·Ï µµ±¸ÀÌ´Ù. Syslogd´Â FIFO¶ó ºÒ¸®´Â Ưº°ÇÑ ÆÄÀÏÀ» ¿©´Â µ¥¸óÀε¥, FIFO´Â ÇϳªÀÇ ÆÄÀÌÇÁ¿Í °°ÀÌ ÀÛµ¿Çϴ Ưº°ÇÑ ÆÄÀÏÀÌ´Ù. ¾²´Â ÂÊ¿¡¼­ ±â·ÏÇÑ ³»¿ëÀº ¸ðµÎ Àд ÂÊ¿¡ ³ªÅ¸³ª°Ô µÈ´Ù. Syslogd´Â Àд ÂÊ¿¡¼­ º¸³»´Â µ¥ÀÌÅ͸¦ ±â´Ù¸®°í ÀÖ´Ù. CÀÇ ÇÔ¼ö °¡¿îµ¥¿¡´Â ¾²´Â ÂÊ¿¡ ¹«¾ð°¡¸¦ ±â·ÏÇÒ ¼ö ÀÖ´Â ÇÔ¼ö°¡ Àִµ¥, ÇÁ·Î±×·¥¿¡¼­ ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù¸é, ´ç½ÅÀÇ Ãâ·Â °á°ú´Â syslogd·Î °¡°Ô µÈ´Ù. Chroot¸¦ »ç¿ëÇϴ ȯ°æ¿¡¼­´Â syslogd°¡ (/dev/log)¿¡¼­ ÀоîµéÀÏ FIFO°¡ Á¸ÀçÇÏÁö ¾Ê°Ô µÈ´Ù. ÀÌ°ÍÀº ¸ðµç °¡»ó ȯ°æ¿¡¼­ syslogd·Î µé¾î°¥ ¼ö ¾ø´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. 6.2. Solution 6.2.1. Setup Links Syslogd´Â ¸í·É¾î ¶óÀο¡¼­ ¼³Á¤À» ÇØÁØ´Ù¸é ´Ù¸¥ FIFO¸¦ ãÀ» ¼ö ÀÖ´Ù: syslogd -p /virtual/log ±×¸®°í´Â /virtual/log¸¦ /dev/log·Î ½Éº¼¸µ ¸µÅ©½ÃŲ´Ù: ln -sf /virtual/log /dev/log ±×¸®°í´Â ¸ðµç /dev/logÀÇ º¹»çº»À» ÀÌ ÆÄÀÏ·Î Çϵ帵ũ ½ÃŲ´Ù: ln -f /virtual/log /virtual/domain1.com/dev/log virtfs ½ºÅ©¸³Æ®´Â ÀÌ¹Ì ÀÌ °úÁ¤À» ¼öÇàÇÑ´Ù. /virtualÀÌ µð½ºÅ© °ø°£¿¡ ÀÎÁ¢ÇØ ÀÖ°í /dev/log°¡ Çϵ帵ũµÇ¾î ÀÖ´Â »óÅÂÀ̱⠶§¹®¿¡, À̵éÀº °°Àº inode ¼ýÀÚ¸¦ °¡Áö°í °°Àº µ¥ÀÌÅ͸¦ °¡¸®Å°°í ÀÖ´Ù. ¸ðµç °¡»óÀÇ /dev/log µéÀÌ µ¿½Ã¿¡ ÀÛµ¿ÁßÀ̱⠶§¹®¿¡ chrootµµ ÀÌ°ÍÀ» ¸ØÃâ ¼ö ¾ø´Ù. ¸ðµç ȯ°æ¿¡¼­ºÎÅÍÀÇ ¸ðµç ¸Þ¼¼Áö°¡ ÇϳªÀÇ Àå¼Ò¿¡ ±â·ÏµÈ´Ù´Â »ç½ÇÀ» ±â¾ïÇ϶ó. ÇÏÁö¸¸, ÀÌ µ¥ÀÌÅÍ¿¡¼­ ¿øÇÏ´Â ÀڷḸ °É·¯³»´Â µ¶¸³ÀûÀÎ ÇÁ·Î±×·¥À» ½±°Ô ¸¸µé ¼ö ÀÖÀ» °ÍÀÌ´Ù. 6.2.2. Syslogd.init syslogd.initÀÇ ÀÌ ¹öÀüÀº syslogd°¡ ½ÃÀÛÇÒ ¶§¸¶´Ù /dev/log FIFO¸¦ Áö¿ì°í »õ·Î ¸¸µé±â ¶§¹®¿¡ ¸Å¹ø /dev/log¿¡ Çϵ帵ũ½ÃÄÑ¾ß ÇÑ´Ù. ¿©±â º¯ÇüµÈ syslogd.init ÆÄÀÏÀÌ ÀÖ´Ù: #!/bin/sh . /etc/rc.d/init.d/functions case "$1" in start) echo -n "Starting dev log: " ln -sf /virtual/log /dev/log echo done echo -n "Starting system loggers: " daemon syslogd -p /virtual/log daemon klogd echo echo -n "Starting virtual dev log: " for i in /virtual/* do if [ ! -d "$i" ] then continue fi if [ "$i" = "/virtual/lost+found" ] then continue fi ln -f /virtual/log $i/dev/log echo -n "." done echo " done" touch /var/lock/subsys/syslogd ;; stop) echo -n "Shutting down system loggers: " killproc syslogd killproc klogd echo rm -f /var/lock/subsys/syslogd ;; *) echo "Usage: syslogd {start|stop}" exit 1 esac exit 0 6.3. ¿©·¯°³ÀÇ Syslogd 6.3.1. ÇϳªÀÇ µð½ºÅ©¿¡ ÇÑ°³ÀÇ syslogd ¸¸¾à ´ç½ÅÀÌ ¼³Á¤ÇÑ ÇϳªÀÇ ÆÄÀϽýºÅÛÀÌ ³ÑÃļ­ ´Ù¸¥ µð½ºÅ©¿¡ ÀÖ´Â °ø°£À» °¡»ó ½Ã½ºÅÛ¿¡¼­ »ç¿ëÇÏ°íÀÚ ÇÑ´Ù¸é, ÇÏµå ¸µÅ©¸¦ ÅëÇؼ­ ¼­·Î ´Ù¸¥ µð½ºÅ©¸¦ ¿¬°áÇÒ ¼ö ¾ø´Ù´Â »ç½ÇÀ» ¸í½ÉÇϱ⠹ٶõ´Ù. ÀÌ°ÍÀº ÇÑ µµ¸ÞÀο¡ ´ëÇؼ­µµ ¼­·Î ´Ù¸¥ µð½ºÅ©¿¡¼­´Â °¢°¢ÀÇ syslogd¸¦ ½ÇÇà½ÃÄÑ¾ß ÇÑ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. ÇÑ ¿¹·Î, ¸¸¾à ´ç½ÅÀÌ /virtual1¿¡ 13°³ÀÇ µµ¸ÞÀÎÀ» °¡Áö°í ÀÖ°í, /virtual2¿¡ 15°³ÀÇ µµ¸ÞÀÎÀ» °¡Áö°í ÀÖ´Ù¸é, 13°³ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­´Â /virtual1/log¿¡ ÇÏµå ¸µÅ©¸¦ ½ÃŲ ÈÄ, syslogd -p /virtual1/log ¿Í °°Àº ¹æ¹ýÀ¸·Î °¢°¢ syslogd¸¦ ½ÇÇà½ÃŲ´Ù. ¸¶Âù°¡Áö ¹æ¹ýÀ¸·Î /virtual2¿¡ 15°³ÀÇ ´Ù¸¥ µµ¸ÞÀÎÀ» /virtual2/log¿¡ Çϵ帵ũ ½ÃŲ ÈÄ syslogd -p /virtual2/log ÀÇ ¹æ¹ýÀ¸·Î syslogd¸¦ ½ÇÇà½ÃŲ´Ù. 6.3.2. ÇϳªÀÇ µµ¸ÞÀο¡ ÇϳªÀÇ syslogd ¸¸¾à ´ç½ÅÀÌ ¸ðµç ±â·ÏµéÀ» ÇϳªÀÇ À§Ä¡·Î ÁýÁß½ÃÅ°°í ½ÍÁö ¾Ê´Ù¸é °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ syslogd¸¦ µû·Î ½ÇÇà½Ãų ¼ö ÀÖ´Ù. ÀÌ°ÍÀº ÇÁ·Î¼¼½º ID¸¦ ³¶ºñÇϱ⠶§¹®¿¡ ±ÇÇÏ°í ½ÍÀº ¹æ¹ýÀº ¾Æ´ÏÁö¸¸, ÀÌ°ÍÀ» ±¸ÇöÇÏ´Â °ÍÀº ½¬¿î ÀÏÀÌ´Ù. ´ç½ÅÀº syslogd.init ÆÄÀÏ¿¡¼­ chroot /virtual/domain1.com syslogd·Î °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇØ syslogd¸¦ ½ÇÇà½Ãų ¼ö ÀÖ´Ù. ÀÌ°ÍÀº chroot ¾È¿¡¼­ °¢°¢ÀÇ syslogd¸¦ ½ÇÇà½ÃÅ°¸ç ±× ±â·ÏÀº /var/log°¡ ¾Æ´Ï¶ó /virtual/domain1.com/var/log¿¡ ±â·ÏµÉ °ÍÀÌ´Ù. ¸ÞÀÎ ½Ã½ºÅÛ¿¡¼­ ÀÏ¹Ý syslogd¿Í Ä¿³Î ±â·ÏÀ» À§ÇÑ klogd¸¦ ½ÇÇà½ÃÅ°´Â °ÍÀ» ÀØÁö ¸»¶ó. 7. °¡»ó FTP 7.1. Inetd Wu-ftpd´Â ÀÚüÀûÀ¸·Î °¡»ó ½Ã½ºÅÛ¿¡ ¸Â°Ô ±¸¼ºµÉ ¼ö ÀÖ´Ù. ÇÏÁö¸¸, °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ ºÐ¸®µÈ ºñ¹Ð¹øÈ£ ÆÄÀÏÀ» °ü¸®ÇÒ ¼ö´Â ¾ø´Ù. ¿¹¸¦ µé¸é, bob@domain1.com ¿Í bob@domain2.com ¸¦ ¿øÇÒ ¶§, µÎ µµ¸ÞÀÎÀÇ °èÁ¤ °¡¿îµ¥ ÇϳªÀÇ À̸§À» bob2·Î ¹Ù²Ù´øÁö ±× ÀÌ¿ÜÀÇ ´Ù¸¥ °èÁ¤ À̸§À» »ç¿ëÇØ¾ß ÇÑ´Ù. ÇÏÁö¸¸ ¸¸¾à ´ç½ÅÀÌ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ °¡»óÀÇ ÆÄÀϽýºÅÛÀ» °¡Áö°í ÀÖ´Ù¸é, °¢°¢ÀÇ ºñ¹Ð¹øÈ£ ÆÄÀÏÀ» °¡Áú ¼ö Àֱ⠶§¹®¿¡ ÀÌ·± ¹®Á¦¸¦ ÇØ°áÇÒ ¼ö ÀÖ´Ù. ´ÜÁö virtnewuser ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÏ¿© »ç¿ëÀÚ¸¦ ¸¸µé°í virtpasswd ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇؼ­ ºñ¹Ð¹øÈ£¸¦ ¼³Á¤ÇØ ÁÖ¸é À§¿¡¼­ ¸»ÇÑ »óȲ¿¡ ´ëÇØ ¸ðµç ¼³Á¤À» ³¡³¾ ¼ö ÀÖ´Ù. wu-ftpd¸¦ À§ÇÑ inetd.confÀÇ ¿£Æ®¸®´Â ´ÙÀ½°ú °°´Ù: ftp stream tcp nowait root /usr/local/bin/virtuald \ virtuald /virtual/conf.ftp wu.ftpd -l -a 7.2. À͸íÀÇ FTP(Anonymous FTP) ÀÌ°ÍÀº virtualdÀÇ ¼³Á¤¿¡ ¿µÇâÀ» ¹ÞÁö ¾Ê´Â´Ù. ¿ì¼± /virtuald/domain1.com/etc/passwd ¾È¿¡ ÀϹÝÀûÀÎ °æ¿ì¿Í ¸¶Âù°¡Áö·Î FTP »ç¿ëÀÚ¸¦ »ý¼ºÇÑ´Ù. ftp:x:14:50:Anonymous FTP:/var/ftp:/bin/false ±×¸®°í´Â À͸íÀÇ FTP¸¦ À§ÇÑ µð·ºÅ丮¸¦ ¼³Á¤ÇÑ´Ù. °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ ¼­·Î ´Ù¸¥ ºñ¹Ð¹øÈ£ ÆÄÀÏÀ» °¡Áö°í Àֱ⠶§¹®¿¡ À͸íÀÇ FTP¸¦ Á¦°øÇÒ µµ¸ÞÀÎÀ» ¼±ÅÃÇÒ ¼ö ÀÖ´Ù. FTP ¼­¹ö´Â ÀÌ¹Ì chroot¿¡ ÀÇÇØ /virtual/domain1.com µð·ºÅ丮¿¡ ¼³Á¤µÇ¾î Àֱ⠶§¹®¿¡ ¾î¶² Ãß°¡°æ·Îµµ ¾Õ¿¡ ¼³Á¤ÇÒ ÇÊ¿ä´Â ¾ø´Ù. 7.3. °¡»óÀÇ FTP »ç¿ëÀÚµé Wu-ftpd´Â ¹æ¹®ÀÚ ±×·ì(guest group)À̶ó´Â °ÍÀ» Áö¿øÇÑ´Ù. ÀÌ°ÍÀ» ÀÌ¿ëÇÏ¸é °¢°¢ÀÇ »ç¿ëÀڵ鿡 ´ëÇؼ­ ´Ù¸¥ FTP °ø°£À» ¸¸µé ¼ö ÀÖ´Ù. ¶ÇÇÑ FTP ¼­¹ö´Â ƯÁ¤ °ø°£¿¡ ´ëÇØ chroot¸¦ ÀÌ¿ëÇؼ­ »ç¿ëÀÚ°¡ Á¤ÇØÁø µð·ºÅ丮 ¹ÛÀ¸·Î ³ª°¥ ¼ö ¾ø°Ô ¸¸µé ¼ö ÀÖ´Ù. ¸¸¾à ´ç½ÅÀÌ °¡»ó µµ¸ÞÀÎ ¾È¿¡ ÀÌ ¹æ¹ýÀ¸·Î »ç¿ëÀÚµéÀ» Ãß°¡ÇÑ´Ù¸é ±× »ç¿ëÀÚµéÀº ½Ã½ºÅÛ ÆÄÀϵéÀ» º¼ ¼ö ¾ø°Ô µÈ´Ù. ¹æ¹®ÀÚ ±×·ìÀº /virtual/domain1.com/etc/ftpaccess ÆÄÀÏ¿¡ Ãß°¡µÈ´Ù. /virtual/domain1.com/etc/passwd ¾È¿¡ ¿£Æ®¸®¸¦ ¸¸µé°í ½ÃÀÛÇϴ Ȩ µð·ºÅ丮´Â chroot µð·ºÅ丮¿Í /./·Î ºÐ¸®ÇÑ´Ù. guest1:x:8500:51:Guest FTP:/home/g/guest1/./incoming:/bin/false ±× ´ÙÀ½¿¡´Â ¹æ¹®ÀÚÀÇ È¨À» À͸íÀÇ FTP¸¦ ¼³Á¤ÇÏ´ø ¶§¿Í ¸¶Âù°¡Áö·Î ¼³Á¤ÇØ ÁØ´Ù. °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ ºñ¹Ð¹øÈ£ ÆÄÀÏÀ» µû·Î °ü¸®Çϱ⠶§¹®¿¡ ¾î¶² µµ¸ÞÀο¡ ¹æ¹®ÀÚ °èÁ¤ÀÌ Á¸ÀçÇÏ´ÂÁö, ±×¸®°í °¢ µµ¸ÞÀÎÀÇ ¾î¶² »ç¿ëÀÚµéÀÌ ¹æ¹®ÀÚ ±×·ìÀ¸·Î ¼³Á¤µÇ¾î ÀÖ´ÂÁö¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù. ´Ù½Ã Çѹø °­Á¶Çϴµ¥, ÀÌ¹Ì chroot¿¡ ÀÇÇؼ­ FTP ¼­¹ö°¡ /virtual/domain1.com µð·ºÅ丮·Î ¼³Á¤µÇ¾î Àֱ⠶§¹®¿¡ °æ·Î¾Õ¿¡ ¾î¶² Ãß°¡ÀûÀÎ Á¤º¸¸¦ ÁÙ ÇÊ¿ä´Â ¾ø´Ù. 8. °¡»óÀÇ À¥ 8.1. Virtuald¿Í ½ÇÇàÇϱâ 8.1.1. ±ÇÇÏÁö ¾ÊÀ½!(Not recommended) ¾ÆÆÄÄ¡´Â ±âº»ÀûÀ¸·Î °¡»óÀÇ µµ¸ÞÀÎÀ» À§ÇÑ Áö¿øÀ» ÇØÁØ´Ù. ¾ÆÆÄÄ¡´Â ³»°¡ ³»ºÎÀÇ °¡»ó µµ¸ÞÀÎ ±âÀÛÀ» »ç¿ëÇÏ´Â °ÍÀ» ±ÇÇÏ´Â À¯ÀÏÇÑ ÇÁ·Î±×·¥ÀÌ´Ù. inetd¸¦ ÅëÇؼ­ ¾î¶² ÇÁ·Î±×·¥ÀÌ ½ÇÇàµÇ´Â °ÍÀº ¸¹Àº ´ë°¡¸¦ ÇÊ¿ä·Î Çϸç, ÇÁ·Î±×·¥ÀÌ ½ÃÀÛÇϱâ À§Çؼ­´Â Ç×»ó inetd°¡ ½ÃÀ۵Ǿî¾ß ÇÑ´Ù´Â ´ÜÁ¡ÀÌ ÀÖ´Ù. ÀÌ·± °á°ú·Î ¹ÝÀÀ ½Ã°£ÀÌ ´À·ÁÁú °ÍÀε¥, ´Ù¸¥ ³×Æ®¿öÅ© ¼­ºñ½º¿¡¼­´Â ÀÌ·± ´À·ÁÁüÀÌ °ßµô¸¸ ÇÏÁö¸¸ À¥ ¼­ºñ½º¿¡¼­´Â ±×·¸Áö ¾ÊÀ» °ÍÀÌ´Ù. ¾ÆÆÄÄ¡´Â ¶ÇÇÑ ³Ê¹« ¸¹Àº ¿äûÀÌ µé¾î¿À´Â °æ¿ì Á¦¾î¸¦ ÇÒ ¼ö ÀÖ´Â ±â´ÉÀ» °¡Áö°í Àִµ¥, ÀÌ ±â´ÉÀº Å©Áö ¾ÊÀº ±Ô¸ðÀÇ »çÀÌÆ®¿¡¼­µµ Áß¿äÇÑ ¹®Á¦°¡ µÉ ¼ö ÀÖ´Ù. °£´ÜÈ÷ ¸»Çϸé, ¾ÆÆÄÄ¡ ¼­¹ö¸¦ virtuald¿Í ÇÔ²² »ç¿ëÇÏ¿© °¡»ó ½Ã½ºÅÛÀ» ±¸ÃàÇÏ´Â °ÍÀº Á¤¸» ¾ÈÁÁÀº »ý°¢ÀÌ´Ù. virtuald°¡ ÁöÇâÇÏ´Â °ÍÀº Á¦°øÇÏ°íÀÚ ÇÏ´Â ¼­ºñ½º°¡ ³»ºÎ¿¡¼­ °¡»ó °ø°£¿¡ ´ëÇÑ ¸¸Á·½º·¯¿î Áö¿øÀ» ÇÏÁö ¾ÊÀ» °æ¿ì¿¡ ºÎÁ·ÇÑ ºÎºÐÀ» ä¿ì´Â ÀÏÀÌ´Ù. virtuald°¡ ÀÌ¹Ì ¿Ïº®ÇÏ°Ô °¡»ó ½Ã½ºÅÛÀ» Áö¿øÇÏ´Â ÁÁÀº Äڵ带 ´ëüÇϱâ À§ÇÑ °ÍÀº ¾Æ´Ï´Ù. ¹°·Ð À§ÀÇ Ãæ°íµµ ²À ±×·¸°³ ÇÏ°í ¸»¸®¶ó »ý°¢ÇÏ´Â ¹«¸ðÇÑ »ç¶÷µé¿¡°Ô´Â º° È¿¿ëÀÌ ¾øÀ» °ÍÀÌÁö¸¸. 8.1.2. Inetd /etc/inetd.conf ¸¦ ÆíÁýÇ϶ó. vi /etc/inetd.conf # Add this line www stream tcp nowait www /usr/local/bin/virtuald \ virtuald /virtual/conf.www httpd -f /var/www/conf/httpd.conf 8.1.3. Httpd.conf /var/www/conf/httpd.conf¸¦ ÆíÁýÇ϶ó. vi /var/www/conf/httpd.conf # Or wherever you put the Apache config files It should say: ServerType standalone Replace it with: ServerType inetd 8.1.4. ¼³Á¤ ±×¸®°í´Â ¾ÆÆÄÄ¡ ¼­¹öÀ» ÀϹÝÀûÀ¸·Î ¼³Á¤ÇÏ´Â °úÁ¤À» ¼öÇàÇÑ´Ù. 8.1.5. Httpd.init inetd¸¦ ÅëÇؼ­ ¾ÆÆÄÄ¡°¡ ½ÇÇàµÉ ¶§¿¡´Â httpd.initÀº ÇÊ¿ä¾ø´Ù. 8.2. Apache VirtualHost¿Í °°ÀÌ ½ÇÇàÇϱ⠾ÆÆÄÄ¡´Â ¼¼ °³ÀÇ ¼³Á¤ ÆÄÀÏ - access.conf , httpd.conf , srm.confÀ» °¡Áø´Ù. ¾ÆÆÄÄ¡ÀÇ »õ·Î¿î ¹öÀüÀº ¼³Á¤ ÆÄÀÏÀÌ ¼¼ °³ÀÏ ÇÊ¿ä´Â ¾ø´Ù. ÇÏÁö¸¸, ¼¼ °³ÀÇ ¼³Á¤ÆÄÀÏ·Î ³ª´©¾îÁ® ÀÖ´Â °ÍÀÌ ÈξÀ °ü¸®ÇÏ°í ¼³Á¤ÇϱⰡ ½±´Ù°í »ý°¢µÇ±â ¶§¹®¿¡ ÀÌ ÇÏ¿ìÅõ ¹®¼­¿¡¼­´Â ÀÌ ½ºÅ¸ÀÏÀ» ±âÁØÀ¸·Î ¼³¸íÇÏ°Ú´Ù. 8.2.1. Access.conf ÀÌ ¼³Á¤ÆÄÀÏÀº À¥ µð·ºÅ丮 ±¸Á¶¿¡¼­ Á¢±ÙÀ» ÅëÁ¦Çϴµ¥ »ç¿ëµÈ´Ù. ¿©±â °¢°¢ÀÇ µµ¸ÞÀο¡ ¾î¶»°Ô ¼­·Î ´Ù¸¥ ¿É¼ÇÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´ÂÁö¸¦ º¸¿©ÁÖ´Â ¿¹Á¦ ¼³Á¤ÆÄÀÏÀÌ ÀÖ´Ù. # /var/www/conf/access.conf: Global access configuration # Options are inherited from the parent directory # Set the main directory with default options AllowOverride None Options Indexes # Give one domain a passwd protected directory AuthUserFile /var/www/passwd/domain1.com-priv AuthGroupFile /var/www/passwd/domain1.com-priv-g AuthName PRIVSECTION AuthType Basic require valid-user # Give another domain Server Side Includes Options IncludesNOEXEC 8.2.2. Httpd.conf ÀÌ ¼³Á¤ÆÄÀÏÀº ¾ÆÆÄÄ¡ ¼­¹öÀÇ ÁÖµÈ ¿É¼ÇÀ» °ü¸®ÇÑ´Ù. ¿©±â °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ ¼­·Î ´Ù¸¥ ¿É¼ÇÀ» ¼³Á¤ÇÏ´Â °Í¿¡ ´ëÇÑ ¿¹Á¦ ÆÄÀÏÀÌ ÀÖ´Ù. # /var/www/conf/httpd.conf: Main server configuration file # Begin: main conf section # Needed since not using inetd ServerType standalone # Port to run on Port 80 # Log clients with names vs IP addresses HostnameLookups on # User to run server as User www Group www # Where server config, error and log files are ServerRoot /var/www # Process Id of server in this file PidFile /var/run/httpd.pid # Internal server process info ScoreBoardFile /var/www/logs/apache_status # Timeout and KeepAlive options Timeout 400 KeepAlive 5 KeepAliveTimeout 15 # Number of servers to run MinSpareServers 5 MaxSpareServers 10 StartServers 5 MaxClients 150 MaxRequestsPerChild 30 # End: main conf section # Begin: virtual host section # Tell server to accept requests for ip:port # I have one for each IP needed so you can explicitly ignore certain domains Listen 10.10.10.129:80 Listen 10.10.10.130:80 # VirtualHost directive allows you to specify another virtual # domain on your server. Most Apache options can be specified # within this section. # Mail to this address on errors ServerAdmin webmaster@domain1.com # Where documents are kept in the virtual domain DocumentRoot /virtual/domain1.com/var/www/html # Name of the server ServerName www.domain1.com # Log files Relative to ServerRoot option ErrorLog logs/domain1.com-error_log TransferLog logs/domain1.com-access_log RefererLog logs/domain1.com-referer_log AgentLog logs/domain1.com-agent_log # Use CGI scripts in this domain ScriptAlias /cgi-bin/ /var/www/cgi-bin/domain1.com/ AddHandler cgi-script .cgi AddHandler cgi-script .pl # Mail to this address on errors ServerAdmin webmaster@domain2.com # Where documents are kept in the virtual domain DocumentRoot /virtual/domain2.com/var/www/html # Name of the server ServerName www.domain2.com # Log files Relative to ServerRoot option ErrorLog logs/domain2.com-error_log TransferLog logs/domain2.com-access_log RefererLog logs/domain2.com-referer_log AgentLog logs/domain2.com-agent_log # No CGI's for this host # End: virtual host section 8.2.3. Srm.conf ÀÌ ¼³Á¤ÆÄÀÏÀº ¾î¶² ¿äû¿¡ ´ëÇØ ¼­ºñ½º¸¦ Á¦°øÇÒ °ÍÀÎÁö¿Í ±× Çü½ÄÀÌ ¾î¶»°Ô µÉ °ÍÀÎÁö¿¡ ´ëÇÑ °ÍÀ» Á¶ÀýÇÑ´Ù. °¡»ó µµ¸ÞÀο¡ ´ëÇؼ­ ÀÌ°ÍÀ» ¹Ù²Ü ÇÊ¿ä´Â ¾ø´Ù. ¾ÆÆÄÄ¡¿¡¼­ ±âº»ÀûÀ¸·Î Á¦°øÇÏ´Â ¿¹Á¦ ÆÄÀÏ Çü½Ä ±×´ë·Î °¡»ó ½Ã½ºÅÛ¿¡ Àû¿ëÇصµ ÀÛµ¿ÇÒ °ÍÀÌ´Ù. 8.2.4. Httpd.init httpd.init ÆÄÀÏ¿¡ ´ëÇؼ­ Ưº°È÷ ÇØÁÙ °ÍÀº ¾ø´Ù. ¾ÆÆÄÄ¡ÀÇ Ç¥ÁØÀûÀÎ ¼³Á¤À» ÀÌ¿ëÇ϶ó. 8.3. ÆÄÀÏ ¼­¼úÀÚ ¿À¹öÇ÷οì(File Descriptor Overflow) 8.3.1. °æ°í ÀÌ°ÍÀº ¿ÀÁ÷ µ¶¸³Àû(standalone style)ÀÎ ¾ÆÆÄÄ¡ ¼­¹ö¿¡¸¸ ÇØ´çµÈ´Ù. inetd¸¦ ÅëÇؼ­ ¼­¹ö°¡ ½ÇÇàµÉ ¶§¿¡´Â ´Ù¸¥ µµ¸ÞÀΰú ¿¬°üÀÌ ¾ø±â ¶§¹®¿¡ ¸ðµç ÆÄÀÏ ¼­¼úÀÚ Å×À̺íÀ» °®´Â´Ù. ¾ÆÆÄÄ¡ ¼­¹ö°¡ ¿©´Â ¸ðµç ·Î±× ÆÄÀϵéÀº ÇÁ·Î¼¼½º¿¡ ´ëÇÑ ¶Ç´Ù¸¥ ÆÄÀÏ ¼­¼úÀÚ (file descriptor)°¡ µÈ´Ù. ¸®´ª½º¿¡¼­´Â °¢°¢ÀÇ ÇÁ·Î¼¼½º¿¡ ´ëÇؼ­ 256°³ ±îÁö ÆÄÀÏ ±â¼úÀÚ¸¦ °¡Áú ¼ö ÀÖ´Ù´Â Á¦¾àÀÌ ÀÖ´Ù. Áï ¿©·¯°³ÀÇ µµ¸ÞÀÎÀ» »ç¿ëÇÑ´Ù¸é ±¸¸ÕÄñ ¸¹Àº ÆÄÀÏ ±â¼úÀÚµéÀÌ ÇÊ¿äÇÏ°Ô µÈ´Ù. ¸¸¾à ÇϳªÀÇ ¾ÆÆÄÄ¡ ¼­¹ö ÇÁ·Î¼¼½º¿¡¼­ ³Ê¹« ¸¹Àº µµ¸ÞÀÎÀ» ¼³Á¤ÇÏ°í »ç¿ëÇÑ´Ù¸é ÀÌ Å×À̺íÀÌ ³ÑÃij¯(overflow) ¼öµµ ÀÖ´Ù. ÀÌ°ÍÀº ƯÁ¤ÇÑ ·Î±×°¡ ÀÛµ¿ÇÏÁö ¾ÊÀ» ¼öµµ ÀÖÀ¸¸ç, CGI°¡ ½ÇÆÐÇÒ ¼öµµ ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. 8.3.2. ¿©·¯°³ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö ¸¸¾à ÇÑ µµ¸ÞÀο¡ ´ëÇؼ­ ´Ù¼¸°³ÀÇ ÆÄÀÏ ±â¼úÀÚ¸¦ °¡Áö°í ÀÖ´Ù°í °¡Á¤ÇÏ¸é ´ç½ÅÀº ¾ÆÆÄÄ¡ ¼­¹ö¿¡¼­ 50°³ÀÇ µµ¸ÞÀÎÀ» ¾Æ¹« ¹®Á¦¾øÀÌ ½ÇÇà½Ãų ¼ö ÀÖ´Ù. ÇÏÁö¸¸, ¸¸¾à ÀÌ·± »óȲ¿¡¼­ ¹®Á¦°¡ ¹ß»ýÇÑ´Ù¸é /var/www1¿¡ µµ¸ÞÀÎ1-µµ¸ÞÀÎ25 ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö¸¦ ÇÒ´çÇÏ°í, /var/www2¿¡ µµ¸ÞÀÎ26-µµ¸ÞÀÎ50ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö¸¦ ÇÒ´çÇÏ´Â ¹æ½ÄÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº °¢°¢ÀÇ ¼­¹ö¿¡ ´ëÇØ ÀڽŸ¸ÀÇ ¼³Á¤°ú ¿¡·¯, ·Î±× µð·ºÅ丮¸¦ °®°Ô µÈ´Ù. °¢°¢ÀÇ ¼­¹ö´Â ¶ÇÇÑ ÀڽŸ¸ÀÇ Listen°ú VirtualHost µð·ºÅ丮¸¦ °¡Áö°í ÀÖ¾î¾ß ÇÑ´Ù. httpd.init ÆÄÀÏ¿¡¼­µµ ¿©·¯°³ÀÇ ¼­¹ö¸¦ ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù´Â »ç½ÇÀ» ÀØÁö ¸»¶ó. 8.4. ÇϳªÀÇ IP¿¡¼­ ¼­¹ö °øÀ¯ 8.4.1. IP Àý¾àÇϱâ HTTP(HyperText Transfer Protocol) ¹öÀü 1.1¿¡´Â ¼­¹öÀÇ À̸§À» Ŭ¶óÀ̾ðÆ®¿¡ ¾Ë¸®´Â ±â´ÉÀÌ Ãß°¡µÇ¾ú´Ù. ÀÌ°ÍÀº Ŭ¶óÀ̾ðÆ®°¡ ¼­¹ö¸¦ ãÀ» ¶§ IP ¾îµå·¹½º·Î ºÎÅÍ Ã£À» ÇÊ¿ä°¡ ¾ø´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. µû¶ó¼­ µÎ°³ÀÇ °¡»ó ¼­¹ö°¡ °°Àº IP ¾îµå·¹½º¸¦ °¡Áö°í ¼­·Î ´Ù¸¥ À¥ »çÀÌÆ®·Î ²Ù¹Ð ¼ö ÀÖ´Ù. ¾ÆÆÄÄ¡ ¼³Á¤Àº À§¿Í ¶È°°Àºµ¥, ´ÜÁö ¼­·Î ´Ù¸¥ ListenÀ» Áö½ÃÇÒ ÇÊ¿ä°¡ ¾ø´Ù´Â Á¡¸¸ ´Ù¸£´Ù. (µÎ°³ÀÇ µµ¸ÞÀÎÀÌ °°Àº IP¸¦ ¾²±â ¶§¹®¿¡ Listen ¿ª½Ã °°°Ô µÈ´Ù.) 8.4.2. °áÁ¡ ¿ÀÁ÷ ¹®Á¦°¡ µÇ´Â Á¡Àº virtuald°¡ µµ¸ÞÀÎÀ» ±¸ºÐÇϱâ À§Çؼ­ IP ¾îµå·¹½º¸¦ »ç¿ëÇÑ´Ù´Â Á¡ÀÌ´Ù. Áö±Ý ÇöÀçÀÇ virtuald ÇüÅ·δ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇÑ ½ºÇ® µð·ºÅ丮¸¦ chroot·Î ´Ù¸£°Ô ¼³Á¤ÇÒ ¼ö ¾ø´Ù. µû¶ó¼­, ¸ÞÀÏÀº ÇϳªÀÇ IP¿¡ ´ëÇؼ­¸¸ ¹ÝÀÀÇÒ ¼ö Àֱ⠶§¹®¿¡ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ µ¶ÀÚÀûÀÎ ½ºÇ® µð·ºÅ丮¸¦ °®´Â °ÍÀº ºÒ°¡´ÉÇÏ´Ù. IP¸¦ °øÀ¯ÇÏ´Â ¸ðµç À¥ Ŭ¶óÀ̾ðÆ®´Â IPÀÇ ½ºÇ® µð·ºÅ丮 ¿ª½Ã °øÀ¯ÇØ¾ß ÇÑ´Ù. ¶Ç ÀÌ°ÍÀº »ç¿ëÀÚÀ̸§À» º¹»çÇؼ­ »ç¿ëÇÏ´Â °Í¿¡ ´ëÇÑ ¹®Á¦¸¦ ¾ð±ÞÇÏ°Ô ÇÏÁö¸¸, ÀÌÁ¤µµ´Â IP¸¦ °øÀ¯ÇÔ¿¡ À־ ÇÊ¿äÇÑ ´ë°¡ÀÏ °ÍÀÌ´Ù. 8.5. ´õ ¸¹Àº Á¤º¸ ÀÌ ÇÏ¿ìÅõ´Â ´ÜÁö ¾î¶»°Ô °¡»ó ½Ã½ºÅÛÀ» ¾ÆÆÄÄ¡ À¥ ¼­¹ö¿¡¼­ Á¦°øÇÒ ¼ö ÀÖ´ÂÁö¸¸À» º¸¿©ÁÖ°í ÀÖ´Ù. ´ëºÎºÐÀÇ À¥ ¼­¹öµéÀº ºñ½ÁÇÑ ÀÎÅÍÆäÀ̽º¸¦ °®´Â´Ù. °¡»ó À¥ È£½ºÆÿ¡ ´ëÇØ ´õ ¸¹Àº ³»¿ëÀ» ¾Ë°í½Í´Ù¸é WWW HOWTO, ¸¦ Âü°íÇϰųª, ¾ÆÆÄÄ¡¿¡ ´ëÇÑ ¹®¼­µé ( Apache »çÀÌÆ®¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù) ȤÀº ApacheWeek¸¦ ã¾Æº¸¶ó. 9. °¡»ó ¸ÞÀÏ/POP ¼­¹ö 9.1. ¹®Á¦ °¡»ó ¸ÞÀÏÀÇ Áö¿ø¿¡ ´ëÇÑ ¿äûÀº ³¯·Î Áõ°¡ÇÏ°í ÀÖ´Ù. ¼¾µå¸ÞÀÏÀº °¡»ó ¸ÞÀÏ ½Ã½ºÅÛÀ» Áö¿øÇÑ´Ù°í ¸»ÇÑ´Ù. ÇÏÁö¸¸ ±×°ÍÀÌ Áö¿øÇÏ´Â °ÍÀº ¿©·¯ µµ¸ÞÀο¡¼­ ¸ÞÀϵéÀ» °Ë»çÇÏ´Â ±â´ÉÀÌ´Ù. ±× ÈÄ ´ç½ÅÀº ƯÁ¤ ¸ÞÀÏÀ» ´Ù¸¥ °÷À¸·Î Æ÷¿öµù ÇÒ ¼ö ÀÖ´Ù. ÇÏÁö¸¸, ·ÎÄà ¸Ó½ÅÀ¸·Î Æ÷¿öµùµÈ ¸ÞÀÏÀ̳ª bob@domain1.com°ú bob@domain2.com¿¡ ¿Â ¸ÞÀÏÀº °°Àº ¸ÞÀÏ Æú´õ¿¡ µé¾î°¡ ÀÖ°Ô µÈ´Ù. À̵éÀÌ ¼­·Î ´Ù¸¥ ¸ÞÀÏÀÌ°í µÎ¸íÀÇ bobÀÌ ¼­·Î ´Ù¸¥ »ç¶÷ÀÏ ¶§¿¡´Â ¹®Á¦°¡ µÈ´Ù. 9.2. ÇØ°áÃ¥ ´ç½ÅÀº °¢°¢ÀÇ »ç¿ëÀÚ À̸§¿¡ ¼ýÀÚ¸¦ ºÙ¿©¼­, ȤÀº Á¤ÇØÁø ¹®ÀÚ¸¦ ¾Õ¿¡ ºÙ¿©¼­ Áߺ¹µÇ´Â »ç¿ëÀÚ°¡ ¾Æ´ÔÀ» ±¸ºÐÇÒ ¼ö ÀÖ´Â ¹æ¹ýÀÌ ÀÖ´Ù.(¿¹: bob1, bob2 ȤÀº dom1bob, dom2bob) ´ç½ÅÀº ¶ÇÇÑ mailÀ̳ª pop¸¦ °íÃļ­ ÀÌ·± ÀüȯÀÌ º¸ÀÌÁö ¾Ê°Ô ÀÌ·ç¾îÁú ¼ö ÀÖ°Ô ¸¸µé¼öµµ ÀÖ´Ù. ¿ÜºÎ·Î ³ª°¡´Â ¸ÞÀÏ ¿ª½Ã ÀÌ·± ½ÄÀ¸·Î °¢°¢ÀÇ ¼­ºêµµ¸ÞÀο¡ ´ëÇؼ­ ±× À̸§À» »ç¿ëÇÏ°Ô ¸¸µé ¼ö ÀÖ´Ù. ³»°¡ °¡Áø ÇØ°áÃ¥Àº µÎ°¡ÁöÀÌ´Ù. Çϳª´Â sendmailÀ» ÀÌ¿ëÇÏ´Â °ÍÀÌ°í, ´Ù¸¥ Çϳª´Â QmailÀ» ÀÌ¿ëÇÏ´Â °ÍÀÌ´Ù. SendmailÀ» ÀÌ¿ëÇÑ ÇØ°áÃ¥Àº ÀÌ ±â´ÉÀ» Ãß°¡ÇÏ¿© sendmail À» ¼³Ä¡ÇÏ´Â °ÍÀÌ´Ù. ÇÏÁö¸¸, ÀÌ ¹æ¹ýÀº ¸ðµç Á¦¾àÀÌ sendmail¿¡ ¶È°°ÀÌ Àû¿ëµÈ´Ù. ÀÌ ¹æ¹ýÀº ¶ÇÇÑ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ Çϳª¾¿ÀÇ sendmailÀÌ queue mode·Î ½ÇÇàµÇ¾î¾ß ÇÑ´Ù´Â ´ÜÁ¡À» °¡Áö°í ÀÖ´Ù. 50°³ ȤÀº ±× ÀÌ»óÀÇ senmail queue ÇÁ·Î¼¼½º´Â ¸Å½Ã°£ ½Ã½ºÅÛÀ» ¹Ù»Ú°Ô ¸¸µé °ÍÀÌ´Ù. QmailÀ» ÀÌ¿ëÇÏ´Â ÇØ°áÃ¥Àº ¿©·¯°³ÀÇ QmailÀ» ÇÊ¿ä·ÎÇÏÁöµµ ¾Ê°í, ÇϳªÀÇ queue µð·ºÅ丮 ÀÌ¿Ü¿¡¼­µµ ½ÇÇà °¡´ÉÇÏ´Ù. ÀÌ ¹æ¹ýÀº QmailÀÌ virtuald¿Í ¸ÂÁö ¾Ê±â ¶§¹®¿¡ Ãß°¡ÀûÀÎ ÇÁ·Î±×·¥À» ÇÊ¿ä·Î ÇÑ´Ù. ³­ sendmailÀ» ÀÌ¿ëÇÑ ¹æ¹ý ¿ª½Ã ºñ½ÁÇÑ °úÁ¤À» ÇÊ¿ä·Î ÇÑ´Ù°í ¹Ï´Â´Ù. ÇÏÁö¸¸, QmailÀº ÀÌ °æ¿ì º¸´Ù ÇØ°áÃ¥À» À§ÇÑ Áغñ°¡ Àß µÇ¾îÀÖ´Â °Í °°´Ù. ³»°¡ ÇÑ ÇÁ·Î±×·¥ÀÌ ´Ù¸¥ ÇÁ·Î±×·¥º¸´Ù ³´´Ù´Â °ÍÀ» º¸ÁõÇÏ´Â °ÍÀº ¾Æ´Ï´Ù. Sendmail ¼³Ä¡´Â º¸´Ù Á÷Á¢ÀûÀÎ ÇØ°áÃ¥ÀÌÁö¸¸, QmailÀ» ÀÌ¿ëÇÏ´Â ¹æ¹ýÀÌ ¾Æ¸¶ ´õ °­·ÂÇÑ ÇØ°áÃ¥ÀÌ µÉ ¼ö ÀÖ´Ù. 9.3. SendmailÀ» ÀÌ¿ëÇÑ ÇØ°áÃ¥ 9.3.1. ¼Ò°³ °¢°¢ÀÇ °¡»ó ÆÄÀÏ ½Ã½ºÅÛÀº ÀÚ½ÅÀÇ /etc/passwd ¾È¿¡ µµ¸ÞÀÎÀ» ¼³Á¤ÇÑ´Ù. ÀÌ°ÍÀº bob@domain1.com°ú bob@domain2.comÀÌ ¼­·Î ´Ù¸¥ »ç¿ëÀÚ·Î /etc/passwd ¾È¿¡ µî·ÏµÇ¾î ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇϸç, ¸ÞÀÏ ÇÁ·Î±×·¥¿¡¼­ µÎ »ç¿ëÀÚ¸¦ ±¸ºÐÇÏ´Â µ¥¿¡´Â ¾Æ¹« ¹®Á¦°¡ ¾ø´Ù. ¶ÇÇÑ ÀڽŸ¸ÀÇ ½ºÇ® µð·ºÅ丮 ¿ª½Ã °¡Áö°í ÀÖÀ¸¹Ç·Î ´Ù¸¥ °¡»ó ÆÄÀÏ ½Ã½ºÅÛ¿¡ ´ëÇؼ­ ¼­·Î ´Ù¸¥ ÆÄÀϷμ­ ¸ÞÀÏ Æú´õ°¡ Á¸ÀçÇÏ°Ô µÈ´Ù. 9.3.2. Sendmail ¼³Á¤ ÆÄÀÏ ¸¸µé±â ÀϹÝÀûÀÎ /etc/sendmail.cf ¸¦ m4¸¦ ÅëÇØ ¸¸µç´Ù. ³»°¡ »ç¿ëÇÏ´Â °ÍÀº ´ÙÀ½°ú °°´Ù: divert(0) VERSIONID(`tcpproto.mc') OSTYPE(linux) FEATURE(redirect) FEATURE(always_add_domain) FEATURE(use_cw_file) FEATURE(local_procmail) MAILER(local) MAILER(smtp) 9.3.3. Sendmail ¼³Á¤ÆÄÀÏ ÆíÁýÇϱâ /virtual/domain1.com/etc/sendmail.cf ¸¦ °¡»ó µµ¸ÞÀο¡ ¹ÝÀÀÇÒ ¼ö ÀÖµµ·Ï ÆíÁýÇÑ´Ù: vi /virtual/domain1.com/etc/sendmail.cf # Approximately Line 86 It should say: #Dj$w.Foo.COM Replace it with: Djdomain1.com 9.3.4. Sendmail Áö¿ª ¹è´Þ /virtual/domain1.com/etc/sendmail.cw¸¦ Áö¿ª È£½ºÆ®À̸§À¸·Î ÆíÁýÇÑ´Ù. vi /virtual/domain1.com/etc/sendmail.cw mail.domain1.com domain1.com domain1 localhost 9.3.5. °¡»ó µµ¸ÞÀÎ »çÀÌÀÇ Sendmail : The Hack (PRE8.8.6) ÇÏÁö¸¸, sendmailÀº ÀÛÀº ¼Ò½º ÄÚµå º¯È¯À» ÇÊ¿ä·Î ÇÑ´Ù. SendmailÀº /etc/sendmail.cw ¶ó´Â ÆÄÀÏÀ» °¡Áö°í Àִµ¥, ¿©±â¿¡´Â sendmailÀÌ ·ÎÄà ³»¿¡¼­(¿ÜºÎÀÇ ´Ù¸¥ ¸Ó½ÅÀÌ ¾Æ´Ñ) ¹è´ÞÇÒ ¸ðµç ¸Ó½ÅµéÀÇ À̸§ÀÌ ±â·ÏµÇ¾î ÀÖ´Ù. SendmailÀº ³»ºÎ¿¡¼­ ¸Ó½ÅÀÇ ¸ðµç ÀåÄ¡µé¿¡ ´ëÇØ °Ë»çÇÏ¿© ÀÌ ¸®½ºÆ®¸¦ ·ÎÄà IP¸¦ °¡Áö°í ÃʱâÈ­ÇÑ´Ù. ÀÌÁ¡ ¶§¹®¿¡ ¸¸¾à °°Àº ¸Ó½Å ³»ÀÇ °¡»ó µµ¸ÞÀÎ »çÀÌ¿¡¼­ ¸ÞÀÏÀ» ÁÖ°í¹Þ°íÀÚ ÇÒ ¶§ ¹®Á¦°¡ µÉ ¼ö ÀÖ´Ù. SendmailÀº ´Ù¸¥ °¡»ó µµ¸ÞÀÎÀ» ·ÎÄà ¾îµå·¹½º·Î »ý°¢ÇÏ°í ·ÎÄà Áö¿ªÀ¸·Î ¸ÞÀÏÀ» ½ºÇ®¸µÇÏ°Ô µÈ´Ù. ¿¹¸¦ µé¸é, bob@domain1.comÀÌ fred@domain2.com¿¡°Ô ¸ÞÀÏÀ» º¸³Â´Ù°í ÇÏÀÚ. ±×·¯¸é domain1.comÀÇ sendmailÀº domain2.comÀ» ·ÎÄ÷ΠÀνÄÇÏ°í ¸ÞÀÏÀ» domain1.com¿¡ ½ºÇ®¸µÇÒ °ÍÀÌ´Ù. (´ç¿¬È÷ domain2.comÀ¸·Î´Â ¸ÞÀÏÀÌ °¡Áö ¾ÊÀ» °ÍÀÌ´Ù.) µû¶ó¼­ ´ç½ÅÀº sendmailÀ» º¯Çü½ÃÄÑ¾ß ÇÑ´Ù. (ÀÌ º¯ÇüÀº v8.8.5¿¡¼­ Å×½ºÆ®Çغ» °á°ú ¾Æ¹« ¹®Á¦°¡ ¾ø¾ú´Ù.) vi v8.8.5/src/main.c # Approximately Line 494 It should say: load_if_names(); Replace it with: /* load_if_names(); Commented out since hurts virtual */ ¸¸¾à °¡»ó µµ¸ÞÀÎ »çÀÌ¿¡¼­ ¸ÞÀÏÀ» ÁÖ°í¹ÞÀ» ÇÊ¿ä°¡ ÀÖÀ» °æ¿ì¿¡¸¸ ÀÌ ¼³Á¤À» ÀÌ¿ëÇ϶ó. (¾Æ¸¶ ´ëºÎºÐÀÇ °æ¿ì ±×·¯ÇÏ°ÚÁö¸¸) ÀÌ°ÍÀº ¹®Á¦Á¡À» ÇØ°áÇÒ °ÍÀÌ´Ù. ÇÏÁö¸¸, ÁÖµÈ ÀÌ´õ³Ý ÀåÄ¡ÀÎ eth0´Â ¾ø¾îÁöÁö ¾Ê´Â´Ù. µû¶ó¼­, ¸¸¾à ´ç½ÅÀÌ °¡»ó IP¿¡¼­ eth0·Î ¸ÞÀÏÀ» º¸³»°Ô µÇ¸é ÀÌ°ÍÀº ·ÎÄ÷Π¹è´ÞÀÌ µÉ °ÍÀÌ´Ù. µû¶ó¼­ ³ª´Â ÀÌ°ÍÀ» ´õ¹Ì(dummy) IPÀÎ virtual1.maindomain.com(10.10.10.157)·Î ÀÌ¿ëÇÑ´Ù. ³­ Àý´ë ÀÌ È£½ºÆ®·Î ¸ÞÀÏÀ» º¸³»Áö ¾ÊÀ¸¸ç, ¹°·Ð ±× °¡»ó µµ¸ÞÀÎÀ¸·Îµµ ¸ÞÀÏÀº °¡Áö ¾Ê´Â´Ù. ÀÌ ¹æ¹ýÀº ¶ÇÇÑ ³»°¡ ssh¸¦ »ç¿ëÇÏ´Â IP¸¦ °¡Áø ½Ã½ºÅÛÀÌ Á¤»óÀûÀÎÁö¸¦ È®ÀÎÇÏ´Â ¹æ¹ýÀ̱⵵ ÇÏ´Ù. 9.3.6. °¡»ó µµ¸ÞÀÎ »çÀÌÀÇ Sendmail : SendmailÀÇ »õ·Î¿î ±â´É (POST8.8.6) Sendmail V8.8.6ºÎÅÍ´Â Ãß°¡ÀûÀÎ ³×Æ®¿öÅ© ÀÎÅÍÆäÀ̽ºÀÇ ºñ»ç¿ë žÀç(disable loading)¿¡ ´ëÇÑ »õ·Î¿î ¿É¼ÇÀÌ »ý°å´Ù. µû¶ó¼­ Äڵ带 ¹Ù²Ü ÇÊ¿ä´Â ¾ø°Ô µÇ¾ú´Âµ¥, ÀÌ°ÍÀ» DontProbeInterfaces¶ó ÇÑ´Ù. /virtual/domain1.com/etc/sendmail.cf¸¦ ÆíÁýÇ϶ó. vi /virtual/domain1.com/etc/sendmail.cf # Add the line O DontProbeInterfaces=True 9.3.7. Sendmail.init SendmailÀº µ¶¸³ÀûÀ¸·Î ½ÇÇàÀÌ ºÒ°¡´ÉÇÏ°í Ç×»ó inetd¸¦ ÅëÇؼ­ ½ÇÇàµÇ°Ô µÈ´Ù. ÀÌ ¹æ¹ýÀº ºñÈ¿À²ÀûÀÌ°í ½ÃÀÛÇÏ´Â µ¥ ½Ã°£ÀÌ °É¸®°ÚÁö¸¸, ¸¸¾à ´ç½ÅÀÌ ¿î¿µÇÏ´Â »çÀÌÆ®°¡ ÀÌ·± Á¡ÀÌ ¹®Á¦°¡ µÉ Á¤µµ·Î ³×Æ®¿öÅ©°¡ ºó¹øÇÏ´Ù¸é ÇϳªÀÇ ½Ã½ºÅÛ¿¡¼­ °¡»óÀÇ ¿©·¯ µµ¸ÞÀÎÀ» °°ÀÌ »ç¿ëÇÏ´Â °ÍÀº ÁÁÀº ¹æ¹ýÀÌ ¾Æ´Ï´Ù. -bd Ç÷¢(flag)°ú °°ÀÌ »ç¿ëÇÏÁö ¾Êµµ·Ï ÁÖÀÇÇ϶ó. ¶ÇÇÑ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ sendmail -q À» ½ÇÇàÇÏ¿© ¹è´ÞµÇÁö ¾ÊÀº ¸ÞÀϵ鿡 ´ëÇÑ Å¥ ÀÛ¾÷À» °¡´ÉÇÏ°Ô ÇÏ´Â °Íµµ ÀØÁö ¸»¶ó. »õ·Î¿î sendmail.init ÆÄÀÏÀº ´ÙÀ½°ú °°´Ù: #!/bin/sh . /etc/rc.d/init.d/functions case "$1" in start) echo -n "Starting sendmail: " daemon sendmail -q1h echo echo -n "Starting virtual sendmail: " for i in /virtual/* do if [ ! -d "$i" ] then continue fi if [ "$i" = "/virtual/lost+found" ] then continue fi chroot $i sendmail -q1h echo -n "." done echo " done" touch /var/lock/subsys/sendmail ;; stop) echo -n "Stopping sendmail: " killproc sendmail echo rm -f /var/lock/subsys/sendmail ;; *) echo "Usage: sendmail {start|stop}" exit 1 esac exit 0 9.3.8. Inetd ¼³Á¤ Pop´Â ´Ù¸¥ ¿µÇâ¾øÀÌ Á¤»óÀûÀ¸·Î ¼³Ä¡µÉ °ÍÀÌ´Ù. ´ÜÁö inetdÀÇ ¿£Æ®¸®¿¡¼­ ÀÌ Ç×À» °¡»óÀÇ Æ÷Æ®¿Í ÇÔ²² °í·ÁÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. inetd.conf ¿£Æ®¸®¿¡¼­ sendmail°ú pop¿¡ ´ëÇÑ °ÍÀº ´ÙÀ½°ú °°´Ù: pop-3 stream tcp nowait root /usr/local/bin/virtuald \ virtuald /virtual/conf.pop in.qpop -s smtp stream tcp nowait root /usr/local/bin/virtuald \ virtuald /virtual/conf.mail sendmail -bs 9.4. QmailÀ» ÀÌ¿ëÇÑ ¹æ¹ý 9.4.1. ¼Ò°³ ÀÌ ¹æ¹ýÀº qmail-localÀÇ ¹è´Þ ½Ã½ºÅÛÀ» Â÷¿ëÇϱ⠶§¹®¿¡, °¡»óÀÇ È¨ µð·ºÅ丮 ¾ÈÀÇ .qmail ÆÄÀÏÀº ÀÛµ¿ÇÏÁö ¾Ê°Ô µÈ´Ù. ÇÏÁö¸¸, °¢°¢ÀÇ µµ¸ÞÀÎÀº µµ¸ÞÀÎ ÀüüÀÇ ¾Ù¸®¾î½Ì (aliasing)À» ÅëÁ¦ÇÏ´Â µµ¸ÞÀÎ ÁÖÀÎ »ç¿ëÀÚ(domain master user)¸¦ °®´Â´Ù. µÎ °³ÀÇ ¿ÜºÎ ÇÁ·Î±×·¥µéÀÌ µµ¸ÞÀÎ ÁÖÀÎÀÇ .qmail-default ÆÄÀÏÀ» »ç¿ëÇÒ ¼ö ÀÖ°Ô ÇØÁÙ °ÍÀÌ´Ù. °¢°¢ÀÇ µµ¸ÞÀο¡ ¸ÞÀÏÀÌ ¹è´ÞµÇ±â À§Çؼ­´Â ÀÌµé µÎ ÇÁ·Î±×·¥À» ÅëÇØ¾ß ÇÒ °ÍÀÌ´Ù. µÎ °³ÀÇ ÇÁ·Î±×·¥ÀÌ ÇÊ¿äÇѵ¥, ±× °¡¿îµ¥ Çϳª´Â setuid root »óÅ·Π½ÇÇàµÈ´Ù. ÀÌ ÀÛÀº ÇÁ·Î±×·¥Àº ÀÏ´Ü ÇÁ·Î¼¼½ºÀÇ ¼ÒÀ¯±ÇÀ» root°¡ ¾Æ´Ñ »ç¿ëÀÚ·Î ¹Ù²Ù°í, ´Ù½Ã µÎ¹ø° ÇÁ·Î±×·¥À» ½ÇÇà½ÃŲ´Ù. °¡±î¿î º¸¾È °ü·Ã »çÀÌÆ®¿¡¼­ ¿Ö ÀÌ·± ¹æ½ÄÀÌ ÇÊ¿äÇÑÁö¸¦ Âü°íÇÒ ¼ö ÀÖÀ» °ÍÀÌ´Ù. ÀÌ ¹æ¹ýÀº virtuald¸¦ »ç¿ëÇÒ Çʿ伺ÀÌ º°·Î ¾ø´Ù. QmailÀº ¸Å¿ì À¯µ¿ÀûÀÎ ÇÁ·Î±×·¥À̶ó ÀϹÝÀûÀÎ virtuald ¼³Á¤À» ÇÊ¿ä·ÎÇÏÁö ¾Ê´Â´Ù. QmailÀº ¸ÞÀÏÀÇ ¹è´ÞÀ» À§ÇØ ÇÁ·Î±×·¥µéÀÇ ¿¬°áÀ» ÀÌ¿ëÇϵµ·Ï ¼³°èµÇ¾ú´Ù. ÀÌ µðÀÚÀÎÀº °¡»ó ¼­ºñ½º ºÎºÐÀ» Qmail ¹è´Þ ÇÁ·Î¼¼½º Áß°£¿¡ ½±°Ô »ðÀÔÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù. ´ç½ÅÀÌ QmailÀ» »ç¿ëÇÑ´Ù¸é ¸ÞÀÎ ¼­¹öÀÇ µµ¸ÞÀο¡¼­ ¹«Á¦ÇÑÀÇ µµ¸ÞÀÎ À̸§À» ¸¸µé¾î ³¾ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇØ ºÐ¸®µÈ QmailÀ» °®´Â °ÍÀÌ ¾Æ´Ï±â ¶§¹®¿¡ °¡´ÉÇÏ´Ù. ¸ÞÀÏ Å¬¶óÀ̾ðÆ® ÇÁ·Î±×·¥(À¯µµ¶ó³ª elm, mutt µî)¿¡¼­ ´ç½ÅÀÌ ÀÓÀÇ·Î ¸¸µé¾î³½ µµ¸ÞÀÎ À̸§À» ÀνÄÇÏ´Â °ÍÀ» È®ÀÎÇØ º¸¶ó. 9.4.2. °¡»ó µµ¸ÞÀÎ ¼³Á¤ QmailÀº ´ç½ÅÀÌ Á¦°øÇÏ´Â °¢°¢ÀÇ °¡»ó µµ¸ÞÀÎÀ» ¹Þ¾ÆµéÀÏ ¼ö ÀÖµµ·Ï ¼³Á¤µÇ¾î¾ß ÇÑ´Ù. ¾Æ·¡ÀÇ ¸í·É¾îµéÀ» ¼öÇàÇ϶ó. echo "domain1.com:domain1" >> /var/qmail/control/virtualdomains 9.4.3. µµ¸ÞÀÎÀÇ ÁÖÀÎ(Domain Master User) ¼³Á¤ ¸ÞÀÎ /etc/passwd ÆÄÀÏ¿¡ domain1ÀÇ »ç¿ëÀÚµéÀ» Ãß°¡ÇÑ´Ù. ³ª´Â /bin/false ¼ÐÀ» ¸¸µé¾î µµ¸ÞÀÎ ÁÖÀÎ(the domain master)ÀÌ ·Î±×ÀÎÇÏÁö ¸øÇÏ°Ô ¸¸µé¾ú´Ù. µµ¸ÞÀÎ ÁÖÀÎÀº domain1ÀÇ .qmail ÆÄÀϵéÀ» Ãß°¡ÇÒ ¼ö ÀÖ°í, µµ¸ÞÀÎÀÇ ¸ðµç ¸ÞÀϵéÀº ÀÌ °èÁ¤À» ÅëÇÏ¿© ¹ß¼ÛµÈ´Ù. »ç¿ëÀÚ À̸§Àº ¿©´ü ÀÚ¸®±îÁö °¡´ÉÇÏ¸ç µµ¸ÞÀÎ À̸§Àº ´õ ±æ¾îÁö ¼ö ÀÖ´Ù´Â °ÍÀ» ÁÖÀÇÇϱ⠹ٶõ´Ù. ³ª¸ÓÁö ¹®ÀÚµéÀº ¹«½ÃµÈ´Ù. ÀÌ°ÍÀº domain12¶ó´Â »ç¿ëÀÚ¿Í domain123À̶ó´Â »ç¿ëÀÚ°¡ °°Àº »ç¿ëÀÚ·Î ÀνĵDZ⠶§¹®¿¡ QmailÀÌ È¥µ¿ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. µû¶ó¼­ µµ¸ÞÀÎ ÁÖÀÎ À̸§ °áÁ¤¿¡ ÁÖÀǸ¦ ±â¿ïÀ̱⠹ٶõ´Ù. ´ÙÀ½°ú °°Àº ÀýÂ÷¸¦ ÅëÇÏ¿© µµ¸ÞÀÎ ÁÖÀÎÀÇ .qmail ÆÄÀÏÀ» ¸¸µéÀÚ. ´Ù¸¥ ½Ã½ºÅÛ ¾Ù¸®¾î½º - ¿¹¸¦ µé¸é À¥¸¶½ºÅͳª È£½ºÆ®¸¶½ºÅÍ- °¡ ÀÌ ÁöÁ¡¿¡ Ãß°¡µÈ´Ù. echo "user@domain1.com" > /home/d/domain1/.qmail-mailer-daemon echo "user@domain1.com" > /home/d/domain1/.qmail-postmaster echo "user@domain1.com" > /home/d/domain1/.qmail-root µµ¸ÞÀÎ ÁÖÀÎÀÇ .qmail-default ÆÄÀÏÀ» ¸¸µéÀÚ. ÀÌ°ÍÀº ¸ðµç ¸ÞÀÏÀ» °¡»óÀÇ µµ¸ÞÀÎÀ¸·Î °É·¯ÁÖ°Ô µÉ °ÍÀÌ´Ù. echo "| /usr/local/bin/virtmailfilter" > /home/d/domain1/.qmail-default 9.4.4. Tcpserver QmailÀº Maildir Çü½ÄÀ» Áö¿øÇϴ Ưº°ÇÑ popÀ» ÇÊ¿ä·Î ÇÑ´Ù. ÀÌ pop ÇÁ·Î±×·¥ ¶ÇÇÑ °¡»ó ½Ã½ºÅÛ¿¡ ¸Â°Ô µÇ¾î¾ß ÇÑ´Ù. QmailÀÇ ÀúÀÚ´Â tcpserver(inetd ´ë¿ë)¸¦ Qmail°ú ÇÔ²² »ç¿ëÇÒ °ÍÀ» ±ÇÇϴµ¥, ³ªÀÇ ¿¹Á¦¿¡¼­µµ inetd ´ë½Å¿¡ tcpserver¸¦ »ç¿ëÇÏ¿´´Ù. Tcpserver´Â ¼³Á¤ ÆÄÀÏÀ» ÇÊ¿ä·Î ÇÏÁö ¾Ê´Â´Ù. ¸ðµç Á¤º¸´Â ¸í·ÉÇà¿¡¼­ ÁÖ¾îÁö°Ô µÈ´Ù. ¿©±â ¸ÞÀÏ µ¥¸ó°ú popper¸¦ »ç¿ëÇϱâ À§ÇÑ tcpserver.initÀÌ ÀÖ´Ù. #!/bin/sh . /etc/rc.d/init.d/functions QMAILDUSER=`grep qmaild /etc/passwd | cut -d: -f3` QMAILDGROUP=`grep qmaild /etc/passwd | cut -d: -f4` # See how we were called. case "$1" in start) echo -n "Starting tcpserver: " tcpserver -u 0 -g 0 0 pop-3 /usr/local/bin/virtuald \ /virtual/conf.pop qmail-popup virt.domain1.com \ /bin/checkpassword /bin/qmail-pop3d Maildir & echo -n "pop " tcpserver -u $QMAILDUSER -g $QMAILDGROUP 0 smtp \ /var/qmail/bin/qmail-smtpd & echo -n "qmail " echo touch /var/lock/subsys/tcpserver ;; stop) echo -n "Stopping tcpserver: " killall -TERM tcpserver echo -n "killing " echo rm -f /var/lock/subsys/tcpserver ;; *) echo "Usage: tcpserver {start|stop}" exit 1 esac exit 0 9.4.5. Qmail.init ´ç½ÅÀº Á¦°øµÇ´Â Ç¥ÁØ Qmail Ãʱ⠽ºÅ©¸³Æ®¸¦ ¹Ù·Î »ç¿ëÇÒ ¼ö ÀÖ´Ù. QmailÀº ÀÌ°ÍÀ» ¾î¶»°Ô ¼³Á¤ÇØ¾ß ÇÏ´ÂÁö¿¡ ´ëÇØ »ó´çÈ÷ ÁÁÀº ¹®¼­¿Í ÇÔ²² ¹èÆ÷µÈ´Ù. 9.4.6. ¼Ò½º(Source) Qmail·Î °¡»ó ¸ÞÀÏ ¼­ºñ½º¸¦ ±¸ÃàÇϱâ À§Çؼ­´Â µÎ°³ÀÇ ¼­·Î ´Ù¸¥ ÇÁ·Î±×·¥ÀÌ ÇÊ¿äÇÏ´Ù. Çϳª´Â virtmailfilterÀÌ°í, ´Ù¸¥ Çϳª´Â virtmaildeliveryÀÌ´Ù. ¿©±â virtmailfilter¿¡ ´ëÇÑ C ¼Ò½º Äڵ尡 ÀÖ´Ù. ÀÌ ÇÁ·Î±×·¥Àº /usr/local/bin¿¡ 4750ÀÇ ¼ÒÀ¯±ÇÀ» °¡Áö°í, root ¼ÒÀ¯, nofiles ±×·ìÀ¸·Î ¼³Ä¡µÇ¾î¾ß ÇÑ´Ù. #include #include #include #include #include #include #include #define VIRTPRE "/virtual" #define VIRTPWFILE "etc/passwd" #define VIRTDELIVERY "/usr/local/bin/virtmaildelivery" #define VIRTDELIVERY0 "virtmaildelivery" #define PERM 100 #define TEMP 111 #define BUFSIZE 8192 int main(int argc,char **argv) { char *username,*usernameptr,*domain,*domainptr,*homedir; char virtpath[BUFSIZE]; struct passwd *p; FILE *fppw; int status; gid_t gid; pid_t pid; if (!(username=getenv("EXT"))) { fprintf(stdout,"environment variable EXT not set\n"); exit(TEMP); } for(usernameptr=username;*usernameptr;usernameptr++) { *usernameptr=tolower(*usernameptr); } if (!(domain=getenv("HOST"))) { fprintf(stdout,"environment variable HOST not set\n"); exit(TEMP); } for(domainptr=domain;*domainptr;domainptr++) { if (*domainptr=='.' && *(domainptr+1)=='.') { fprintf(stdout,"environment variable HOST has ..\n"); exit(TEMP); } if (*domainptr=='/') { fprintf(stdout,"environment variable HOST has /\n"); exit(TEMP); } *domainptr=tolower(*domainptr); } for(domainptr=domain;;) { snprintf(virtpath,BUFSIZE,"%s/%s",VIRTPRE,domainptr); if (chdir(virtpath)>=0) break; if (!(domainptr=strchr(domainptr,'.'))) { fprintf(stdout,"domain failed: %s\n",domain); exit(TEMP); } domainptr++; } if (!(fppw=fopen(VIRTPWFILE,"r+"))) { fprintf(stdout,"fopen failed: %s\n",VIRTPWFILE); exit(TEMP); } while((p=fgetpwent(fppw))!=NULL) { if (!strcmp(p->pw_name,username)) break; } if (!p) { fprintf(stdout,"user %s: not exist\n",username); exit(PERM); } if (fclose(fppw)==EOF) { fprintf(stdout,"fclose failed\n"); exit(TEMP); } gid=p->pw_gid; homedir=p->pw_dir; if (setgid(gid)<0 || setuid(p->pw_uid)<0) { fprintf(stdout,"setuid/setgid failed\n"); exit(TEMP); } switch(pid=fork()) { case -1: fprintf(stdout,"fork failed\n"); exit(TEMP); case 0: if (execl(VIRTDELIVERY,VIRTDELIVERY0,username,homedir,NULL)<0) { fprintf(stdout,"execl failed\n"); exit(TEMP); } default: if (wait(&status)<0) { fprintf(stdout,"wait failed\n"); exit(TEMP); } if (!WIFEXITED(status)) { fprintf(stdout,"child did not exit normally\n"); exit(TEMP); } break; } exit(WEXITSTATUS(status)); } 9.4.7. ¼Ò½º(Source) ¿©±â¿¡´Â virtmaildelivery¿¡ ´ëÇÑ C ¼Ò½º Äڵ尡 ÀÖ´Ù. ÀÌ°ÍÀº /usr/local/bin¿¡ 0755ÀÇ ¼ÒÀ¯±ÇÀ¸·Î, ¼ÒÀ¯ÀÚ¿Í ±×·ì ¸ðµÎ root·Î ¼³Ä¡µÇ¾î¾ß ÇÑ´Ù. #include #include #include #include #include #include #include #include #define TEMP 111 #define BUFSIZE 8192 #define ATTEMPTS 10 int main(int argc,char **argv) { char *user,*homedir,*dtline,*rpline,buffer[BUFSIZE],*p,mail[BUFSIZE]; char maildir[BUFSIZE],newmaildir[BUFSIZE],host[BUFSIZE]; int fd,n,nl,i,retval; struct stat statp; time_t thetime; pid_t pid; FILE *fp; retval=0; if (!argv[1]) { fprintf(stdout,"invalid arguments: need username\n"); exit(TEMP); } user=argv[1]; if (!argv[2]) { fprintf(stdout,"invalid arguments: need home directory\n"); exit(TEMP); } homedir=argv[2]; if (!(dtline=getenv("DTLINE"))) { fprintf(stdout,"environment variable DTLINE not set\n"); exit(TEMP); } if (!(rpline=getenv("RPLINE"))) { fprintf(stdout,"environment variable RPLINE not set\n"); exit(TEMP); } while (*homedir=='/') homedir++; snprintf(maildir,BUFSIZE,"%s/Maildir",homedir); if (chdir(maildir)<0) { fprintf(stdout,"chdir failed: %s\n",maildir); exit(TEMP); } time(&thetime); pid=getpid(); if (gethostname(host,BUFSIZE)<0) { fprintf(stdout,"gethostname failed\n"); exit(TEMP); } for(i=0;i=ATTEMPTS) { fprintf(stdout,"could not create %s\n",mail); exit(TEMP); } if (!(fp=fopen(mail,"w+"))) { fprintf(stdout,"fopen failed: %s\n",mail); retval=TEMP; goto unlinkit; } fd=fileno(fp); if (fprintf(fp,"%s",rpline)<0) { fprintf(stdout,"fprintf failed\n"); retval=TEMP; goto unlinkit; } if (fprintf(fp,"%s",dtline)<0) { fprintf(stdout,"fprintf failed\n"); retval=TEMP; goto unlinkit; } while(fgets(buffer,BUFSIZE,stdin)) { for(p=buffer;*p=='>';p++) ; if (!strncmp(p,"From ",5)) { if (fputc('>',fp)<0) { fprintf(stdout,"fputc failed\n"); retval=TEMP; goto unlinkit; } } if (fprintf(fp,"%s",buffer)<0) { fprintf(stdout,"fprintf failed\n"); retval=TEMP; goto unlinkit; } } p=buffer+strlen(buffer); nl=2; if (*p=='\n') nl=1; for(n=0;n