Samba 可用空间问题,dfree 命令未被调用

Samba 可用空间问题,dfree 命令未被调用

我有一台运行 Ubuntu 16.04.1 的 Samba 服务器,它提供一些 btrfs 子卷。这些卷的 btrfs 配额是通过 设置的btrfs qgroup

为了向客户反映配额,我想使用自定义的dfree command

我的问题是 Samba 似乎从不调用我的dfree command,而只是显示 btrfs 文件系统的可用空间。

username@NAS:~$ smbd --version
Version 4.3.11-Ubuntu

我的smb.conf:

[global]
max log size = 1000
usershare allow guests = yes
dns proxy = no
pam password change = yes
workgroup = WORKGROUP
map to guest = bad user
obey pam restrictions = yes
server role = standalone server
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
passdb backend = tdbsam
encrypt passwords = yes
server string = %h server (Samba, Ubuntu)
panic action = /usr/share/samba/panic-action %d
log file = /var/log/samba/log.%m
log level = 10
syslog = 0
dfree cache time = 0

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no

[username_backup]
path = /backup_tank/username
browsable = yes
force group = username
directory mode = 750
force user = username
guest ok = no
valid users = username
create mode = 650
writable = yes
security = user
dfree command = /usr/local/bin/df_btrfs

usr/local/bin/df_btrfs (所有者 root:root 和 700 权限):

#!/bin/bash

STR=$(/bin/btrfs qgroup show -rF --raw /backup_tank/username/ | /usr/bin/tail -1)

SIZE=$(/usr/bin/expr `/bin/echo $STR | /usr/bin/cut -d \  -f 4` / 1024)
USED=$(/usr/bin/expr `/bin/echo $STR | /usr/bin/cut -d \  -f 2` / 1024)
AVAIL=$(/usr/bin/expr $SIZE - $USED)

/bin/echo $SIZE $AVAIL

当我运行此脚本时(由于 btrfs 命令,以 root 身份运行),它会以 Samba 期望的格式给我正确的数字:

username@NAS:~$ sudo /usr/local/bin/df_btrfs
734003200 196187016

我尝试过但没有成功(Samba 一直给我相同的数字,日志没有显示任何错误或脚本正在运行的迹象):

  • chmod 777 /usr/local/bin/df_btrfs
    
  • /usr/local/bin/df_btrfs内容替换为:

     #!/bin/bash
    
     /bin/echo "734003200 196187016"
    
  • dfree command用以下设置替换

    dfree command = 734003200 196187016
    
  • dfree command用不存在的文件路径替换设置

    dfree command = /usr/local/bin/df_btrfs_nonexistant  
    

    (即使此文件不存在,日志中仍然没有错误)

  • dfree command尝试上述方法[global]

每次尝试之间我都会重新启动 smbd 服务,然后重新启动服务器和客户端计算机。

smbd 日志中唯一的dfree command“或”标志是:/usr/local/bin/df_btrfs

[2016/12/27 12:16:52.059912,  5, pid=23203, effective(0, 0), real(0, 0)] ../source3/param/loadparm.c:1325(free_param_opts)
doing parameter dfree command = /usr/local/bin/df_btrfs
doing parameter dfree cache time = 0

答案1

您可以在此处找到描述和有风险的解决方法: https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1310792

相关内容