From 5b51fc4f065e9e68eefb530eb99ad8da9f4e5d28 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Apr 2003 23:32:00 +0000 Subject: smbcquota patch from metze (This used to be commit 74fab8f0d24004b1dfd5ce0fd7402895652f941f) --- source3/libsmb/cliquota.c | 633 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 633 insertions(+) create mode 100644 source3/libsmb/cliquota.c (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c new file mode 100644 index 0000000000..a56a6bd674 --- /dev/null +++ b/source3/libsmb/cliquota.c @@ -0,0 +1,633 @@ +/* + Unix SMB/CIFS implementation. + client quota functions + Copyright (C) Stefan (metze) Metzmacher 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +BOOL cli_get_quota_handle(struct cli_state *cli, int *quota_fnum) +{ + *quota_fnum = cli_nt_create_full(cli, FAKE_FILE_NAME_QUOTA, + 0x00000016, DESIRED_ACCESS_PIPE, + 0x00000000, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, 0x00000000, 0x03); + + if (*quota_fnum == (-1)) { + return False; + } + + return True; +} + +void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list) +{ + if (!qt_list) + return; + + if ((*qt_list)->mem_ctx) + talloc_destroy((*qt_list)->mem_ctx); + + (*qt_list) = NULL; + + return; +} + +static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, unsigned int *offset, SMB_NTQUOTA_STRUCT *pqt) +{ + int sid_len; + SMB_NTQUOTA_STRUCT qt; + + ZERO_STRUCT(qt); + + if (!rdata||!offset||!pqt) + smb_panic("parse_quota_record: called with NULL POINTER!\n"); + + if (rdata_count < 40) { + return False; + } + + /* offset to next quota record. + * 4 bytes IVAL(rdata,0) + * unused here... + */ + *offset = IVAL(rdata,0); + + /* sid len */ + sid_len = IVAL(rdata,4); + + if (rdata_count < 40+sid_len) { + return False; + } + + /* unknown 8 bytes in pdata + * maybe its the change time in NTTIME + */ + + /* the used space 8 bytes (SMB_BIG_UINT)*/ + qt.usedspace = (SMB_BIG_UINT)IVAL(rdata,16); +#ifdef LARGE_SMB_OFF_T + qt.usedspace |= (((SMB_BIG_UINT)IVAL(rdata,20)) << 32); +#else /* LARGE_SMB_OFF_T */ + if ((IVAL(rdata,20) != 0)&& + ((qt.usedspace != 0xFFFFFFFF)|| + (IVAL(rdata,20)!=0xFFFFFFFF)))) { + /* more than 32 bits? */ + return False; + } +#endif /* LARGE_SMB_OFF_T */ + + /* the soft quotas 8 bytes (SMB_BIG_UINT)*/ + qt.softlim = (SMB_BIG_UINT)IVAL(rdata,24); +#ifdef LARGE_SMB_OFF_T + qt.softlim |= (((SMB_BIG_UINT)IVAL(rdata,28)) << 32); +#else /* LARGE_SMB_OFF_T */ + if ((IVAL(rdata,28) != 0)&& + ((qt.softlim != 0xFFFFFFFF)|| + (IVAL(rdata,28)!=0xFFFFFFFF)))) { + /* more than 32 bits? */ + return False; + } +#endif /* LARGE_SMB_OFF_T */ + + /* the hard quotas 8 bytes (SMB_BIG_UINT)*/ + qt.hardlim = (SMB_BIG_UINT)IVAL(rdata,32); +#ifdef LARGE_SMB_OFF_T + qt.hardlim |= (((SMB_BIG_UINT)IVAL(rdata,36)) << 32); +#else /* LARGE_SMB_OFF_T */ + if ((IVAL(rdata,36) != 0)&& + ((qt.hardlim != 0xFFFFFFFF)|| + (IVAL(rdata,36)!=0xFFFFFFFF)))) { + /* more than 32 bits? */ + return False; + } +#endif /* LARGE_SMB_OFF_T */ + + sid_parse(rdata+40,sid_len,&qt.sid); + + qt.qtype = SMB_USER_QUOTA_TYPE; + + *pqt = qt; + + return True; +} + +BOOL cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +{ + BOOL ret = False; + uint16 setup; + char params[16]; + unsigned int data_len; + char data[SID_MAX_SIZE+8]; + char *rparam=NULL, *rdata=NULL; + unsigned int rparam_count=0, rdata_count=0; + unsigned int sid_len; + unsigned int offset; + + if (!cli||!pqt) + smb_panic("cli_get_user_quota() called with NULL Pointer!"); + + setup = NT_TRANSACT_GET_USER_QUOTA; + + SSVAL(params, 0,quota_fnum); + SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_FOR_SID); + SIVAL(params, 4,0x00000024); + SIVAL(params, 8,0x00000000); + SIVAL(params,12,0x00000024); + + sid_len = sid_size(&pqt->sid); + data_len = sid_len+8; + SIVAL(data, 0, 0x00000000); + SIVAL(data, 4, sid_len); + sid_linearize(data+8, sid_len, &pqt->sid); + + if (!cli_send_nt_trans(cli, + NT_TRANSACT_GET_USER_QUOTA, + 0, + &setup, 1, 0, + params, 16, 4, + data, data_len, 112)) { + DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); + goto cleanup; + } + + + if (!cli_receive_nt_trans(cli, + &rparam, &rparam_count, + &rdata, &rdata_count)) { + DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); + goto cleanup; + } + + if (cli_is_error(cli)) { + ret = False; + goto cleanup; + } else { + ret = True; + } + + if ((rparam&&rdata)&&(rparam_count>=4&&rdata_count>=8)) { + ret = parse_user_quota_record(rdata, rdata_count, &offset, pqt); + } else { + DEBUG(0,("Got INVALID NT_TRANSACT_GET_USER_QUOTA reply.\n")); + ret = False; + } + + cleanup: + SAFE_FREE(rparam); + SAFE_FREE(rdata); + return ret; +} + +BOOL cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +{ + BOOL ret = False; + uint16 setup; + char params[2]; + char data[112]; + char *rparam=NULL, *rdata=NULL; + unsigned int rparam_count=0, rdata_count=0; + unsigned int sid_len; + memset(data,'\0',112); + + if (!cli||!pqt) + smb_panic("cli_set_user_quota() called with NULL Pointer!"); + + setup = NT_TRANSACT_SET_USER_QUOTA; + + SSVAL(params,0,quota_fnum); + + sid_len = sid_size(&pqt->sid); + SIVAL(data,0,0); + SIVAL(data,4,sid_len); + SBIG_UINT(data, 8,(SMB_BIG_UINT)0); + SBIG_UINT(data,16,pqt->usedspace); + SBIG_UINT(data,24,pqt->softlim); + SBIG_UINT(data,32,pqt->hardlim); + sid_linearize(data+40, sid_len, &pqt->sid); + + if (!cli_send_nt_trans(cli, + NT_TRANSACT_SET_USER_QUOTA, + 0, + &setup, 1, 0, + params, 2, 0, + data, 112, 0)) { + DEBUG(1,("Failed to send NT_TRANSACT_SET_USER_QUOTA\n")); + goto cleanup; + } + + + if (!cli_receive_nt_trans(cli, + &rparam, &rparam_count, + &rdata, &rdata_count)) { + DEBUG(1,("NT_TRANSACT_SET_USER_QUOTA failed\n")); + goto cleanup; + } + + if (cli_is_error(cli)) { + ret = False; + goto cleanup; + } else { + ret = True; + } + + cleanup: + SAFE_FREE(rparam); + SAFE_FREE(rdata); + return ret; +} + +BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list) +{ + BOOL ret = False; + uint16 setup; + char params[16]; + char *rparam=NULL, *rdata=NULL; + unsigned int rparam_count=0, rdata_count=0; + unsigned int offset; + const char *curdata = NULL; + unsigned int curdata_count = 0; + TALLOC_CTX *mem_ctx = NULL; + SMB_NTQUOTA_STRUCT qt; + SMB_NTQUOTA_LIST *tmp_list_ent; + + if (!cli||!pqt_list) + smb_panic("cli_list_user_quota() called with NULL Pointer!"); + + setup = NT_TRANSACT_GET_USER_QUOTA; + + SSVAL(params, 0,quota_fnum); + SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_LIST_START); + SIVAL(params, 4,0x00000000); + SIVAL(params, 8,0x00000000); + SIVAL(params,12,0x00000000); + + if (!cli_send_nt_trans(cli, + NT_TRANSACT_GET_USER_QUOTA, + 0, + &setup, 1, 0, + params, 16, 4, + NULL, 0, 2048)) { + DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); + goto cleanup; + } + + + if (!cli_receive_nt_trans(cli, + &rparam, &rparam_count, + &rdata, &rdata_count)) { + DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); + goto cleanup; + } + + if (cli_is_error(cli)) { + ret = False; + goto cleanup; + } else { + ret = True; + } + + if (rdata_count == 0) { + *pqt_list = NULL; + return True; + } + + if ((mem_ctx=talloc_init("SMB_USER_QUOTA_LIST"))==NULL) { + DEBUG(0,("talloc_init() failed\n")); + return (-1); + } + + offset = 1; + for (curdata=rdata,curdata_count=rdata_count; + ((curdata)&&(curdata_count>=8)&&(offset>0)); + curdata +=offset,curdata_count -= offset) { + ZERO_STRUCT(qt); + if (!parse_user_quota_record(curdata, curdata_count, &offset, &qt)) { + DEBUG(1,("Failed to parse the quota record\n")); + goto cleanup; + } + + if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) { + DEBUG(0,("talloc_zero() failed\n")); + return (-1); + } + + if ((tmp_list_ent->quotas=(SMB_NTQUOTA_STRUCT *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_STRUCT)))==NULL) { + DEBUG(0,("talloc_zero() failed\n")); + return (-1); + } + + memcpy(tmp_list_ent->quotas,&qt,sizeof(qt)); + tmp_list_ent->mem_ctx = mem_ctx; + + DLIST_ADD((*pqt_list),tmp_list_ent); + } + + SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_LIST_CONTINUE); + while(1) { + if (!cli_send_nt_trans(cli, + NT_TRANSACT_GET_USER_QUOTA, + 0, + &setup, 1, 0, + params, 16, 4, + NULL, 0, 2048)) { + DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); + goto cleanup; + } + + SAFE_FREE(rparam); + SAFE_FREE(rdata); + if (!cli_receive_nt_trans(cli, + &rparam, &rparam_count, + &rdata, &rdata_count)) { + DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); + goto cleanup; + } + + if (cli_is_error(cli)) { + ret = False; + goto cleanup; + } else { + ret = True; + } + + if (rdata_count == 0) { + break; + } + + offset = 1; + for (curdata=rdata,curdata_count=rdata_count; + ((curdata)&&(curdata_count>=8)&&(offset>0)); + curdata +=offset,curdata_count -= offset) { + ZERO_STRUCT(qt); + if (!parse_user_quota_record(curdata, curdata_count, &offset, &qt)) { + DEBUG(1,("Failed to parse the quota record\n")); + goto cleanup; + } + + if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) { + DEBUG(0,("talloc_zero() failed\n")); + talloc_destroy(mem_ctx); + goto cleanup; + } + + if ((tmp_list_ent->quotas=(SMB_NTQUOTA_STRUCT *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_STRUCT)))==NULL) { + DEBUG(0,("talloc_zero() failed\n")); + talloc_destroy(mem_ctx); + goto cleanup; + } + + memcpy(tmp_list_ent->quotas,&qt,sizeof(qt)); + tmp_list_ent->mem_ctx = mem_ctx; + + DLIST_ADD((*pqt_list),tmp_list_ent); + } + } + + + ret = True; + cleanup: + SAFE_FREE(rparam); + SAFE_FREE(rdata); + + return ret; +} + +BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +{ + BOOL ret = False; + uint16 setup; + char param[2]; + char *rparam=NULL, *rdata=NULL; + unsigned int rparam_count=0, rdata_count=0; + SMB_NTQUOTA_STRUCT qt; + ZERO_STRUCT(qt); + + if (!cli||!pqt) + smb_panic("cli_get_fs_quota_info() called with NULL Pointer!"); + + setup = TRANSACT2_QFSINFO; + + SSVAL(param,0,SMB_FS_QUOTA_INFORMATION); + + if (!cli_send_trans(cli, SMBtrans2, + NULL, + 0, 0, + &setup, 1, 0, + param, 2, 0, + NULL, 0, 560)) { + goto cleanup; + } + + if (!cli_receive_trans(cli, SMBtrans2, + &rparam, &rparam_count, + &rdata, &rdata_count)) { + goto cleanup; + } + + if (cli_is_error(cli)) { + ret = False; + goto cleanup; + } else { + ret = True; + } + + if (rdata_count < 48) { + goto cleanup; + } + + /* unknown_1 24 NULL bytes in pdata*/ + + /* the soft quotas 8 bytes (SMB_BIG_UINT)*/ + qt.softlim = (SMB_BIG_UINT)IVAL(rdata,24); +#ifdef LARGE_SMB_OFF_T + qt.softlim |= (((SMB_BIG_UINT)IVAL(rdata,28)) << 32); +#else /* LARGE_SMB_OFF_T */ + if ((IVAL(rdata,28) != 0)&& + ((qt.softlim != 0xFFFFFFFF)|| + (IVAL(rdata,28)!=0xFFFFFFFF)))) { + /* more than 32 bits? */ + goto cleanup; + } +#endif /* LARGE_SMB_OFF_T */ + + /* the hard quotas 8 bytes (SMB_BIG_UINT)*/ + qt.hardlim = (SMB_BIG_UINT)IVAL(rdata,32); +#ifdef LARGE_SMB_OFF_T + qt.hardlim |= (((SMB_BIG_UINT)IVAL(rdata,36)) << 32); +#else /* LARGE_SMB_OFF_T */ + if ((IVAL(rdata,36) != 0)&& + ((qt.hardlim != 0xFFFFFFFF)|| + (IVAL(rdata,36)!=0xFFFFFFFF)))) { + /* more than 32 bits? */ + goto cleanup; + } +#endif /* LARGE_SMB_OFF_T */ + + /* quota_flags 2 bytes **/ + qt.qflags = SVAL(rdata,40); + + qt.qtype = SMB_USER_FS_QUOTA_TYPE; + + *pqt = qt; + + ret = True; +cleanup: + SAFE_FREE(rparam); + SAFE_FREE(rdata); + + return ret; +} + +BOOL cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +{ + BOOL ret = False; + uint16 setup; + char param[4]; + char data[48]; + char *rparam=NULL, *rdata=NULL; + unsigned int rparam_count=0, rdata_count=0; + SMB_NTQUOTA_STRUCT qt; + ZERO_STRUCT(qt); + memset(data,'\0',48); + + if (!cli||!pqt) + smb_panic("cli_set_fs_quota_info() called with NULL Pointer!"); + + setup = TRANSACT2_SETFSINFO; + + SSVAL(param,0,quota_fnum); + SSVAL(param,2,SMB_FS_QUOTA_INFORMATION); + + /* Unknown1 24 NULL bytes*/ + + /* Default Soft Quota 8 bytes */ + SBIG_UINT(data,24,pqt->softlim); + + /* Default Hard Quota 8 bytes */ + SBIG_UINT(data,32,pqt->hardlim); + + /* Quota flag 2 bytes */ + SSVAL(data,40,pqt->qflags); + + /* Unknown3 6 NULL bytes */ + + if (!cli_send_trans(cli, SMBtrans2, + NULL, + 0, 0, + &setup, 1, 0, + param, 4, 0, + data, 48, 0)) { + goto cleanup; + } + + if (!cli_receive_trans(cli, SMBtrans2, + &rparam, &rparam_count, + &rdata, &rdata_count)) { + goto cleanup; + } + + if (cli_is_error(cli)) { + ret = False; + goto cleanup; + } else { + ret = True; + } + +cleanup: + SAFE_FREE(rparam); + SAFE_FREE(rdata); + + return ret; +} + +static char *quota_str_static(SMB_BIG_UINT val, BOOL special, BOOL _numeric) +{ + static fstring buffer; + + memset(buffer,'\0',sizeof(buffer)); + + if (!_numeric&&special&&(val == SMB_NTQUOTAS_NO_LIMIT)) { + fstr_sprintf(buffer,"NO LIMIT"); + return buffer; + } +#if defined(HAVE_LONGLONG) + fstr_sprintf(buffer,"%llu",val); +#else + fstr_sprintf(buffer,"%lu",val); +#endif + return buffer; +} + +void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, BOOL _verbose, BOOL _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, BOOL _numeric)) +{ + if (!qt) + smb_panic("dump_ntquota() called with NULL pointer"); + + switch (qt->qtype) { + case SMB_USER_FS_QUOTA_TYPE: + { + d_printf("File System QUOTAS:\n"); + d_printf("Limits:\n"); + d_printf(" Default Soft Limit: %15s\n",quota_str_static(qt->softlim,True,_numeric)); + d_printf(" Default Hard Limit: %15s\n",quota_str_static(qt->hardlim,True,_numeric)); + d_printf("Quota Flags:\n"); + d_printf(" Quotas Enabled: %s\n", + ((qt->qflags"AS_ENABLED)||(qt->qflags"AS_DENY_DISK))?"On":"Off"); + d_printf(" Deny Disk: %s\n",(qt->qflags"AS_DENY_DISK)?"On":"Off"); + d_printf(" Log Soft Limit: %s\n",(qt->qflags"AS_LOG_THRESHOLD)?"On":"Off"); + d_printf(" Log Hard Limit: %s\n",(qt->qflags"AS_LOG_LIMIT)?"On":"Off"); + } + break; + case SMB_USER_QUOTA_TYPE: + { + fstring username_str = {0}; + + if (_sidtostring) { + _sidtostring(username_str,&qt->sid,_numeric); + } else { + fstrcpy(username_str,sid_string_static(&qt->sid)); + } + + if (_verbose) { + d_printf("Quotas for User: %s\n",username_str); + d_printf("Used Space: %15s\n",quota_str_static(qt->usedspace,False,_numeric)); + d_printf("Soft Limit: %15s\n",quota_str_static(qt->softlim,True,_numeric)); + d_printf("Hard Limit: %15s\n",quota_str_static(qt->hardlim,True,_numeric)); + } else { + d_printf("%-30s: ",username_str); + d_printf("%15s/",quota_str_static(qt->usedspace,False,_numeric)); + d_printf("%15s/",quota_str_static(qt->softlim,True,_numeric)); + d_printf("%15s\n",quota_str_static(qt->hardlim,True,_numeric)); + } + } + break; + default: + d_printf("dump_ntquota() invalid qtype(%d)\n",qt->qtype); + return; + } +} + +void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, BOOL _verbose, BOOL _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, BOOL _numeric)) +{ + SMB_NTQUOTA_LIST *cur; + + for (cur = *qtl;cur;cur = cur->next) { + if (cur->quotas) + dump_ntquota(cur->quotas,_verbose,_numeric,_sidtostring); + } +} -- cgit From 99fd07350510c07517ae5e05f5fb180cef56fc0e Mon Sep 17 00:00:00 2001 From: Paul Green Date: Mon, 14 Apr 2003 19:48:56 +0000 Subject: Rebalance parentheses in cliquota.c when LARGE_SMB_OFF_T is false. (This used to be commit bd69cbce93054548b6d1e3bac89032ff4f693423) --- source3/libsmb/cliquota.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index a56a6bd674..ed808aa1f5 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -85,7 +85,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,20) != 0)&& ((qt.usedspace != 0xFFFFFFFF)|| - (IVAL(rdata,20)!=0xFFFFFFFF)))) { + (IVAL(rdata,20)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } @@ -98,7 +98,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| - (IVAL(rdata,28)!=0xFFFFFFFF)))) { + (IVAL(rdata,28)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } @@ -111,7 +111,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| - (IVAL(rdata,36)!=0xFFFFFFFF)))) { + (IVAL(rdata,36)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } @@ -459,7 +459,7 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| - (IVAL(rdata,28)!=0xFFFFFFFF)))) { + (IVAL(rdata,28)!=0xFFFFFFFF))) { /* more than 32 bits? */ goto cleanup; } @@ -472,7 +472,7 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| - (IVAL(rdata,36)!=0xFFFFFFFF)))) { + (IVAL(rdata,36)!=0xFFFFFFFF))) { /* more than 32 bits? */ goto cleanup; } -- cgit From d15cd357c702aaad4093f770d557b61a4e12f3a0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 15 Apr 2003 19:51:17 +0000 Subject: merge in metze' smbcquotas patch from HEAD (This used to be commit b6a77048886151435a4a5eeb9a04be44d397c504) --- source3/libsmb/cliquota.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index ed808aa1f5..a56a6bd674 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -85,7 +85,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,20) != 0)&& ((qt.usedspace != 0xFFFFFFFF)|| - (IVAL(rdata,20)!=0xFFFFFFFF))) { + (IVAL(rdata,20)!=0xFFFFFFFF)))) { /* more than 32 bits? */ return False; } @@ -98,7 +98,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| - (IVAL(rdata,28)!=0xFFFFFFFF))) { + (IVAL(rdata,28)!=0xFFFFFFFF)))) { /* more than 32 bits? */ return False; } @@ -111,7 +111,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| - (IVAL(rdata,36)!=0xFFFFFFFF))) { + (IVAL(rdata,36)!=0xFFFFFFFF)))) { /* more than 32 bits? */ return False; } @@ -459,7 +459,7 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| - (IVAL(rdata,28)!=0xFFFFFFFF))) { + (IVAL(rdata,28)!=0xFFFFFFFF)))) { /* more than 32 bits? */ goto cleanup; } @@ -472,7 +472,7 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| - (IVAL(rdata,36)!=0xFFFFFFFF))) { + (IVAL(rdata,36)!=0xFFFFFFFF)))) { /* more than 32 bits? */ goto cleanup; } -- cgit From ddf662d11886189151dca188a2eb4f6bd602caa0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2003 14:45:11 +0000 Subject: More merges from HEAD: - Stephan Kulow's changes (fixing warnings in libsmbclient) - VFS modules - Seperating libs (This used to be commit 6e9b7802335428c88ecf4e44a0e2395ac58e96b5) --- source3/libsmb/cliquota.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index a56a6bd674..ed808aa1f5 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -85,7 +85,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,20) != 0)&& ((qt.usedspace != 0xFFFFFFFF)|| - (IVAL(rdata,20)!=0xFFFFFFFF)))) { + (IVAL(rdata,20)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } @@ -98,7 +98,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| - (IVAL(rdata,28)!=0xFFFFFFFF)))) { + (IVAL(rdata,28)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } @@ -111,7 +111,7 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| - (IVAL(rdata,36)!=0xFFFFFFFF)))) { + (IVAL(rdata,36)!=0xFFFFFFFF))) { /* more than 32 bits? */ return False; } @@ -459,7 +459,7 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| - (IVAL(rdata,28)!=0xFFFFFFFF)))) { + (IVAL(rdata,28)!=0xFFFFFFFF))) { /* more than 32 bits? */ goto cleanup; } @@ -472,7 +472,7 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| - (IVAL(rdata,36)!=0xFFFFFFFF)))) { + (IVAL(rdata,36)!=0xFFFFFFFF))) { /* more than 32 bits? */ goto cleanup; } -- cgit From 10e4a96b5399a7ecbc893d2493a9ceb3ec66c8ed Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Sep 2004 15:09:20 +0000 Subject: r2388: fix client quota support for the client we need the windows path and for server we need unix path metze (This used to be commit 54fd28f5e7b70ce2b192c2037ce28da3fea9ef92) --- source3/libsmb/cliquota.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index ed808aa1f5..af8b4422b7 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -22,13 +22,13 @@ BOOL cli_get_quota_handle(struct cli_state *cli, int *quota_fnum) { - *quota_fnum = cli_nt_create_full(cli, FAKE_FILE_NAME_QUOTA, + *quota_fnum = cli_nt_create_full(cli, FAKE_FILE_NAME_QUOTA_WIN32, 0x00000016, DESIRED_ACCESS_PIPE, 0x00000000, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x00000000, 0x03); if (*quota_fnum == (-1)) { - return False; + return False; } return True; -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/libsmb/cliquota.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index af8b4422b7..25c36c214f 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -321,12 +321,12 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST goto cleanup; } - if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) { + if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("talloc_zero() failed\n")); return (-1); } - if ((tmp_list_ent->quotas=(SMB_NTQUOTA_STRUCT *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_STRUCT)))==NULL) { + if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("talloc_zero() failed\n")); return (-1); } @@ -379,13 +379,13 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST goto cleanup; } - if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) { + if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("talloc_zero() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } - if ((tmp_list_ent->quotas=(SMB_NTQUOTA_STRUCT *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_STRUCT)))==NULL) { + if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("talloc_zero() failed\n")); talloc_destroy(mem_ctx); goto cleanup; -- cgit From 8e00e9d7a6114089fc176bc3446c6c97a01543d6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2007 02:43:33 +0000 Subject: r21609: Fix memory leaks in error code paths (and one in winbindd_group.c). Patch from Zack Kirsch . Jeremy. (This used to be commit df07a662e32367a52c1e8473475423db2ff5bc51) --- source3/libsmb/cliquota.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 25c36c214f..5627d28bb5 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -323,11 +323,13 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { DEBUG(0,("talloc_zero() failed\n")); + talloc_destroy(mem_ctx); return (-1); } if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("talloc_zero() failed\n")); + talloc_destroy(mem_ctx); return (-1); } -- cgit From 12ba88574bf91bdcc4447bfc3d429b799064bfd9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 23:18:41 +0000 Subject: r22542: Move over to using the _strict varients of the talloc calls. No functional changes. Looks bigger than it is :-). Jeremy. (This used to be commit f6fa3080fee1b20df9f1968500840a88cf0ee592) --- source3/libsmb/cliquota.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 5627d28bb5..2a47ae2463 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -322,13 +322,13 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST } if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { - DEBUG(0,("talloc_zero() failed\n")); + DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); return (-1); } if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { - DEBUG(0,("talloc_zero() failed\n")); + DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); return (-1); } @@ -382,13 +382,13 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST } if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) { - DEBUG(0,("talloc_zero() failed\n")); + DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { - DEBUG(0,("talloc_zero() failed\n")); + DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } -- cgit From b1ce226af8b61ad7e3c37860a59c6715012e738b Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 15 Jun 2007 21:58:49 +0000 Subject: r23510: Tidy calls to smb_panic by removing trailing newlines. Print the failed expression in SMB_ASSERT. (This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713) --- source3/libsmb/cliquota.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 2a47ae2463..8bba453d52 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -54,8 +54,9 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, ZERO_STRUCT(qt); - if (!rdata||!offset||!pqt) - smb_panic("parse_quota_record: called with NULL POINTER!\n"); + if (!rdata||!offset||!pqt) { + smb_panic("parse_quota_record: called with NULL POINTER!"); + } if (rdata_count < 40) { return False; @@ -138,8 +139,9 @@ BOOL cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC unsigned int sid_len; unsigned int offset; - if (!cli||!pqt) + if (!cli||!pqt) { smb_panic("cli_get_user_quota() called with NULL Pointer!"); + } setup = NT_TRANSACT_GET_USER_QUOTA; @@ -204,8 +206,9 @@ BOOL cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC unsigned int sid_len; memset(data,'\0',112); - if (!cli||!pqt) + if (!cli||!pqt) { smb_panic("cli_set_user_quota() called with NULL Pointer!"); + } setup = NT_TRANSACT_SET_USER_QUOTA; @@ -265,8 +268,9 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST SMB_NTQUOTA_STRUCT qt; SMB_NTQUOTA_LIST *tmp_list_ent; - if (!cli||!pqt_list) + if (!cli||!pqt_list) { smb_panic("cli_list_user_quota() called with NULL Pointer!"); + } setup = NT_TRANSACT_GET_USER_QUOTA; @@ -419,8 +423,9 @@ BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST SMB_NTQUOTA_STRUCT qt; ZERO_STRUCT(qt); - if (!cli||!pqt) + if (!cli||!pqt) { smb_panic("cli_get_fs_quota_info() called with NULL Pointer!"); + } setup = TRANSACT2_QFSINFO; @@ -507,8 +512,9 @@ BOOL cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST ZERO_STRUCT(qt); memset(data,'\0',48); - if (!cli||!pqt) + if (!cli||!pqt) { smb_panic("cli_set_fs_quota_info() called with NULL Pointer!"); + } setup = TRANSACT2_SETFSINFO; @@ -577,8 +583,9 @@ static char *quota_str_static(SMB_BIG_UINT val, BOOL special, BOOL _numeric) void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, BOOL _verbose, BOOL _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, BOOL _numeric)) { - if (!qt) + if (!qt) { smb_panic("dump_ntquota() called with NULL pointer"); + } switch (qt->qtype) { case SMB_USER_FS_QUOTA_TYPE: -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/libsmb/cliquota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 8bba453d52..4e06f1e339 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/libsmb/cliquota.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 4e06f1e339..47d8cfe5fe 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/libsmb/cliquota.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 47d8cfe5fe..1932c044e2 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -19,7 +19,7 @@ #include "includes.h" -BOOL cli_get_quota_handle(struct cli_state *cli, int *quota_fnum) +bool cli_get_quota_handle(struct cli_state *cli, int *quota_fnum) { *quota_fnum = cli_nt_create_full(cli, FAKE_FILE_NAME_QUOTA_WIN32, 0x00000016, DESIRED_ACCESS_PIPE, @@ -46,7 +46,7 @@ void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list) return; } -static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, unsigned int *offset, SMB_NTQUOTA_STRUCT *pqt) +static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, unsigned int *offset, SMB_NTQUOTA_STRUCT *pqt) { int sid_len; SMB_NTQUOTA_STRUCT qt; @@ -126,9 +126,9 @@ static BOOL parse_user_quota_record(const char *rdata, unsigned int rdata_count, return True; } -BOOL cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { - BOOL ret = False; + bool ret = False; uint16 setup; char params[16]; unsigned int data_len; @@ -194,9 +194,9 @@ BOOL cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC return ret; } -BOOL cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { - BOOL ret = False; + bool ret = False; uint16 setup; char params[2]; char data[112]; @@ -253,9 +253,9 @@ BOOL cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC return ret; } -BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list) +bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list) { - BOOL ret = False; + bool ret = False; uint16 setup; char params[16]; char *rparam=NULL, *rdata=NULL; @@ -412,9 +412,9 @@ BOOL cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST return ret; } -BOOL cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { - BOOL ret = False; + bool ret = False; uint16 setup; char param[2]; char *rparam=NULL, *rdata=NULL; @@ -499,9 +499,9 @@ cleanup: return ret; } -BOOL cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { - BOOL ret = False; + bool ret = False; uint16 setup; char param[4]; char data[48]; @@ -562,7 +562,7 @@ cleanup: return ret; } -static char *quota_str_static(SMB_BIG_UINT val, BOOL special, BOOL _numeric) +static char *quota_str_static(SMB_BIG_UINT val, bool special, bool _numeric) { static fstring buffer; @@ -580,7 +580,7 @@ static char *quota_str_static(SMB_BIG_UINT val, BOOL special, BOOL _numeric) return buffer; } -void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, BOOL _verbose, BOOL _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, BOOL _numeric)) +void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric)) { if (!qt) { smb_panic("dump_ntquota() called with NULL pointer"); @@ -630,7 +630,7 @@ void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, BOOL _verbose, BOOL _numeric, void (*_ } } -void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, BOOL _verbose, BOOL _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, BOOL _numeric)) +void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric)) { SMB_NTQUOTA_LIST *cur; -- cgit From 63d141d4e8b6fa0977b9b89545e9cf8bc694f416 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 Nov 2007 15:50:16 +0100 Subject: Remove a static fstring Feel free to push :-) Volker (This used to be commit f213556f50de4a28b5c5d2e1e762013837feb722) --- source3/libsmb/cliquota.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 1932c044e2..690da5928c 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -562,26 +562,26 @@ cleanup: return ret; } -static char *quota_str_static(SMB_BIG_UINT val, bool special, bool _numeric) +static const char *quota_str_static(SMB_BIG_UINT val, bool special, bool _numeric) { - static fstring buffer; - - memset(buffer,'\0',sizeof(buffer)); + const char *result; if (!_numeric&&special&&(val == SMB_NTQUOTAS_NO_LIMIT)) { - fstr_sprintf(buffer,"NO LIMIT"); - return buffer; + return "NO LIMIT"; } #if defined(HAVE_LONGLONG) - fstr_sprintf(buffer,"%llu",val); + result = talloc_asprintf(talloc_tos(), "%llu", val); #else - fstr_sprintf(buffer,"%lu",val); -#endif - return buffer; + result = talloc_asprintf(talloc_tos(), "%lu", val); +#endif + SMB_ASSERT(result != NULL); + return result; } void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric)) { + TALLOC_CTX *frame = talloc_stackframe(); + if (!qt) { smb_panic("dump_ntquota() called with NULL pointer"); } @@ -626,8 +626,9 @@ void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_ break; default: d_printf("dump_ntquota() invalid qtype(%d)\n",qt->qtype); - return; } + TALLOC_FREE(frame); + return; } void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, DOM_SID *sid, bool _numeric)) -- cgit From d899b8c56ad6556baf2d2374704cc8cd1b15d5ad Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 21:58:28 +0100 Subject: Use sid_to_string directly It seems a bit pointless to do a fstrcpy(dst, sid_string_static(src)) (This used to be commit c221c246b10e2dbbd54a9af2dc45de2eae237380) --- source3/libsmb/cliquota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 690da5928c..3c794240bc 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -608,7 +608,7 @@ void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_ if (_sidtostring) { _sidtostring(username_str,&qt->sid,_numeric); } else { - fstrcpy(username_str,sid_string_static(&qt->sid)); + sid_to_string(username_str, &qt->sid); } if (_verbose) { -- cgit From 2e07c2ade89f4ff281c61f74cb88e09990cf5f46 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 22:47:30 +0100 Subject: s/sid_to_string/sid_to_fstring/ least surprise for callers (This used to be commit eb523ba77697346a365589101aac379febecd546) --- source3/libsmb/cliquota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 3c794240bc..206576f040 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -608,7 +608,7 @@ void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_ if (_sidtostring) { _sidtostring(username_str,&qt->sid,_numeric); } else { - sid_to_string(username_str, &qt->sid); + sid_to_fstring(username_str, &qt->sid); } if (_verbose) { -- cgit From a59280792cab616f5b269960ab68bc44ccc1fd38 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 29 Dec 2007 22:16:31 +0100 Subject: Remove tiny code duplication sid_size did the same as ndr_size_dom_sid (This used to be commit 8aec5d09ba023413bd8ecbdfbc7d23904df94389) --- source3/libsmb/cliquota.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/cliquota.c') diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 206576f040..f369d28dff 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -150,7 +150,7 @@ bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC SIVAL(params, 8,0x00000000); SIVAL(params,12,0x00000024); - sid_len = sid_size(&pqt->sid); + sid_len = ndr_size_dom_sid(&pqt->sid, 0); data_len = sid_len+8; SIVAL(data, 0, 0x00000000); SIVAL(data, 4, sid_len); @@ -213,7 +213,7 @@ bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC SSVAL(params,0,quota_fnum); - sid_len = sid_size(&pqt->sid); + sid_len = ndr_size_dom_sid(&pqt->sid, 0); SIVAL(data,0,0); SIVAL(data,4,sid_len); SBIG_UINT(data, 8,(SMB_BIG_UINT)0); -- cgit