diff options
author | Jeremy Allison <jra@samba.org> | 2001-04-27 19:56:15 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-04-27 19:56:15 +0000 |
commit | 8f88c7cf4e2029be8b38ee9052dc12e90efcc8d7 (patch) | |
tree | 6406fb4d2193f5319f2ef930d65760c87ddf8151 /source3 | |
parent | 7c7770a3662d8173d646f5b15497d031e65e0b57 (diff) | |
download | samba-8f88c7cf4e2029be8b38ee9052dc12e90efcc8d7.tar.gz samba-8f88c7cf4e2029be8b38ee9052dc12e90efcc8d7.tar.bz2 samba-8f88c7cf4e2029be8b38ee9052dc12e90efcc8d7.zip |
Fixes for problems in NFS server code from Michael Gerdts <Michael.Gerdts@usa.alcatel.com>.
Jeremy.
(This used to be commit 2fd5e0bf141807d31f6f1a817d271548d0ccfadc)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/quotas.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index ccb5534641..81da013cec 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -322,6 +322,9 @@ static BOOL nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B int len; static struct timeval timeout = {2,0}; enum clnt_stat clnt_stat; + BOOL ret = True; + + *bsize = *dfree = *dsize = (SMB_BIG_UINT)0; len=strcspn(mnttype, ":"); pathname=strstr(mnttype, ":"); @@ -338,15 +341,21 @@ static BOOL nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B DEBUG(5,("nfs_quotas: Asking for host \"%s\" rpcprog \"%i\" rpcvers \"%i\" network \"%s\"\n", host, RQUOTAPROG, RQUOTAVERS, "udp")); - if ((clnt = clnt_create(host, RQUOTAPROG, RQUOTAVERS, "udp")) != NULL) { - clnt->cl_auth = authunix_create_default(); - DEBUG(9,("nfs_quotas: auth_success\n")); + if ((clnt = clnt_create(host, RQUOTAPROG, RQUOTAVERS, "udp")) == NULL) { + ret = False; + goto out; + } - clnt_stat=clnt_call(clnt, RQUOTAPROC_GETQUOTA, xdr_getquota_args, (caddr_t)&args, xdr_getquota_rslt, (caddr_t)&gqr, timeout); - if (clnt_stat == RPC_SUCCESS) - DEBUG(9,("nfs_quotas: rpccall_success\n")); - }; + clnt->cl_auth = authunix_create_default(); + DEBUG(9,("nfs_quotas: auth_success\n")); + clnt_stat=clnt_call(clnt, RQUOTAPROC_GETQUOTA, xdr_getquota_args, (caddr_t)&args, xdr_getquota_rslt, (caddr_t)&gqr, timeout); + + if (clnt_stat != RPC_SUCCESS) { + DEBUG(9,("nfs_quotas: clnt_call fail\n")); + ret = False; + goto out; + } /* * quotastat returns 0 if the rpc call fails, 1 if quotas exist, 2 if there is @@ -354,26 +363,30 @@ static BOOL nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B * something sensible. */ - if (quotastat == 1) { + switch ( quotastat ) { + case 0: + DEBUG(9,("nfs_quotas: Remote Quotas Failed! Error \"%i\" \n", quotastat )); + ret = False; + goto out; + + case 1: DEBUG(9,("nfs_quotas: Good quota data\n")); D.dqb_bsoftlimit = gqr.getquota_rslt_u.gqr_rquota.rq_bsoftlimit; D.dqb_bhardlimit = gqr.getquota_rslt_u.gqr_rquota.rq_bhardlimit; D.dqb_curblocks = gqr.getquota_rslt_u.gqr_rquota.rq_curblocks; - } + break; - if (quotastat == 0 || quotastat == 3) { + case 2: + case 3: D.dqb_bsoftlimit = 1; D.dqb_curblocks = 1; - DEBUG(9,("nfs_quotas: Remote Quotas Failed! Error \"%i\" \n", quotastat )); - } + DEBUG(9,("nfs_quotas: Remote Quotas returned \"%i\" \n", quotastat )); + break; - if (quotastat == 2) { - DEBUG(9,("nfs_quotas: Remote Quotas Failed! Error \"%i\" \n", quotastat )); - auth_destroy(clnt->cl_auth); - clnt_destroy(clnt); - free(cutstr); - return(False); - } + default: + DEBUG(9,("nfs_quotas: Remote Quotas Questionable! Error \"%i\" \n", quotastat )); + break; + } DEBUG(10,("nfs_quotas: Let`s look at D a bit closer... status \"%i\" bsize \"%i\" active? \"%i\" bhard \"%i\" bsoft \"%i\" curb \"%i\" \n", quotastat, @@ -395,14 +408,19 @@ static BOOL nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B } else *dfree = D.dqb_bsoftlimit - D.dqb_curblocks; - auth_destroy(clnt->cl_auth); - clnt_destroy(clnt); + out: + + if (clnt) { + if (clnt->cl_auth) + auth_destroy(clnt->cl_auth); + clnt_destroy(clnt); + } DEBUG(5,("nfs_quotas: For path \"%s\" returning bsize %.0f, dfree %.0f, dsize %.0f\n",args.gqa_pathp,(double)*bsize,(double)*dfree,(double)*dsize)); - free(cutstr); + safe_free(cutstr); DEBUG(10,("nfs_quotas: End of nfs_quotas\n" )); - return(True); + return ret; } #endif |