SMB HOWTO §@ªÌ: David Wood, [1]dwood@plugged.net.au ĶªÌ: J.S. Lin, [2]r6921068@ms.cc.ntu.edu.tw v1.0, 10 August 1996 _________________________________________________________________ ³o¬O SMB HOWTO {¦p¦ó¨Ï¥Î SMB}. ³o¤å¥ó´y­z¦b Linux ¤W¦p¦ó¨Ï¥Î Session Message Block (SMB) protocol{¨ó©w}, ¤]¥s°µ NetBIOS ©Î LanManager protocol. _________________________________________________________________ 1. ¤¶²Ð 2. ¶i¤@¨B¸ê°T 3. ¦w¸Ë 4. °õ¦æ³o¨â­Ó daemon 5. ¤@¯ë²ÕºA³]©w (/etc/smb.conf) 6. ¤À¨É Linux ºÏºÐµ¹ Windows ¾÷¾¹ 7. ¤À¨É Windows ºÏºÐµ¹ Linux ¾÷¾¹ 8. ¤À¨É Linux ¦Lªí¾÷µ¹ Windows ¾÷¾¹ 9. ¤À¨É Windows ¦Lªí¾÷µ¹ Linux ¾÷¾¹ 10. ª©Åv 11. ·P¿E _________________________________________________________________ 1. ¤¶²Ð ³o¬O SMB HOWTO {¦p¦ó¨Ï¥Î SMB} . ³o¤å¥ó´y­z¦b Linux ¤W¦p¦ó¨Ï¥Î Session Message Block (SMB) protocol, ¤]¥s°µ NetBIOS ©Î LanManager protocol. ¥»¤å¥óªººûÅ@ªÌ¬O David Wood ( [3]dwood@plugged.net.au). ¦AªÌ,­×§ï©Î­×¥¿ ¥i¥H±H¨ì¨º,¥H«K¤U¤@ª©¥]²[¶i¥h. SMB protocol ³Q¨Ï¥Î¦b Microsoft Windows 3.11, NT ©M 95 ¥Î¨Ó¤À¨ÉºÏºÐ¤Î¦L ¾÷. ¨Ï¥Î Andrew Tridgell ©Ò°µªº Samba ¤u¨ã®M¥ó, UNIX (¥]§t Linux) ¾÷¾¹ ¯à¤À¨ÉºÏºÐ»P¦Lªí¾÷µ¹ Windows ¥D¾÷. §^¤H¨Ï¥Î Samba ¦³¥|¼ËªF¦è¥i¥H°µ: 1. ¤À¨É linux ºÏºÐµ¹ Windows ¾÷¾¹. 2. ¤À¨É Windows ºÏºÐµ¹ linux ¾÷¾¹. 3. ¤À¨É linux ¦Lªí¾÷µ¹ Windows ¾÷¾¹. 4. ¤À¨É Windows ¦Lªí¾÷µ¹ linux ¾÷¾¹. ³o¨ÇªF¦è³£¤w¥]§t¦b¥»¤å¥ó¤¤. Disclaimer: procedures ©M script ­n¹À¹ï§@ªÌ¬O¥i¥H¥¿±`¹B§@ªº,©Î­n¹À¥Ñ¨º ¨Ç(procedures©Mscript)ªº´£¨ÑªÌ³ø§i¥i¥H¥¿±`¹B§@. ¥H¦b³oùتº¸ê°T°µ¤£¦Pªº ³]©w¥i¯à·|¤£¯à¥¿±`¹B§@.¦pªG§A¾D¹JÃþ¦üªº§x¹Ò,§A¥i¥H e-mail µ¹§@ªÌ,´£¥X«Ø ij¨Ó§ï¶i¥»¤å¥ó, ¦ý§@ªÌ¨Ã¤£§@¥ô¦ó«OÃÒ.§A¹w´Á¤°»ò©O? §@ªÌ²¦³º¥u¬O­ÓÅU °Ý..... 2. ¶i¤@¨B¸ê°T ³o­Ó HOWTO ³]ªk¥h¸ÑÄÀ¦p¦ó³]©w°ò¥»ªº SMBÀÉ¥H¤Î¦C¦LªA°È¦b linux ¾÷¾¹¤W. Samba ¬O­Ó«D±`½ÆÂø¥B§¹¾ãªº¥]¸Ë. ¦b³o­Ó¦a¤è¨S¦³­n³]ªk¥h½Æ»s©Ò¦³ªº Samba ¤å¥ó. ¶i¤@¨B¸ê°T,½Ð¬Ý¥H¤U¤å¥ó: * Samba ¤å¥ó, ¥i¨ú±o©ó Samba µo¦æ®M¥ó{distribution}ªº³¡¤À. ¦¹µo¦æ®M¥ó ¥i¨ú±o¦b: [4]ftp://nimbus.anu.edu.au/pub/tridge/samba/ * The linux Printing HOWTO. * The Print2Win Mini-HOWTO. 3. ¦w¸Ë ³Ì·s Samba ªº­ì©lµ{¦¡¥i¥H¨ú±o¦Û: [5]ftp://nimbus.anu.edu.au/pub/tridge/samba/ µM¦Ó,¦pªG¤w¦w¸Ë linux ªº Redhat ª©¥»,§A¥i¥H¨Ï¥Î³nÅé®M¥ó{package} ¨Ó¦w¸Ë ¥¦.¦³¨Ç¨ä¥Lª©¥»¤]¥]§t Samba ªºbinaries{¤G¤¸Àɵ{¦¡}. ¥H¤U¨â­Ó daemon{ºÞ²zºëÆF} ¹ï Samba ³nÅé®M¥ó ¬O¥²­nªº. ¥¦­Ì¤@¯ë¬O³Q¦w¸Ë ¦b /usr/sbin ,¦Ó¥i¦b¶}¾÷®É,±q¨t²Î°_°Êªº scripts©Îinetd¨Ó°õ¦æ. scriptªº ¨Ò¤l³Q®i¥Ü¦b [6]°õ¦æ Daemons. _________________________________________________________________ smbd (The SMB daemon) nmbd (´£¨Ñ NetBIOS nameserver ªº¤ä´©µ¹ clients) _________________________________________________________________ ¤@¯ë¦Ó¨¥,¥H¤Uªº Samba ªº binaries ³Q¦w¸Ë¦b /usr/bin, ÁöµM»¡¥¦ªº¦ì¸m¬O¥i ¿ï¾Ü©Ê. _________________________________________________________________ smbclient (¤@ºØ¨Ñµ¹ UNIX ¾÷¾¹¥Îªº SMB client{µ{¦¡}) smbprint (¤@ºØ script ¥Î¦b¦C¦L©ó SMB ¥D¾÷{host}¤Wªº¦Cªí¾÷) smbprint.sysv (¦P¤W, ¦ý¬O´£¨Ñµ¹ SVR4 UNIX ¾÷¾¹¥Îªº) smbstatus (¦C¥X¹ï·í¦a¥D¾÷¤§¥Ø«e SMB ³sµ²±¡ªp) smbrun (¤@ºØ 'glue' script ¥Î¨Ó²©ö¦a°õ¦æÀ³¥Îµ{¦¡©ó SMB ¥D¾÷) _________________________________________________________________ ¦AªÌ,¤@ºØ¥s 'print' ªº script ³Q¥]¨ç¦b¥» HOWTO ¤§¤¤, ¨ä¥Î¨Ó·í§@¤@ºØ¦³¥Î ªº front end{«eºÝ¤¶­±} µ¹ smbprint script¥Î. Samba ³nÅé®M¥ó¬O²©ö¦w¸Ëªº.²³æ¦a±q¤W­zªº¦ì§}¨ú±o­ì©l½X, ¥B¾\Ū¦bµo¦æ®M ¥ó¤¤ªº README ÀÉ®×. ¦bµo¦æ®M¥ó¤¤¤]¦³¤@­Ó docs/INSTALL.txt ÀÉ´£¨Ñ¤@­Ó² ³æªº³v¨B¦w¸Ë«ü¥Ü. ±µµÛ¦w¸Ë«á, §â daemons ©ñ¨ì /usr/sbin ¦Ó binaries ©ñ¨ì /usr/bin. ¦Ó man pages{¤â¥U­¶} Â\¦b /usr/local/man. ·í§A¦b°µ Samba ³nÅé®M¥ó, §A¦b Makefile ¤¤·|¦³°O¸ü²ÕºAÀÉ,smb.conf,ªº¦ì ¸m. ³o¤@¯ë¬O¦b /etc¤U, ¦ý¥i¥H§â¥¦Â\¨ì§A³ßÅwÂ\ªº¥ô·N¦ì¸m. ¹ï©ó³o¨Ç¨Ï¥Î¤è ªk{directions}, §Ú­Ì±N°²³]§A°O¸ü²Õ¸üÀɦì¸m¦¨ /etc/smb.conf, log Àɦì¸m ¬° log file = /var/log/samba-log.%m ,¦Ó lock ¥Ø¿ý¬° lock directory = /var/lock/samba. ¦w¸Ë²ÕºA{configuration}ÀÉ, smb.conf. ¥h Samba ©Ò¦bªºªº¥Ø¿ý. ¬Ý¤@¤U¦b¨ä ¤l¥Ø¿ý example/simple ¦Ó¥BŪ¤@¤U README ÀÉ. ½Æ»s¦b¨º­Ó¥Ø¿ý¤Uªº smb.conf Àɨì /etc ¤U. ª`·N! ¦pªG§A¦³¤@ linux µo¦æ®M¥ó¤w¦w¸Ë¦n Samba, §A¤]³\¤w¦³ Samba ²ÕºAÀɦb /etc ¤U. ©Î³\§AÀ³¸Ó±q¨º­ÓÀɶ}©l. ¦pªG§A¤£·Q§â²ÕºAÀÉ©ñ¦b /etc ¥Ø¿ý¤U,¥i¥H§â¥¦Â\¦b§A·Q­nÂ\ªº¦a¤è,µM«á¦b /etc ¤U°µ¤@¤U symlink{²Å¸¹³sµ²}: _________________________________________________________________ ln -s /path/to/smb.conf /etc/smb.conf _________________________________________________________________ 4. °õ¦æ³o¨â­Ó daemon ³o¨â­Ó daemon ¬O /usr/sbin/smbd ©M /usr/sbin/nmbd. §A¥i¥H°õ¦æ Samba daemon ±q inetd ©Î·í¦¨³æ¿Wªºµ{§Ç. ¦pªG§A¥¿³]©w¤@­Ó¥Ã¤[ ÀɮצøªA¾¹,§AÀ³¸Ó±q inetd ¨Ó°õ¦æ,©Ò¥H¦pªG¥L­Ì¦º±¼,¨º±N­«·s¶}©l.¦pªG§A¥u ¬O°¸º¸·Q­n¨Ï¥Î SMB ¦øªA¾¹,©ÎªÌ¥Î¨t²ÎºÞ²z¨Ó»²§U,·í§A»Ý­n®É,§A¥i¥HÂÇ¥Ñ¨Ï ¥Î /etc/rc.d/init.d script,©Î¬Æ¦Üª½±µ¤â°Êªº. ­n±q inetd ¨Ó°õ¦æ daemon , ½Ð©ñ¥H¤U´X¦æ¦b inetd ²ÕºAÀÉ, /etc/inetd.conf: ______________________________________________________________ # SAMBA NetBIOS services (for PC file and print sharing) netbios-ssn stream tcp nowait root /usr/sbin/smbd smbd netbios-ns dgram udp wait root /usr/sbin/nmbd nmbd ______________________________________________________________ µM«á¤U«ü¥O¥H«K­«·s±Ò°Ê inetd daemon : _________________________________________________________________ kill -HUP 1 _________________________________________________________________ ­n±q¨t²Î±Ò°Êªº script ¨Ó°õ¦æ daemon, ½Ð§â¥H¤Uªº script ¸m©ó¤@­Ó¥s°µ /etc/rc.d/init.d/smb ÀÉ, ¦Ó¥B symbolically link ¨ìµùÄÀ{comments}©Ò»¡©ú ªºÀÉ®×: ______________________________________________________________ #!/bin/sh # # /etc/rc.d/init.d/smb - starts and stops SMB services. # # The following files should be synbolic links to this file: # symlinks: /etc/rc.d/rc1.d/K35smb (Kills SMB services on shutdown) # /etc/rc.d/rc3.d/S91smb (Starts SMB services in multiuser mode) # /etc/rc.d/rc6.d/K35smb (Kills SMB services on reboot) # # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 # See how we were called. case "$1" in start) echo -n "Starting SMB services: " daemon smbd -D daemon nmbd -D echo touch /var/lock/subsys/smb ;; stop) echo -n "Shutting down SMB services: " killproc smbd killproc nmbd rm -f /var/lock/subsys/smb echo "" ;; *) echo "Usage: smb {start|stop}" exit 1 esac ______________________________________________________________ 5. ¤@¯ë²ÕºA³]©w (/etc/smb.conf) ¦b linux (©Î¨ä¥L UNIX¾÷¾¹)¤Wªº Samba ²ÕºA³]©w¬O³Q³æ¤@ÀÉ®×, /etc/smb.conf ,©Ò±±¨î. ³o­ÓÀɨM©w§A·Q­n­þ­Ó¨t²Î¸ê·½¤À¨Éµ¹¥~­±¥@¬É¥H¤Î§A ·Q¹ï¥L­Ì°µ¤°»ò­­¨î. ¦]¬°¥H¤U³¹¸`±N·|³B²z¤À¨É linux ºÏºÐ»P¦Lªí¾÷µ¹ Windows ¾÷¾¹, ¥»¤p¸`©Ò®i ¥Üªº smb.conf Àɾ¨¶q¬O§A©Ò¯à¨ú±o¸û²³æªº, ¥¦¥u¬O¥H¤¶²Ð©Ê¬°¥Øªº. ¥Ø«eÁÙ¤£­n¾á¤ß²Ó¸`³¡¤À. «á­±ªº³¹¸`±N·|¤¶²Ð¥D­nªº·§©À. ¦bÀɮפ¤ªº¨Cªº¬q¸¨{section}·|¦³­Ó¬q¸¨¼ÐÀY¶}©l, ¨ä¼ÐÀY¹³¬O [global], [homes], [printers] µ¥µ¥. [global] ¬q¸¨©w¸q¤@¨ÇÅܼÆ, ¦Ó Samba ±N¥Î¨Ó©w¸q©ó©Ò¦³¸ê·½¤§¤À¨É. [homes] ¬q¸¨¤¹³\»·ºÝ¨Ï¥ÎªÌ¨Ó¦s¨ú¦b·í¦a(linux)¾÷¾¹¤W¤§¥L­Ìªº(¥B¥u¦³¥L­Ì ªº) home directories{®a¥Ø¿ý}. ¤]´N¬O, ¦pªG¤@­Ó Windows ¨Ï¥ÎªÌ±q¥L­Ìªº Windows ¾÷¾¹­n³]ªk³s±µ¨ì³o­Ó¤À¨É, ¥L­Ì±N¬O³s±µ¨ì¥L­Ì¦Û¤v­Ó¤Hªº home directiory. ­n°µ³o¼Ë¨Æ±¡,©Ò­nª`·Nªº¬O,¥L­Ì¥²¶·¦blinux box¤W¦³­Ó±b¸¹. ¥H¤Uªº smb.conf Àɮ׼˥»¤¹³\»·ºÝ¨Ï¥ÎªÌ¨Ó¥Î·í¦a¾÷¾¹¤W¥L­Ìªº home directories ¦Ó¥B¼g¨ì¤@­Ó¼È¦sªº¥Ø¿ý. ¹ï¤@­Ó Windows ¨Ï¥ÎªÌ,­n·Q¬Ý¨ì³o¨Ç ¤À¨É, linux box ¥²¶·¬O¦b°Ï°ìºô¸ô{local network}¤º. µM«á,¨Ï¥ÎªÌ²³æ¦a±q Windows File Manager ©Î Windows Explorer ³s±µ¨ìºô¸ôºÏºÐ. ¦b¥H¤U¬q¸¨­nª`·Nªº¬O, ¹ï³o­ÓÀɤ§ÃB¥~¶µ¥Ø±N·|¥Î¨Ó¤¹³\§ó¦h¸ê·½³Q¤À¨É. ______________________________________________________________ ; /etc/smb.conf ; ; Make sure and restart the server after making changes to this file, ex: ; /etc/rc.d/init.d/smb stop ; /etc/rc.d/init.d/smb start [global] ; Uncomment this if you want a guest account ; guest account = nobody log file = /var/log/samba-log.%m lock directory = /var/lock/samba share modes = yes [homes] comment = Home Directories browseable = no read only = no create mode = 0750 [tmp] comment = Temporary file space path = /tmp read only = no public = yes ______________________________________________________________ 6. ¤À¨É Linux ºÏºÐµ¹ Windows ¾÷¾¹ ¥H¤W©Ò®i¥Üªº smb.conf ¼Ë¥»ÀÉ, ¤À¨É linux ºÏºÐµ¹ Windows ¨Ï¥ÎªÌ¬O«Ü®e©ö ªº. µM¦Ó, ¹³ Samba ¨ä¥LªºªF¦è, §A¥i¥H±±¨î¨ì«Ü¤jªºµ{«×. ¥H¤U¦³¨Ç¨Ò¤l : ¬°¤F¤À¨É¥Ø¿ýµ¹¤j®a¨Ï¥Î, ´N«Ø¥ß­ÓÃþ¦ü¤W­z [tmp] ¬q¸¨, ¥ç§Y¥[¤J¹³³o­ÓªºªF ¦è¨ì smb.conf: ______________________________________________________________ [public] comment = Public Stuff path = /home/public public = yes writable = yes printable = yes ______________________________________________________________ ¬°¤F¨Ï¥H¤W¥Ø¿ý¨Ñ¤j²³¥iŪ¨ú,¦ý¥u¦³¸s²Õ¦¨­û{group staff}¥i¼g¤J,½Ð­×§ï¨ä¶µ ¥Ø¹³³o¼Ë: ______________________________________________________________ [public] comment = Public Stuff path = /home/public public = yes writable = yes printable = no write list = @staff ______________________________________________________________ ¨ä¥Lª±ºÏºÐ¤À¨Éªº§Þ¥©,½Ð¬Ý Samba ¤å¥ó©Î man pages. 7. ¤À¨É Windows ºÏºÐµ¹ Linux ¾÷¾¹ ¤@ºØµ¹ UNIX ¾÷¾¹¥Îªº SMB client µ{¦¡³Q¥]§t¦b Samba µo¦æ®M¥ó¤§¤¤.¥¦´£¨Ñ ¤@ºØ¦b©R¥O¦C¤Uªº¹³ftpªº¤¶­±. ·Q­n¬Ý¦bµ¹©wªº¥D¾÷¤W¦³­þ¨Ç¤À¨É¥i¨ú±o, °õ¦æ: _________________________________________________________________ /usr/sbin/smbclient -L host _________________________________________________________________ ³oùتº 'host' ¬O§A·Q­nÂsÄýªº¾÷¾¹¦W¤l. ³o±N·|¦^À³¤@¦ê 'service' ªº¦WºÙ - ¤]´N¬O, ¥¦©Ò¤À¨Éµ¹§AªººÏºÐ©Î¦Lªí¾÷ªº¦WºÙ. °£«D SMB ¦øªA¾¹¨S¦³¦w¥þ¤Wªº ³]©w, §_«h¥¦±N­n¨D§A¿é¤J±K½X. µ¹¥¦ 'guest' ±b¸¹ªº±K½X©Î¬O§A­Ó¤H¦b¨º¥x¾÷ ¾¹¤W±b¸¹ªº±K½X. Á|­Ó¨Ò¤l: _________________________________________________________________ smbclient -L zimmerman _________________________________________________________________ ³o­Ó«ü¥Oªº¿é¥XÀ³¸Ó¬Ý°_¨Ó¹³¬O³o¼Ë: ______________________________________________________________ Server time is Sat Aug 10 15:58:27 1996 Timezone is UTC+10.0 Password: Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51] Server=[ZIMMERMAN] User=[] Workgroup=[WORKGROUP] Domain=[] Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin public Disk Public C$ Disk Default share IPC$ IPC Remote IPC OReilly Printer OReilly print$ Disk Printer Drivers This machine has a browse list: Server Comment --------- ------- HOPPER Samba 1.9.15p8 KERNIGAN Samba 1.9.15p8 LOVELACE Samba 1.9.15p8 RITCHIE Samba 1.9.15p8 ZIMMERMAN ______________________________________________________________ ³o­Ó browse list ¦C¥X¨ä¥L¦³¸ê·½¤À¨Éµ¹ºô¸ôªº SMB ¦øªA¾¹. ­n¨Ï¥Î¦¹ client, ½Ð°õ¦æ: _________________________________________________________________ /usr/sbin/smbclient service _________________________________________________________________ ³oùتº 'service' ¬O¤@¥x¾÷¾¹©M¤À¨É¦WºÙ. Á|¨Ò¦Ó¨¥,¦pªG§A³]ªk³s¨ì¤@¥x¥s°µ zimmerman ªº¾÷¾¹¤W¤§¥H 'public' ¬°¤À¨É¦WºÙªº¥Ø¿ý ,¦¹ service ­n¥s°µ \\zimmerman\public. µM¦Ó,¦]¬° shell ­­¨î, §A·|»Ý­n²æÂ÷ backslashes, ©Ò ¥H§A­n¹³³o¼Ëªºµ²§ô: _________________________________________________________________ /usr/sbin/smbclient \\\\zimmerman\\public mypasswd _________________________________________________________________ ³o¼Ëªº 'mypasswd' ¬O§Aªº±K½X¤§¤å¦r¦ê{literal string}. §A±N·|¦³ smbclient ªº´£¥Ü²Å¸¹{prompt}¥X²{: ______________________________________________________________ Server time is Sat Aug 10 15:58:44 1996 Timezone is UTC+10.0 Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51] smb: \> ______________________________________________________________ Áä¤J 'h' ¨ú±oÃö©ó¨Ï¥Î smbclient ªº help: ______________________________________________________________ smb: \> h ls dir lcd cd pwd get mget put mput rename more mask del rm mkdir md rmdir rd prompt recurse translate lowercase print printmode queue cancel stat quit q exit newer archive tar blocksize tarmode setmode help ? ! smb: \> ______________________________________________________________ ¦pªG§A¯à¨Ï¥Îftp,§AÀ³¸Ó¤£»Ý­n¬d¸ß smbclient ªº man pages. 8. ¤À¨É Linux ¦Lªí¾÷µ¹ Windows ¾÷¾¹ ¬°¤F¤À¨É Linux ¦Lªí¾÷µ¹ Windows ¾÷¾¹, §A¥²¶·½T©w§Aªº¦Lªí¾÷¤w¸g¸Ë³]¦n. ¦pªG§A¯à±q linux ¤W¦C¦L,³]©w SMB ªº¦Lªí¾÷¤À¨É±N·|«Üª½±µ. ½Ð¨£ Printing HOWTO ¨Ó³]©w·í¦aªº¦C¦L. ¦]¬°§@ªÌ¨Ï¥Î³Q³s±µ¨ì Windows NT ¾÷¾¹ªº¦Lªí¾÷, ³o¤p¸`¤£À³¸Ó³Qµø¬°«Ü§¹¾ã ªº,¦Ó¥u¬O«Øij.¥ô¦ó¦³¸Ô²Ó¸ê®Æ¥i¤À¨É¥X¨Óªº¤H, ½Ð±N³o¨Ç¸ê®Æ±H¨ì [7]dwood@plugged.net.au ¨Ï±o³o¤p¸`¯à°÷§¹¦¨. ¥[¤J¦C¦L³]©w¨ì§Aªº smb.conf: ______________________________________________________________ [global] printing = bsd printcap name = /etc/printcap load printers = yes log file = /var/log/samba-log.%m lock directory = /var/lock/samba [printers] comment = All Printers security = server path = /var/spool/lpd/lp browseable = no printable = yes public = yes writable = no create mode = 0700 [ljet] security = server path = /var/spool/lpd/lp printer name = lp writable = yes public = yes printable = yes print command = lpr -r -h -P %p %s ______________________________________________________________ ½T»{¦Lªí¾÷ªº¸ô®|(¥»¨Ò¤l¤¤¬O¦b[ljet]¤U)­n»P /etc/printcap¤¤ªº spool ¥Ø¿ý ¬Û²Å¦X! ª`·N: ¨Ï¥Î Samba ¨Ó¤À¨É UNIX boxes ¤Wªº¦Lªí¾÷µ¹ Windows NT ¾÷¾¹¦³¤@¨Ç°Ý ÃD. ¨ä¤¤¤@­Ó°ÝÃD¬O¨Ï¥Î NT ¾A·í¦a¬Ý¨ì¤À¨Éªº¦Lªí¾÷. ·Q­n­×¥¿³o­Ó°ÝÃD, ½Ð ¬Ý Samba µo¦æ®M¥ó¤Wªº»¡©ú, §Y docs/WinNT.txt ÀÉ®×.¨ä¥L¬O³B²z±K½Xªº°Ý ÃD. ¹ï©ó³oÂZ¤H°ÝÃDªº¤F¸Ñ»P¤£¯à¦¨¥\ªº­×¥¿,½Ð¬Ý¬Û¦P¤å¥ó¤Wªº»¡©ú. 9. ¤À¨É Windows ¦Lªí¾÷µ¹ Linux ¾÷¾¹ ¬°¤F¤À¨É Windows ¾÷¾¹¤Wªº¦Lªí¾÷, §A¥²¶·°µ¥H¤U¨BÆJ: a) §A¥²¶·¦b /etc/printcap ¤º¦³¾A·íªº°O¿ý,¦Ó¥B¥L­Ì¥²¶·»P·í¦a¥Ø¿ýµ²ºc (¹³ spool ¥Ø¿ýµ¥) ¬Û²Å¦X. b) §A¥²¶·¦³ script ÀÉ /usr/bin/smbprint. ³o·|ÀHªþ¦b Samba source, ¦ý¤£ ¬OÀHªþ©ó©Ò¦³ Samba binary µo¦æ®M¥ó. ¤@­Óµy·L­×§ïª©¥»¦b¥H¤U°Q½×. c) ¦pªG§A·Q­nÂà´« ASCII Àɨì Postscript,§A¥²¶·¦³netscript,©Î»P¨äµ¥®Ä ªº. netscipt ¬O¤@ºØ Postscript Âà´«¾¹¦Ó¥B¤@¯ë¬O¦w¸Ë¦b /usr/bin. d) §A¥i¥H§Æ±æÂǥѦ³©ö©ó¨Ï¥Îªº frond end ¨Ó¨Ï Samba ¦C¦L§ó®e©ö. ¤@ºØ¥Î©ó ³B²z ASCII, Postscript ©Î«Ø¥ß Postscript ªºÂ²³æ perl script ¦b¤U­±µ¹ ©w. ¥H¤U /etc/printcap ¶µ¥Ø¥Î¦b Windows NT ¥D¾÷¤W HP 5MP ¦Lªí¾÷. ³o¨Ç¶µ¥Ø¦p ¤U: _________________________________________________________________ cm - comment {»¡©ú} lp - device name to open for output {¬°¤F¿é¥X,¦Ó­n¶}±Òªº³]³Æ¦WºÙ} sd - the printer's spool directory (on the local machine) {¦Lªí¾÷ªº spool ¥Ø¿ý (¦b·í¦aªº¾÷¾¹¤W)} af - the accounting file {±b¸¹ÀÉ®×} mx - the maximum file size (zero is unlimited) {³Ì¤jÀɮפj¤p (¹sªí¥Ü¨S­­¨î)} if - name of the input filter (script) {¿é¤J¹LÂo¤§¦WºÙ (script)} _________________________________________________________________ ­n¨ú±o§ó¦h¸ê°T,½Ð¬Ý Printing HOWTO ©ÎªÌÃö©ó printcap ªº man page. ______________________________________________________________ # /etc/printcap # # //zimmerman/oreilly via smbprint # lp:\ :cm=HP 5MP Postscript OReilly on zimmerman:\ :lp=/dev/lp1:\ :sd=/var/spool/lpd/lp:\ :af=/var/spool/lpd/lp/acct:\ :mx#0:\ :if=/usr/bin/smbprint: ______________________________________________________________ ½Ð½T©w spool ©M accounting{±b¸¹} ªº¥Ø¿ý¦s¦b¥B¥i¼g¤J. ½Ð½T«H¬Y¦æ¦³¾A·íªº ¸ô®|«ü¨ì smbprint script (¦b¤U­±·|µ¹) ¦Ó¥B½T©w¾A·íªº³]³Æ³Q«ü¨ì ( /dev ¤U¬Y­ÓÀÉ). ¤U­Ó¬O smbprint script ¥»¨­. ¥¦³q±`³QÂ\¦b /usr/bin ¦Ó¥B¬O¦]¬° Andrew Tridgell ªº½t¬G,¦Ó¾Ú§Ú©Òª¾¬O¥L³Ð³y¤F Samba. ¥¦ÀHªþ¦b Samba source µo¦æ ®M¥ó, ¦ý¦b¬Y¨Ç binary µo¦æ®M¥ó¨Ã¨S¦³, ©Ò¥H¦b³o§Ú¦A³y¤@­Ó. §A¥i¥H§Æ±æ¥J²Ó¦a¬Ý³o­Ó. ¦³¬Y¨Ç¸û¤pªº­×§ï¤w¸gÃÒ©ú¥¦­Ì¬O«Ü¦³¥Îªº. ______________________________________________________________ #!/bin/sh -x # This script is an input filter for printcap printing on a unix machine. It # uses the smbclient program to print the file to the specified smb-based # server and service. # For example you could have a printcap entry like this # # smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint # # which would create a unix printer called "smb" that will print via this # script. You will need to create the spool directory /usr/spool/smb with # appropriate permissions and ownerships for your system. # Set these to the server and service you wish to print to # In this example I have a WfWg PC called "lapland" that has a printer # exported called "printer" with no password. # # Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton) # so that the server, service, and password can be read from # a /usr/var/spool/lpd/PRINTNAME/.config file. # # In order for this to work the /etc/printcap entry must include an # accounting file (af=...): # # cdcolour:\ # :cm=CD IBM Colorjet on 6th:\ # :sd=/var/spool/lpd/cdcolour:\ # :af=/var/spool/lpd/cdcolour/acct:\ # :if=/usr/local/etc/smbprint:\ # :mx=0:\ # :lp=/dev/null: # # The /usr/var/spool/lpd/PRINTNAME/.config file should contain: # server=PC_SERVER # service=PR_SHARENAME # password="password" # # E.g. # server=PAULS_PC # service=CJET_371 # password="" # # Debugging log file, change to /dev/null if you like. # logfile=/tmp/smb-print.log # logfile=/dev/null # # The last parameter to the filter is the accounting file name. # spool_dir=/var/spool/lpd/lp config_file=$spool_dir/.config # Should read the following variables set in the config file: # server # service # password # user eval `cat $config_file` # # Some debugging help, change the >> to > if you want to same space. # echo "server $server, service $service" >> $logfile ( # NOTE You may wish to add the line `echo translate' if you want automatic # CR/LF translation when printing. echo translate echo "print -" cat ) | /usr/bin/smbclient "\\\\$server\\$service" $password -U $user -N -P >> $log file ______________________________________________________________ ¤j³¡¤À linux µo¦æ®M¥óÀHªþ nenscript ¨ä¥Î¨ÓÂà´« ASCII ¤å¥ó¦¨ Postscript. ¥H¤U perl script ¸g¥Ñ smbprint ¨Ï§ó®e©ö´£¨Ñ¤@ºØ²³æ¤¶­±µ¹ linux ªº¦C¦L. _________________________________________________________________ Usage: print [-a|c|p] -a prints as ASCII -c prints formatted as source code -p prints as Postscript If no switch is given, print attempts to guess the file type and print appropriately. _________________________________________________________________ ¨Ï¥Î smbprint ¨Ó¦C¦L ASCII Àɮ׫K©óºIÂ_¹Lªøªº¦æ. ¦pªG¥i¯àªº¸Ü,³o­Ó script ºIÂ_ªø¦æ©óªÅ¥ÕÁä³B(¨ú¥N¦b¦rªº¤¤¶¡). ®æ¦¡¤Æ¹Lªº­ì©l½X¬O³Q nenscript ³B²z¹L. ¥¦³B²z ASCII ÀɦӥB¥Î­Ó¯S¿ïªº¼Ð ÀY(¹³ date,filenameµ¥)®æ¦¡¤Æ¦¨¨âÄæ. ¥¦¤]¥i­pºâ¦æ¼Æ. ¨Ï¥Î³o·í§@¨Ò¤l, ¨ä ¥L®æ¦¡«¬ºA¥i¥H¹F¦¨ªº. Postscript ¤å¥ó¤w¸g¾A·í¦a®æ¦¡¤Æ¤F,©Ò¥H¥¦­Ìª½±µ³q¹L. ______________________________________________________________ #!/usr/bin/perl # Script: print # Authors: Brad Marshall, David Wood # Plugged In Communications # Date: 960808 # # Script to print to oreilly which is currently on zimmerman # Purpose: Takes files of various types as arguments and # processes them appropriately for piping to a Samba print script. # # Currently supported file types: # # ASCII - ensures that lines longer than $line_length characters wrap on # whitespace. # Postscript - Takes no action. # Code - Formats in Postscript (using nenscript) to display # properly (landscape, font, etc). # # Set the maximum allowable length for each line of ASCII text. $line_length = 76; # Set the path and name of the Samba print script $print_prog = "/usr/bin/smbprint"; # Set the path and name to nenscript (the ASCII-->Postscript converter) $nenscript = "/usr/bin/nenscript"; unless ( -f $print_prog ) { die "Can't find $print_prog!"; } unless ( -f $nenscript ) { die "Can't find $nenscript!"; } &ParseCmdLine(@ARGV); # DBG print "filetype is $filetype\n"; if ($filetype eq "ASCII") { &wrap($line_length); } elsif ($filetype eq "code") { &codeformat; } elsif ($filetype eq "ps") { &createarray; } else { print "Sorry..no known file type.\n"; exit 0; } # Pipe the array to smbprint open(PRINTER, "|$print_prog") || die "Can't open $print_prog: $!\n"; foreach $line (@newlines) { print PRINTER $line; } # Send an extra linefeed in case a file has an incomplete last line. print PRINTER "\n"; close(PRINTER); print "Completed\n"; exit 0; # --------------------------------------------------- # # Everything below here is a subroutine # # --------------------------------------------------- # sub ParseCmdLine { # Parses the command line, finding out what file type the file is # Gets $arg and $file to be the arguments (if the exists) # and the filename if ($#_ < 0) { &usage; } # DBG # foreach $element (@_) { # print "*$element* \n"; # } $arg = shift(@_); if ($arg =~ /\-./) { $cmd = $arg; # DBG # print "\$cmd found.\n"; $file = shift(@_); } else { $file = $arg; } # Defining the file type unless ($cmd) { # We have no arguments if ($file =~ /\.ps$/) { $filetype = "ps"; } elsif ($file =~ /\.java$|\.c$|\.h$|\.pl$|\.sh$|\.csh$|\.m4$|\ .inc$|\.html$|\.htm$/) { $filetype = "code"; } else { $filetype = "ASCII"; } # Process $file for what type is it and return $filetype } else { # We have what type it is in $arg if ($cmd =~ /^-p$/) { $filetype = "ps"; } elsif ($cmd =~ /^-c$/) { $filetype = "code"; } elsif ($cmd =~ /^-a$/) { $filetype = "ASCII" } } } sub usage { print " Usage: print [-a|c|p] -a prints as ASCII -c prints formatted as source code -p prints as Postscript If no switch is given, print attempts to guess the file type and print appropriately.\n "; exit(0); } sub wrap { # Create an array of file lines, where each line is < the # number of characters specified, and wrapped only on whitespace # Get the number of characters to limit the line to. $limit = pop(@_); # DBG #print "Entering subroutine wrap\n"; #print "The line length limit is $limit\n"; # Read in the file, parse and put into an array. open(FILE, "<$file") || die "Can't open $file: $!\n"; while() { $line = $_; # DBG #print "The line is:\n$line\n"; # Wrap the line if it is over the limit. while ( length($line) > $limit ) { # DBG #print "Wrapping..."; # Get the first $limit +1 characters. $part = substr($line,0,$limit +1); # DBG #print "The partial line is:\n$part\n"; # Check to see if the last character is a space. $last_char = substr($part,-1, 1); if ( " " eq $last_char ) { # If it is, print the rest. # DBG #print "The last character was a space\n"; substr($line,0,$limit + 1) = ""; substr($part,-1,1) = ""; push(@newlines,"$part\n"); } else { # If it is not, find the last space in the # sub-line and print up to there. # DBG #print "The last character was not a space\n"; # Remove the character past $limit substr($part,-1,1) = ""; # Reverse the line to make it easy to find # the last space. $revpart = reverse($part); $index = index($revpart," "); if ( $index > 0 ) { substr($line,0,$limit-$index) = ""; push(@newlines,substr($part,0,$limit-$index) . "\n"); } else { # There was no space in the line, so # print it up to $limit. substr($line,0,$limit) = ""; push(@newlines,substr($part,0,$limit) . "\n"); } } } push(@newlines,$line); } close(FILE); } sub codeformat { # Call subroutine wrap then filter through nenscript &wrap($line_length); # Pipe the results through nenscript to create a Postscript # file that adheres to some decent format for printing # source code (landscape, Courier font, line numbers). # Print this to a temporary file first. $tmpfile = "/tmp/nenscript$$"; open(FILE, "|$nenscript -2G -i$file -N -p$tmpfile -r") || die "Can't open nenscript: $!\n"; foreach $line (@newlines) { print FILE $line; } close(FILE); # Read the temporary file back into an array so it can be # passed to the Samba print script. @newlines = (""); open(FILE, "<$tmpfile") || die "Can't open $file: $!\n"; while() { push(@newlines,$_); } close(FILE); system("rm $tmpfile"); } sub createarray { # Create the array for postscript open(FILE, "<$file") || die "Can't open $file: $!\n"; while() { push(@newlines,$_); } close(FILE); } ______________________________________________________________ 10. ª©Åv 1996 ¦~ªº HOWTO ª©Åv¬OÄÝ©ó David Wood. ¥¦¥i¥H¥Î¥ô¦ó«¬¦¡ªº¦A­«Âв£¥Í¥H¤Î ¦Û¥Ñªº´²¼½,¥u­n³o­ÓÀÉ­ì«Ê¤£°Ê,¥]§t³o¬q±Ô­z. 11. ·P¿E ¥u­n§A¼g«Hµ¹§Ú´£¨Ñ·N¨£, §Ú±N·|¦b³o(¤å¥ó)ªº¤U¤@ª©·P¿E§A. References 1. mailto:dwood@plugged.net.au 2. mailto:r6921068@ms.cc.ntu.edu.tw 3. mailto:dwood@plugged.net.au 4. ftp://nimbus.anu.edu.au/pub/tridge/samba/ 5. ftp://nimbus.anu.edu.au/pub/tridge/samba/ 6. file://localhost/tmp/zh-sgmltools.16199/SMB-HOWTO.txt.html#sec-daemons 7. mailto:dwood@plugged.net.au