Red Hat Training

A Red Hat training course is available for RHEL 8

3.2. 使用 testparm 工具验证 smb.conf 文件

testparm工具验证/etc/samba/smb.conf文件中的 Samba 配置是否正确。该工具不但检测无效的参数和值,还检测不正确的设置,如 ID 映射。如果testparm报告没有问题,Samba 服务将成功加载/etc/samba/smb.conf文件。请注意,testparm无法验证配置的服务是否可用或按预期工作。

重要

红帽建议在每次修改此文件后,使用testparm来验证/etc/samba/smb.conf文件。

先决条件

  • 已安装 Samba。
  • 退出/etc/samba/smb.conf文件。

流程

  1. root用户身份运行testparm工具:

    # testparm
    Load smb config files from /etc/samba/smb.conf
    rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
    Unknown parameter encountered: "log levell"
    Processing section "[example_share]"
    Loaded services file OK.
    ERROR: The idmap range for the domain * (tdb) overlaps with the range of DOMAIN (ad)!
    
    Server role: ROLE_DOMAIN_MEMBER
    
    Press enter to see a dump of your service definitions
    
    # Global parameters
    [global]
    	...
    
    [example_share]
    	...

    前面的示例输出会报告不存在的参数以及不正确的 ID 映射配置。

  2. 如果testparm报告了配置中不正确的参数、值或其他错误,请修复问题并再次运行该工具。