67 FreeBSD连载:配置samba( 五 )


其他专有共享目录
# This one is useful for people to share files;[tmp];comment = Temporary file space;path = /tmp;read only = no;public = yes # A publicly accessible directory, but read only, except for people in# the "staff" group;[public];comment = Public Stuff;path = /home/samba;public = yes;writable = yes;printable = no;write list = @staff # Other examples.## A private printer, usable only by fred. Spool data will be placed in fred"s# home directory. Note that fred must have write access to the spool directory,# wherever it is.;[fredsprn];comment = Fred"s Printer;valid users = fred;path = /homes/fred;printer = freds_printer;public = no;writable = no;printable = yes # A private directory, usable only by fred. Note that fred requires write# access to the directory.;[fredsdir];comment = Fred"s Service;path = /usr/somewhere/private;valid users = fred;public = no;writable = yes;printable = no # a service which has a different directory for each machine that connects# this allows you to tailor configurations to incoming machines. You could# also use the \u option to tailor it by user name.# The %m gets replaced with the machine name that is connecting.;[pchome];comment = PC Directories;path = /usr/pc/%m;public = no;writable = yes # A publicly accessible directory, read/write to all users. Note that all files# created in the directory by users will be owned by the default user, so# any user with access can delete any other user"s files. Obviously this# directory must be writable by the default user. Another user could of course# be specified, in which case all files would be owned by that user instead.;[public];path = /usr/somewhere/else/public;public = yes;only guest = yes;writable = yes;printable = no # The following two entries demonstrate how to share a directory so that two# users can place files there that will be owned by the specific users. In this# setup, the directory should be writable by both users and should have the# sticky bit set on it to prevent abuse. Obviously this could be extended to# as many users as required.;[myshare];comment = Mary"s and Fred"s stuff;path = /usr/somewhere/shared;valid users = mary fred;public = no;writable = yes;printable = no;create mask = 0765此后,缺省smb.conf中给出了一些设定各种共享文件资源、打印机资源的例子,例如设置特定打印机的[fredprn],设置私人文件共享资源的[freddir]和[myshare],使用宏为多个用户设置共享的[pchome],提供公共访问的[public]和[tmp],FreeBSD的管理员可以根据具体情况,根据这些设置例子设置相应的共享资源,并设置相应的访问权限,以保护文件系统不被非法访问 。
需要注意的是,当使用valid user用来设置合法访问用户时,或者使用wirte list定义具备写权限的用户时,都可以使用@staff的形式使用Unix的组名,这样凡是属于该staff组成员的用户,都会具备相应权限 。
从这些例子中可以看到[global]用于设定全局参数,不会出现在资源列表中,[homes]用于设定个人目录共享,其共享的名字映射为个人标识符而非homes,[printers]设定打印机共享,将共享所有的打印机名字,除了这些标题的共享名字与标题不同之外,其他每个标题都将代表一个共享资源的名字 。
当更改设置之后,可以重新启动Samba服务器,提供新的共享服务了 。但在重新启动服务器之前,最好使用Samba软件包中提供的测试软件,检查一下设置是否正确 。这些小工具程序包括检查smb.conf设置的testparm,检查打印机名字的正确性的程序testprn,用于进行NetBIOS名字解析的nmblookup等 。
使用swat配置samba
samba 2.0提供了一个能够通过浏览器来配置samba的工具──swat 。它是一个专用www服务器,使用inetd来启动,然后经过认证,可以允许用户通过浏览器来配置smb.conf 。为了达到这个目的,首先要为swat分配一个固定的端口,这个工作可以通过在/etc/services中增加一行来完成:

推荐阅读