Bug 12871 - get quota command broken
Summary: get quota command broken
Status: RESOLVED WORKSFORME
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.6.5
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-03 10:13 UTC by Stephan
Modified: 2023-05-10 01:19 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan 2017-07-03 10:13:21 UTC
Hi,

samba 4.6.5 seems to have broken the get quota command. I can't tell in which version this problem surfaced but I can tell that it still kind of worked in 4.2.12. The problem is that the command does not get called with the proper arguments, according to the manpage it is still a combination of either 1 or 3 as query type and the uid/gidnumber or 2 or 4 with -1 as uid/gidnumber. The behavoiur in samba 4.2.12 is to combine 2 or 4 as type of query with a correct uid/gidnumber which is wrong but at least can be worked around in the script:

[2017/07/03 11:52:31.582927,  3, pid=11520, effective(1001, 1000), real(1001, 0), class=quota] ../source3/lib/sysquotas.c:218(command_get_quota)
  get_quota: Running command /usr/local/bin/getsambaquota.pl . 2 1001

It is worse in 4.6.5 - the query type is correct now but there is no uidnumber in the call:

[2017/07/03 11:56:22.372398,  3, pid=15426, effective(1001, 1000), real(1001, 0), class=quota] ../source3/lib/sysquotas.c:273(command_get_quota)
  get_quota: Running command /usr/local/bin/getsambaquota.pl . 1 -1


[2017/07/03 11:56:22.209320,  3, pid=15426, effective(1001, 1000), real(1001, 0), class=quota] ../source3/lib/sysquotas.c:273(command_get_quota)
  get_quota: Running command /usr/local/bin/getsambaquota.pl . 3 -1

which is why the script fails since it obviously can't tell the quota without a proper uidnumber.
Comment 1 Björn Jacke 2023-05-10 01:18:48 UTC
the uid is "-1" if the quota type is SMB_USER_FS_QUOTA_TYPE, which means it asks for the quota of the calling user. The uid is only the actual user's uid if the quota type is SMB_USER_QUOTA_TYPE, which is usually when the quota command is used to query the quota of a different user. Yes, this is a bit confusing but this is how it is designed. Your quota script needs to be fixed accordingly.