\documentclass[letterpaper]{article}
\nonstopmode
\akai
\usepackage{linuxdoc-sgml}
\usepackage{qwertz}
\usepackage{url}
\usepackage[latin1]{inputenc}
\usepackage{t1enc}
\usepackage[english]{babel}
\usepackage{epsfig}
\usepackage{null}
\def\addbibtoc{
\addcontentsline{toc}{section}{\numberline{\mbox{}}\relax\bibname}
}%end-preamble
\setcounter{page}{1}
\title{SMB HOWTO}
\author{×÷Õß: David Wood, {\ttfamily \onlynameurl{dwood@plugged.net.au}}\\ 
ÒëÕß: J.S. Lin, {\ttfamily \onlynameurl{r6921068@ms.cc.ntu.edu.tw}}}
\date{v1.0, 10 August 1996}
\abstract{ÕâÊÇ SMB HOWTO $\{$ÈçºÎÊ¹ÓÃ SMB$\}$.  ÕâÎÄ¼þÃèÊöÔÚ Linux ÉÏÈçºÎÊ¹ÓÃ Session Message Block (SMB) protocol$\{$Ð­¶¨$\}$, Ò²½Ð×ö NetBIOS »ò LanManager protocol.}


\begin{document}
\maketitle
\tableofcontents

\section{½éÉÜ}

ÕâÊÇ SMB HOWTO $\{$ÈçºÎÊ¹ÓÃ SMB$\}$ .  ÕâÎÄ¼þÃèÊöÔÚ Linux ÉÏÈçºÎÊ¹ÓÃ Session Message Block (SMB) protocol, Ò²½Ð×ö NetBIOS »ò LanManager protocol.

±¾ÎÄ¼þµÄÎ¬»¤ÕßÊÇ David Wood (\onlynameurl{dwood@plugged.net.au}).  ÔÙÕß,ÐÞ¸Ä»òÐÞÕý¿ÉÒÔ¼Äµ½ÄÇ,ÒÔ±ãÏÂÒ»°æ°üº­½øÈ¥.

SMB protocol ±»Ê¹ÓÃÔÚ Microsoft Windows 3.11, NT ºÍ 95 ÓÃÀ´·ÖÏí´Åµú¼°Ó¡»ú.  Ê¹ÓÃ Andrew Tridgell Ëù×öµÄ Samba ¹¤¾ßÌ×¼þ, UNIX (°üº¬ Linux) »úÆ÷ÄÜ·ÖÏí´ÅµúÓëÓ¡±í»ú¸ø Windows Ö÷»ú.

ÎáÈËÊ¹ÓÃ Samba ÓÐËÄÑù¶«Î÷¿ÉÒÔ×ö:

\begin{enumerate}
\item ·ÖÏí linux ´Åµú¸ø Windows »úÆ÷.
\item ·ÖÏí Windows ´Åµú¸ø linux »úÆ÷.
\item ·ÖÏí linux Ó¡±í»ú¸ø Windows »úÆ÷.
\item ·ÖÏí Windows Ó¡±í»ú¸ø linux »úÆ÷.
\end{enumerate}


ÕâÐ©¶«Î÷¶¼ÒÑ°üº¬ÔÚ±¾ÎÄ¼þÖÐ.

Disclaimer: procedures ºÍ script ÒªÂï¶Ô×÷ÕßÊÇ¿ÉÒÔÕý³£ÔË×÷µÄ,»òÒªÂïÓÉÄÇÐ©(proceduresºÍscript)µÄÌá¹©Õß±¨¸æ¿ÉÒÔÕý³£ÔË×÷. ÒÔÔÚÕâ¡õµÄ×ÊÑ¶×ö²»Í¬µÄÉè¶¨¿ÉÄÜ»á²»ÄÜÕý³£ÔË×÷.Èç¹ûÄãÔâÓöÀàËÆµÄÀ§¾³,Äã¿ÉÒÔ e-mail ¸ø×÷Õß,Ìá³ö½¨ÒéÀ´¸Ä½ø±¾ÎÄ¼þ, µ«×÷Õß²¢²»×÷ÈÎºÎ±£Ö¤.ÄãÔ¤ÆÚÊ²÷áÄØ? ×÷Õß±Ï¾¹Ö»ÊÇ¸ö¹ËÎÊ.....






\section{½øÒ»²½×ÊÑ¶}

Õâ¸ö HOWTO Éè·¨È¥½âÊÍÈçºÎÉè¶¨»ù±¾µÄ SMBµµÒÔ¼°ÁÐÓ¡·þÎñÔÚ linux »úÆ÷ÉÏ. Samba ÊÇ¸ö·Ç³£¸´ÔÓÇÒÍêÕûµÄ°ü×°. ÔÚÕâ¸öµØ·½Ã»ÓÐÒªÉè·¨È¥¸´ÖÆËùÓÐµÄ Samba ÎÄ¼þ.

½øÒ»²½×ÊÑ¶,Çë¿´ÒÔÏÂÎÄ¼þ:
\begin{itemize}
\item Samba ÎÄ¼þ, ¿ÉÈ¡µÃì¶ Samba ·¢ÐÐÌ×¼þ$\{$distribution$\}$µÄ²¿·Ö. ´Ë·¢ÐÐÌ×¼þ¿ÉÈ¡µÃÔÚ:
\nameurl{ftp://nimbus.anu.edu.au/pub/tridge/samba/}{ftp://nimbus.anu.edu.au/pub/tridge/samba/}
\item The linux Printing HOWTO.
\item The Print2Win Mini-HOWTO.
\end{itemize}







\section{°²×°}

×îÐÂ Samba µÄÔ­Ê¼³ÌÊ½¿ÉÒÔÈ¡µÃ×Ô:

\nameurl{ftp://nimbus.anu.edu.au/pub/tridge/samba/}{ftp://nimbus.anu.edu.au/pub/tridge/samba/}

È»¶ø,Èç¹ûÒÑ°²×° linux µÄ Redhat °æ±¾,Äã¿ÉÒÔÊ¹ÓÃÈíÌåÌ×¼þ$\{$package$\}$ À´°²×°Ëü.ÓÐÐ©ÆäËû°æ±¾Ò²°üº¬ Samba µÄbinaries$\{$¶þÔªµµ³ÌÊ½$\}$.

ÒÔÏÂÁ½¸ö daemon$\{$¹ÜÀí¾«Áé$\}$ ¶Ô Samba ÈíÌåÌ×¼þ ÊÇ±ØÒªµÄ. ËüÃÇÒ»°ãÊÇ±»°²×°ÔÚ /usr/sbin ,¶ø¿ÉÔÚ¿ª»úÊ±,´ÓÏµÍ³Æð¶¯µÄ scripts»òinetdÀ´Ö´ÐÐ. scriptµÄÀý×Ó±»Õ¹Ê¾ÔÚ \ref{sec-daemons} {(Ö´ÐÐ Daemons)}. 

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
        smbd (The SMB daemon)
        nmbd (Ìá¹© NetBIOS nameserver µÄÖ§Ô®¸ø clients)
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Ò»°ã¶øÑÔ,ÒÔÏÂµÄ Samba µÄ binaries ±»°²×°ÔÚ /usr/bin, ËäÈ»ËµËüµÄÎ»ÖÃÊÇ¿ÉÑ¡ÔñÐÔ.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
        smbclient       (Ò»ÖÖ¹©¸ø UNIX »úÆ÷ÓÃµÄ SMB  client{³ÌÊ½})
        smbprint        (Ò»ÖÖ script ÓÃÔÚÁÐÓ¡ì¶ SMB Ö÷»ú{host}ÉÏµÄÁÐ±í»ú)
        smbprint.sysv   (Í¬ÉÏ, µ«ÊÇÌá¹©¸ø SVR4 UNIX »úÆ÷ÓÃµÄ)
        smbstatus       (ÁÐ³ö¶Ôµ±µØÖ÷»úÖ®Ä¿Ç° SMB Á¬½áÇé¿ö)
        smbrun          (Ò»ÖÖ 'glue' script ÓÃÀ´¼òÒ×µØÖ´ÐÐÓ¦ÓÃ³ÌÊ½ì¶ SMB Ö÷»ú)
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÔÙÕß,Ò»ÖÖ½Ð 'print' µÄ script ±»°üº¯ÔÚ±¾ HOWTO Ö®ÖÐ, ÆäÓÃÀ´µ±×÷Ò»ÖÖÓÐÓÃµÄ front end$\{$Ç°¶Ë½éÃæ$\}$ ¸ø smbprint scriptÓÃ.

Samba ÈíÌåÌ×¼þÊÇ¼òÒ×°²×°µÄ.¼òµ¥µØ´ÓÉÏÊöµÄÎ»Ö·È¡µÃÔ­Ê¼Âë, ÇÒÔÄ¶ÁÔÚ·¢ÐÐÌ×¼þÖÐµÄ README µµ°¸. ÔÚ·¢ÐÐÌ×¼þÖÐÒ²ÓÐÒ»¸ö docs/INSTALL.txt µµÌá¹©Ò»¸ö¼òµ¥µÄÖð²½°²×°Ö¸Ê¾.

½ÓÖø°²×°áá, °Ñ daemons ·Åµ½ /usr/sbin ¶ø binaries ·Åµ½ /usr/bin. ¶ø man pages$\{$ÊÖ²áÒ³$\}$ °ÚÔÚ /usr/local/man.

µ±ÄãÔÚ×ö Samba ÈíÌåÌ×¼þ, ÄãÔÚ Makefile ÖÐ»áÓÐ¼ÇÔØ×éÌ¬µµ,smb.conf,µÄÎ»ÖÃ. ÕâÒ»°ãÊÇÔÚ /etcÏÂ, µ«¿ÉÒÔ°ÑËü°Úµ½ÄãÏ²»¶°ÚµÄÈÎÒâÎ»ÖÃ. ¶Ôì¶ÕâÐ©Ê¹ÓÃ·½·¨$\{$directions$\}$, ÎÒÃÇ½«¼ÙÉèÄã¼ÇÔØ×éÔØµµÎ»ÖÃ³É /etc/smb.conf, log µµÎ»ÖÃÎª log file = /var/log/samba-log.\%m ,¶ø lock Ä¿Â¼Îª lock directory = /var/lock/samba.

°²×°×éÌ¬$\{$configuration$\}$µµ, smb.conf. È¥ Samba ËùÔÚµÄµÄÄ¿Â¼. ¿´Ò»ÏÂÔÚÆä×ÓÄ¿Â¼ example/simple ¶øÇÒ¶ÁÒ»ÏÂ README µµ. ¸´ÖÆÔÚÄÇ¸öÄ¿Â¼ÏÂµÄ smb.conf µµµ½ /etc ÏÂ. ×¢Òâ! Èç¹ûÄãÓÐÒ» linux ·¢ÐÐÌ×¼þÒÑ°²×°ºÃ Samba, ÄãÒ²ÐíÒÑÓÐ Samba ×éÌ¬µµÔÚ /etc ÏÂ. »òÐíÄãÓ¦¸Ã´ÓÄÇ¸öµµ¿ªÊ¼.



Èç¹ûÄã²»Ïë°Ñ×éÌ¬µµ·ÅÔÚ /etc Ä¿Â¼ÏÂ,¿ÉÒÔ°ÑËü°ÚÔÚÄãÏëÒª°ÚµÄµØ·½,È»ááÔÚ /etc ÏÂ×öÒ»ÏÂ symlink$\{$·ûºÅÁ¬½á$\}$:

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
        ln -s /path/to/smb.conf /etc/smb.conf
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}





\section{Ö´ÐÐÕâÁ½¸ö daemon\label{sec-daemons}}

ÕâÁ½¸ö daemon ÊÇ /usr/sbin/smbd ºÍ /usr/sbin/nmbd. 

Äã¿ÉÒÔÖ´ÐÐ Samba daemon ´Ó inetd »òµ±³Éµ¥¶ÀµÄ³ÌÐò. Èç¹ûÄãÕýÉè¶¨Ò»¸öÓÀ¾Ãµµ°¸ËÅ·þÆ÷,ÄãÓ¦¸Ã´Ó inetd À´Ö´ÐÐ,ËùÒÔÈç¹ûËûÃÇËÀµô,ÄÇ½«ÖØÐÂ¿ªÊ¼.Èç¹ûÄãÖ»ÊÇÅ¼¶ûÏëÒªÊ¹ÓÃ SMB ËÅ·þÆ÷,»òÕßÓÃÏµÍ³¹ÜÀíÀ´¸¨Öú,µ±ÄãÐèÒªÊ±,Äã¿ÉÒÔ½åÓÉÊ¹ÓÃ /etc/rc.d/init.d script,»òÉõÖÁÖ±½ÓÊÖ¶¯µÄ. 

Òª´Ó inetd À´Ö´ÐÐ daemon , Çë·ÅÒÔÏÂ¼¸ÐÐÔÚ inetd ×éÌ¬µµ, /etc/inetd.conf:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    # 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
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


È»ááÏÂÖ¸ÁîÒÔ±ãÖØÐÂÆô¶¯ inetd daemon :

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    kill -HUP 1
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Òª´ÓÏµÍ³Æô¶¯µÄ script À´Ö´ÐÐ daemon, Çë°ÑÒÔÏÂµÄ script ÖÃì¶Ò»¸ö½Ð×ö /etc/rc.d/init.d/smb µµ, ¶øÇÒ symbolically link µ½×¢ÊÍ$\{$comments$\}$ËùËµÃ÷µÄµµ°¸:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    #!/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
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}







\section{Ò»°ã×éÌ¬Éè¶¨ (/etc/smb.conf)}

ÔÚ linux (»òÆäËû UNIX»úÆ÷)ÉÏµÄ Samba ×éÌ¬Éè¶¨ÊÇ±»µ¥Ò»µµ°¸, /etc/smb.conf ,Ëù¿ØÖÆ. Õâ¸öµµ¾ö¶¨ÄãÏëÒªÄÄ¸öÏµÍ³×ÊÔ´·ÖÏí¸øÍâÃæÊÀ½çÒÔ¼°ÄãÏë¶ÔËûÃÇ×öÊ²÷áÏÞÖÆ.

ÒòÎªÒÔÏÂÕÂ½Ú½«»á´¦Àí·ÖÏí linux ´ÅµúÓëÓ¡±í»ú¸ø Windows »úÆ÷, ±¾Ð¡½ÚËùÕ¹Ê¾µÄ smb.conf µµ¾¡Á¿ÊÇÄãËùÄÜÈ¡µÃ½Ï¼òµ¥µÄ, ËüÖ»ÊÇÒÔ½éÉÜÐÔÎªÄ¿µÄ.

Ä¿Ç°»¹²»Òªµ£ÐÄÏ¸½Ú²¿·Ö. ááÃæµÄÕÂ½Ú½«»á½éÉÜÖ÷ÒªµÄ¸ÅÄî.

ÔÚµµ°¸ÖÐµÄÃ¿µÄ¶ÎÂä$\{$section$\}$»áÓÐ¸ö¶ÎÂä±êÍ·¿ªÊ¼, Æä±êÍ·ÏñÊÇ {[}global], {[}homes], {[}printers] µÈµÈ.

{[}global] ¶ÎÂä¶¨ÒåÒ»Ð©±äÊý, ¶ø Samba ½«ÓÃÀ´¶¨Òåì¶ËùÓÐ×ÊÔ´Ö®·ÖÏí.

{[}homes] ¶ÎÂäÔÊÐíÔ¶¶ËÊ¹ÓÃÕßÀ´´æÈ¡ÔÚµ±µØ(linux)»úÆ÷ÉÏÖ®ËûÃÇµÄ(ÇÒÖ»ÓÐËûÃÇµÄ) home directories$\{$¼ÒÄ¿Â¼$\}$. Ò²¾ÍÊÇ, Èç¹ûÒ»¸ö Windows Ê¹ÓÃÕß´ÓËûÃÇµÄ Windows »úÆ÷ÒªÉè·¨Á¬½Óµ½Õâ¸ö·ÖÏí, ËûÃÇ½«ÊÇÁ¬½Óµ½ËûÃÇ×Ô¼º¸öÈËµÄ home directiory. Òª×öÕâÑùÊÂÇé,ËùÒª×¢ÒâµÄÊÇ,ËûÃÇ±ØÐëÔÚlinux boxÉÏÓÐ¸öÕÊºÅ.

ÒÔÏÂµÄ smb.conf µµ°¸Ñù±¾ÔÊÐíÔ¶¶ËÊ¹ÓÃÕßÀ´ÓÃµ±µØ»úÆ÷ÉÏËûÃÇµÄ home directories ¶øÇÒÐ´µ½Ò»¸öÔÝ´æµÄÄ¿Â¼. ¶ÔÒ»¸ö Windows Ê¹ÓÃÕß,ÒªÏë¿´µ½ÕâÐ©·ÖÏí, linux box ±ØÐëÊÇÔÚÇøÓòÍøÂ·$\{$local network$\}$ÄÚ. È»áá,Ê¹ÓÃÕß¼òµ¥µØ´Ó Windows File Manager »ò Windows Explorer Á¬½Óµ½ÍøÂ·´Åµú.

ÔÚÒÔÏÂ¶ÎÂäÒª×¢ÒâµÄÊÇ, ¶ÔÕâ¸öµµÖ®¶îÍâÏîÄ¿½«»áÓÃÀ´ÔÊÐí¸ü¶à×ÊÔ´±»·ÖÏí.

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
; /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
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}







\section{·ÖÏí Linux ´Åµú¸ø Windows »úÆ÷}

ÒÔÉÏËùÕ¹Ê¾µÄ smb.conf Ñù±¾µµ, ·ÖÏí linux ´Åµú¸ø Windows Ê¹ÓÃÕßÊÇºÜÈÝÒ×µÄ. È»¶ø, Ïñ Samba ÆäËûµÄ¶«Î÷, Äã¿ÉÒÔ¿ØÖÆµ½ºÜ´óµÄ³Ì¶È. ÒÔÏÂÓÐÐ©Àý×Ó :

ÎªÁË·ÖÏíÄ¿Â¼¸ø´ó¼ÒÊ¹ÓÃ, ¾Í½¨Á¢¸öÀàËÆÉÏÊö {[}tmp] ¶ÎÂä, Òà¼´¼ÓÈëÏñÕâ¸öµÄ¶«Î÷µ½ smb.conf:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
[public]
   comment = Public Stuff
   path = /home/public
   public = yes
   writable = yes
   printable = yes
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


ÎªÁËÊ¹ÒÔÉÏÄ¿Â¼¹©´óÖÚ¿É¶ÁÈ¡,µ«Ö»ÓÐÈº×é³ÉÔ±$\{$group staff$\}$¿ÉÐ´Èë,ÇëÐÞ¸ÄÆäÏîÄ¿ÏñÕâÑù:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
[public]
   comment = Public Stuff
   path = /home/public
   public = yes
   writable = yes
   printable = no
   write list = @staff
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


ÆäËûÍæ´Åµú·ÖÏíµÄ¼¼ÇÉ,Çë¿´ Samba ÎÄ¼þ»ò man pages.






\section{·ÖÏí Windows ´Åµú¸ø Linux »úÆ÷}

Ò»ÖÖ¸ø UNIX »úÆ÷ÓÃµÄ SMB client ³ÌÊ½±»°üº¬ÔÚ Samba ·¢ÐÐÌ×¼þÖ®ÖÐ.ËüÌá¹©Ò»ÖÖÔÚÃüÁîÁÐÏÂµÄÏñftpµÄ½éÃæ.

ÏëÒª¿´ÔÚ¸ø¶¨µÄÖ÷»úÉÏÓÐÄÄÐ©·ÖÏí¿ÉÈ¡µÃ, Ö´ÐÐ:

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    /usr/sbin/smbclient -L host
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Õâ¡õµÄ 'host' ÊÇÄãÏëÒªä¯ÀÀµÄ»úÆ÷Ãû×Ó. Õâ½«»á»ØÓ¦Ò»´® 'service' µÄÃû³Æ - Ò²¾ÍÊÇ, ËüËù·ÖÏí¸øÄãµÄ´Åµú»òÓ¡±í»úµÄÃû³Æ. ³ý·Ç SMB ËÅ·þÆ÷Ã»ÓÐ°²È«ÉÏµÄÉè¶¨, ·ñÔòËü½«ÒªÇóÄãÊäÈëÃÜÂë. ¸øËü 'guest' ÕÊºÅµÄÃÜÂë»òÊÇÄã¸öÈËÔÚÄÇÌ¨»úÆ÷ÉÏÕÊºÅµÄÃÜÂë.

¾Ù¸öÀý×Ó:

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    smbclient -L zimmerman
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Õâ¸öÖ¸ÁîµÄÊä³öÓ¦¸Ã¿´ÆðÀ´ÏñÊÇÕâÑù:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
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            
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


Õâ¸ö browse list ÁÐ³öÆäËûÓÐ×ÊÔ´·ÖÏí¸øÍøÂ·µÄ SMB ËÅ·þÆ÷.

ÒªÊ¹ÓÃ´Ë client, ÇëÖ´ÐÐ:

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    /usr/sbin/smbclient service <password>
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Õâ¡õµÄ 'service' ÊÇÒ»Ì¨»úÆ÷ºÍ·ÖÏíÃû³Æ. ¾ÙÀý¶øÑÔ,Èç¹ûÄãÉè·¨Á¬µ½Ò»Ì¨½Ð×ö zimmerman µÄ»úÆ÷ÉÏÖ®ÒÔ 'public' Îª·ÖÏíÃû³ÆµÄÄ¿Â¼ ,´Ë service Òª½Ð×ö  $\backslash$$\backslash$zimmerman$\backslash$public. È»¶ø,ÒòÎª shell ÏÞÖÆ, Äã»áÐèÒªÍÑÀë backslashes, ËùÒÔÄãÒªÏñÕâÑùµÄ½áÊø:

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
    /usr/sbin/smbclient \\\\zimmerman\\public mypasswd
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÕâÑùµÄ 'mypasswd' ÊÇÄãµÄÃÜÂëÖ®ÎÄ×Ö´®$\{$literal string$\}$.

Äã½«»áÓÐ smbclient µÄÌáÊ¾·ûºÅ$\{$prompt$\}$³öÏÖ:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
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: \> 
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


¼üÈë 'h' È¡µÃ¹Øì¶Ê¹ÓÃ smbclient µÄ help:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
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: \> 
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


Èç¹ûÄãÄÜÊ¹ÓÃftp,ÄãÓ¦¸Ã²»ÐèÒª²éÑ¯ smbclient µÄ man pages.






\section{·ÖÏí Linux Ó¡±í»ú¸ø Windows »úÆ÷}

ÎªÁË·ÖÏí Linux Ó¡±í»ú¸ø Windows »úÆ÷, Äã±ØÐëÈ·¶¨ÄãµÄÓ¡±í»úÒÑ¾­×°ÉèºÃ. Èç¹ûÄãÄÜ´Ó linux ÉÏÁÐÓ¡,Éè¶¨ SMB µÄÓ¡±í»ú·ÖÏí½«»áºÜÖ±½Ó.

Çë¼û Printing HOWTO À´Éè¶¨µ±µØµÄÁÐÓ¡.

ÒòÎª×÷ÕßÊ¹ÓÃ±»Á¬½Óµ½ Windows NT »úÆ÷µÄÓ¡±í»ú, ÕâÐ¡½Ú²»Ó¦¸Ã±»ÊÓÎªºÜÍêÕûµÄ,¶øÖ»ÊÇ½¨Òé.ÈÎºÎÓÐÏêÏ¸×ÊÁÏ¿É·ÖÏí³öÀ´µÄÈË, Çë½«ÕâÐ©×ÊÁÏ¼Äµ½
\onlynameurl{dwood@plugged.net.au}
Ê¹µÃÕâÐ¡½ÚÄÜ¹»Íê³É.

¼ÓÈëÁÐÓ¡Éè¶¨µ½ÄãµÄ smb.conf:

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
[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
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


È·ÈÏÓ¡±í»úµÄÂ·¾¶(±¾Àý×ÓÖÐÊÇÔÚ{[}ljet]ÏÂ)ÒªÓë /etc/printcapÖÐµÄ spool Ä¿Â¼Ïà·ûºÏ!

×¢Òâ:  Ê¹ÓÃ Samba À´·ÖÏí UNIX boxes ÉÏµÄÓ¡±í»ú¸ø Windows NT »úÆ÷ÓÐÒ»Ð©ÎÊÌâ. ÆäÖÐÒ»¸öÎÊÌâÊÇÊ¹ÓÃ NT ÊÊµ±µØ¿´µ½·ÖÏíµÄÓ¡±í»ú. ÏëÒªÐÞÕýÕâ¸öÎÊÌâ, Çë¿´ Samba ·¢ÐÐÌ×¼þÉÏµÄËµÃ÷, ¼´ docs/WinNT.txt µµ°¸.ÆäËûÊÇ´¦ÀíÃÜÂëµÄÎÊÌâ. ¶Ôì¶ÕâÈÅÈËÎÊÌâµÄÁË½âÓë²»ÄÜ³É¹¦µÄÐÞÕý,Çë¿´ÏàÍ¬ÎÄ¼þÉÏµÄËµÃ÷.






\section{·ÖÏí Windows Ó¡±í»ú¸ø Linux »úÆ÷}

ÎªÁË·ÖÏí Windows »úÆ÷ÉÏµÄÓ¡±í»ú, Äã±ØÐë×öÒÔÏÂ²½Öè:

a) Äã±ØÐëÔÚ /etc/printcap ÄÚÓÐÊÊµ±µÄ¼ÇÂ¼,¶øÇÒËûÃÇ±ØÐëÓëµ±µØÄ¿Â¼½á¹¹ (Ïñ spool Ä¿Â¼µÈ) Ïà·ûºÏ.

b) Äã±ØÐëÓÐ script µµ /usr/bin/smbprint. Õâ»áËæ¸½ÔÚ Samba source, µ«²»ÊÇËæ¸½ì¶ËùÓÐ Samba binary ·¢ÐÐÌ×¼þ. Ò»¸öÉÔÎ¢ÐÞ¸Ä°æ±¾ÔÚÒÔÏÂÌÖÂÛ.

c) Èç¹ûÄãÏëÒª×ª»» ASCII µµµ½ Postscript,Äã±ØÐëÓÐnetscript,»òÓëÆäµÈÐ§µÄ. netscipt ÊÇÒ»ÖÖ Postscript ×ª»»Æ÷¶øÇÒÒ»°ãÊÇ°²×°ÔÚ /usr/bin.

d) Äã¿ÉÒÔÏ£Íû½åÓÉÓÐÒ×ì¶Ê¹ÓÃµÄ frond end À´Ê¹ Samba ÁÐÓ¡¸üÈÝÒ×. Ò»ÖÖÓÃì¶´¦Àí ASCII, Postscript »ò½¨Á¢ Postscript µÄ¼òµ¥ perl script ÔÚÏÂÃæ¸ø¶¨. 

ÒÔÏÂ /etc/printcap ÏîÄ¿ÓÃÔÚ Windows NT Ö÷»úÉÏ HP 5MP Ó¡±í»ú. ÕâÐ©ÏîÄ¿ÈçÏÂ:

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
        cm - comment
             {ËµÃ÷}
        lp - device name to open for output
             {ÎªÁËÊä³ö,¶øÒª¿ªÆôµÄÉè±¸Ãû³Æ}
        sd - the printer's spool directory (on the local machine)
             {Ó¡±í»úµÄ spool Ä¿Â¼ (ÔÚµ±µØµÄ»úÆ÷ÉÏ)}
        af - the accounting file
             {ÕÊºÅµµ°¸}
        mx - the maximum file size (zero is unlimited)
             {×î´óµµ°¸´óÐ¡ (Áã±íÊ¾Ã»ÏÞÖÆ)}
        if - name of the input filter (script)
             {ÊäÈë¹ýÂËÖ®Ãû³Æ (script)}
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÒªÈ¡µÃ¸ü¶à×ÊÑ¶,Çë¿´ Printing HOWTO »òÕß¹Øì¶ printcap µÄ man page.

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
# /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:
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


ÇëÈ·¶¨ spool ºÍ accounting$\{$ÕÊºÅ$\}$ µÄÄ¿Â¼´æÔÚÇÒ¿ÉÐ´Èë. ÇëÈ·ÐÅÄ³ÐÐÓÐÊÊµ±µÄÂ·¾¶Ö¸µ½ smbprint script (ÔÚÏÂÃæ»á¸ø) ¶øÇÒÈ·¶¨ÊÊµ±µÄÉè±¸±»Ö¸µ½ ( /dev ÏÂÄ³¸öµµ).

ÏÂ¸öÊÇ smbprint script ±¾Éí. ËüÍ¨³£±»°ÚÔÚ /usr/bin ¶øÇÒÊÇÒòÎª Andrew Tridgell µÄÔµ¹Ê,¶ø¾ÝÎÒËùÖªÊÇËû´´ÔìÁË Samba. ËüËæ¸½ÔÚ Samba source ·¢ÐÐÌ×¼þ, µ«ÔÚÄ³Ð© binary ·¢ÐÐÌ×¼þ²¢Ã»ÓÐ, ËùÒÔÔÚÕâÎÒÔÙÔìÒ»¸ö. 

Äã¿ÉÒÔÏ£Íû×ÐÏ¸µØ¿´Õâ¸ö. ÓÐÄ³Ð©½ÏÐ¡µÄÐÞ¸ÄÒÑ¾­Ö¤Ã÷ËüÃÇÊÇºÜÓÐÓÃµÄ.

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
#!/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 >> $logfile
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}


´ó²¿·Ö linux ·¢ÐÐÌ×¼þËæ¸½ nenscript ÆäÓÃÀ´×ª»» ASCII ÎÄ¼þ³É Postscript. ÒÔÏÂ perl script ¾­ÓÉ smbprint Ê¹¸üÈÝÒ×Ìá¹©Ò»ÖÖ¼òµ¥½éÃæ¸ø linux µÄÁÐÓ¡.

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
Usage: print [-a|c|p] <filename>
       -a prints <filename> as ASCII
       -c prints <filename> formatted as source code
       -p prints <filename> as Postscript
        If no switch is given, print attempts to
        guess the file type and print appropriately.
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Ê¹ÓÃ smbprint À´ÁÐÓ¡ ASCII µµ°¸±ãì¶½Ø¶Ï¹ý³¤µÄÐÐ. Èç¹û¿ÉÄÜµÄ»°,Õâ¸ö script ½Ø¶Ï³¤ÐÐì¶¿Õ°×¼ü´¦(È¡´úÔÚ×ÖµÄÖÐ¼ä). 

¸ñÊ½»¯¹ýµÄÔ­Ê¼ÂëÊÇ±» nenscript ´¦Àí¹ý. Ëü´¦Àí ASCII µµ¶øÇÒÓÃ¸öÌØÑ¡µÄ±êÍ·(Ïñ date,filenameµÈ)¸ñÊ½»¯³ÉÁ½À¸. ËüÒ²¿É¼ÆËãÐÐÊý. Ê¹ÓÃÕâµ±×÷Àý×Ó, ÆäËû¸ñÊ½ÐÍÌ¬¿ÉÒÔ´ï³ÉµÄ.

Postscript ÎÄ¼þÒÑ¾­ÊÊµ±µØ¸ñÊ½»¯ÁË,ËùÒÔËüÃÇÖ±½ÓÍ¨¹ý.

\begin{tscreen}
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
#!/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] <filename>
       -a prints <filename> as ASCII
       -c prints <filename> formatted as source code
       -p prints <filename> 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(<FILE>) {
                $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(<FILE>) {
                push(@newlines,$_);
        }
        close(FILE);
        system("rm $tmpfile");
}

sub createarray {
        # Create the array for postscript
        open(FILE, "<$file") || die "Can't open $file: $!\n";
        while(<FILE>) {
                push(@newlines,$_);
        }
        close(FILE);
}
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}
\end{tscreen}







\section{°æÈ¨}

1996 ÄêµÄ HOWTO °æÈ¨ÊÇÊôì¶ David Wood. Ëü¿ÉÒÔÓÃÈÎºÎÐÍÊ½µÄÔÙÖØ¸²²úÉúÒÔ¼°×ÔÓÉµÄÉ¢²¥,Ö»ÒªÕâ¸öµµÔ­·â²»¶¯,°üº¬Õâ¶ÎÐðÊö.






\section{¸Ð¼¤}

Ö»ÒªÄãÐ´ÐÅ¸øÎÒÌá¹©Òâ¼û, ÎÒ½«»áÔÚÕâ(ÎÄ¼þ)µÄÏÂÒ»°æ¸Ð¼¤Äã.



\end{document}
