[Samba] 3.6.9 samba does not propagate (or show) Linux quota for windows users to see it

Rowland Penny rowlandpenny at googlemail.com
Tue Sep 30 03:56:32 MDT 2014


On 30/09/14 10:33, Karel Lang AFD wrote:
> Hi Rowland,
> thanks for excellent suggestion - should have thought of it myself.
> I redirected the "echo $RET" in my script to file to:
> /tmp/user.quota.log
>
> Strange thing is, if I right-click on Windows workstation on my 
> "H:\username" homefolder and pick "properties", than the log show 
> exactly 4 empty rows.
>
> Nothing in there, nothing at all, just 4 empty rows
>
> cat user.quota.log | wc -l
> 4
>
> Not sure if it would tell you - or anybody anything, but i'm out of 
> ideas ..:[
>
> Karel
>
>
>
> On 09/29/2014 08:00 PM, Rowland Penny wrote:
>> On 29/09/14 15:03, Karel Lang AFD wrote:
>>>
>>> Hi list,
>>> perhaps someone can help me out?
>>>
>>> fact:
>>> - samba 3.6.9 plus CentOS 6.5
>>>
>>> - i have user quotas set up on their HOME directories, which resides
>>> in the "/home" filesystem
>>>
>>> - on windows workstation their disk quota is not shown, instead they
>>> see whole filesystem free/taken space (which generate much grumbling)
>>>
>>>
>>> After searching lists, googling etc., i decided to give a try the
>>> "smb.conf" option:
>>> "get quota command" and written a script to back it up.
>>>
>>> so i have got in "smb.conf":
>>> get quota command = /usr/local/bin/query_quota.sh
>>>
>>>
>>> Script (based on the script that was written by Rick Brown back in
>>> 2005 that i dug out of samba list):
>>> ************************************************************************ 
>>>
>>> #!/bin/bash
>>> PATH=/usr/bin:/usr/sbin:/bin
>>>
>>> IAM=`id -un`
>>>
>>> # find the user's home file system.
>>> DIR="home"
>>>
>>> #check and see if they're over quota, as it will affect output
>>> # user with reached quota has 9 fields in row, 'ok' user only 8
>>> OVER=`/usr/bin/sudo /usr/sbin/repquota /$DIR | grep -w $IAM | wc -w`
>>>
>>> # over quota
>>> if [ $OVER -eq 9 ]; then
>>>         RET=`/usr/bin/sudo /usr/sbin/repquota /$DIR | grep -w $IAM  |
>>> awk -F" " '{print "2 "$3" "$4" "$5" "$7" "$8" "$9}'`
>>> else
>>> # not over quota
>>>         RET=`/usr/bin/sudo /usr/sbin/repquota /$DIR | grep -w $IAM  |
>>> awk -F" " '{print "2 "$3" "$4" "$5" "$6" "$7" "$8}'`
>>> fi
>>> echo $RET
>>> ************************************************************************ 
>>>
>>>
>>> script output if run by user on linux:
>>> 2 2494580 3300000 3500000 3444 0 0
>>>
>>>
>>> Which should be about right - according to the Manpage of smb.conf
>>> that says:
>>>
>>> "This script should print one line as output with spaces between the
>>> arguments.
>>> The arguments are:
>>>
>>>            ·   Arg 1 - quota flags (0 = no quotas, 1 = quotas enabled,
>>> 2 = quotas enabled and
>>>                enforced)
>>>
>>>            ·   Arg 2 - number of currently used blocks
>>>
>>>            ·   Arg 3 - the softlimit number of blocks
>>>
>>>            ·   Arg 4 - the hardlimit number of blocks
>>>
>>>            ·   Arg 5 - currently used number of inodes
>>>
>>>            ·   Arg 6 - the softlimit number of inodes
>>>
>>>            ·   Arg 7 - the hardlimit number of inodes
>>>
>>>            ·   Arg 8(optional) - the number of bytes in a
>>> block(default is 1024)
>>>
>>>
>>> But still i see only report of free / used space on the whole
>>> Filesystem, that i mapped to windows as H:\username
>>>
>>> Anybody could share some insight on this matter?
>>>
>>> Thanks a LOT.
>>>
>>> Karel Lang
>>
>> Hi Karl, have you tried altering the script to dump $RET to a file in
>> /tmp, this will show you just what the script is actually producing 
>> in use.
>>
>> Rowland
>>
>
Hi Karl, I tried your script and I couldn't get it to output anything to 
a temp file until I altered it to this:

#!/bin/bash
# /usr/local/bin/query_quota.sh

PATH=/usr/bin:/usr/sbin:/bin

IAM=`id -un`

# find the user's home file system.
DIR="home"

#check and see if they're over quota, as it will affect output
# user with reached quota has 9 fields in row, 'ok' user only 8
OVER=$(/usr/sbin/repquota /$DIR | grep -w $IAM | wc -w)

# over quota
if [ "$OVER" = "9" ]; then
     RET=$(/usr/sbin/repquota /$DIR | grep -w $IAM  | awk -F" " '{print 
"2 "$3" "$4" "$5" "$7" "$8" "$9}')
else
     # not over quota
     RET=$(/usr/sbin/repquota /$DIR | grep -w $IAM  | awk -F" " '{print 
"2 "$3" "$4" "$5" "$6" "$7" "$8}')
fi

echo "$RET"
echo "$RET" > /tmp/results.txt

exit 0

I also ran these two commands:

chmod +r /home/aquota.group
chmod +r /home/aquota.user

With the above alterations, I get this in /tmp/results.txt:

2 157536380 0 0 134072 0 0

Which I think is what you require ;-)

Rowland


More information about the samba mailing list