smb_nt_transact_quota.c revision 148c5f43199ca0b43fc8e3b643aab11cd66ea327
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
#include <smbsrv/smb_share.h>
#include <smbsrv/smb_door.h>
#include <smbsrv/smb_idmap.h>
/*
* - next offset (uint32_t)
* - length of SID (uint32_t)
* - last modified time (uint64_t)
* - quota used (uint64_t)
* - quota limit (uint64_t)
* - quota threahold (uint64_t)
* - variable length sid - max = 32 bytes
* SMB_QUOTA_SIZE_NO_SID is the size of the above, excluding the sid.
*/
#define SMB_QUOTA_SIZE_NO_SID \
smb_ofile_t *);
static void smb_quota_free_sids(smb_quota_query_t *);
smb_quota_response_t *, smb_ofile_t *);
static void smb_quota_free_quotas(list_t *);
/*
* smb_nt_transact_query_quota
*
* This method allows the client to retrieve quota information from
* the server. The result of the call is returned to the client in the
* Data part of the transaction response.
*
* On entry, the 'TotalParameterCount' field must be equal to 16, and the
* client parameter block must be encoded with the following parameters:
*
* Request Description
* ========================== ==================================
* WORD fid SMB file identifier of the target directory
* BYTE ReturnSingleEntry A boolean indicating whether to return
* a single entry (TRUE) or multiple entries (FALSE).
* BYTE RestartScan A boolean indicating whether to continue from
* the previous request (FALSE) or restart a new
* sequence (TRUE).
* DWORD SidListLength The length, in bytes, of the SidList in the
* data block or 0 if there is no SidList.
* DWORD StartSidLength If SidListLength is 0 (i.e. there is no SidList
* in the data block), then this is either:
* 1) the (non-zero) length in bytes of the
* StartSid in the parameter buffer, or
* 2) if 0, there is no StartSid in the
* parameter buffer, in which case, all SIDs
* are to be enumerated as if they were
* passed in the SidList.
* Otherwise, StartSidLength is ignored.
* DWORD StartSidOffset The offset, in bytes, to the StartSid in the
* parameter block (if one exists).
*
* One of SidListLength and StartSidLength must be 0.
*
* An SMB_COM_NT_TRANSACTION response is sent in reply when the request
* is successful. The 'TotalParameterCount' is set to 4, and the parameter
* block in the server response contains a 32-bit unsigned integer
* indicating the length, in bytes, of the returned quota information.
* The 'TotalDataCount' is set to indicate the length of the data buffer,
* and the data buffer contains the following quota information:
*
* Data Block Encoding Description
* ================================== =================================
* ULONG NextEntryOffset; Offset to start of next entry from
* start of this entry, or 0 for the
* final entry
* ULONG SidLength; Length (bytes) of SID
* SMB_TIME ChangeTime; Time that the quota was last changed
* LARGE_INTEGER QuotaUsed; Amount of quota (bytes) used by user
* LARGE_INTEGER QuotaThreshold; Quota warning limit (bytes) for user
* LARGE_INTEGER QuotaLimit; The quota limit (bytes) for this user
* USHORT Sid; Search handle
*/
{
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
if ((sidlistlen != 0) && (startsidlen != 0)) {
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
if (sidlistlen != 0)
else if (startsidlen != 0)
else
if (status == NT_STATUS_SUCCESS) {
} else {
if (status == NT_STATUS_SUCCESS) {
}
}
}
if (status != NT_STATUS_SUCCESS) {
if (status == NT_STATUS_NO_MORE_ENTRIES) {
} else {
}
}
}
/*
* smb_nt_transact_set_quota
*
* This method allows the client to set quota information on the server.
* The result status of the call is returned to the client in the
* 'status' field of the SMB response header.
*
* On entry, the 'TotalParameterCount' field must be equal to 2, and the
* client parameter block must be encoded with the following parameters:
*
* Data Block Encoding Description
* ================================== =================================
* ULONG NextEntryOffset; Offset to start of next entry from
* start of this entry, or 0 for the
* final entry
* ULONG SidLength; Length (bytes) of SID
* SMB_TIME ChangeTime; Time that the quota was last changed
* LARGE_INTEGER QuotaUsed; Amount of quota (bytes) used by user
* LARGE_INTEGER QuotaThreshold; Quota warning limit (bytes) for user
* LARGE_INTEGER QuotaLimit; The quota limit (bytes) for this user
* VARIABLE Sid; Security identifier of the user
*
* An SMB_COM_NT_TRANSACTION response is sent in reply when the request
* is successful. The 'TotalParameterCount' and the 'TotalDataCount' are set
* to 0, and the parameter block 'Status' field in the server SMB response
* header contains a 32-bit unsigned integer indicating the result status
* (NT_STATUS_SUCCESS if successful).
*
* Only users with Admin privileges (i.e. of the BUILTIN/Administrators
* group) will be allowed to set quotas.
*/
{
char *root_path;
return (SDRC_ERROR);
}
return (-1);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
if (status == NT_STATUS_SUCCESS) {
} else {
}
}
if (status != NT_STATUS_SUCCESS) {
return (SDRC_ERROR);
}
return (SDRC_SUCCESS);
}
/*
* smb_quota_init_sids
*
* If the query is of type SMB_QUOTA_QUERY_SIDLIST or
* SMB_QUOTA_QUERY_STARTSID decode the list of sids from
* the client request into request->qq_sid_list.
* Otherwise (type SMB_QUOTA_QUERY_ALL) find the resume sid
* and insert it into request->qq_sid_list, or reset the
* resume sid to NULL if request->qq_restart.
*
* Returns: NT_STATUS codes
*/
static uint32_t
{
switch (request->qq_query_op) {
case SMB_QUOTA_QUERY_SIDLIST:
case SMB_QUOTA_QUERY_STARTSID:
break;
case SMB_QUOTA_QUERY_ALL:
if (request->qq_restart)
else {
}
break;
default:
break;
}
return (status);
}
/*
* smb_quota_free_sids
*/
static void
{
}
}
/*
* smb_quota_decode_sids
*
* Decode the SIDs from the data block and stores them in string form in list.
* Eaxh sid entry comprises:
* next_offset (4 bytes) - offset of next entry
* sid length (4 bytes)
* sid (variable length = sidlen)
* The last entry will have a next_offset value of 0.
*
* Returns NT_STATUS codes.
*/
static uint32_t
{
struct mbuf_chain sidbuf;
offset = 0;
do {
break;
}
break;
}
offset += next_offset;
} while ((next_offset != 0) && (bytes_left > 0));
return (status);
}
/*
* smb_quota_max_quota
*
* If the query is if type SMB_QUOTA_QUERY_SIDLIST a quota entry
* is returned for each sid in the sidlist. request->qr_max_quota
* is set to 0 and is unused.
* Otherwise (for SMB_QUOTA_QUERY_STARTSID and SMB_QUOTA_QUERY_ALL)
* max_quota is the maximum number of quota entries requested from
* the file system (via door call smb_quota_query()).
* If single is set max_quota is set to 1. If single is not set
* max quota is calculated as the number of quotas of size
* SMB_QUOTA_EST_SIZE that would fit in the response buffer.
*/
static void
{
request->qq_max_quota = 0;
else
}
/*
* smb_quota_decode_quotas
*
* Decode the quota entries into a list_t of smb_quota_t.
* SMB_QUOTA_SIZE_NO_SID is the size of a quota entry,
* excluding the sid.
* The last entry will have a next_offset value of 0.
*
* Returns NT_STATUS codes.
*/
static uint32_t
{
struct mbuf_chain quotabuf;
offset = 0;
do {
break;
}
break;
}
offset += next_offset;
} while ((next_offset != 0) && (bytes_left > 0));
return (status);
}
/*
* smb_quota_free_quotas
*/
static void
{
}
}
/*
* smb_quota_encode_quotas
*
* Encode the quota entries from a list_t of smb_quota_t.
* SMB_QUOTA_SIZE_NO_SID is the size of a quota entry,
* excluding the sid.
* The last entry will have a next_offset value of 0.
* Sets the last encoded SID as the resume sid.
*/
static uint32_t
{
int rc;
total_bytes = 0;
while (quota) {
quota = next_quota;
continue;
}
next_offset += pad;
break;
}
next_quota = NULL;
}
if (rc == 0) {
}
if (rc != 0) {
break;
}
quota = next_quota;
}
if ((status == NT_STATUS_SUCCESS) &&
}
return (status);
}
/*
* smb_quota_query_user_quota
*
* Get user quota information for a single user (uid)
* for the current file system.
* Find the user's sid, insert it in the sidlist of a
* smb_quota_query_t request and invoke the door call
* smb_quota_query() to obtain the quota information.
*
* Returns: NT_STATUS codes.
*/
{
smb_quota_t *q;
return (NT_STATUS_INTERNAL_ERROR);
return (NT_STATUS_INTERNAL_ERROR);
}
} else {
} else {
if ((q == NULL) ||
/* should never happen */
} else {
}
}
}
return (status);
}
/*
* smb_quota_query
*
* Door call to query quotas for the provided filesystem path.
* 0 - success. Status set in reply.
*/
static int
{
int rc;
return (rc);
}
/*
* smb_quota_set
*
* Door call to set quotas for the provided filesystem path.
* 0 - success. Status set in reply.
*/
static int
{
int rc;
return (rc);
}