¦p¦ó¨ú±o¡A¦w¸Ë¡A³]©w shadow ±K½X §@ªÌ:¡@Michael H. Jackson, [1]mhjack@tscnet.com ĶªÌ:¡@Sung Min-Ju, [2]songmj@ms1.hinet.net v1.3, 3 April 1996 ½Ķ¤é´Á:¡@15 MAY 2000 _________________________________________________________________ ³o¥÷¤å¥ó¥D­n´y­z¦p¦ó¨ú±o¡A¦w¸Ë©M³]©w Shadow Suite ±K½X¡C¥¦¤]´y­z¨ú±o©M ¦w¸Ë»Ý­n¦s¨ú¨Ï¥ÎªÌ±K½X¤§¨ä¥L³nÅé©Mºô¸ôºÊ±±µ{¦¡(network daemons)¡C³o¨Ç¨ä ¥L³nÅ餣¬O Shadow Suit ªº¯u¹ê³¡¤À¡A¦ý¬O³o¨Çµ{¦¡±N»Ý­n³Q­«·s½sĶ¥Î¥H¤ä ´©Shadow Suite ¡C³o¥÷¤å¥ó¥ç¥]¬A¤@­Óµ{¦¡½d¨Ò¡G¹ïµ{¦¡¥[¤J shadow ¤ä´©¡C¥» ¤åµ²§À³¡¤À¬°±`°Ý°ÝÃD¤Îµª®×¡C _________________________________________________________________ 1. ²¤¶ * 1.1 §ó§ï¤W¤@ª©¥»³¡¤À * 1.2 ·sª©¤å¥ó * 1.3 ¦^ÂÐ 2. ¬°¦ó shadow §Aªº passwd ÀÉ? * 2.1 ¬°¦ó±z¤£­n shadow §Aªº passwd ÀÉ * 2.2 ®æ¦¡¤Æ /etc/passwd ÀÉ * 2.3 ®æ¦¡¤Æ shadow ÀÉ * 2.4 ¦^ÅU crypt(3). 3. ¨ú±o Shadow Suite. * 3.1 Shadow Suite for Linux ªº¾ú¥v(¼È¤£Â½Ä¶) * 3.2 History of the Shadow Suite for Linux * 3.3 ¦p¦ó¨ú±o Shadow Suite¡H * 3.4 Shadow Suite¥]§t¤°»ò¡H 4. ½sĶµ{¦¡ * 4.1 ¸ÑÀ£ÁY * 4.2 ³]©w config.h ÀÉ * 4.3 ³Æ¥÷­ì©lµ{¦¡ * 4.4 °õ¦æ make 5. ¦w¸Ë * 5.1 ¤âÃä·Ç³Æ¤@­Ó¶}¾÷¤ù * 5.2 ²¾°£½Æ»sªº man pages * 5.3 °õ¦æ make install * 5.4 °õ¦æ pwconv * 5.5 ­«·s©R¦W npasswd ©M nshadow 6. ¨ä¥L§A»Ý­n¤É¯Å(upgrade)©Î¸É±j(patch)µ{¦¡ * 6.1 Slackware adduser µ{¦¡ * 6.2 wu_ftpd Server * 6.3 ¼Ð·Ç ftpd * 6.4 pop3d (Post Office Protocol 3) * 6.5 xlock * 6.6 xdm * 6.7 sudo * 6.8 imapd (E-Mail [pine package]) * 6.9 pppd (Point-to-Point Protocol Server) 7. ±N Shadow Suite ©ñ¶i¨Ó¨Ï¥Î¡C * 7.1 ·s¼W¡B­×§ï©M§R°£¨Ï¥ÎªÌ * 7.2 passwd «ü¥O©M passwd ¦Ñ¤Æ * 7.3 login.defs ÀÉ * 7.4 ¸s²Õ±K½X * 7.5 Àˬdµ{¦¡¤@­P©Ê * 7.6 Dial-up ±K½X 8. ¥[¤J shadow ¤ä´© C »y¨¥ * 8.1 ¼ÐÀYÀÉ(Header files) * 8.2 libshadow.a ¨ç¦¡®w(library) * 8.3 Shadow µ²ºc(Structure) * 8.4 Shadow ¨ç¦¡(Functions) * 8.5 ½d¨Ò 9. ±`°Ý°ÝÃD¤Îµª®× 10. ª©ÅvÁn©ú(¼È¤£Â½Ä¶) 11. Miscellaneous and Acknowledgments. _________________________________________________________________ 1. ²¤¶ ³o½g¤å³¹¬° Linux Shadow-Password-HOWTO¡C ¥D­n¬O¦b´y­z¬°¦ó¤Î¦p¦ó©ó Linux ¨t²Î¥[¤J shadow ±K½X¤ä´©¡C ¨ä¥ç¥]¬A¦p¦ó¨Ï¥Î Shadow Suite's ¬Y¨Ç½d ¨Ò¡C ·í¶i¦æ Shadow Suite ¦w¸Ë¤Î¨Ï¥Î³\¦hªº utility µ{¦¡®É¡E§A¥²¶·¥H root Åv­­ ñ¤J¡C ¥B¶i¦æ Shadow Suite ¦w¸Ë®É¡A¨t²Î³nÅé±N³Q§ïÅÜ¡A¦]¦¹±j¯Pªº«Øij ±z ·Ó»¡©úÀɳƤÀµ{¦¡¡C¦b¦¹±j½Õ¦b±z¶}©l§@·~«e»Ý¥ý¾\Ū¤Î¤F¸Ñ©Ò¦³ªº»¡©ú®Ñ¡C 1.1 §ó§ï¤W¤@ª©¥»³¡¤À ·s¼W¡G ·s¼W¤@­Ó¤l¸`¡G¬°¦ó±z¤£­n¦w¸Ë shadow ·s¼W¤@­Ó¤l¸`¡G­×§ï xdm µ{¦¡ ·s¼W¤@¸`¡G¬°¦ó±z¤£­n¦w¸Ë shadow ·s¼W¤@¸`¡G¦p¦ó©ó¥¼¨Ó¹B§@ Shadow Suite ·s¼W¤@¸`¡G±`°Ý°ÝÃD¤Îµª®× §ó¥¿/­×§ï¡G §ó¥¿¦b Sunsite ªº html °Ñ¦Ò¸ê®Æ §ó¥¿¦b wu-ftp ¸`¦b Makefile ·s¼W -lshadow §ó¥¿¸û¤£ÄY­««÷­µ©M±¹µü¿ù»~ §ó§ï wu-ftp ¸`¥Î¥H¤ä´© ELF ­×§ï¦b¤£¦Pñ¤J(login)µ{¦¡¦w¥þ°ÝÃD ­×§ï Linux Shadow Suite «Øij¬° Marek Michalkiewicz 1.2 ·sª©¤å¥ó ±z¥i§Q¥Î°Î¦WÀɶi¤J¸Ó FTP ¯¸¤U¸ü³Ì·sª©¤å¥ó¡G sunsite.unc.edu /pub/Linux/docs/HOWTO/Shadow-Password-HOWTO or: /pub/Linux/docs/HOWTO/other-formats/Shadow-Password-HOWTO{-html.tar,ps,dvi}.gz ©Î³z¹Lºô¯¸¡G [3]Linux Documentation Project Web Server¡Aºô­¶¡G [4]Shadow-Password-HOWTO ©Î»P§ÚÁpµ¸¡G . ¥ç¥i³z¹L·s»D ¸s²Õ±i¶K¡G comp.os.linux.answers ³o¨Ç¤å¥ó²{¦b¤w¸g¥]©ó Shadow-YYDDMM ®M¥ó¤¤¡C 1.3 ¦^ÂÐ ½Ð±N¥ô¦óµû»y¡B­×§ï©Î«Øij±H¦Ü¡G [5]Michael H. Jackson §Ú·|ºÉ§Ö¦^ÂШç󥿸Ӥå¥ó¡C ¦pªG§Aµo²{¥ô¦ó°ÝÃD¡A½Ðª½ ±µ email µ¹§Ú¡A§Ú·|±N¦¹³Ì·s§Þ³N±i¶K©ó·s»D¸s²Õ¡C 2. ¬°¦ó shadow §Aªº passwd ÀÉ? ¤j³¡¤À¥Ø«e Linux µo¦æª©¥»¹w³]­È¨Ã¥¼¥]§tShadow Suite ¦w¸Ë¡C ³o¨Çª©¥»¥]¬A Slackware 2.3, Slackware 3.0 ©M¨ä¥L¨üÅwªïªºµo¦æª©¥»¡C ¥D­n­ì¦]¤§¤@¬O¦b ­ì©lShadow Suiteª©ÅvÁn©ú¤¤¨Ã¥¼«Ü²M·¡ªº´y­z¸Ó³nÅé¬O §_»Ý¨Ï¥ÎªÌ¥I¶O¡C Linux ¨Ï¥Î GNU ª©Åv³q±`¤¹Äò¨Ï¥ÎªÌ¥i§K¶O¥B¥ô·N¨Ï¥Î¬ÛÃö®M¥ó¡C Shadow Suite²{¦bºûÅ@¤H­û [6]Marek Michalkiewicz ¤w¸g¥i¥H±q¦b BSD ¼Ë¦¡¤¹»Ý¦A¨Ï¥Îª©Åv ¤§­ì©l§@ªÌ¨º±µ¦¬­ì©l½X¡C ¥Ø«eª©Åvµo¦æ¤w ¸Ñ¨M¡A¦]¦¹¥i¥H¹w´Á¦b¥¼¨Óª©¥»¤§ ¹w³]­È±N¥]¬A password shadowing¡C §Y¨Ï¦p¦¹¡A §A¤´»Ý­n¦Û¦æ¦w¸Ë¡C ¦pªG§Aªºª©¥»¬O±q CD-ROM ¦w¸Ë¡C§A¥i¯àµo²{§Y¨Ï¥Ø«eª©¥»¨Ã¥¼¦³Shadow Suite ¦w¸Ë¡A¦ý§A¤´µM¥i¥H¦b¸Ó¤ù CD-ROM §ä¨ì§A»Ý­n¦w¸ËªºShadow Suite¡C µM¦Ó¡A©Ò¦³Shadow Suite 3.3.1, 3.3.1-2 ª©¥»©M shadow-mk ¦ñÀHñ¤J(login) µ{¦¡©M ¨ä¥Lsuid rootµ{¦¡§¡¦³¦w¥þ¤W°ÝÃD¡A¦]¦¹¤£À³¸Ó¨Ï¥Î¤Ó¤[¡C ©Ò¦³¥²­nÀɮק¡¥i¥H³z¹L°Î¦W FTP ¯¸©Îºô¯¸§ä¨ì¡C ¦b¨S¦³¦w¸ËShadow Suiteªº Linux ¨t²Î¡A¥]¬A±K½Xªº±b¸¹¨Ï¥ÎªÌ¸ê°T³q±`Àx¦s¦b /etc/passwd ÀÉ¡C Àx¦sªº±K½X¬° ¥[±K(encrypted)®æ¦¡¡C µM¦Ó¡A¦pªG§A°Ý¤@­Ó ±K½X±M®a¡A¥L/¦o±N §i¶D§A¯u¥¿ªº±K½XÀÉ¥u¬O½s½X(encoded)¦Ó¤£¬O¥[±K®æ¦¡¡A¦] ¬°·í¨Ï¥Î crypt(3) ®É¡A¤å¦rÀÉ­¿³]¬° null ¥B±K½X¬OÁä­È(key)¡C ¦]¦¹¡A±µ¤U ¨Ó§Ú±N¦b³o½g¤å¥ó¤¤¨Ï¥Î ½s½X¡C ¨Ï¥Î¦b±K½XÄæ¦ì½s½Xªººtºâªk©ó§Þ³N¤W¬O¨Ï¥Îone way hash function¡C³o¬O¤@­Ó ¦b³æ¤@¤è¦V­pºâ²³æ¦ý°f¦V­pºâ«D±`§xÃøªººtºâªk¡CÃö©ó³o¥¿½Tªººtºâªk¥i¥H¦b 2.4 ¸`©Î ©ó crypt(3) ¾Þ§@¤â¥U§ä¨ì¡C ·í¨Ï¥ÎªÌ¬D¿ï©Î«ü©w¤@­Ó±K½X¡A¨t²Î±NÀH¾÷²£¥Í¤@­Ó­È¡A¥s°µsalt¡A±N±K½X¶i¦æ ½s½X¡C ³oªí¥Ü¥ô¦ó¯S©wªº±K½X¥i¥H 4096 ¤¤¤£¦P¤èªkÀx¦s¡C salt ­È±NÀx¦s³Q½s ½Xªº±K½X ¡C ·í¨Ï¥ÎªÌñ¤J©Î´£¨Ñ¤@­Ó±K½X¡A salt ­º¥ý±µ¦¬±ýÀx¦s½s½X±K½X¡CµM«á³o´£¨Ñ±K ½X ·|©M salt ­È¤@°_½s½X¡A¥B¤ñ¸û¤w¸g½s½X±K½X¡C¦pªG¦³ match ¡A¸Ó¨Ï¥ÎªÌ³q ¹LÅv­­Àˬd¡C ÀH¾÷½s½X©M´_­ì­ì©l±K½X¬O¦³­pºâ½ÆÂø«×ªº(¦ý¤£¬O¤£¥i¯àªº)¡CµM¦Ó¡A¦b¬Y¨Ç¨t ²Î «Ü¦h¨Ï¥ÎªÌªº±K½X³£³]¬°¤@¯ë¤å¦r(©Î¬O¤@¯ë¤å¦rªºÂ²³æÅܤÆ) ¨t²ÎÀb«Èª¾¹D³o¥ó¨Æ¡A¥B±N²³æªº¥[±K¤å¦r©M¤@¯ë¨Ï¥Î4096 salt ­È±K½X¤§¥Ø¿ý ¡CµM «á¥L­Ì±N¤ñ¸û¦b¸ê®Æ®w¤§ /etc/passwd Àɤ§½s½X±K½X¡A¥u­n¥L­Ì§ä¨ì¤@­Ó ¤ñ¹ï¡A¥L­Ì ¥i¥H§ä¨ì¤@­Ó±b¸¹¤§±K½X¡C³o©Mdictionary attack¦³Ãö¡A¥B¥Î©ó¥¼ ¸g³\¥i¦s¨ú¨t²Î¨ú ±o©M®i¶}±`¥Îªº¤èªk¤§¤@¡C ¦pªG§A·Q¹L¤@­Ó 8 ½Xªº±K½X½s½X¦¨ 4096 * 13 ½Xªº¦r¦ê¡A¨º»ò¤@­Ó¥Î¦b´y­z 400,000 ¤@¯ë¤å¦r ¡B¦W¦r¡B±K½X©M²³æÅܤƪº¦r¨å±N»Ý­n 4GB µwºÐ¦s¨úªÅ¶¡¡C Àb«È»Ý­n°µªº¥u¬O¤ÀÃþ¦r¦ê¸òÀˬd ¤ñ¹ïµ²ªG¡C ¦Û±q 4GB µwºÐ¥i¥H¥H¬üª÷ 1000.00 ¥H¤U¶R¨ì«á¡A¹ï¤j¦h¼Æ¨t²ÎÀb«Èªº·N¸q¥i·Q¦Ó ª¾ ¡C ¦pªGÀb«È­º¥ýµo²{§Aªº /etc/passwd ÀÉ¡A¥L­Ì¥u»Ý­n±N¯u¥¿¥]§t¦b /etc/passwd ÀÉ salt ­Èªº¦r¨å½s½X¡A³o¤èªk¥i¥Ñ¾Ö¦³486¯Å¹q¸£©Î´X­Ó¦³ ´X¦Ê MB µwºÐªÅ¶¡ªº¤Q¨Ó·³ªº¤p«Ä¾A¥Î¡C §Y¨Ï¨S¦³«Ü¤jªººÏºÐªÅ¶¡¡A¹³ crack(1) ªº¤u¨ãµ{¦¡³q±`¥i¥H¦b¨¬°÷¨Ï¥ÎªÌ¨t²Î ¤¤¦Ü¤Ö¯}¸Ñ¤@¹ï ±K½X¡]°²³]¨t²Î¨Ï¥ÎªÌ­¿¤¹³\¬D¿ï¥L­Ì·Q­nªº±K½X¡^¡C /etc/passwd Àɤ]¥]¬A¤@¨Ç¬ÛÃö¸ê°T¡A¹³¨Ï¥ÎªÌ ID¡@©M¸s²Õ ID©Ò¨Ï¥Îªº¨t²Îµ{ ¦¡¡F¦]¦¹ /etc/passwd ÀÉ ¥²¶· «O«ù¥þ¥@¬É¥iŪ©Ê. ¦pªG§A§ïÅÜ /etc/passwd ÀÉ¥H­P©ó¨S¦³¤H¥i¥HŪ¨ú¡A§A±Nµo²{ªº²Ä¤@¥ó¨Æ¬O ls -l ©R¥O±N¨ú¥N¦WºÙ¦ÓÅã¥Ü ¨Ï¥ÎªÌ ID ¡C Shadow Suite ³z¹L±N±K½X¦s¦Ü¥t¤@­ÓÀÉ¡]³q±`¬O /etc/shadow ÀÉ¡^¨Ó¸Ñ¨M¸Ó °Ý ÃD¡C /etc/shadow Àɹï¥ô¦ó¤H³]©w¥iŪÀÉ¡A¥u¦³ root Åv­­¥i¥HŪ¼g /etc/shadow ÀÉ¡C¬Y¨Çµ{¦¡¡]¹³ xlock¡^¤£»Ý­n§ïÅܱK½X¡A¥u»Ý­n½T»{±K½X§Y¥i ¡C³o¨Çµ{¦¡ ¥i¥H¥H suid root °õ¦æ©ÎªÌ§A¥i¥H³]©w¤@­Ó¸s²Õ shadow ¥Î¨Ó°ßŪ /etc/shadow ÀÉ¡AµM«á³o¨Çµ{¦¡¥i¥H°õ¦æ sgid¡@shadow¡C ³z¹L²¾°Ê±K½X¦Ü /etc/shadow ÀÉ¡A§Ú­Ì¥i¥H¦³¤Oªº³Æ¦³Àb«È±q¦s¨ú½s½X±K½X¨ì°õ ¦æ dictionary attack ªºÃÒ¾Ú¡C °£¦¹¤§¥~¡A Shadow Suite ·s¼W³\¦h¯S¦â¡G * ³]©wÀÉ©ó³]©w¬°Ã±¤J®É¹w³](/etc/login.defs) * ·s¼W¡B­×§ï©M§R°£¨Ï¥ÎªÌ±b¸¹¸s²Õ¤§¤u¨ãµ{¦¡ * ±K½X¹Ø©R­pºâ¤Î¨ì´Á¤é * ±b¸¹¨ì´Á¤é¸òÂꦺ * ÁôÂøs²Õ±K½X (¥i¿ï¾Üªº) * ¨â­¿ªø«×±K½X (16 ¦r¤¸±K½X) [¤£«Øij¨Ï¥Î] * °w¹ï¨Ï¥ÎªÌ±K½X¿ï¾Ü¦³¸û¦nªº±±¨î * ¥i¼·±µ±K½X * ³Æ¥Î¦³®ÄÅv­­µ{¦¡ [¤£«Øij¨Ï¥Î] ¦w¸Ë Shadow Suite °^Äm¬°¦³§ó¦w¥þ¨t²Î¡A¦ý¬OÁÙ¦³¨ä¥L¤èªk¥i¥H§ïµ½ Linux ¨t ²Îªº¦w¥þ ¡A¥B³Ì²×±N¦³¤@¨t¦Cªº Linux ¦w¥þ HOWTO's ±N°Q½×¨ä¥L¦w¥þ°ò·Ç©M¬Û Ãö¤å¥óª©¥»¡E °w¹ï¥Ø«e¨ä¥L Linux ¦w¥þ¤å¥ó¸ê°T¡A½Ð°Ñ·Óºô§}¡G [7]Linux Security home page. 2.1 ¬°¦ó±z¤£­n shadow §Aªº passwd ÀÉ ¦³¤@¨Çª¬ªp¸ò³]©w¹B¥Î¦b¦w¸Ë Shadow Suite ±N ¤£¬O ¦n¥D·N¡G¡@ There are a few circumstances and configurations in which installing the Shadow Suite would NOT be a good idea: * ¥D¾÷¨S¦³¥]§t¨Ï¥ÎªÌ±b¸¹¡C * ¥D¾÷¬O¦b LAN ¤W¶]¥B¨Ï¥Îºô¸ô¸ê°TªA°È(Network Information Services, NIS)±o¨ì©Î¨ÑÀ³¨Ï¥ÎªÌ¦WºÙ©M±Kµ¹ºô¸ô¤Wªº¨ä¥L¾÷¾¹¨Ï¥Î(¨Æ¹ê¤W³oÁÙ¬O ¥i ¥H°õ¦æ¡A¦ý¬O¹ê»Ú¤W¨Ã¤£¯à¼W¥[¥ô¦ó¦w¥þ)¡C * ¾÷¾¹¬O¨Ï¥Î²×ºÝ¥D¾÷¨ÓÅçÃҨϥΪ̸g¥Ñ NFS(Network File System), NIS ©Î ¬Y¨Ç¨ä¥L¤èªk¡C * ¾÷¾¹¶]¨ä¥L³nÅéÅçÃҨϥΪ̥B¨S¦³¥ô¦ó shadow ª©¥»©Î­ì©l½X¥iÀò±o¡C 2.2 ®æ¦¡¤Æ /etc/passwd ÀÉ ¤@­Ó non-shadowed /etc/passwd Àɮ榡¦p¤U©Ò¥Ü¡G username:passwd:UID:GID:full_name:directory:shell ¨ä¤¤ username ¨Ï¥ÎªÌ(ñ¤J)¦WºÙ passwd ½s½X±K½X UID ¨Ï¥ÎªÌ½s¸¹ GID ¹w³]¦s²Õ½s¸¹ full_name ¨Ï¥ÎªÌ¥þ¦W - ¨Æ¹ê¤W³o­ÓÄæ¦ìºÙ§@ GECOS (General Electric Comprehensive Operating System) Äæ¦ì¥B¥i¥HÀx¦s¥þ¦W¥~ªº¸ê°T ¡CShadow commands and manual pages refer to this field as the comment field. directory ¨Ï¥ÎªÌ®Ú¥Ø¿ý (µ´¹ï¸ô®|) shell ¨Ï¥ÎªÌñ¤JªºÀô¹Ò (µ´¹ï¸ô®|) Á|¨Ò»¡©ú¡G username:Npge08pfz4wuk:503:100:Full Name:/home/username:/bin/sh ¡@¤¤¡ANp ¬O salt ¥B ge08pfz4wuk ¬O½s½X±K½X¡C ¤w½s½Xªº salt/password ´N ¹³ kbeMVnZM0oL7I ¥B³o¨â­Ó¦r¦ê¬O¤@¼Ëªº±K½X¡C¹ï¬Û¦P ±K½X¥i¯à¦³ 4096 ºØ¥i ¯àªº½s½X¡C(¥»½d¨Òªº±K½X¬O "passwaor"¡A³o¬O¤ñ¸û ¤£¦n ªº±K½X)¡C ¥u­n shadow suite ¤w¸g¦w¸Ë¡A /etc/passwd ÀɱN³Q´À¥N¦¨¡G username:x:503:100:Full Name:/home/username:/bin/sh ¥»½d¨Ò¤§²Ä¤GÄæ¦ì x ²{¦b¥u¬O¤@­Ó¡@place holder¡C¡@/etc/passwdÀɪº®æ¦¡ ¨Ã ¥¼¯uªº§ïÅÜ¡A¥u¬O¤£¦A¥]§t ½s½X±K½X¡C³oªí¥Ü¥ô¦óµ{¦¡¥i¥HŪ¨ú /etc/passwd ÀÉ¡A¦ý¨Ã¤£¯uªº»Ý­n½T»{±K½X¬O¤£¬O¥¿½T¦a¹B§@¡C ³o¨Ç±K½X²{¦b³Q­«·s©ñ¦b shadow ÀÉ(³q±`¬O¦b /etc/shadow ÀÉ)¡C 2.3 ®æ¦¡¤Æ shadow ÀÉ /etc/shadow ÀÉ¥]¬A¤U¦C¸ê°T¡G username:passwd:last:may:must:warn:expire:disable:reserved ¨ä¤¤ username ¨Ï¥ÎªÌ¦WºÙ passwd ½s½X±K½X last ±K½X¤W¦¸§ó°Ê¤é´Á¡A¥H±q1970¦~1¤ë1¤éºâ°_ªº¤Ñ¼Æ¥Nªí may ±K½X§ïÅÜ«e¤Ñ¼Æ must ±K½X³Ì±`¨Ï¥Î¤Ñ¼Æ warn ¥Nªí´Á­­«e´X¤Ñ´N¨Æ¥ýĵ§i¨Ï¥ÎªÌ expire ¶W¹L±K½X¹L´Á¤Ñ¼Æ«á¡A´NÃö³¬¸Ó±b¸¹ disable ±b¸¹Ãö³¬¡A¥H±q1970¦~1¤ë1¤éºâ°_ªº¤Ñ¼Æ¥Nªí reserved ¹w³ÆÄæ¦ì ¨Ì·Ó¤§«e½d¨Ò±NÅܦ¨¡G username:Npge08pfz4wuk:9479:0:10000:::: 2.4 ¦^ÅU crypt(3). ±q crypt(3) ¨Ï¥ÎªÌ¤å¥ó±o¨ì¡G "crypt ¬O±K½X¥[±K¤èµ{¦¡¡C It is based on the Data Encryption Standard algorithm with variations intended (among other things) to discourage use of hardware implementations of a key search. [The] key ¬O¨Ï¥ÎªÌ¿é¤Jªº±K½X¡C [½s½X¦r¦ê¥þ¬O NULLs] [The] salt ¬O±q [a-zA-Z0-9./] ¶°¦X¤¤¿ï¥Xªº¨â­Ó¦ì¤¸¦r¦ê¡C ¸Ó¦r¦ê¬O¥Î©óÂZ ¶Ã¦b 4096 ºØ¤£¦P¤èªk¤§¤@­Óºtºâªk¡C ³z¹L±o¨ì key ªº¨C­Ó¦ì¤¸ªº³Ì§C 7 bit[s]¡A¥i¥H«Ø¥ß 56-bit key ¡C ³o56-bit key ¬O¥Î¦b­«½Æ¥[±K¤@­Ó±`¼Æ¦r¦ê(³q±`¬O¥]§t©Ò¦³ÆFªº¦r¦ê)¡C ¶Ç¦^ ­È«ü¨ì¥[±K±K½X¬O¤@³s¦ê ¥i¦L¥X¤§13­Ó ASCII ¦r¤¸(³Ì«e­±ªº¤@¨â­Ó¦r¤¸ªí¥Ü salt ¥»¨­)¡C ³z¹L¨C¦¸ªº©I¥s¥i±N ¶Ç¦^ª½«ü¨ìÀRºA¸ê®Æ¡C ĵ§i°T®§¡G Key space ¥]¬A 2**56 §Yµ¥©ó 7.2e16 ¥i¯àªº­È¡C»P¥Î­«¤jªº¥­¦æ ¹q¸£ ±N Key space ·¥ºÉªº·j´M¬O¥i¯à¡C¹³ crack(1) ³nÅé¥Î¨Ó·j´M³¡¤Àªº¥Ñ¤H ²£¥Í¤§±K½Xªº key space ¬O¥iÀò±oªº¡C¦]¦¹¡A±K½Xªº¿ï¾Ü¦Ü¤ÖÀ³¸ÓÁקK¨Ï¥Î¤@¯ë ¦r¤Î¦W¦r¡C ¤@­Ó¥Î¨ÓÀˬd¸Ñ¶}±K½X¿ï¾Üªº passwd(1) µ{¦¡¨Ï¥Î¬O­È±o±ÀÂ˪º¡C DES ºtºâªk¥»¨­¦³¤@¨Ç¨Ï crypt(3) ¦b¥ô¦ó¨ä¥L±K½XÅv­­°Ï¹j¤¶­±«Ü®t¿ï¾Üªº¨Ï ¥Î ¤è­±¼@ÅÜ¡C¦pªG§A­pµe¨Ï¥Î crypt(3) ¤¶­±¨Ó¥[±K­pµe¡A¥H¤U´y­z¤d¸U§O³o»ò §@¡G ±o­n¤@¥»¥[±K¦n®Ñ©M¼sªxÀò±o DES µ{¦¡®w ." ¤@°_¨Ï¥Î¡C ¤j¦h Shadow Suites ¥]¬A 16 ¦ì¤¸ªº±K½Xªø«×¨â­¿¤§­ì©l½X¡C ¦b des ±M ®a«Ø ijÁקK¨Ï¥Î·í¶}©l¹ï¸û±`±K½X¥ý²³æªº½s½X¥ª¥bµM«á¥k¥b¡C¥Ñ©ó crypt ¹B§@¤èªk ¡A³o±N³y¦¨ ¸û®tªº ¦w¥þ½s½X±K½X¡C°£¦¹¤§¥~¡A¨Ï¥ÎªÌ¦³¥i¯à°O¦í 16 ¦ì¤¸±K½X ¬O ¤@¥ó¤ñ¸û®tªº¨Æ±¡¡C ¥Ø«e¦³¤¹³\Åv­­²z½×¥Î¥H¨ú¥N¬Y¨Ç§ó¦w¥þ©M¤ä´©¸ûªø±K½X(¨Ò¦p MD5 ºtºâªk)¥B«O ¦³©M crypt ¤èªk¬Û®eªºµo®i¤u§@¥¿¦b¶i¦æ¡C ¦pªG§A¥¿¦b´M§ä¤@¥»¥[±Kªº¦n®Ñ¡A«Øij¦p¤U¡G "Applied Cryptography: Protocols, Algorithms, and Source Code in C" by Bruce Schneier ISBN: 0-471-59756-2 3. ¨ú±o Shadow Suite. 3.1 Shadow Suite for Linux ªº¾ú¥v(¼È¤£Â½Ä¶) 3.2 History of the Shadow Suite for Linux DO NOT USE THE PACKAGES IN THIS SECTION, THEY HAVE SECURITY PROBLEMS The original Shadow Suite was written by John F. Haugh II. There are several versions that have been used on Linux systems: * shadow-3.3.1 is the original. * shadow-3.3.1-2 is Linux specific patch made by [8]Florian La Roche and contains some further enhancements. * shadow-mk was specifically packaged for Linux. The shadow-mk package contains the shadow-3.3.1 package distributed by John F. Haugh II with the shadow-3.3.1-2 patch installed, a few fixes made by [9]Mohan Kokal that make installation a lot easier, a patch by Joseph R.M. Zbiciak for login1.c (login.secure) that eliminates the -f, -h security holes in /bin/login, and some other miscellaneous patches. The shadow.mk package was the previously recommended package, but should be replaced due to a security problem with the login program. There are security problems with Shadow versions 3.3.1, 3.3.1-2, and shadow-mk involving the login program. This login bug involves not checking the length of a login name. This causes the buffer to overflow causing crashes or worse. It has been rumored that this buffer overflow can allow someone with an account on the system to use this bug and the shared libraries to gain root access. I won't discuss exactly how this is possible because there are a lot of Linux systems that are affected, but systems with these Shadow Suites installed, and most pre-ELF distributions without the Shadow Suite are vulnerable! For more information on this and other Linux security issues, see the [10]Linux Security home page (Shared Libraries and login Program Vulnerability) 3.3 ¦p¦ó¨ú±o Shadow Suite¡H ¥Ø«e«Øij Shadow Suite ª©¥»¥Ø«eÁÙ¬O BETA ´ú¸Õª©¡AµM«á¡A³Ìªñª©¥»¦b¥Í²£Àô ¹Ò ¬O¦w¥þªº¥B¨S¦³¥]§t©ö¨ü§ðÀ»ªº ñ¤J(login) µ{¦¡¡C ¸Ó®M¥ó(package)¨Ï¥ÎºD¨Ò©R¦W¬°¡G shadow-YYMMDD.tar.gz ¨ä¤¤ YYMMDD ¬OSuite ªºµo¦æ¤é´Á¡C ¥Ø«e BETA ´ú¸Õª©¥»¬O Version 3.3.3 ¡A¥B¥Ñ [11]Marek Michalkiewicz ºûÅ@¡C ÁÙ¥i¥H±q¸Ó³B±o¨ì¡G [12]shadow-current.tar.gz. ¤U¦Cºô¯¸¤]¥i¥H§ä¨ì¬ÛÃö¸ê°T¡G * [13]ftp://ftp.icm.edu.pl/pub/Linux/shadow/shadow-current.tar.gz * [14]ftp://iguana.hut.fi/pub/linux/shadow/shadow-current.tar.gz * [15]ftp://ftp.cin.net/usr/ggallag/shadow/shadow-current.tar.gz * [16]ftp://ftp.netural.com/pub/linux/shadow/shadow-current.tar.gz §AÀ³¸Ó¥i¥HÀò±o¥Ø«e³Ì·sªºª©¥»¡C §AÀ³¸Ó¤£­n¬O¥Î¤ñ shadow-960129 §óª©¥»¡A¦]¬°¥¦­Ì¦³ ñ¤J ªº¦w¥þ°ÝÃD¡C ©ó°Ñ¦Ò¸ê®Æ¤è­±¡A§Ú¥Î shadow-960129 Àɶi¦æ¦w¸Ë¤¶²Ð¡C ¦pªG§A¤§«e¨Ï¥Î shadow-mk ¡A§AÀ³¸Ó§ó«H³o­Óª©¥»¥B­««Ø½sĶ¡C 3.4 Shadow Suite¥]§t¤°»ò¡H Shadow Suite ¥]¬A¹ï¤U¦C¥\¯à¤§´À¥Nµ{¦¡¡G su, login, passwd, newgrp, chfn, chsh, and id ¸Ó®M¥óÁÙ¥]¬A·sµ{¦¡¡G chage, newusers, dpasswd, gpasswd, useradd, userdel, usermod, groupadd, groupdel, groupmod, groups, pwck, grpck, lastlog, pwconv, and pwunconv °£¦¹¤§¥~¡A¨ç¦¡®w¡G libshadow.a ¤]¥]¬A»Ý­n¦s¨ú¨Ï¥ÎªÌ±K½X¤§¼g©M½sĶµ{¦¡¡C µ{¦¡¤§¾Þ§@¤â¥U¤]¥]§t¦b¨ä¤¤¡C ¤]¦³¹ïñ¤Jµ{¦¡ªº configuration file ¡A¥¦±N³Q¦w¸Ë¦b /etc/login.defs ÀÉ¡C 4. ½sĶµ{¦¡ 4.1 ¸ÑÀ£ÁY ¦b±µ¦¬®M¥ó«á²Ä¤@­Ó¨BÆJ´N¬O unpacking¡C¸Ó®M¥ó¬O tar Àɮ׮榡¨Ï¥Î gzip À£ ÁY ¡A©Ò¥H­º¥ý±N¸ÓÀɮײ¾¨ì /usr/src ¡AµM«á¿é¤J¡G tar -xzvf shadow-current.tar.gz ³o±N·| unpack ¨ì¤@­Ó¥Ø¿ý¡G/usr/src/shadow-YYMMDD 4.2 ³]©w config.h ÀÉ ²Ä¤@¥ó¨Æ¬O§A»Ý­n½Æ»s Makefile ©M config.h ÀÉ¡G cd /usr/src/shadow-YYMMDD cp Makefile.linux Makefile cp config.h.linux config.h µM«á§AÀ³¸Ó¯d·N config.h ÀÉ¡C ¸ÓÀÉ®×¥]¬A¬Y¨Ç³]©w¿ï¶µªº©w¸q¡C¦pªG§A¨Ï¥Î «Øij ®M¥ó¡A§Ú«Øij§A¦b²Ä¤@¦¸³]©wÃö±¼ group shadow support¡C shadowed group passwords ¹w³]­È¬O¶}±Òªº¡C ¦b config.h ÀÉÃö¨ì³o­Ó³]©w¡A ¥B§ïÅÜ #define SHADOWGRP Åܦ¨ #undef SHADOWGRP¡C§Ú«Øij±z¤@¶}©l Ãö±¼¥¦­Ì ¡AµM«á¦pªG§A¯uªº»Ý­n group passwords ©M group administrators ®É§A¦b ¶} ±Ò¥¦­Ì©M­«·s½sĶ¡C ¦pªG§A¶}±Ò¥¦¡A §A ¥²¶· «Ø¥ß /etc/gshadow ÀÉ¡C ¶}±Òªø±K½Xªº¿ï¶µ¤]¤£«Øij¨Ï¥Î¡C ¤£­n §ïÅÜ #undef AUTOSHADOW ªº³]©w¡C AUTOSHADOW ¿ï¶µªì©l³]­p¬O¥Î¥HÅý shadow ¥i¥H¹³ function ¤@¼Ë°õ¦æ¡C²z½×¤W Å¥°_¨Ó¤£¿ù¡A¦ý¬O¨S¿ìªk¥¿½Tªº¹B§@¡C ¦pªG§A¶}±Ò³o­Ó¿ï¶µ¡A¥B³o­Óµ{¦¡¥H root Åv­­¦b°õ ¦æ¡A ¥¦·|¹³ root Åv­­°õ¦æ¤@¶µ©I¥s getpwnam() ¡AµM«áÅܧó /etc/passwd ÀÉ (¦³no-longer-shadowed ±K½X)¡C ³oÃþµ{¦¡¥]¬A chfn ©M chsh ¡C(¦pªG root ¦b©I¥s getpwnam() ¤§«e¨Ï¥Î chfn ©M chsh¡A¨Ï¥ÎªÌ±b¸¹±N ¨S¦³ ¿ìªk¯u¹ê¥B¦³®Ä¥æ©ö¡C) ¦pªG§A­n«Ø¥ß libc¡A¦P¼ËªºÄµ§i¤]¦³®Ä¡A¥¦¦³­Ó SHADOW_COMPAT §@¬Û¦Pªº¨Æ¡C ¥¦ ¤£À³¸Ó³Q¨Ï¥Î¡I¦pªG§A¶}©l±q§Aªº /etc/passwd ÀÉÂ^¨ú½s½X±K½X¡A ³o·|¬O­Ó °ÝÃD¡C ¦pªG§A¥¿¨Ï¥Î¤ñ 4.6.27 ÁÙ°ªªº libc ª©¥»¡A§A±N»Ý­n¦b config.h ©M Makefile¨â­ÓÀÉ°µ«Ü¦h§ïÅÜ¡C ¦b config.h Àɪº½s¿è©M§ïÅÜ¡G ±q¡G #define HAVE_BASENAME ¨ì¡G #undef HAVE_BASENAME µM«á¦b Makefile Àɪº§ïÅÜ¡G SOBJS = smain.o env.o entry.o susetup.o shell.o \ sub.o mail.o motd.o sulog.o age.o tz.o hushed.o SSRCS = smain.c env.c entry.c setup.c shell.c \ pwent.c sub.c mail.c motd.c sulog.c shadow.c age.c pwpack.c rad64.c \ tz.c hushed.c SOBJS = smain.o env.o entry.o susetup.o shell.o \ sub.o mail.o motd.o sulog.o age.o tz.o hushed.o basename.o SSRCS = smain.c env.c entry.c setup.c shell.c \ pwent.c sub.c mail.c motd.c sulog.c shadow.c age.c pwpack.c rad64.c \ tz.c hushed.c basename.c ³o¨Ç¥]§t¦b basename.c µ{¦¡½Xªº§ïÅܧ¡»Ý­¿¥]¬A¦b libc 4.6.27 ¤º¡C 4.3 ³Æ¥÷­ì©lµ{¦¡ ¦b shadow suite ­n§ó·s®É¡A»s§@µ{¦¡³Æ¥÷±N¬O¤@­Ó«Ü¦nªºÂI¤l¡C¦b Slackware 3.0 ¨t²Î¤¤¡A ³o¨ÇÀɮ׬O¡G * /bin/su * /bin/login * /usr/bin/passwd * /usr/bin/newgrp * /usr/bin/chfn * /usr/bin/chsh * /usr/bin/id ³o BETA ®M¥ó¤w¸g¦³­Ó Àx¦s ¦b Makefile ªº¥ØªºÀÉ¡A¦ý¬O ¦]¬°¤£¦Pªºª©¥»³q±` ±Nµ{¦¡©ñ¦b¤£¦Pªº¦a¤è¡A¦]¦¹±`³Q¤Hµû½×¡C §AÀ³¸Ó³Æ¥÷§Aªº /etc/passwd ÀÉ¡A¦ý¬O§A­n«Ü¤p¤ß¦a©R¦W¡A¤£µM¦p§Ú§A±N¥¦©ñ¦b ¬Û¦P¥Ø¿ý¡A§A±NµLªk­«¼g passwd ©R¥O¡C 4.4 °õ¦æ make §A»Ý­n¥H root Åv­­Ã±¤J¥H°õ¦æ¦w¸Ëµ{§Ç. °õ¦æ make ¨Ó½sĶ®M¥ó¤¤ªº°õ¦æÀÉ¡G make all §A¥i¯à·|¬Ý¨ìĵ§i»y¡G rcsid defined but not used. ³o¨SÃö«Y¡A ¦]¬°§@ªÌ¨Ï ¥Îª©¥»±±¨î®M¥ó¤~·|µo¥Í¡C 5. ¦w¸Ë 5.1 ¤âÃä·Ç³Æ¤@­Ó¶}¾÷¤ù ¦pªG¯uªºµo¥ÍÄY­«¿ù»~¡A¦³­Ó¶}¾÷ºÏ¤ù¤§¦³¥Îªº¡C¦pªG§A­n boot/root ¦X¨Öªº¦w ¸Ë¡A§A¥i¥H °Ñ¦Ò [17]Bootdisk-HOWTO ¥H»s§@ root ¶}¾÷¤§¶}¾÷¤ù¡C 5.2 ²¾°£½Æ»sªº man pages §A¤]À³¸Ó±N¾Þ§@¤â¥U§ó·s¡A§Y¨Ï§A«Ü¼F®`¨ì¨¬¥H¤£¥Î³Æ¥÷¦w¸Ë Shadow Suite¡A§A ¤´µM­n±N ±Nªº¾Þ§@¤â¥U²¾°£¡A¦]¬°·sª©ªº¾Þ§@¤â¥UµLªk¥¿±`ªºÂл\ª©¥»¡C §A¥i¥H¨Ï¥Î¤@­Ó²Õ¦X¡G man -aW ©R¥O ©M locate ©R¥O ´M§ä»Ý³Æ²¾°£ ªº¾Þ§@¤â ¥U¡C¦b§A°õ¦æ make install «e§ä¥X¸ûª©¥»¤ñ¸û®e©ö¡C ¦pªG§A¨Ï¥Î Slackware 3.0 ª©¥»¡AµM«á§A­n²¾°£ªº¾Þ§@¤â¥U¬O¡G * /usr/man/man1/chfn.1.gz * /usr/man/man1/chsh.1.gz * /usr/man/man1/id.1.gz * /usr/man/man1/login.1.gz * /usr/man/man1/passwd.1.gz * /usr/man/man1/su.1.gz * /usr/man/man5/passwd.5.gz ¦b /var/man/cat[1-9] ¦¸¥Ø¿ý¤]¦³¬Û¦Pªº¦W¦r»Ý­n³Q§R°£¡C 5.3 °õ¦æ make install ²{¦b§A¤w¸g·Ç³Æ­n¿é¤J¡G (¥H root Åv­­°õ¦æ) make install ³o±N¦w¸Ë³Ì·s©M§ó·sµ{¦¡¥B­×´_Àɮ׳\¥iÅv¡C¥¦¤]·|¦w¸Ë¾Þ§@¤â¥U¡C ³o¤]±N¦b¦w¸Ë®É¦Ò¼{±N Shadow Suite ¥]§tÀɮשñ¦b¥¿½Tªº¦ì¸m /usr/include/shadow ¡C ¨Ï¥Î BETA ®M¥ó¡A§A»Ý­n¤â°Ê½Æ»s login.defs ³o­ÓÀɨì /etc ³o­Ó¥Ø¿ý¤U¡A ¦Ó ¥B­n½T»{¥u¦³ root Åv­­¥i¥H§ïÅÜ¥¦¡C cp login.defs /etc chmod 700 /etc/login.defs ³o­ÓÀɮ׬O ñ¤J µ{¦¡ªº configuration file¡C §AÀ³¸ÓÀˬd¸ò½T©w³o­ÓÀɪº§ï Åܪ¬ªp¡C ³o¬O§A¨M©w­þ­Ó tty ªº root ¥i¥H±q­þ¸Ìñ¤J©M³]©w¨ä¥L¦w¥þ¤è°wªº ¦a¤è(¹³¹w³]±K½Xªº¨ì´Á¤é)¡C 5.4 °õ¦æ pwconv ±µ¤U¨Óªº¨BÆJ¬O°õ¦æ pwconv¡C ³o¤]»Ý¥H root°õ¦æ¥B³Ì¦n¦b /etc ¥Ø¿ý¤U°õ¦æ¡G cd /etc /usr/sbin/pwconv pwconv Â^¨ú§Aªº /etc/passwd ÀÉ¥B§R°£¬Y¨ÇÄæ¦ì¬°¤F«Ø¥ß¨â­ÓÀɮסG /etc/npasswd ©M /etc/nshadow. ¤@­Ó pwunconv ¤]´£¨Ñ§A«Ø¥ß¤@­Ó /etc/passwd ©M /etc/shadow ²Õ¦Xªº¥¿±` /etc/passwd ÀɮסC 5.5 ­«·s©R¦W npasswd ©M nshadow ²{¦b§A¤w¸g°õ¦æ pwconv ¡A¦Ó¥B§A¤w¸g«Ø¥ß /etc/npasswd ©M /etc/nshadow ÀÉ ®×¡C³o»Ý­n½Æ»s¨ì /etc/passwd ©M /etc/shadow ÀÉ¡C §Ú­Ì¤]»Ý­n½Æ»s­ì©l /etc/passwd ÀÉ¡A¦Ó¥B½T©w¥u¦³ root ¥i¥HŪ¥¦¡C §Ú­Ì±N¸ÓÀɮשñ¦b root ±o®Ú ¥Ø¿ý¡G cd /etc cp passwd ~passwd chmod 600 ~passwd mv npasswd passwd mv nshadow shadow §A¤]À³¸Ó½T©wÀɮתº¾Ö¦³ªÌ¸ò¦s¨úÅv­­¬O¥¿½Tªº¡C ¦pªG§A±N­n¨Ï¥Î X-Windows ¡A xlock ©M xdm ¥i¯à»Ý­nŪ¨ú shadow ÀÉ(¦ý»Ý¤£­n¼g¤J¸ÓÀÉ)¡C ¦³¨â­Ó¤èªk¥i¥H°µ¡C §A¥i¥H³]©w xlock ªº suid ¬O root (xdm ³q±`¥H root Åv ­­°õ¦æ)¡C ©ÎªÌ§A¥i¥H¨Ï root ¦¨¬° shadow ªº¸s²Õ¥i¥H¾Ö¦³ shadow ÀÉ ¡A¦ý¬O ¦b§@³o¤§«e¡A­n½T©w§A¤w¸g¦³­Ó shadow group (¥i¥H¦b /etc/group Àɬݨì)¡C ¤£À³§ï¦³¥ô¦ó¨Ï¥ÎªÌ¯uªº¦b shadow group ¡C chown root.root passwd chown root.shadow shadow chmod 0644 passwd chmod 0640 shadow §Aªº¨t²Î²{¦b¦³ shadow ªº±K½XÀÉÅo¡C §A²{¦b À³¸Ó ­«¶}¤@­Ó²×ºÝ¾÷µøµ¡©M½T»{ §A ¥i¥Hñ¤J(login)¡C ½Ð°¨¤W½T¹êªº§@³o¥ó¨Æ¡I ¦p¹L§A¤£¯à¡A¥i¯à¬Y¨Ç¨Æ±¡¦³¿ù»~Åo¡I ¬°¤F­n¦^¨ì to a non-shadowed ª¬ºA¡A ½Ð§@¤U¦C¨BÆJ¡G cd /etc cp ~passwd passwd chmod 644 passwd §A±N­«·sÀx¦s³o¨ÇÀɮרì¥ý«e§AÀx¦s¥¦­Ìªº¥¿½T¦ì¸m¡C 6. ¨ä¥L§A»Ý­n¤É¯Å(upgrade)©Î¸É±j(patch)µ{¦¡ §Y¨Ï shadow suite ¹ï¤j³¡¤À»Ý­n¦s¨ú±K½XÀɪºµ{¦¡¥i¥H¥]§t§ó·sµ{¦¡¡A¦ý¬O¤´ ¦³¤@¨Ç»Ý­n ¦s¨ú±K½XÀɪºÃB¥~µ{¦¡¦b¨t²Î¤¤¡C ¦pªG§A¥¿°õ¦æ Debian ª©¥» (©ÎªÌ§Y¨Ï§A¤£¬O)¡A§A¥i¥H§ä¨ì Debian »Ý­n rebuild ªº­ì©l½X¡G ftp://ftp.debian.org/debian/stable/source/ ³o¸`³Ñ¾lªº³¡¤À¦b°Q½×§ó·s adduser, wu_ftpd, ftpd, pop3d, xlock,xdm ©M sudo µ{¦¡¥H«K©óÅý³o¨Çµ{¦¡¤ä´© shadow suite¡C ½Ð¬Ý [18]Adding Shadow Support to a C program ³o¸`¡A¥D­n¬O¦b °Q½×¦p¦ó±N shadow ¤ä´©©ñ¨ì¨ä¥L»Ý­nµ{¦¡(ÁöµM³o¨Çµ{¦¡»Ý­n¥H SUID root °õ¦æ©Î SGID shadow »Ý¥¿½T¦s¨ú shadow ÀÉ)¡C 6.1 Slackware adduser µ{¦¡ Slackware ª©¥»¥]§t¤@­Ó·s¼W¨Ï¥ÎªÌªº¥æ¤¬µ{¦¡¥s°µ /sbin/adduser¡C¸Óµ{¦¡ªº shadow ª©¥»¥i¥H¦b [19]ftp://sunsite.unc.edu/pub/Linux/system/ Admin/accounts/adduser.shadow-1.4.tar.gz§ä¨ì¡C §Ú«Ü¹ªÀy§A¨Ï¥Î Shadow Suite ¨ÑÀ³ªºµ{¦¡(¨Ò¦puseradd, usermod, ©M userdel) ¨Ó¨ú¥N slackware ªºadduser µ{¦¡¡C ¥¦­Ì¥u»Ýªá¤@ÂI®É¶¡¾Ç²ß ¡A¦ý ¬O¥¦±N­È±oªº¡A¦]¬°§A¥i¥H¬Ý¨ì§ó¦h±±¨î©M¦b¥¿½T®i²{Âê¦í /etc/passwd ©M /etc/shadow ªºÀÉ®×(adduser ´N¨S¦³¿ìªkÅo)¡C °Ñ¦Ò [20]Putting the Shadow Suite to use ¸Ó¸`±o¨ì§ó¦h¬ÛÃö¸ê°T¡C ¦ý¬O¦pªG§A¤w¸g¾Ö¦³Åo¡A±µ¤U¨Ó¬O§A­n°µªº³¡¤À¡G tar -xzvf adduser.shadow-1.4.tar.gz cd adduser make clean make adduser chmod 700 adduser cp adduser /sbin 6.2 wu_ftpd Server ¤j³¡¤Àªº Linux ¨t²Î³£¦³ wu_ftpd server¡C ¦pªG§Aªºª©¥»¨S¦³ªþ±a shadow ¦w ¸Ë¡A ¨º»ò§Aªº wu_ftpd ´N¨S¦³¿ìªk¹ï shadow ½sĶ¡C wu_ftpd ¬O±q inetd/tcpd ¶}©l¥B¥H root Åv­­°õ¦æªºµ{¦¡¡C ¦pªG§A¥¿¦b¶]¤@­Óª©ªº wu_ftpd daemon¡A µL½×¦p¦ó§A±N­n§ó·s¥¦¦]¬°¸ûª©¥»¦³ bug ±N¦M¤Î root Åv ­­¡C(°Ñ¦Ò [21]Linux security home page ±o¨ì§ó¦h¬ÛÃö¸ê°T)¡C ©¯¹Bªº¬O§A¥u»Ý­n¨úªº¦³´O¤J shaow ªº­ì©l½X©M­«·s½sĶ´N¥i¥HÅo¡I ¦pªG§A¤£¬O¥¿¦b°õ¦æ ELF ¨t²Î¡A wu_ftp server ¥i¥H±q Sunsite ºô§} [22]wu-ftp-2.4-fixed.tar.gz §ä¨ì¡C ·í§AÀò±o³o­Ó server¡A§â¥¦©ñ¦b /usr/src¥Ø¿ý¡AµM«á¿é¤J¡G cd /usr/src tar -xzvf wu-ftpd-2.4-fixed.tar.gz cd wu-ftpd-2.4-fixed cp ./src/config/config.lnx.shadow ./src/config/config.lnx µM«á½s¿è ./src/makefiles/Makefile.lnx¡A©M§ïÅÜ LIBES = -lbsd -support ³o¤@¦æ¨ì¡G LIBES = -lbsd -support -lshadow ²{¦b§A¤w¸g·Ç³Æ¦n°õ¦æ script «Ø¥ß¸ò¦w¸Ë¡G cd /usr/src/wu-ftpd-2.4-fixed /usr/src/wu-ftp-2.4.fixed/build lnx cp /usr/sbin/wu.ftpd /usr/sbin/wu.ftpd.old cp ./bin/ftpd /usr/sbin/wu.ftpd ³o¬O¥Î¦b Linux shadow configuration file¡B½sĶ©M¦w¸Ë server¡C ¦b§Úªº Slackware 2.3 ¨t²Î¡A§Ú¤]»Ý­n¦b°õ¦æ«e§@¤U¦C¨BÆJ¡G build: cd /usr/include/netinet ln -s in_systm.h in_system.h cd - ¦b ELF ¨t²Î¤U·|¦³½sĶ°ÝÃDªº³ø§i¡A¦ý¬O¤U¤@ª©ªº Beta ª©«h¥i¥H¥¿½Tªº°õ¦æ¡C ¥i¥H±q [23]wu-ftp-2.4.2-beta-10.tar.gz §ä¨ì¡C ·í§AÀò±o³o­Ó server¡A§â¥¦©ñ¦b /usr/src¥Ø¿ý¡AµM«á¿é¤J¡G cd /usr/src tar -xzvf wu-ftpd-2.4.2-beta-9.tar.gz cd wu-ftpd-beta-9 cd ./src/config µM«á½s¿è config.lnx¡A©M§ïÅÜ¡G #undef SHADOW.PASSWORD ³o¤@¦æ¨ì¡G #define SHADOW.PASSWORD µM«á¡A cd ../Makefiles ¥B½s¿è Makefile.lnx ÀÉ©M§ïÅÜ LIBES = -lsupport -lbsd # -lshadow ³o¤@¦æ¨ì¡G LIBES = -lsupport -lbsd -lshadow µM«á«Ø¥ß(build)©M¦w¸Ë(install)¡G cd .. build lnx cp /usr/sbin/wu.ftpd /usr/sbin/wu.ftpd.old cp ./bin/ftpd /usr/sbin/wu.ftpd µù¡G§AÀ³¸ÓÀˬd§Aªº /etc/inetd.conf ÀɨӽT»{§Aªº wu.ftpd server ¬O¤£¬O¯u ªº¬¡µÛ¡C ¦³¨Çª©¥»¥i¯à±N server daemons ©ñ¦b¤£¦Pªº¦a¤è©Î¥Î¤£¦Pªº¦W¦rªí¥Ü ¡C 6.3 ¼Ð·Ç ftpd ¦pªG§A¥¿¦b°õ¦æ¼Ð·Çªº ftpd server¡A§Ú±N«Øij§A§ó·s wu_ftpd server¡C Â÷¶} ¤W­zªº bug ¡A¨t²Î·|¤ñ¸û¦w¥þ¡C ¦pªG§A°í«ù¦b¼Ð·Ç¼Ò¦¡¡A©ÎªÌ§A»Ý­n NIS ¤ä´©¡A¦b Sunsite [24]ftpd-shadow-nis.tgz ¦³°Ñ¦Ò¸ê®Æ¡C 6.4 pop3d (Post Office Protocol 3) ¦pªG§A»Ý­n¤ä´©²Ä¤Tª© Post Office Protocol (POP3)¡A§A±N»Ý­n­«·s½sĶ pop3d µ{¦¡¡C pop3d ¥i¥H³z¹L inetd/tcpd ¥H root Åv­­¥¿±`ªº°õ¦æ¡C ±q Sunsite ¦³¨â­Óª©¥»¥i¥HÀò±o¡G [25]pop3d-1.00.4.linux.shadow.tar.gz ©M [26]pop3d+shadow+elf.tar.gz ³o¨â­Ó³£«Ü²³æ¥i¥H¦w¸Ë¡C 6.5 xlock ¦pªG§A¦w¸Ë shadow suite¡AµM«á°õ¦æ X Windows System ©M lock ¿Ã¹õ¨S¥H§ó·s §Aªº xlock ÀÉ¡A §A±N¥²¶·¨Ï¥Î CNTL-ALT-Fx ¥h¤Á´« ¥t¤@­Ó tty¡Añ ¤J(login)©M±þ±¼(kill) xlock process (©Î¨Ï¥Î CNTL-ALT-BS ±þ±¼ X server) ¡C «Ü©¯¹Bªº³o¤]«Ü®e©ö¥i¥H§ó·s§Aªº xlock µ{¦¡¡C ¦pªG§A¥¿°õ¦æ XFree86 Versions 3.x.x¡A¥B¥¿¥¿½T¨Ï¥Î xlockmore (¬O¤@­Ó«Ü´Î ªº¿Ã¹õ«OÅ@µ{¦¡). ³o­Ó®M¥ó¤ä´© shadow¡A¥u­n­«·s½sĶ§Y¥i¡C¦pªG§A¦³¥ô¦ó¸û ¦Ñªº xlock ª©¥»¡A§Ú«Øij§A§ó·s¤U¦Cª©¥»¡G xlockmore-3.5.tgz ¥i¥H±q [27]ftp://sunsite.unc.edu/pub/Linux/X11/xutils/screensavers/xlockmore- 3.7.tgz ºô¯¸Àò±o¡C °ò¥»¤W³o¬O§A©Ò­nªº¡C Â^¨ú xlockmore-3.7.tgz ¡A¨Ã±N¥¦©ñ¦b /usr/src ¥Ø¿ý¨Ã¸ÑÀ£ÁY¡G tar -xzvf xlockmore-3.7.tgz ½s¿è³o­ÓÀÉ¡G /usr/X11R6/lib/X11/config/linux.cf, ©M§ïÅÜ #define HasShadowPasswd NO ³o¤@¦æ¨ì¡G #define HasShadowPasswd YES µM«á«Ø¥ß¥i°õ¦æÀÉ¡G cd /usr/src/xlockmore xmkmf make depend make µM«á·h²¾©Ò¥HÀɮר쥿½T¥Ø¿ý¥B§ó·sÀÉ®×¾Ö¦³ªÌ¤Î°õ¦æÅv­­¡G cp xlock /usr/X11R6/bin/ cp XLock /var/X11R6/lib/app-defaults/ chown root.shadow /usr/X11R6/bin/xlock chmod 2755 /usr/X11R6/bin/xlock chown root.shadow /etc/shadow chmod 640 /etc/shadow §Aªº xlock ±N¥i¥H¥¿½Tªº¹B§@Åo¡I 6.6 xdm xdm ¬O¤@­Ó¥i¥Hªí¥Ü¦b X-Windows ñ¤Jµe­±ªºµ{¦¡¡C¬Y¨Ç¨t²Î¶}©l xdm ·í¨t²Î ³Q§iª¾¹D¤@­Ó¯S©wªº°õ¦æ¤ô·Ç(°Ñ¦Ò /etc/inittab)¡C ¦ñÀHµÛ Shadow Suite ¦w¸Ë¡A xdm »Ý­n³Q§ó·s¡C «Ü©¯¹Bªº³o¤]«Ü®e©ö¥i¥H§ó·s §Aªº xdm µ{¦¡¡C xdm.tar.gz ¥i¥H±q¤U¦Cºô§}Àò±o¡G [28]ftp://sunsite.unc.edu/pub/Linux/X11/xutils/xdm.tar.gz Â^¨ú xdm.tar.gz ÀɨñN¥¦©ñ¦b /usr/src¥Ø¿ýµM«á¸ÑÀ£ÁY¡G tar -xzvf xdm.tar.gz ½s¿è³o­ÓÀÉ¡G /usr/X11R6/lib/X11/config/linux.cf¡A¥B§ïÅÜ #define HasShadowPasswd NO ³o¤@¦æ¨ì¡G #define HasShadowPasswd YES µM«á«Ø¥ß¥i°õ¦æÀÉ¡G cd /usr/src/xdm xmkmf make depend make µM«á·h²¾©Ò¦³ÀÉ®×¥¿½T¥Ø¿ý¡G cp xdm /usr/X11R6/bin/ xdm ¥H root Åv­­¦b°õ¦æ¡A©Ò¥H§A¤£»Ý­n§ïÅÜÀɮצs¨úÅv­­¡C 6.7 sudo sudo µ{¦¡¤¹³\¨t²ÎºÞ²z­ûÅý¨Ï¥ÎªÌ¥i¥H¥H root Åv­­¥¿±`ªº°õ¦æµ{¦¡¡C ³o¬O«D ±`¤è«Kªº¦]¬°¥¦¥i¥H­­¨îºÞ²zªÌ°õ¦æ root ±b¸¹¥»¨­Åv­­¡AÁÙ¥i¥H¤¹³\¨Ï¥ÎªÌ§@ ¹³ mounte drives ªº¨Æ±¡¡C sudo »Ý­nŪ¨ú±K½X¦]¬°¦b°õ¦æ®É»Ý½T»{¨Ï¥ÎªÌ±K½X¡C sudo ¤w¸g°õ¦æ SUID root¡A ©Ò¥H¦s¨ú /etc/shadow ÄÒ¤£¬O°ÝÃD¡C sudo ¤ä´© shadow suite ¥i¦b¤U¦Cºô§}¨ú±o¡G [29]ftp://sunsite.unc.edu/pub/Linux/system/Admin/sudo-1.2-shadow.tgz ĵ§i¡G·í§A¦w¸Ë sudo §Aªº /etc/sudoers ÀɱN¨ú¥N¹w³]­È¡A©Ò¥H§A »Ý­n³Æ¥÷­ì ©lµ{¦¡¡C¦pªG§A¦³®a¥ô¦ó³]©w¦b¹w³]µ{¦¡¡A§A¥i¯à­n½s¿è Makefile ¥B²¾°£½Æ»s ¸ÓÀɨì /etc ªº³o¦æ¡C ¸Ó®M¥ó¤w¸g¹ï shadow ¶i¦æ³]©w¡A©Ò¥H¥u­n­«·s½sĶ¸Ó®M¥ó§Y¥i (§â¥¦©ñ¦b /usr/src ¥Ø¿ý)¡G cd /usr/src tar -xzvf sudo-1.2-shadow.tgz cd sudo-1.2-shadow make all make install 6.8 imapd (E-Mail [pine package]) imapd ¬O¤@­Ó¹³ pop3d ªº email server¡C imapd ÀHµÛ Pine E-mail ®M¥óµo¥Í ¡C ¨ä¾Þ§@¤â¥U¦b¤¶²Ð¸Ó®M¥ó®É§Y¥]§t shadow ¤ä´©¡CµM¦Ó¡A§Úµo²{³o¤£¥þµM¥¿½T ¡C ¦A¥[¤W¦b½sĶ®É¥[¤W libshadow.a ¨ç¦¡®w ©M¸Ó®M¥óµ²¦X build script / Makefile ¬O«D±`¤£®e©öªº¡C©Ò¥H¹ï imapd ¥[¤J shadow ¤ä´©¬O¤£¤Ó¥i¯àªº¡C ¦pªG¦³¥ô¦óµª®×¡A¥i¥H Email µ¹§Ú¡A§Ú·|±N¸Ó¸Ñµª©ñ¨ì³o¸Ì¡C 6.9 pppd (Point-to-Point Protocol Server) pppd server ¥i¥H¨Ï¥Î´XºØÅv­­³]©w¡G Password Authentication Protocol (PAP) ©M Cryptographic Handshake Authentication Protocol (CHAP)¡C pppd server ±q /etc/ppp/chap-secrets ©M/©Î /etc/ppp/pap-secrets ÀÉŪ¨ú±K½X¦r ¦ê¡C ¦pªG§A¥¿¨Ï¥Î¹w³] pppd ªº°õ¦æ¡A´N¨S¦³¥²­n¦A­«·s¦w¸Ë pppd ¡C pppd ¥H¤¹³\§A¨Ï¥Î login °Ñ¼Æ¡C ¦pªG login ¿ï¶µ³Q¿ï¨ú¡A pppd ±N¨Ï¥Î /etc/passwd Àɪº±b¸¹±K½Xµ¹ PAP. ·íµM¦b¤£¤[±K½XÀÉ·|¬O shadowedm ¡Cpppd-1.2.1d Àɤw¸g¥[¤J¹ï shadow ªº¤ä´©¡C ¤U¤@¸`¥[¤J¤ä´© shadow ªº½d¨Ò¬O°w¹ï pppd-1.2.1d (¤@­Ó¸û¦Ñª©¥»ªº pppd). pppd-2.2.0 ª©´N¤w¸g¥]¬A shadow ¤ä´©Åo¡C 7. ±N Shadow Suite ©ñ¶i¨Ó¨Ï¥Î¡C ³o¸`´y­z§A»Ý­nª¾¹D¦³¨Çµ{¦¡¦b¦w¸Ë®É´N¤w¸g¦³ Shadow Suite¡C ¤j³¡¤Àªº¸ê°T ¦b¾Þ§@¤â¥U¥i¥H§ä¨ì¡C 7.1 ·s¼W¡B­×§ï©M§R°£¨Ï¥ÎªÌ Shadow Suite ·s¼W¤U¦C«ü¥O¥Î¨Ó·s¼W¡B­×§ï©M§R°£¨Ï¥ÎªÌ¡C ³o¤]¬O¥i¥H¦w¸Ë adduser µ{¦¡¡C useradd useradd ¨Ï¥O¥i¥Î¦b¨t²Î¤¤·s¼W¨Ï¥ÎªÌ¡C §A¤]¥i¥H±Ä¥Î¦¹«ü¥O¨Ó§ïÅܹw³]¦r¦ê¡C §AÀ³¸Ó°µªº²Ä¤@¥ó¨Æ¬OÀˬd¹w³]­È³]©w©M°w¹ï§Aªº¨t²Î¶i¦æ§ïÅÜ¡G useradd -D _________________________________________________________________ GROUP=1 HOME=/home INACTIVE=0 EXPIRE=0 SHELL= SKEL=/etc/skel _________________________________________________________________ ¹w³]­È¤£¥þ¬O§A­nªº¡A©Ò¥H¦pªG§A¶}©l·s¼W¨Ï¥ÎªÌ¡A§A¥²¶·¸Ô¾\¨C­Ó¨Ï¥ÎªÌ¸ê°T ¡C ¦Ó¥B¡A§Ú­Ì¥i¯à©MÀ³¸Ó§ïÅܳ]©w­È¡C ¦b§Úªº¨t²Î¤W¡G * §Ú­n¹w³]¸s²Õ¬O 100 * §Ú­n±K½X¨C¨ì 60 ¤Ñ´N¨ì´Á * §Ú¤£­nÂê¦í±b¸¹¦]¬°±K½X·|¨ì´Á * §Ú­n¹w³] shell ¬O /bin/bash ¬°¤F³o¨Ç§ïÅÜ¡A§Ú­n¨Ï¥Î¡G useradd -D -g100 -e60 -f0 -s/bin/bash ²{¦b°õ¦æ useradd -D ±N±o¨ì¡G _________________________________________________________________ GROUP=100 HOME=/home INACTIVE=0 EXPIRE=60 SHELL=/bin/bash SKEL=/etc/skel _________________________________________________________________ ¾¨ºÞ¨Ì·Ó§A»Ý­n­×§ï¡A¹w³]­È±N¦s¦b /etc/default/useradd. ¥ý¦b§A¥i¥H¨Ï¥Î useradd ¨Ó·s¼W¨t²Î¨Ï¥ÎªÌ¡CÁ|¨Ò»¡©ú¡A·s¼W¤@¨Ï¥ÎªÌ fred ¨Ï ¥Î¹w³]­È¤è¦¡¦p¤U¡G useradd -m -c "Fred Flintstone" fred ³o±N¦b /etc/passwd Àɤ¤ªº¤@¦æ«Ø¥ß¦p¤U¡G fred:*:505:100:Fred Flintstone:/home/fred:/bin/bash ¥B¦b /etc/shadow Àɤ¤ªº¤@¦æ«Ø¥ß¦p¤U¡F fred:!:0:0:60:0:0:0:0 fredªº®Ú¥Ø¿ý±N³Q«Ø¥ß¥B /etc/skel ªº¤º®e±N³Q½Æ»s¦]¬°«ü¥O¥y¤¤¦³ -m ³]©w¡C ¦]¬°§Ú­Ì¨Ã¥¼¸Ô­z UID¡A¨t²Î·|ª½±µ´M§ä¤U¤@­Ó¥iÀò±oªº½s¸¹¡C fredªº±b¸¹³Q«Ø¥ßÅo¡A¦ý¬O fred ¤´µM¤£¯àñ¤Jª½¨ì§Ú­Ì¤£¦AÂê¦í(unlock)³o­Ó ±b¸¹¡C ³z¹L§ó§ï±K½X§¹¦¨ unlock ±b¸¹¡A¤èªk¦p¤U¡G passwd fred _________________________________________________________________ Changing password for fredó Enter the new password (minimum of 5 characters) Please use a combination of upper and lower case letters and numbers. New Password: ******* Re-enter new password: ******* _________________________________________________________________ ²{¦b /etc/shadow ÀɱN¥]§t¡G fred:J0C.WDR1amIt6:9559:0:60:0:0:0:0 ¥B fred ±N¥i¥Hñ¤J©M¨Ï¥Î¸Ó¨t²Î¡C useradd ©M¨ä¥Lªþ±a Shadow Suite ¤ñ¸û¦n ªº¦a¤è¬O¥i¥H¦Û°Ê§ïÅÜ /etc/passwd ©M /etc/shadow ¡C ©Ò¥H¦pªG§A¥¿¦b·s¼W¤@ ­Ó¨Ï¥ÎªÌ¡A ¥B¥t¤@­Ó¨Ï¥ÎªÌ¥¿¦b§ó§ï±K½X¡A³o¨â­Ó¾Þ§@³£¥i¥H¥¿½Tªº°õ¦æ¡C §A¨Ï¥Î´£¨Ñªº«ü¥O¤ñª½±µ¦s¨ú /etc/passwd ©M /etc/shadow ÀÉÁÙ¦n¡C ¦pªG§A¥¿ ½s¿è /etc/shadow ÀÉ¡A¥B¦³­Ó¨Ï¥ÎªÌ¦b§A½s¿è®É­n§ïÅÜ¥Lªº±K½X¡A µM«á§AÀx¦s ½s¿èµ²ªG¡A³o­Ó¨Ï¥ÎªÌªº±K½X±N·|¿ò¥¢±¼¡C ³o¸Ì¬O¨Ï¥Î useradd ©M passwd ·s¼W¨Ï¥ÎªÌªº¤@¨Ç interactive script ¡G _________________________________________________________________ #!/bin/bash # # /sbin/newuser - A script to add users to the system using the Shadow # Suite's useradd and passwd commands. # # Written my Mike Jackson as an example for the Linux # Shadow Password Howto. Permission to use and modify is expressly granted. # # This could be modified to show the defaults and allow modification similar # to the Slackware Adduser program. It could also be modified to disallow # stupid entries. (i.e. better error checking). # ## # Defaults for the useradd command ## GROUP=100 # Default Group HOME=/home # Home directory location (/home/username) SKEL=/etc/skel # Skeleton Directory INACTIVE=0 # Days after password expires to disable account (0=never) EXPIRE=60 # Days that a passwords lasts SHELL=/bin/bash # Default Shell (full path) ## # Defaults for the passwd command ## PASSMIN=0 # Days between password changes PASSWARN=14 # Days before password expires that a warning is given ## # Ensure that root is running the script. ## WHOAMI=`/usr/bin/whoami` if [ $WHOAMI != "root" ]; then echo "You must be root to add news users!" exit 1 fi ## # Ask for username and fullname. ## echo "" echo -n "Username: " read USERNAME echo -n "Full name: " read FULLNAME # echo "Adding user: $USERNAME." # # Note that the "" around $FULLNAME is required because this field is # almost always going to contain at least on space, and without the "'s # the useradd command would think that you we moving on to the next # parameter when it reached the SPACE character. # /usr/sbin/useradd -c"$FULLNAME" -d$HOME/$USERNAME -e$EXPIRE \ -f$INACTIVE -g$GROUP -m -k$SKEL -s$SHELL $USERNAME ## # Set password defaults ## /bin/passwd -n $PASSMIN -w $PASSWARN $USERNAME >/dev/null 2>&1 ## # Let the passwd command actually ask for password (twice) ## /bin/passwd $USERNAME ## # Show what was done. ## echo "" echo "Entry from /etc/passwd:" echo -n " " grep "$USERNAME:" /etc/passwd echo "Entry from /etc/shadow:" echo -n " " grep "$USERNAME:" /etc/shadow echo "Summary output of the passwd command:" echo -n " " passwd -S $USERNAME echo "" _________________________________________________________________ ·s¼W¨Ï¥ÎªÌ¬O¥Î script ¤ñª½±µ½s¿è /etc/passwd / /etc/shadow ÀɩΨϥΠ¹³ Slackware ªº adduser µ{¦¡ÁÙ­n¦n¡C »Ý­n§ó¦h useradd ¸ê°T½Ð°Ñ·Ó½u¤W¾Þ§@¤â¥U¡C usermod usermod µ{¦¡¬O¥Î¦b­×§ï¨Ï¥ÎªÌ¸ê°T¡C ¥¦ªº°Ñ¼Æ¨Ï¥Î©M useradd µ{¦¡Ãþ¦ü¡C ¦pªG§A­n§ó·s fred ªº shell¡A§A­n§@¤U¦C¨BÆJ¡G usermod -s /bin/tcsh fred ²{¦b fred ªº /etc/passwd ÀɱNÅܦ¨¡G fred:*:505:100:Fred Flintstone:/home/fred:/bin/tcsh ¦pªG­n¨Ï fred ªº±b¸¹¨ì´Á¤é¬° 09/15/97¡G usermod -e 09/15/97 fred ²{¦b fred ¦b /etc/shadow ªºÄæ¦ìÅܦ¨¡G fred:J0C.WDR1amIt6:9559:0:60:0:0:10119:0 »Ý­n§ó¦h usermod ¸ê°T½Ð°Ñ·Ó½u¤W¾Þ§@¤â¥U¡C userdel userdel ¥Î¦b§R°£¨Ï¥ÎªÌ¡A¨Ï¥Î¤èªk¬°¡G userdel -r username -r °Ñ¼Æ¥i¥H±N¸Ó¨Ï¥ÎªÌ®Ú¥Ø¿ý¥þ³¡²¾°£¡C¦ì¦b´Á«Ý¥Ø¿ýªºÀɮ׫h»Ý¤â°Ê²¾°£¡C ¦pªG§A¥u¬O­n²³æªºÂê¦í±b¸¹¦Ó¨S¦³­n§R°£¥¦¡A«Øij§A¨Ï¥Î passwd «ü¥O¡C 7.2 passwd «ü¥O©M passwd ¦Ñ¤Æ passwd «ü¥O«Ü©úÅã¨Ï¥Î¦b§ïÅܱK½X¡A°£¦¹¤§¥~¡A ¥i¥Ñ root ¨Ï¥Î¦b¡G * Lock ©M unlock ±b¸¹ (-l and -u) * ³]©w±K½X¦Xªkªº³Ì¤j¤Ñ¼Æ (-x) * ³]©w±K½X§ïÅܶ¡ªº³Ì¤p¤Ñ¼Æ (-n) * ³]©w±K½X¨ì´ÁªºÄµ§i¤Ñ¼Æ (-w) * ³]©w¦b±b¸¹¥¼³QÂꦺ±K½X¨ì´Á«áªºÄµ§i¤Ñ¼Æ (-i) * ¤¹³\¬d¸ß±b¸¹¸ê°T (-S) Á|¨Ò»¡©ú¡A¦pªG­nÂꦺ fred ±b¸¹¡G passwd -S fred fred P 03/04/96 0 60 0 0 ³oªí¥Ü fred ªº±K½X¬O¦³®Äªº¡A¥¦¦b 03/04/96 ³Q­×§ï¥B¥ô¦ó®É¶¡³£¥i³Q­×§ï ¡A fred ±N¤£·|¦¬¨ìĵ§i¥B±b¸¹±N¤£·|¦]±K½X¨ì´Á¦ÓÃö³¬¡C ³oªí¥Ü¦pªG fred ¦b±K½X¨ì´Á«áñ¤J¡A¥¦±N³Q­n¨D¥Î¤@­Ó·s±K½Xñ¤J¡C ¦pªG§Ú­Ì¨M©w­nĵ§i fred ¦b±K½X¹L´Á«e 14 ¤Ñ¡A¥BÅý¥¦ªº±b¸¹¦b¨ì´Á«á14¤Ñĵ §i¡A §Ú­Ì»Ý­n§@¤U¦C¨BÆJ¡G passwd -w14 -i14 fred ²{¦b fred §ïÅܬ°¡G fred P 03/04/96 0 60 14 14 »Ý­n§ó¦h passwd ¸ê°T½Ð°Ñ·Ó½u¤W¾Þ§@¤â¥U¡C 7.3 login.defs ÀÉ /etc/login ÀɬO¹ï login µ{¦¡ªº configuration file ¥B ¹ï Shadow Suite¡C /etc/login ¥]§t±q¹w³]­È±K½X§ïÅܪºÅX°Ê³]©w¡C /etc/login.defs ÀɬO¤@­Ó«Ü¦nªº¤å¥óÀÉ¡AµM¦Ó¤´¦³¨Ç¨Æ±¡­nª`·N¡G * It contains flags that can be turned on or off that determine the amount of logging that takes place. * It contains pointers to other configuration files. * It contains defaults assignments for things like password aging. ¸ò¥h¤W­z§A¥i¥Hµo²{³o¬O¤@­Ó­«­nÀÉ¡A¥B§AÀ³¸Ó½T»{¥Ø«e³]©w¤Î§A±N¹ï§A¨t²Îªº ³]©w¤º®e¡C 7.4 ¸s²Õ±K½X /etc/groups ÀÉ¥]¬A¤¹³\¬O¥ÎªÌ¦s¨ú¸s²Õ¤§±K½X¡C ¦pªG§A©w¸q SHADOWGRP ¦b /usr/src/shadow-YYMMDD/config.h ÀɱN¶}±Ò¸Ó¥\¯à¡C ¦pªG§A©w¸q¸Ó±`¼Æ¥B½sĶ¥¦¡A§A»Ý«Ø¥ß¤@­Ó /etc/gshadow ÀɨӫO¦s¸s²Õ±K½X ©M ¸s²ÕºÞ²zªÌ¸ê°T¡C ·í§A«Ø¥ß /etc/shadow¡C§A¨Ï¥Î¤@­Ó©I¥sµ{¦¡¥s°µ pwconv¡A ¸Óµ{¦¡¤£·|«Ø¥ß /etc/gshadow ÀÉ¡A¦ý¬O³o¨SÃö«Y¡A¥u­n§A¦Û¦æ«Ø¥ß§Y¥i¡C ¬°¤F«Ø¥ß°_©l /etc/gshadow ÀÉ­n°õ¦æ¤U¦C¨BÆJ¡G touch /etc/gshadow chown root.root /etc/gshadow chmod 700 /etc/gshadow ¨C¦¸§A«Ø¥ß¤@­Ó·s¸s²Õ¡A¥¦­Ì·|³Q¥[¨ì /etc/group ©M /etc/gshadow ÀÉ¡C ¦pªG §A³z¹L·s¼W©Î²¾°£¨Ï¥ÎªÌ¨Ó­×§ï¸s²Õ©Î§ïÅܸs²Õ±K½X¡A/etc/gshadow Àɳ£±N³Q§ï ÅÜ¡C groups, groupadd, groupmod, ©M groupdel µ{¦¡¬O¥Î¨Ó¨ÑÀ³ Shadow Suite ³¡ ¤À¥i¥HÅܧó¸s²Õ¡C /etc/group Àɮ榡¦p¤U¡G groupname:!:GID:member,member,... ¨ä¤¤¡G groupname The name of the group ! The field that normally holds the password, but that is now relocated to the /etc/gshadow file. GID The numerical group ID number member List of group members /etc/gshadow Àɮ榡¦p¤U¡G groupname:password:admin,admin,...:member,member,... ¨ä¤¤¡G groupname The name of the group password The encoded group password. admin List of group administrators member List of group members gpasswd «ü¥O¬O¥Î¦b·s¼W©Î²¾°£ºÞ²zªÌ©M¸s²Õ¦¨­û¡C root ©Î¨ä¥L¦b ¸s²ÕºÞ²zªÌ ¤H­û¥i·s¼W©Î²¾°£¸s²Õ¦¨­û¡C ¸s²Õ±K½X¥i¥H³z¹L passwd «ü¥O§ïÅÜ¡A»Ý³z¹L root ©Î¦b¸Ó¸s²ÕºÞ²zªÌ¦³Åv­­ªº ±b¸¹¤è¥i­×§ï¡C Despite the fact that there is not currently a manual page for gpasswd, typing gpasswd without any parameters gives a listing of options. It's fairly easy to grasp how it all works once you understand the file formats and the concepts. 7.5 Àˬdµ{¦¡¤@­P©Ê pwck pwck µ{¦¡´£¨Ñ¦b /etc/passwd ©M /etc/shadow Àɪº¤@­P©ÊÀˬd¡C ¥¦±NÀˬd¨C ­Ó¨Ï¥ÎªÌ¦WºÙ¥B¨Ì·Ó¤U¦C¨BÆJ½T»{¡G * the correct number of fields * unique user name * valid user and group identifier * valid primary group * valid home directory * valid login shell ¥¦¤]·|ĵ§i¨S¦³±K½Xªº±b¸¹¡C ¦b¦w¸Ë Shadow Suite «á°õ¦æ pwck ¬O¤@­Ó«Ü¦nªºÂI¤l¡C ¥¦¤]¥i¥H¨C¶g©Î¨C¤ë¶g ´Á©Êªº°õ¦æ¡C ¦pªG§A¨Ï¥Î -r °Ñ¼Æ¡A§A¥i¥H¥Î cron ¨Ó°õ¦æ¥B¦¬¨ì¹q¤l¶l¥ó³ø§i grpck grpck Àˬd /etc/group ©M /etc/gshadow Àɤ@­P©Êªºµ{¦¡¡C ¥¦§@¤U¦CÀˬd¡G * the correct number of fields * unique group name * valid list of members and administrators ¥¦¤]¦³ -r °Ñ¼Æ¦Û°Ê²£¥Í³øªí¡C 7.6 Dial-up ±K½X Dial-up ±K½X¬O¥t¤@­Ó¹ï¨t²Î¨¾¿mªº¿ï¶µ¦C¡A¸Ó¨t²Î¤¹³\¼·±µ¦s¨ú¡C ¦pªG§A¦³¤@ ­Ó¨t²Î¤¹³\³\¦h¤H°Ï°ìºô¸ô³sµ²¡A¦ý¬O§A·Q­­¨î¼·±µªºÅv­­¡A¨º§A»Ý¨Ï¥Î dial-up ±K½X¡C ¬°¤F­n¶}±Ò dial-up ±K½X¡A§A¥²¶·½s¿è /etc/login.defs ÀÉ¥B ½T©w±N DIALUPS_CHECK_ENAB ³]©w¬° yes. ¦³¨â­ÓÀÉ®×¥]¬A dial-up ¸ê°T¡A /etc/dialups ¥]¬A ttys (one per line, with the leading "/dev/" removed)¡C ¦pªG tty ¦³³Q¦C¥X¡A dial-up ªí¥Ü¤w ¸g³QÀˬd¡C ²Ä¤G­ÓÀɬO /etc/d_passwd ¡C ³o­ÓÀÉ¥]¬A shell ¥þ³¡¦Xªk¸ô®|¦WºÙ¡C ¦pªG¥H­Ó¨Ï¥ÎªÌñ¤J¤@±ø¦C¦b /etc/dialups ªº½u(line)¡A¥B¥Lªº shell ³Q¦C¦b /etc/d_passwd ÀÉ¡A¥L±N³Q¤¹³\¦s¨ú³z¹L´£¨Ñ¥¿½Tªº±K½X¡C ¥t¤@­Ó¨Ï¥Î dial-up ±K½Xªº¥Øªº¬O³]©w«ü¤¹³\¬Y¨Ç§Î¦¡³sµ²ªº½u(¥i¯à¬OPPP ©Î UUCP ³sµ²)¡C ¦pªG¤@­Ó¨Ï¥ÎªÌ¸ÕµÛ±o¨ì¥t¤@ºØ§Î¦¡³sµ² (i.e. a list of shells)¡A¥L¥²¶·ª¾¹D¨Ï¥Î³o±ø½uªº±K½X¡C ¦b§A¥i¥H¦b¥¼¨Ó¨Ï¥Î dial-up «e¡A§A±K»Ý«Ø¥ß¤@¨ÇÀɮסC dpasswd «ü¥O´£¨Ñ¹ï¦b /etc/d_passwd Àɪº shells «ü¬£±K½X¡C ¥i¥H¬Ý¾Þ§@¤â ¥Uªº¨ì§ó¦h¸ê°T¡C 8. ¥[¤J shadow ¤ä´© C »y¨¥ ·s¼W¤ä´© shadow µ{¦¡¨Æ¹ê¤W¬O«Üª½±µªº¡C °ß¤@ªº°ÝÃD¬Oµ{¦¡»Ý­n¥H root (©Î SUID root) Åv­­°õ¦æ¡A³o¼Ë¤~¥i¥H¦s¨ú /etc/shadow ÀÉ¡C ³oÅã¥Ü¤@­Ó¤j°ÝÃD¡G ·í«Ø¥ß SUID µ{¦¡®É»Ý­n«Ü¤p¤ß¨Ì·Óµ{¦¡¹B§@¡CÁ|¨Ò»¡©ú¡G ¦pªG¥H­Ó µ{¦¡¦³ shell escape¡A¦pªGµ{¦¡¥»¨­¬O SUID root ±N¤£»Ý­n¥H root ¤è¦¡§e²{¡C ¹ïµ{¦¡·s¼W¤ä´© shadow ¦Ó¨¥¡A¥¦¥i¥HÀˬd±K½X¡A¦ý¤£»Ý¥H root Åv­­°õ¦æ¡A¦Ó ¬O¥H SUID shadow ¨ú¥N°õ¦æ¤ñ¸û¦w¥þ¡C xlock µ{¦¡´N¬O¤@­Ó¨Ò¤l¡C ±µ¤U¨Ó½d¨Ò¤¶²Ð¡A pppd-1.2.1d ¤w¸g¥H SUID as root ¤è¦¡°õ¦æ¡A©Ò¥H·s¼W shadow ¤ä´©À³¸Ó¤£·|¨Ïµ{¦¡²£¥Í¥ô¦ó¼vÅT¡C 8.1 ¼ÐÀYÀÉ(Header files) ¼ÐÀYÀÉÀ³¦s¦b /usr/include/shadow¡C À³¸Ó¦³¤@­Ó /usr/include/shadow.hÀÉ¡A ¦ý¬O¥¦±N symbolic link ¨ì /usr/include/shadow/shadow.h¡C ¬°¤F·s¼W¤ä´© shadow µ{¦¡¡A§A»Ý­n include ¼ÐÀYÀÉ¡G #include #include 8.2 libshadow.a ¨ç¦¡®w(library) ·í§A¦w¸Ë Shadow Suite¡A libshadow.a ÀɳQ«Ø¥ß©M¦w¸Ë¦b /usr/lib ¥Ø¿ý¡C ·í½sĶ¤@­Ó shadow support µ{¦¡¡Alinker »Ý­n¥]¬A libshadow.a ¨ç¦¡®w¶i¤J Ãìµ²¡C °õ¦æ¦p¤U¡G gcc program.c -o program -lshadow µM¦Ó¡A´N¹³§Ú­Ì±µ¤U¨Ó­n¬Ýªº¨Ò¤l¡A¤j³¡¤À¤jµ{¦¡¨Ï¥Î Makefile ¥B ³q±`¦³ÅÜ¼Æ ©I¥s LIBS=... »Ý­n³Q­×§ï¡C 8.3 Shadow µ²ºc(Structure) libshadow.a ¨ç¦¡®w¹ï¥¦±q /etc/shadow Àɱµ¦¬¸ê°T¨Ï¥Îµ²ºc¤Æ©I¥s¡C ³o¬O±q /usr/include/shadow/shadow.h ¼ÐÀYÀɪº spwd µ²ºc©w¸q¡G _________________________________________________________________ struct spwd { char *sp_namp; /* login name */ char *sp_pwdp; /* encrypted password */ sptime sp_lstchg; /* date of last change */ sptime sp_min; /* minimum number of days between changes */ sptime sp_max; /* maximum number of days between changes */ sptime sp_warn; /* number of days of warning before password expires */ sptime sp_inact; /* number of days after password expires until the account becomes unusable. */ sptime sp_expire; /* days since 1/1/70 until account expires */ unsigned long sp_flag; /* reserved for future use */ }; _________________________________________________________________ Shadow Suite ¥i¥H©ñ°£¤F½s½X±K½X¤§¥~ªº¸ê®Æ¨ì sp_pwdp Äæ¦ì¡C ±K½XÄæ¦ì¥i¥] ¬A¡G username:Npge08pfz4wuk;@/sbin/extra:9479:0:10000:::: ³oªí¥Ü¤@­ÓÃB¥~ªº±K½X¡A /sbin/extra µ{¦¡À³¸Ó³Q§ó¦hªºÅv­­©I¥s¡C µ{¦¡ªº©I ¥s»Ý¨ú±o¨Ï¥ÎªÌ¦WºÙ©M«ü¥X¬°¦ó»Ý³Q©I¥sªº switch¤~¥i³q¹L¡C ¬d¬Ý /usr/include/shadow/pwauth.h ©M­ì©l½X pwauth.c Àò±o§ó¦h¸ê°T¡C ¬°¦ó§Ú­ÌÀ³¨Ï¥Î pwauth ¥hªí¥Ü¯u¥¿ªºÅv­­¡A³o¬O¤°»ò·N«ä¡A¥¦±N¨Ï²Ä¤G²ÕÅv­­ ¤] ¶]±o«Ü¦n¡C Shadow Suite §@ªÌ«ü¥X¦]¬°¤j³¡¤À¦s¦bªºµ{¦¡³£¤£³o»ò§@Åo¡A©Ò¥H Shadow Suite¥¼¨Óªºª©¥»±N²¾°£¡C 8.4 Shadow ¨ç¦¡(Functions) shadow.h ¥]§t libshadow.a ¨ç¦¡®w¡G _________________________________________________________________ extern void setspent __P ((void)); extern void endspent __P ((void)); extern struct spwd *sgetspent __P ((__const char *__string)); extern struct spwd *fgetspent __P ((FILE *__fp)); extern struct spwd *getspent __P ((void)); extern struct spwd *getspnam __P ((__const char *__name)); extern int putspent __P ((__const struct spwd *__sp, FILE *__fp)); _________________________________________________________________ §Ú­Ì±N¨Ï¥Îªº½d¨Òµ{¦¡¬O¡G getspnam ±N¹ï¨ÑÀ³¦WºÙ«ì´_¹ï§Ú­Ì spwd µ²ºc¡C 8.5 ½d¨Ò ³o¬O¤@­Ó½d¨Ò´y­z·s¼W shadow ¤ä´©µ{¦¡¡A¦ý¹w³]­È¨Ã¨S¦³¡C ¥»½d¨Ò¨Ï¥Î Point-to-Point Protocol Server (pppd-1.2.1d)¡A¥¦¦³­Ó¼Ò¦¡¬Oªí ¥Ü ±q /etc/passwd Àɨú¥N PAP ©Î CHAP Àɨϥαb¸¹±K½Xªº PAP Åv­­¡A§A±N¤£ »Ý­n¦b pppd-2.2.0 ¥[³o¨Çµ{¦¡½X¡A¦]¬°¥¦¤w¸g¦s¦bÅo¡C pppd ªº¥¼¨Ó¤j­P¤W¤£·|³Q¨Ï¥Î«Ü¦h¡A¦ý¬O¦pªG§A¦w¸Ë Shadow Suite¡AÀx¦s¦b /etc/passwd Àɪº±K½X±NµLªk¹B§@¡C ¦b pppd-1.2.1d Åv­­¨Ï¥Îªºµ{¦¡½X¬O¦ì¦b /usr/src/pppd-1.2.1d/pppd/auth.c ÀÉ¡C ±µ¤U¨Óµ{¦¡½X»Ý­n³Q¥[¦b©Ò¦³¨ä¥L #include «ü¥OÀɮתº³Ì¤WÀY¡A§Ú­Ì±Nª`·N¦³ Àô¹Ò«ü¥Oªº #includes¡C _________________________________________________________________ #ifdef HAS_SHADOW #include #include #endif _________________________________________________________________ ±µ¤U¨Ó­n°µªº¨Æ±¡¬OÅܧó¹ê»Ú½X¡A §Ú­Ì±NÅܧó auth.c ÀÉ¡C Åܧó«e auth.c ÀÉ function ¬°¡G _________________________________________________________________ /* * login - Check the user name and password against the system * password database, and login the user if OK. * * returns: * UPAP_AUTHNAK: Login failed. * UPAP_AUTHACK: Login succeeded. * In either case, msg points to an appropriate message. */ static int login(user, passwd, msg, msglen) char *user; char *passwd; char **msg; int *msglen; { struct passwd *pw; char *epasswd; char *tty; if ((pw = getpwnam(user)) == NULL) { return (UPAP_AUTHNAK); } /* * XXX If no passwd, let them login without one. */ if (pw->pw_passwd == '\0') { return (UPAP_AUTHACK); } epasswd = crypt(passwd, pw->pw_passwd); if (strcmp(epasswd, pw->pw_passwd)) { return (UPAP_AUTHNAK); } syslog(LOG_INFO, "user %s logged in", user); /* * Write a wtmp entry for this user. */ tty = strrchr(devname, '/'); if (tty == NULL) tty = devname; else tty++; logwtmp(tty, user, ""); /* Add wtmp login entry */ logged_in = TRUE; return (UPAP_AUTHACK); } _________________________________________________________________ ¨Ï¥ÎªÌªº±K½X³Q©ñ¦b pw->pw_passwd¡A©Ò¥H§Ú­Ì»Ý·s¼W getspnam function¡A³o ±N·|§â±K½X©ñ¨ì spwd->sp_pwdp¡C §Ú­Ì±N·s¼W pwauth function ¨Óªí¥Ü¯u¥¿ªºÅv­­¡C ³o±N¦b shadow Àɳ]©w®É ¦Û °Ê²£¥Í²Ä¤G­ÓÅv­­¡C Åܧ󬰥i¥H¤ä´© shadow «áªº auth.c function¡G _________________________________________________________________ /* * login - Check the user name and password against the system * password database, and login the user if OK. * * This function has been modified to support the Linux Shadow Password * Suite if USE_SHADOW is defined. * * returns: * UPAP_AUTHNAK: Login failed. * UPAP_AUTHACK: Login succeeded. * In either case, msg points to an appropriate message. */ static int login(user, passwd, msg, msglen) char *user; char *passwd; char **msg; int *msglen; { struct passwd *pw; char *epasswd; char *tty; #ifdef USE_SHADOW struct spwd *spwd; struct spwd *getspnam(); #endif if ((pw = getpwnam(user)) == NULL) { return (UPAP_AUTHNAK); } #ifdef USE_SHADOW spwd = getspnam(user); if (spwd) pw->pw_passwd = spwd->sp-pwdp; #endif /* * XXX If no passwd, let NOT them login without one. */ if (pw->pw_passwd == '\0') { return (UPAP_AUTHNAK); } #ifdef HAS_SHADOW if ((pw->pw_passwd && pw->pw_passwd[0] == '@' && pw_auth (pw->pw_passwd+1, pw->pw_name, PW_LOGIN, NULL)) || !valid (passwd, pw)) { return (UPAP_AUTHNAK); } #else epasswd = crypt(passwd, pw->pw_passwd); if (strcmp(epasswd, pw->pw_passwd)) { return (UPAP_AUTHNAK); } #endif syslog(LOG_INFO, "user %s logged in", user); /* * Write a wtmp entry for this user. */ tty = strrchr(devname, '/'); if (tty == NULL) tty = devname; else tty++; logwtmp(tty, user, ""); /* Add wtmp login entry */ logged_in = TRUE; return (UPAP_AUTHACK); } _________________________________________________________________ ÄYÂÔªº½d¨Ò±N±Òµo§Ú­Ì¦b§@¨ä¥L§ïÅܪºÀ°§U¡C ­ì©lªºª©¥»¦pªG¦b /etc/passwd ÀÉ ¨S¦³¥ô¦ó±K½X¡A¥i¤¹³\¦s¨ú¶Ç¦^ªº UPAP_AUTHACK ¡C³o¬O¤£¦nªº¡A¦]¬° ñ¤J ªº¨Ï¥Î¬O¨Ï¥Î¤@­Ó¤¹³\¦s¨ú PPP processªº±b¸¹¡AµM«áÀˬd±b¸¹±K½X¡A¸Ó±b¸¹±K ½X¬O¥Ñ RAP ¡B¦b /etc/passwd Àɪº±b¸¹©M /etc/shadow Àɪº±K½X¨ÑÀ³¡C ©Ò¥H¦pªG§Ú­Ì³]©w­ì¥»ª©¥»¹ï¨C­Ó¨Ï¥ÎªÌ¡A¦p ppp ¥i¥H¦b shell °õ¦æ¡AµM«á¥ô ¦ó¤H¥i¥H Àò±o ppp Ãìµ²³z¹L³]©w¥L­Ì¹ï¨Ï¥ÎªÌ ppp ªº PAP ©M null ªº±K½X¡C §Ú­Ì­×¥¿ UPAP_AUTHNAK ¨ú¥N UPAP_AUTHACK ¦pªG±K½XÄæ¦ì¬OªÅªº¡C ¦³½ìªº¬O pppd-2.2.0 ¦³¬Û¦Pªº°ÝÃD¡C ±µ¤U¨Ó§Ú­Ì»Ý­nÅܧó Makefile ¥H«KÅý¨â¥ó¨Æµo¥Í¡G USE_SHADOW ¥²¶·³Q­«·s©w¸q¥Blibshadow.a »Ý­n³Q·s¼W¨ìÃìµ² process¡C ½s¿è Makefile ¥B·s¼W¡G LIBS = -lshadow µM«á§Ú­Ì§ä¨ì³o¤@¦æ¡G COMPILE_FLAGS = -I.. -D_linux_=1 -DGIDSET_TYPE=gid_t µM«á§ïÅÜ¥¦Åܦ¨¡G COMPILE_FLAGS = -I.. -D_linux_=1 -DGIDSET_TYPE=gid_t -DUSE_SHADOW ²{¦b°õ¦æ make ¸ò install. 9. ±`°Ý°ÝÃD¤Îµª®× Q: §Ú¥Î tty's ¥Îroot Åv­­¨Ï¥Î /etc/securettys ÀÉ¡A¦ý¬O³£¨S¦³ ¥ô¦ó¹B§@¡A ¸Ó¦p¦ó¸Ñ¨M¡H A: /etc/securettys Àɦb Shadow Suite ¦w¸Ë«á´N¤£¨ã¥ô¦ó·N¸qÅo¡C tty's ¥Î root Åv­­¥i¥H¨Ï¥Î¤@­Ó©ñ¦b /etc/login.defs ñ¤J³]©wÀɶi¦æ­×§ï¡C ¸Ó³]©wÀɤ]¥i¯à«ü¨ì¥t¤@­ÓÀÉ¡C Q: §Ú¹ï Shadow Suite ¶i¦æ¦w¸Ë«á¡A²{¦b§Ú¨S¿ìªkñ¤J(login)¨t²Î¡A §Ú¦³©¿²¤ ¤°»ò¨BÆJ¶Ü¡H A: §A¬O¯uªº¦w¸Ë Shadow µ{¦¡Åo¡A¦ý¬O¨Ã¥¼°õ¦æ pwconv ©Î§A§Ñ°O½Æ»s /etc/npasswd ¨ì /etc/passwd ¥B½Æ»s /etc/nshadow ¨ì /etc/shadowÅo¡C §A¤] »Ý­n½Æ»s login.defs ¨ì /etc¡C Q: ¦b xlock ¨º¤@³¹¸`¦³´£¨ì§ïÅÜ /etc/shadow Àɪº¸s²Õ¾Ö¦³ªÌ¨ì shadow¡C§Ú ¨S¦³ shadow ¸s²Õ¡A¸Ó¦p¦ó³B²z¡H A: §A¥i¥H·s¼W¤@­Ó¡C ²³æªº½s¿è /etc/group ÀÉ¡AµM«á·s¼W¤@¦æµ¹ shadow ¸s ²Õ¡A§A»Ý­n½T»{¸s²Õ½s¸¹¨Ã¥¼³Q¨ä¥L¸s²Õ¨Ï¥Î¡A¥B§A»Ý­n¦b nogroup ¬ö¿ý¤§«e´¡ ¤J¸Ó³]©w¡C ©Î³o§A¥i¥H²¤Æ¹ï rootÅv­­³]©w suid xlock¡C Q: ¦³¥ô¦ó¹ï Linux Shadow Password Suite ªº¹q¤l¶l¥ó¦Cªí¶Ü¡H A: ¦³¡A¦ý¬O¥¦ªº¥Øªº¬O°w¹ï Linux ¤U¤@­Ó Shadow Suiteª©¥»µo®i¸ò´ú¸Õ¡A§A¥i ¥H ¨ìshadow-list-request@neptune.cin.net ¹q¤l¶l¥óºK­n¿é¤J¡G subscribe¡C ³o¬O¦b°Q½× Linux shadow-YYMMSS¨t¦Cª©¥»¡C§AÀ³¸Ó°Ñ¥[¦pªG§A ·Q°Ñ¤©¥¼¨Óµo®i ©Î§A¦w¸Ë Suite ¦b§Aªº¹q¸£¥B·Q­n±o¨ì·sª©¥»ªº¸ê°T¡C Q: §Ú¦w¸Ë Shadow Suite¡A¦ý¬O·í§Ú¨Ï¥Î userdel ©R¥O«á¡A §Ú±o¨ì "userdel: cannot open shadow group file" °T®§¡A§Ú¦³­þ¸Ì§@¿ù¤F¶Ü¡H A: §A½sĶ Shadow Suite ®É¦³¶}±Ò SHADOWGRP ¿ï¶µ¡A¦ý¬O §A¨S¦³¤@­Ó /etc/gshadow ÀɮסA§A»Ý­n½s¿è config.h ÀÉ©M­«·s½s Ķ©Î«Ø¥ß¤@­Ó /etc/group ÀÉ¡A½Ð¬Ý shadow groups ¨º¤@¸`¡C Q: §Ú¦w¸Ë Shadow Suite ¦ý¬O§ÚµLªk§ä¨ì½s½X±K½X¦b§Úªº /etc/passwd ÀÉ¡Aµo ¥Í¤°»ò°ÝÃD¡H A: §A¥i¯à¦b Shadow config.h Àɶ}±Ò AUTOSHADOW ¿ï¶µ©ÎªÌ §Aªº libc ³Q SAHDOW_COMPAT ¿ï¶µ½sĶ¡A§A»Ý­n¨M©w¬O­þ­Ó°ÝÃD¡AµM«á ¦A­«·s½sĶ¡C 10. ª©ÅvÁn©ú(¼È¤£Â½Ä¶) The Linux Shadow Password HOWTO is Copyright (c) 1996 Michael H. Jackson. Permission is granted to make and distribute verbatim copies of this document provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this document under the conditions for verbatim copies above, provided a notice clearly stating that the document is a modified version is also included in the modified document. Permission is granted to copy and distribute translations of this document into another language, under the conditions specified above for modified versions. Permission is granted to convert this document into another media under the conditions specified above for modified versions provided the requirement to acknowledge the source document is fulfilled by inclusion of an obvious reference to the source document in the new media. Where there is any doubt as to what defines 'obvious' the copyright owner reserves the right to decide. 11. Miscellaneous and Acknowledgments. The code examples for auth.c are taken from pppd-1.2.1d and ppp-2.1.0e, Copyright (c) 1993 and The Australian National University and Copyright (c) 1989 Carnegie Mellon University. Thanks to Marek Michalkiewicz for writing and maintaining the Shadow Suite for Linux, and for his review and comments on this document. Thanks to Ron Tidd for his helpful review and testing. Thanks to everyone who has sent me feedback to help improve this document. Please, if you have any comments or suggestions then mail them to me. regards [30]Michael H. Jackson References 1. mailto:mhjack@tscnet.com 2. mailto:songmj@ms1.hinet.net 3. http://sunsite.unc.edu/mdw/linux.html 4. http://sunsite.unc.edu/linux/HOWTO/Shadow-Password-HOWTO.html 5. mailto:mhjack@tscnet.com 6. mailto:marekm@i17linuxb.ists.pwr.wroc.pl 7. http://bach.cis.temple.edu/linux/linux-security/ 8. mailto:flla@stud.uni-sb.de 9. mailto:magnus@texas.net 10. http://bach.cis.temple.edu/linux/linux-security/Linux-Security-FAQ/Linux-telnetd.html 11. mailto:marekm@i17linuxb.ists.pwr.wroc.pl 12. ftp://i17linuxb.ists.pwr.wroc.pl/pub/linux/shadow/shadow-current.tar.gz 13. ftp://ftp.icm.edu.pl/pub/Linux/shadow/shadow-current.tar.gz 14. ftp://iguana.hut.fi/pub/linux/shadow/shadow-current.tar.gz 15. ftp://ftp.cin.net/usr/ggallag/shadow/shadow-current.tar.gz 16. ftp://ftp.netural.com/pub/linux/shadow/shadow-current.tar.gz 17. http://sunsite.unc.edu/mdw/HOWTO/Bootdisk-HOWTO.html 18. file://localhost/tmp/zh-sgmltools.9490/Shadow-Password-HOWTO.txt.html#sec-adding 19. ftp://sunsite.unc.edu/pub/Linux/system/Admin/accounts/adduser.shadow-1.4.tgz 20. file://localhost/tmp/zh-sgmltools.9490/Shadow-Password-HOWTO.txt.html#sec-work 21. http://bach.cis.temple.edu/linux/linux-security/Linux-Security-FAQ/Linux-wu.ftpd-2.4-Update.html 22. ftp://sunsite.unc.edu/pub/Linux/system/Network/file-transfer/wu-ftpd-2.4-fixed.tar.gz 23. ftp://tscnet.com/pub/linux/network/ftp/wu-ftpd-2.4.2-beta-10.tar.gz 24. ftp://sunsite.unc.edu/pub/Linux/system/Network/file-transfer/ftpd-shadow-nis.tgz 25. ftp://sunsite.unc.edu/pub/Linux/system/Mail/pop/pop3d-1.00.4.linux.shadow.tar.gz 26. ftp://sunsite.unc.edu/pub/Linux/system/Mail/pop/pop3d+shadow+elf.tar.gz 27. ftp://sunsite.unc.edu/pub/Linux/X11/xutils/screensavers/xlockmore-3.7.tgz 28. ftp://sunsite.unc.edu/pub/Linux/X11/xutils/xdm.tar.gz 29. ftp://sunsite.unc.edu/pub/Linux/system/Admin/sudo-1.2-shadow.tgz 30. mailto:mhjack@tscnet.com