[Samba] get quota command

rick at oit.gatech.edu rick at oit.gatech.edu
Thu Sep 22 20:14:40 GMT 2005


I found the answer to my own question in a round about sort of way..
My NFS server is Solaris w/UFS - thus no group quota support.   It
seems when samba queries for user quotas and group quotas, it gets
unhappy when no group quota is returned, so the quotas are thrown
out and the windows boxes see the entire volume's free, used and
capacity.   To fix this I set the two options in my conf file:
   vfs objects = default_quota:quotasettings
   quotasettings: gid = 65534

Rick Brown wrote:
> I've discovered that if I make a share from a local filesystem, 
> the PC's mounting the share see their quota (hard limit, not 
> soft which is another matter) as their capacity and their
> appropriate free space... this is good. 

I found in the source that the hard limit is used instead of the
soft limit if the user is over quota.

> When I share ouf the NFS mounted volume, the PC's see the entire
> volume size and free space.   Not so good.   Okay fine, so I 
> wrote a little cheesy script to run run quota and report back and
> defined it as "get quota command = myscript" in smb.conf. 
> This works great...   mostly.    I wasn't seeing the values I 
> expected to see, so I started dumping the arguments samba was
> passing to my scipt.   I expected 3 fields: Path, type of query, and
> user/group ID.    something like:
> "." 1 32849		(user quota)
> "." 3 1178		(group quota) 
> 
> instead, I'm seeing samba pass:
> "." 2 32849		(default user quota)
> "." 4 1178		(default group quota)
> 
> Why is samba asking for the default user and group quotas instead of 
> the actual user and group quotas?  From the documentation I would
> have expected that if field 2 was a 2 or 4, then the uid/gid would be
> -1.   How can I make samba request the actual user and group's quota
> instead of the defaults?

And since I didn't easily find any examples of a "get quota command"
I'll share my super-cheesy script which totally ignores the values
passed to it by samba.  It's not pretty, but it works. 

#!/bin/ksh
PATH=/usr/bin:/usr/sbin:/bin
IAM=`id -un`
# find the user's home file system.
DIR=`ypmatch $IAM passwd | awk -F: '{print $6}' | cut -f 2 -d "/"`
#check and see if they're over quota, as it will affect output
OVER=`quota -F rpc -v $IAM | grep $DIR | wc -w`
#OVER=`quota -f rpc -v $IAM | grep $DIR | egrep -i "expired|days"
#if [ $? -ne 0]; then

# over quota
if [ $OVER -gt 7 ]; then
        RET=`quota -v $IAM | grep ${DIR} | awk -F" " '{print "2 "$2"
"$3" "$4" "$7" "$8" "$9}'`
else
# not over quota
        RET=`quota -v $IAM | grep ${DIR} | awk -F" " '{print "2 "$2"
"$3" "$4" "$5" "$6" "$7}'`
fi
# linux "quota" puts a * after the used blocks if the user is over quota
STRIPPED=`echo $RET | sed 's/*/ /g'`
echo $STRIPPED


-- 
[         Rick Brown               ][      (404) 894-6175           ]
[ Office of Information Technology ][    rick at oit.gatech.edu 	    ]
[ Georgia Institute of Technology  ][  258 4th street. Atlanta, GA  ]


More information about the samba mailing list