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


1

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

为了向客户反映配额,我想使用custom dfree command

我的问题是Samba似乎从不调用my 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和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 commandin 尝试上述操作[global]

在每次尝试之间,甚至服务器和客户端计算机之间,我都重新启动了smbd服务。

dfree command/usr/local/bin/df_btrfssmbd日志中的唯一标志是:

[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

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.