Use rpccli_lsa_QueryInfoPolicy and rpccli_lsa_QueryInfoPolicy2 in rpcclient.
[kai/samba.git] / source3 / smbd / ntquotas.c
index 6a217a32587955d89cf0075443a56fc0bdf75da1..fcccf9d9fc02a2c4dda848f95c89ff3a10ece8e8 100644 (file)
@@ -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,
    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 <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_QUOTA
+
 static SMB_BIG_UINT limit_nt2unix(SMB_BIG_UINT in, SMB_BIG_UINT bsize)
 {
        SMB_BIG_UINT ret = (SMB_BIG_UINT)0;
@@ -84,9 +86,9 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid,
 
        id.uid = -1;
 
-       if (psid && NT_STATUS_IS_ERR(sid_to_uid(psid, &id.uid))) {
+       if (psid && !sid_to_uid(psid, &id.uid)) {
                DEBUG(0,("sid_to_uid: failed, SID[%s]\n",
-                       sid_string_static(psid)));      
+                        sid_string_dbg(psid)));
        }
 
        ret = SMB_VFS_GET_QUOTA(fsp->conn, qtype, id, &D);
@@ -128,9 +130,9 @@ int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid,
        D.isoftlimit = limit_blk2inodes(D.softlimit);
        D.ihardlimit = limit_blk2inodes(D.hardlimit);
 
-       if (psid && NT_STATUS_IS_ERR(sid_to_uid(psid, &id.uid))) {
+       if (psid && !sid_to_uid(psid, &id.uid)) {
                DEBUG(0,("sid_to_uid: failed, SID[%s]\n",
-                       sid_string_static(psid)));      
+                        sid_string_dbg(psid)));
        }
 
        ret = SMB_VFS_SET_QUOTA(fsp->conn, qtype, id, &D);
@@ -138,7 +140,7 @@ int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid,
        return ret;
 }
 
-static BOOL allready_in_quota_list(SMB_NTQUOTA_LIST *qt_list, uid_t uid)
+static bool allready_in_quota_list(SMB_NTQUOTA_LIST *qt_list, uid_t uid)
 {
        SMB_NTQUOTA_LIST *tmp_list = NULL;
        
@@ -182,29 +184,27 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list)
                        continue;
                }
 
-               if (NT_STATUS_IS_ERR(uid_to_sid(&sid, usr->pw_uid))) {
-                       DEBUG(0,("uid_to_sid failed for %ld\n",(long)usr->pw_uid));
-                       continue;
-               }
+               uid_to_sid(&sid, usr->pw_uid);
 
                if (vfs_get_ntquota(fsp, SMB_USER_QUOTA_TYPE, &sid, &tmp_qt)!=0) {
-                       DEBUG(1,("no quota entry for sid[%s] path[%s]\n",
-                               sid_string_static(&sid),fsp->conn->connectpath));
+                       DEBUG(5,("no quota entry for sid[%s] path[%s]\n",
+                                sid_string_dbg(&sid),
+                                fsp->conn->connectpath));
                        continue;
                }
 
                DEBUG(15,("quota entry for id[%s] path[%s]\n",
-                       sid_string_static(&sid),fsp->conn->connectpath));
+                         sid_string_dbg(&sid), fsp->conn->connectpath));
 
-               if ((tmp_list_ent=(SMB_NTQUOTA_LIST *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_LIST)))==NULL) {
-                       DEBUG(0,("talloc_zero() failed\n"));
+               if ((tmp_list_ent=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_LIST))==NULL) {
+                       DEBUG(0,("TALLOC_ZERO() failed\n"));
                        *qt_list = NULL;
                        talloc_destroy(mem_ctx);
                        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"));
+               if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) {
+                       DEBUG(0,("TALLOC_ZERO() failed\n"));
                        *qt_list = NULL;
                        talloc_destroy(mem_ctx);
                        return (-1);
@@ -229,9 +229,9 @@ void *init_quota_handle(TALLOC_CTX *mem_ctx)
        if (!mem_ctx)
                return False;
 
-       qt_handle = (SMB_NTQUOTA_HANDLE *)talloc_zero(mem_ctx,sizeof(SMB_NTQUOTA_HANDLE));
+       qt_handle = TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_HANDLE);
        if (qt_handle==NULL) {
-               DEBUG(0,("talloc_zero() failed\n"));
+               DEBUG(0,("TALLOC_ZERO() failed\n"));
                return NULL;
        }
 
@@ -244,7 +244,7 @@ void destroy_quota_handle(void **pqt_handle)
        if (!pqt_handle||!(*pqt_handle))
                return;
        
-       qt_handle = (*pqt_handle);
+       qt_handle = (SMB_NTQUOTA_HANDLE *)(*pqt_handle);
        
        
        if (qt_handle->quota_list)
@@ -256,4 +256,3 @@ void destroy_quota_handle(void **pqt_handle)
 
        return;
 }
-