LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1638|回复: 8

关于TCP_wrapper,hosts.allow中后台进程的问题,kevin能不能解答一下?

[复制链接]
发表于 2005-6-8 10:15:39 | 显示全部楼层 |阅读模式
关于TCP_wrapper,hosts.allow中后台进程的问题,kevin能不能解答一下?
在教材中有如下的表述:
后台进程应该是服务的可执行工具名,例如:ftp服务的可执行工具是vsftpd,
因此在/etc/hosts.allow及/etc/hosts.deny中应该写vsftpd
  可以使用的后台进程:
  sendmail , slpad,sshd, stunnel,tcpd, xinetd,gdm,gnome-session,ORBit
   portmap (注意nis及 nfs依赖 portmap)

我对此理解是:上述所列的后台进程是可以被写在hosts.allow,hosts.deny
中的,其它的是不可以的,如:httpd,smbd(虽然没有明确指出)

我在参考手册中看到一段话:
  NOTE:
To determine if a network service binary is linked against libwrap.a,type the
following command as the root user:
string -f  <binary-name> |grep  hosts_access
Replace <binary-name> with the name of the network service binary.
If a prompt is returned ,the  network service is not linked against libwrap.a
依据这段话的意思,只要用命令:
string -f  <binary-name> |grep  hosts_access
查看网络服务后台进程没有返回值,就可以将这个网络服务后台进程写入
/etc/hosts.allow和/etc/hosts.deny中.
我简单试了一下:/usr/sbin/下的一些程序:
httpd,imapd ,in.telnetd,ipop2d,ipop3d, named ,postfix,
sendmail, smbd,squid,ypserv  都没有返回值.
而httpd,named,smbd不能在hosts.allow,hosts.deny中实现基于主机的限制,
(虽然在httpd,smbd的配置文件就可实现基于主机的控制)


是不是教材中只是例举了部分做例子?
另外,如果nfs 写在hosts.allow,hosts.deny中,应该写portmap,
我在服务端用了:/etc/hosts.deny     portmap:192.168.1.5
并没有阻止192.168.1.5访问服务器,写错了什么吗?
怎样写nfs中基于主机的控制?
发表于 2005-6-8 19:05:05 | 显示全部楼层
所谓后台进程是对一类常驻内存运行的程序的总称。是否该守护程序会受TCPWRAPPER制约,要看此程序的验证PAM模块是否调用libwrap.so
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-8 21:59:50 | 显示全部楼层
string -f <binary-name> |grep hosts_access
就是检查后台进程是否调用libwrap.so
可检查完了/usr/sbin/下的一些网络服务程序,有些
并不能实现TCP_wrapper的控制!
另外:关于nfs 基于主机控制的问题,我在
/usr/share/doc/portmap*/README中找到如下内容:
In order to avoid deadlocks, the portmap program does not attempt to
look up the remote host name or user name, nor will it try to match NIS
netgroups. The upshot of all this is that only network number patterns
will work for portmap access control.

Sample entries for the host access-control files are:

    /etc/hosts.allow:
        portmap: your.sub.net.number/your.sub.net.mask
        portmap: 255.255.255.255 0.0.0.0

    /etc/hosts.deny
        portmap: ALL: (/some/where/safe_finger -l @%h | mail root) &
我在/etc/hosts.deny中用
   portmap:ALL可以拒绝nfs的访问,但是我怎样拒绝某一个网段中的一个或几个
IP地址的访问?该如何写呢?
我用portmap:192.168.1.5  不能拒绝192.168.1.5的nfs访问!
回复 支持 反对

使用道具 举报

发表于 2005-6-8 22:17:39 | 显示全部楼层
在/etc/hosts.deny中写
portmap:192.168.1. EXCEPT 192.168.1.1
拒绝所有192.168.1.0网段中的地址除了192.168.1.1
回复 支持 反对

使用道具 举报

发表于 2005-6-10 18:27:44 | 显示全部楼层
楼主没写错吧~
vi /etc/hosts.deny
portmap:192.168.1.5
他只要阻止这个主机阿。。
还有看是否支持~要看这个服务便以德过程中是否加入了libwap.so这个库
回复 支持 反对

使用道具 举报

发表于 2005-6-10 19:51:26 | 显示全部楼层
Post by jackson
string -f <binary-name> |grep hosts_access
就是检查后台进程是否调用libwrap.so
可检查完了/usr/sbin/下的一些网络服务程序,有些
并不能实现TCP_wrapper的控制!
另外:关于nfs 基于主机控制的问题,我在
/usr/share/doc/portmap*/README中找到如下内容:
In order to avoid deadlocks, the portmap program does not attempt to
look up the remote host name or user name, nor will it try to match NIS
netgroups. The upshot of all this is that only network number patterns
will work for portmap access control.

Sample entries for the host access-control files are:

    /etc/hosts.allow:
        portmap: your.sub.net.number/your.sub.net.mask
        portmap: 255.255.255.255 0.0.0.0

    /etc/hosts.deny
        portmap: ALL: (/some/where/safe_finger -l @%h | mail root) &
我在/etc/hosts.deny中用
   portmap:ALL可以拒绝nfs的访问,但是我怎样拒绝某一个网段中的一个或几个
IP地址的访问?该如何写呢?
我用portmap:192.168.1.5  不能拒绝192.168.1.5的nfs访问!



对于/usr/sbin/下的网络服务进程
可以用
ldd /usr/sbin/xx
查看是否有下面这句话
libwrap.so.0 => /usr/lib/libwrap.so.0 (0xb75d6000)
就说明可以用tcp_wrapper
回复 支持 反对

使用道具 举报

发表于 2005-6-10 20:01:33 | 显示全部楼层
还有对于NFS的主机访问控制不是用控制portmap来实现的
如果是这样的话一些依赖portmap的服务也会受影响,比如NIS

其实对于NFS的访问控制在/etc/exports文件里就实现了
比如:
/home        *.example.com(ro.sync)
/var            192.168.0.0/255.255.255.0(ro,sync)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-10 22:49:05 | 显示全部楼层
klsonic
Post by klsonic
在/etc/hosts.deny中写
portmap:192.168.1. EXCEPT 192.168.1.1
拒绝所有192.168.1.0网段中的地址除了192.168.1.1



也不算大错啊!
只要将portmap:192.168.1. EXCEPT 192.168.1.1
放入/etc/hosts.allow就行了!
我想他也是这个意思,只不过随手写错了hosts.allow

suddenly5171
写道:还有对于NFS的主机访问控制不是用控制portmap来实现的
如果是这样的话一些依赖portmap的服务也会受影响,比如NIS

其实对于NFS的访问控制在/etc/exports文件里就实现了
比如:
/home *.example.com(ro.sync)
/var 192.168.0.0/255.255.255.0(ro,sync)

suddenly5171兄说得对,要慎用portmap,只有在/etc/exports
中限制不能实现时,再用portmap!
回复 支持 反对

使用道具 举报

发表于 2005-6-12 23:12:34 | 显示全部楼层
JACKSON ~ 我的写法没有错的,你再仔细想想 :)
不过suddenly5171的做法我觉得是最正确的,我怎么舍弃了/etc/exports而用/etc/hosts.deny了,呵呵
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表