[Samba] Samba dfree command not working

Keram Yasin keramyasina at gmail.com
Mon Sep 11 14:45:51 UTC 2023


Dear Samba Team Member,

I installed Samba on my server and It worked perfect so far. Now I wanted
to use some advanced feature of samba like dfree option. I created a shell
script named dfree according to the "dfree command (S)" section in the
following url:
https://www.samba.org/samba/docs/current/manhtml/smb.conf.5.html

The content of the dfree command is as followings:

STR=$(/usr/sbin/btrfs qgroup show -rF --raw "$1" | /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

I set the shell script to be owned by nobody user and nobody group. The
script also has chmod 777 enabled. The script is located at the following
directory: /var/lib/samba/bin/dfree;

All users' home directory is quota enabled by the btrfs file system. And the
shell script calculates correctly when executed on the server with the user
home directory passed as command variable. for example:
/var/lib/samba/bin/dfree /home/user

First I put the dfree command option to individual share directory such as
[homes], [users]; After I have saved the changes in /etc/samba/smb.conf
(the smb.conf file is attached to this email), I restarted samba, then I
connected to the server from another Windows PC. Then I checked the disk
size on my Windows PC. The disk size is incorrect. Then, I checked the
status of the samba with systemctl status smb command. The command output
shows no error either. For me it seems that the script is not executed by
Samba with these settings.

Then I put the code in the [global] section. Then connected to the samba
server from Windows PC again. On the Windows PC, the disk size is incorrect
as well. Afterwards, I checked the status of samba on linux server with
this command systemctl status smb. The command output shows as following:

Sep 11 15:42:33 hpstorage systemd[1]: Started Samba SMB Daemon.
Sep 11 15:42:36 hpstorage smbd[30728]: [2023/09/11 15:42:36.253421,  0]
../../lib/util/sys_popen.c:111(sys_popenv)
Sep 11 15:42:36 hpstorage smbd[30728]:   sys_popenv: ERROR executing
command '/var/lib/samba/bin/dfree': Permission denied
Sep 11 15:42:36 hpstorage smbd[30727]: [2023/09/11 15:42:36.256470,  0]
../../source3/smbd/dfree.c:135(sys_disk_free)
Sep 11 15:42:36 hpstorage smbd[30727]:   sys_disk_free: file_lines_load()
failed for command '/var/lib/samba/bin/dfree .'. Error was : No child
processes

I put the script in various directories owned by nobody user and nobody
group. But, the above error has never disappeared. I also did a lot of
searching on the internet, tried various answers to similar questions. But,
I could not resolve the issue. In the end I decided to contact the Samba
team directly. That's why I am sending you this email. I would really
appreciate it if you can give any idea about how to resolve the issue.

Best Regard,
Keram Yasin


More information about the samba mailing list