s3:winbindd: Fix size types in idmap_tdb_common
[samba.git] / source3 / lib / sysquotas_nfs.c
index 63f114b057fdab3b4fc68cf42c9fce9dc8031e58..dd2b12d0ffdaa7ecb31b9c089f47e2225fb45882 100644 (file)
  * This is based on the FreeBSD / SUNOS5 section of quotas.c
  */
 
+/* <rpc/xdr.h> uses TRUE and FALSE */
+#ifdef TRUE
+#undef TRUE
+#endif
+
+#ifdef FALSE
+#undef FALSE
+#endif
+
 #include <rpc/rpc.h>
 #include <rpc/types.h>
+#include <rpc/xdr.h>
 #include <rpcsvc/rquota.h>
 #ifdef HAVE_RPC_NETTYPE_H
 #include <rpc/nettype.h>
 #endif
-#include <rpc/xdr.h>
 
 #ifndef RQ_PATHLEN
 #define RQ_PATHLEN 1024
@@ -113,7 +122,7 @@ int sys_get_nfs_quota(const char *path, const char *bdev,
        enum clnt_stat clnt_stat;
 
        int ret = -1;
-       uint32 qflags = 0;
+       uint32_t qflags = 0;
 
        if (!path || !bdev || !dp) {
                smb_panic("sys_get_nfs_quota: called with NULL pointer");
@@ -155,7 +164,7 @@ int sys_get_nfs_quota(const char *path, const char *bdev,
 
        DEBUG(10, ("sys_get_nfs_quotas: Asking for quota of path '%s' on "
                   "host '%s', rpcprog '%i', rpcvers '%i', network '%s'\n",
-                   host, testpath+1, RQUOTAPROG, RQUOTAVERS, "udp"));
+                  host, testpath+1, (int)RQUOTAPROG, (int)RQUOTAVERS, "udp"));
 
        clnt = clnt_create(host, RQUOTAPROG, RQUOTAVERS, "udp");
        if (clnt == NULL) {
@@ -180,8 +189,20 @@ int sys_get_nfs_quota(const char *path, const char *bdev,
                              timeout);
 
        if (clnt_stat != RPC_SUCCESS) {
-               DEBUG(3, ("sys_get_nfs_quotas: clnt_call failed\n"));
-               ret = -1;
+               if (errno == ECONNREFUSED) {
+                       /* If we cannot connect with rpc.quotad, it may
+                        * simply be because there's no quota on the remote
+                        * system
+                        */
+                       DBG_INFO("clnt_call failed with ECONNREFUSED - "
+                                "assuming no quotas on server\n");
+                       ret = 0;
+               } else {
+                       int save_errno = errno;
+                       DBG_NOTICE("clnt_call failed - %s\n", strerror(errno));
+                       errno = save_errno;
+                       ret = -1;
+               }
                goto out;
        }
 
@@ -211,19 +232,12 @@ int sys_get_nfs_quota(const char *path, const char *bdev,
 
        /*
         * gqr.status returns
-        *   0 if the rpc call fails,
         *   1 if quotas exist,
         *   2 if there is no quota set, and
         *   3 if no permission to get the quota.
         */
 
        switch (gq_rslt.GQR_STATUS) {
-       case 0:
-               DEBUG(3, ("sys_get_nfs_quotas: Remote Quotas Failed! "
-                         "Error '%i'\n", gq_rslt.GQR_STATUS));
-               ret = -1;
-               goto out;
-
        case 1:
                DEBUG(10, ("sys_get_nfs_quotas: Good quota data\n"));
                dp->bsize = (uint64_t)gq_rslt.GQR_RQUOTA.rq_bsize;