1993.1.19

SUBJECT: "vipw"¿¡ ´ëÇÏ¿©

DESCRIPTION:
0. "vipw" µîÀåÀÇ ¹è°æ
   * /etc/passwd fileÀÌ editµÇ´Â µ¿¾È machineÀÌ crash ³ª´Â °æ¿ì¸¦ »óÁ¤ÇØ º¸ÀÚ.
     ¹°·Ð ´ë°³ÀÇ °æ¿ì systemÀÌ rebootingÇÑ µÚ "vi -r"·Î¼­ recovery°¡ µÇÁö¸¸
     ¿¹¸¦ µé¾î, tape ÀÛ¾÷À» ÇÏ´Ù root fullÀÌ ³ª´Â °æ¿ì´Â editÇÏ´ø fileÀÇ ³»¿ëÀÌ
     ¸ù¶¥ ³¯¶ó°¡ ¹ö¸®°í size°¡ 0°¡ µÇ´Â °Í°ú °°Àº °æ¿ì¿¡´Â ¾î¶»°Ô ´ëóÇÒ °ÍÀΰ¡.
   * password fileÀº user°¡ systemÀ¸·Î loginÇϴµ¥ ÇÊ¿äÇÑ Á¤º¸¸¦ Æ÷ÇÔÇÏ°í Àֱ⠶§¹®¿¡
     system operation¿¡ ÀÖ¾î ¸Å¿ì Áß¿äÇÑ fileÀÌ´Ù.
     ÀÌó·³ Áß¿äÇÑ fileÀ» Á÷Á¢ editÇÑ´Ù´Â °ÍÀº °áÄÚ ÁÁÀº ¹æ¹ýÀÌ ¾Æ´Ò °ÍÀÌ´Ù.
   * ÀÌ·± ¹®Á¦¸¦ ÇØ°áÄÚÀÚ ¸î¸î BSD °è¿­ÀÇ system¿¡¼­´Â "vipw"¸¦ »ç¿ëÇÏ¿©
     /etc/passwd fileÀ» editÇÑ´Ù.
   
1. "vipw"¶õ ?
   * "vipw"´Â /etc/passwd¸¦ copyÇÏ¿© /etc/ptmp¶ó´Â fileÀ» ¸¸µç´Ù. 
     ±×¸®°í (default·Î) vi editor¸¦ »ç¿ëÇÏ¿© /etc/ptmp¸¦ openÇÑ´Ù.
     edit°¡ ³¡³ª¸é º¯°æµÈ »çÇ×À» /etc/passwd¿¡ writeÇÏ°í /etc/ptmp¸¦ Áö¿î´Ù.
     µû¶ó¼­ /etc/ptmp°¡ editµÇ´Â µ¿¾È 
     /etc/passwd´Â disk¿¡ ¿ø·¡ »óÅ ±×´ë·Î Àß º¸Á¸µÇ¾î ÀÖÀ» °ÍÀÌ´Ù.
     ¾Õ¼­ password file edit½Ã system crash·Î ÀÎÇØ password file ÀÚü¿¡ ¹®Á¦°¡ »ý±â´Â
     Çö»ó µûÀ§¿¡¼­´Â ÃæºÐÈ÷ º¸È£°¡ µÇ´Â °ÍÀÌ´Ù. 
   * ¶Ç "vipw"¸¦ »ç¿ëÇÏ°í ÀÖ´Â µ¿¾È ´Ù¸¥ window/terminal¿¡¼­ "vipw"¸¦ »ç¿ëÇÏ¿©
     password fileÀ» editÇÒ ¼ö´Â ¾ø´Ù.
     "vipw: password file busy"¶ó´Â message°¡ ³ª¿Ã °ÍÀÌ´Ù.
     ¹°·Ð "vipw"¸¦ »ç¿ëÇÏ°í ÀÖ´õ¶óµµ ´Ù¸¥ ÂÊ¿¡¼­ "vi"·Î /etc/passwd¸¦ ¿­¾î ³õ°í ÀÖ´Ù°¡
     "vipw"º¸´Ù ³ªÁß¿¡ saveÇÑ´Ù¸é "vipw"¸¦ »ç¿ëÇÏ¿© ÀÛ¾÷Çß´ø °ÍÀÌ µµ·Î¾Æ¹ÌŸºÒ µÉ °ÍÀÌ´Ù. 
     "vipw"´Â /etc/passwd fileÀÌ ¾Æ´Ï¶ó /etc/ptmp fileÀ»  lockingÇÏ´Â °ÍÀÌ´Ù.
     ±×·¯¹Ç·Î "vipw"´Â "vi"°¡ /etc/passwd fileÀ» ¾îÂîÇÏ´Â °Í±îÁö ¸·À» ¼ö ¾ø´Â °Í.
   * "vipw"°¡ »ç¿ëÇÏ´Â default editor´Â viÀÌÁö¸¸
     ȯ°æº¯¼ö "EDITOR"¿¡ ´Ù¸¥ editor¸¦ settingÇÏ¿© "vipw"¿¡¼­ ºÒ·¯ ¾µ ¼öµµ ÀÖ´Ù.

2. "vipw"¿Í /etc/rc fileÀÇ °ü°è   
   * /etc/rc file¿¡ º¸¸é ¾Æ·¡¿Í °°Àº scriptÀÌ ÀÖ´Ù.
   +-------------------------------------------------------------------------------+
   |  # attempt to rationally recover the passwd file if needed                    |
   |  if [ -s /etc/ptmp ]; then                                                    |
   |          if [ -s /etc/passwd ]; then                                          |
   |                  ls -l /etc/passwd /etc/ptmp                                  |
   |                  rm -f /etc/ptmp         # should really remove the shorter   |
   |          else                                                                 |
   |                  echo 'passwd file recovered from ptmp'                       |
   |                  mv /etc/ptmp /etc/passwd                                     |
   |          fi                                                                   |
   |  elif [ -r /etc/ptmp ]; then                                                  |
   |          echo 'removing passwd lock file'                                     |
   |          rm -f /etc/ptmp                                                      |
   |  fi                                                                           |
   +-------------------------------------------------------------------------------+
   * systemÀÌ crash ³µÀ» ´ç½Ã "vipw"¸¦ »ç¿ëÇÏ°í ÀÖ¾ú´Ù¸é
     /etc/ptmp fileÀÌ deleteµÇÁö ¾Ê°í ³²¾Æ ÀÖÀ» ¼ö ÀÖ°í
     °¡´ÉÇÏ´Ù¸é À̸¦ ÅëÇØ /etc/passwd¸¦ recoveryÇϵµ·Ï ÇÏ´Â routineÀÌ´Ù.




Revision History
Created        on Jan. 19 ,1993