summaryrefslogtreecommitdiff
path: root/mail/dovecot2/patches/patch-src_plugins_quota_quota-fs.c
blob: 08a9d259570bb0357a9e8541d769dbad78e6fc24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$NetBSD: patch-src_plugins_quota_quota-fs.c,v 1.3.2.1 2013/08/06 15:57:07 tron Exp $

fix support for NetBSD's libquota

--- src/plugins/quota/quota-fs.c.orig	2013-02-26 09:42:04.000000000 +0100
+++ src/plugins/quota/quota-fs.c	2013-08-06 01:00:32.000000000 +0200
@@ -672,34 +672,38 @@
 {
 	struct quotakey qk;
 	struct quotaval qv;
+	struct quotahandle *qh;
+	int ret;
 
-	if (root->qh == NULL) {
-		if ((root->qh = quota_open(root->mount->mount_path)) == NULL) {
-			i_error("cannot open quota for %s: %m",
-				root->mount->mount_path);
-			fs_quota_root_disable(root, group);
-			return 0;
-		}
-	} 
+	if ((qh = quota_open(root->mount->mount_path)) == NULL) {
+		i_error("cannot open quota for %s: %m",
+			root->mount->mount_path);
+		fs_quota_root_disable(root, group);
+		return 0;
+	}
 
 	qk.qk_idtype = group ? QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER;
 	qk.qk_id = group ? root->gid : root->uid;
 	qk.qk_objtype = bytes ? QUOTA_OBJTYPE_BLOCKS : QUOTA_OBJTYPE_FILES;
 
-	if (quota_get(root->qh, &qk, &qv) != 0) {
+	if (quota_get(qh, &qk, &qv) != 0) {
 		if (errno == ESRCH) {
 			fs_quota_root_disable(root, group);
 			return 0;
 		}
 		i_error("quotactl(Q_GETQUOTA, %s) failed: %m",
 			root->mount->mount_path);
-		return -1;
+		ret = -1;
+		goto end;
 	}
 
 	*value_r = qv.qv_usage * DEV_BSIZE;
 	*limit_r = qv.qv_softlimit * DEV_BSIZE;
 
-	return 1;
+	ret = 1;
+end:
+	quota_close(qh);
+	return ret;
 }
 #endif