From 428653ef7257240e9318f5fed71869f0124ff379 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 29 Jul 2003 18:07:13 +0000 Subject: Add NT quotas support. Users allowed now to manage quotas on systems with sysquotas interface detected (Linux at least) using native Windows tools. Also move default quota support for NT quotas to VFS module default_quota. Code by Metze (This used to be commit e856a96c2c42c39843e5e1a3a6b0d538e7179900) --- source3/modules/vfs_default_quota.c | 180 ++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 source3/modules/vfs_default_quota.c (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c new file mode 100644 index 0000000000..1294a51533 --- /dev/null +++ b/source3/modules/vfs_default_quota.c @@ -0,0 +1,180 @@ +/* + * Store default Quotas in a specified quota record + * + * 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" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +#define DEFAULT_QUOTA_NAME "default_quota" + +#define DEFAULT_QUOTA_UID_DEFAULT 0 +#define DEFAULT_QUOTA_UID_NOLIMIT_DEFAULT True +#define DEFAULT_QUOTA_GID_DEFAULT 0 +#define DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT True + +#define DEFAULT_QUOTA_UID(handle) \ + (uid_t)lp_parm_int(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"uid",DEFAULT_QUOTA_UID_DEFAULT) + +#define DEFAULT_QUOTA_UID_NOLIMIT(handle) \ + lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"uid nolimit",DEFAULT_QUOTA_UID_NOLIMIT_DEFAULT) + +#define DEFAULT_QUOTA_GID(handle) \ + (gid_t)lp_parm_int(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid",DEFAULT_QUOTA_GID_DEFAULT) + +#define DEFAULT_QUOTA_GID_NOLIMIT(handle) \ + lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid nolimit",DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT) + +static int default_quota_get_quota(vfs_handle_struct *handle, connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq) +{ + int ret = -1; + + if ((ret=SMB_VFS_NEXT_GET_QUOTA(handle, conn, qtype, id, dq))!=0) { + return ret; + } + + switch (qtype) { + case SMB_USER_QUOTA_TYPE: + /* we use id.uid == 0 for default quotas */ + if ((id.uid==DEFAULT_QUOTA_UID(handle)) && + DEFAULT_QUOTA_UID_NOLIMIT(handle)) { + SMB_QUOTAS_SET_NO_LIMIT(dq); + } + break; +#ifdef HAVE_GROUP_QUOTA + case SMB_GROUP_QUOTA_TYPE: + /* we use id.gid == 0 for default quotas */ + if ((id.gid==DEFAULT_QUOTA_GID(handle)) && + DEFAULT_QUOTA_GID_NOLIMIT(handle)) { + SMB_QUOTAS_SET_NO_LIMIT(dq); + } + break; +#endif /* HAVE_GROUP_QUOTA */ + case SMB_USER_FS_QUOTA_TYPE: + { + unid_t qid; + uint32 qflags = dq->qflags; + qid.uid = DEFAULT_QUOTA_UID(handle); + SMB_VFS_NEXT_GET_QUOTA(handle, conn, SMB_USER_QUOTA_TYPE, qid, dq); + dq->qflags = qflags; + } + break; +#ifdef HAVE_GROUP_QUOTA + case SMB_GROUP_FS_QUOTA_TYPE: + { + unid_t qid; + uint32 qflags = dq->qflags; + qid.gid = DEFAULT_QUOTA_GID(handle); + SMB_VFS_NEXT_GET_QUOTA(handle, conn, SMB_GROUP_QUOTA_TYPE, qid, dq); + dq->qflags = qflags; + } + break; +#endif /* HAVE_GROUP_QUOTA */ + default: + errno = ENOSYS; + return -1; + break; + } + + return ret; +} + +static int default_quota_set_quota(vfs_handle_struct *handle, connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq) +{ + int ret = -1; + + switch (qtype) { + case SMB_USER_QUOTA_TYPE: + /* we use id.uid == 0 for default quotas */ + if ((id.uid==DEFAULT_QUOTA_UID(handle)) && + DEFAULT_QUOTA_UID_NOLIMIT(handle)) { + return -1; + } + break; +#ifdef HAVE_GROUP_QUOTA + case SMB_GROUP_QUOTA_TYPE: + /* we use id.gid == 0 for default quotas */ + if ((id.gid==DEFAULT_QUOTA_GID(handle)) && + DEFAULT_QUOTA_GID_NOLIMIT(handle)) { + return -1; + } + break; +#endif /* HAVE_GROUP_QUOTA */ + case SMB_USER_FS_QUOTA_TYPE: + break; +#ifdef HAVE_GROUP_QUOTA + case SMB_GROUP_FS_QUOTA_TYPE: + break; +#endif /* HAVE_GROUP_QUOTA */ + default: + errno = ENOSYS; + return -1; + break; + } + + if ((ret=SMB_VFS_NEXT_SET_QUOTA(handle, conn, qtype, id, dq))!=0) { + return ret; + } + + switch (qtype) { + case SMB_USER_QUOTA_TYPE: + break; +#ifdef HAVE_GROUP_QUOTA + case SMB_GROUP_QUOTA_TYPE: + break; +#endif /* HAVE_GROUP_QUOTA */ + case SMB_USER_FS_QUOTA_TYPE: + { + unid_t qid; + qid.uid = DEFAULT_QUOTA_UID(handle); + ret = SMB_VFS_NEXT_SET_QUOTA(handle, conn, SMB_USER_QUOTA_TYPE, qid, dq); + } + break; +#ifdef HAVE_GROUP_QUOTA + case SMB_GROUP_FS_QUOTA_TYPE: + { + unid_t qid; + qid.gid = DEFAULT_QUOTA_GID(handle); + ret = SMB_VFS_NEXT_SET_QUOTA(handle, conn, SMB_GROUP_QUOTA_TYPE, qid, dq); + } + break; +#endif /* HAVE_GROUP_QUOTA */ + default: + errno = ENOSYS; + return -1; + break; + } + + return ret; +} + +/* VFS operations structure */ + +static vfs_op_tuple default_quota_ops[] = { + {SMB_VFS_OP(default_quota_get_quota), SMB_VFS_OP_GET_QUOTA, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(default_quota_set_quota), SMB_VFS_OP_SET_QUOTA, SMB_VFS_LAYER_TRANSPARENT}, + + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_default_quota_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, DEFAULT_QUOTA_NAME, default_quota_ops); +} -- cgit From 3a6d5a3ab3a94dd25f2d19f81edf75ba0a327c44 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 24 May 2004 11:05:19 +0000 Subject: r840: use quota debug class metze (This used to be commit fd94bdaef57b258fcccb9fae1e2f0b96688d51c4) --- source3/modules/vfs_default_quota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 1294a51533..f7c5dce4d6 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -21,7 +21,7 @@ #include "includes.h" #undef DBGC_CLASS -#define DBGC_CLASS DBGC_VFS +#define DBGC_CLASS DBGC_QUOTA #define DEFAULT_QUOTA_NAME "default_quota" -- cgit From 9c90642198864e1d1cbac56eab02b67e4a4c1fd6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Sep 2005 08:50:00 +0000 Subject: r10061: add some description to the default_quota module jht: can you merge that to the howto, please? metze (This used to be commit 48c5c760afd77f86778b96925486d1b21e332a61) --- source3/modules/vfs_default_quota.c | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index f7c5dce4d6..4636441999 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -18,6 +18,56 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + * This module allows the default quota values, + * in the windows explorer GUI, to be stored on a samba server. + * The problem is that linux filesystems only store quotas + * for users and groups, but no default quotas. + * + * Samba returns NO_LIMIT as the default quotas by default + * and refuses to update them. + * + * With this module you can store the default quotas that are reported to + * a windows client, in the quota record of a user. By default the root user + * is taken because quota limits for root are typically not enforced. + * + * This module takes 2 parametric parameters in smb.conf: + * (the default prefix for them is 'default_quota', + * it can be overwrittem when you load the module in + * the 'vfs modules' parameter like this: + * vfs modules = default_quota:myprefix) + * + * ":uid" parameter takes a integer argument, + * it specifies the uid of the quota record, that will be taken for + * storing the default USER-quotas. + * + * - default value: '0' (for root user) + * - e.g.: default_quota:uid = 65534 + * + * ":uid nolimit" parameter takes a boolean argument, + * it specifies if we should report the stored default quota values, + * also for the user record, or if you should just report NO_LIMIT + * to the windows client for the user specified by the ":uid" parameter. + * + * - default value: yes (that means to report NO_LIMIT) + * - e.g.: default_quota:uid nolimit = no + * + * ":gid" parameter takes a integer argument, + * it's just like ":uid" but for group quotas. + * (NOTE: group quotas are not supported from the windows explorer!) + * + * - default value: '0' (for root group) + * - e.g.: default_quota:gid = 65534 + * + * ":gid nolimit" parameter takes a boolean argument, + * it's just like ":uid nolimit" but for group quotas. + * (NOTE: group quotas are not supported from the windows explorer!) + * + * - default value: yes (that means to report NO_LIMIT) + * - e.g.: default_quota:uid nolimit = no + * + */ + #include "includes.h" #undef DBGC_CLASS -- cgit From ab7273c6425fa6869922be4811870aa12b181d20 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Fri, 9 Sep 2005 06:25:28 +0000 Subject: r10105: Fix typos. Oops, modules are called objects. (This used to be commit 4cf1a2ee719291951774476e2768b06558d7e0aa) --- source3/modules/vfs_default_quota.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 4636441999..923820de9c 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -34,8 +34,8 @@ * This module takes 2 parametric parameters in smb.conf: * (the default prefix for them is 'default_quota', * it can be overwrittem when you load the module in - * the 'vfs modules' parameter like this: - * vfs modules = default_quota:myprefix) + * the 'vfs object' parameter like this: + * vfs object = default_quota:myprefix) * * ":uid" parameter takes a integer argument, * it specifies the uid of the quota record, that will be taken for -- cgit From 951a0cec620f03b4ae56bdbfef9940f0ef31b2d6 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Fri, 9 Sep 2005 06:40:17 +0000 Subject: r10106: Fix typos. Oops, more fixes. (This used to be commit 80952a7edab50315c3a17744683a8cb378eec8ae) --- source3/modules/vfs_default_quota.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 923820de9c..9922a30315 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -34,17 +34,17 @@ * This module takes 2 parametric parameters in smb.conf: * (the default prefix for them is 'default_quota', * it can be overwrittem when you load the module in - * the 'vfs object' parameter like this: - * vfs object = default_quota:myprefix) + * the 'vfs objects' parameter like this: + * vfs objects = default_quota:myprefix) * - * ":uid" parameter takes a integer argument, + * ":uid" parameter takes a integer argument, * it specifies the uid of the quota record, that will be taken for * storing the default USER-quotas. * * - default value: '0' (for root user) * - e.g.: default_quota:uid = 65534 * - * ":uid nolimit" parameter takes a boolean argument, + * ":uid nolimit" parameter takes a boolean argument, * it specifies if we should report the stored default quota values, * also for the user record, or if you should just report NO_LIMIT * to the windows client for the user specified by the ":uid" parameter. @@ -52,14 +52,14 @@ * - default value: yes (that means to report NO_LIMIT) * - e.g.: default_quota:uid nolimit = no * - * ":gid" parameter takes a integer argument, + * ":gid" parameter takes a integer argument, * it's just like ":uid" but for group quotas. * (NOTE: group quotas are not supported from the windows explorer!) * * - default value: '0' (for root group) * - e.g.: default_quota:gid = 65534 * - * ":gid nolimit" parameter takes a boolean argument, + * ":gid nolimit" parameter takes a boolean argument, * it's just like ":uid nolimit" but for group quotas. * (NOTE: group quotas are not supported from the windows explorer!) * -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/modules/vfs_default_quota.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 9922a30315..55dc287b88 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -92,11 +92,11 @@ #define DEFAULT_QUOTA_GID_NOLIMIT(handle) \ lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid nolimit",DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT) -static int default_quota_get_quota(vfs_handle_struct *handle, connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq) +static int default_quota_get_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq) { int ret = -1; - if ((ret=SMB_VFS_NEXT_GET_QUOTA(handle, conn, qtype, id, dq))!=0) { + if ((ret=SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, dq))!=0) { return ret; } @@ -122,7 +122,7 @@ static int default_quota_get_quota(vfs_handle_struct *handle, connection_struct unid_t qid; uint32 qflags = dq->qflags; qid.uid = DEFAULT_QUOTA_UID(handle); - SMB_VFS_NEXT_GET_QUOTA(handle, conn, SMB_USER_QUOTA_TYPE, qid, dq); + SMB_VFS_NEXT_GET_QUOTA(handle, SMB_USER_QUOTA_TYPE, qid, dq); dq->qflags = qflags; } break; @@ -132,7 +132,7 @@ static int default_quota_get_quota(vfs_handle_struct *handle, connection_struct unid_t qid; uint32 qflags = dq->qflags; qid.gid = DEFAULT_QUOTA_GID(handle); - SMB_VFS_NEXT_GET_QUOTA(handle, conn, SMB_GROUP_QUOTA_TYPE, qid, dq); + SMB_VFS_NEXT_GET_QUOTA(handle, SMB_GROUP_QUOTA_TYPE, qid, dq); dq->qflags = qflags; } break; @@ -146,7 +146,7 @@ static int default_quota_get_quota(vfs_handle_struct *handle, connection_struct return ret; } -static int default_quota_set_quota(vfs_handle_struct *handle, connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq) +static int default_quota_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq) { int ret = -1; @@ -179,7 +179,7 @@ static int default_quota_set_quota(vfs_handle_struct *handle, connection_struct break; } - if ((ret=SMB_VFS_NEXT_SET_QUOTA(handle, conn, qtype, id, dq))!=0) { + if ((ret=SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq))!=0) { return ret; } @@ -194,7 +194,7 @@ static int default_quota_set_quota(vfs_handle_struct *handle, connection_struct { unid_t qid; qid.uid = DEFAULT_QUOTA_UID(handle); - ret = SMB_VFS_NEXT_SET_QUOTA(handle, conn, SMB_USER_QUOTA_TYPE, qid, dq); + ret = SMB_VFS_NEXT_SET_QUOTA(handle, SMB_USER_QUOTA_TYPE, qid, dq); } break; #ifdef HAVE_GROUP_QUOTA @@ -202,7 +202,7 @@ static int default_quota_set_quota(vfs_handle_struct *handle, connection_struct { unid_t qid; qid.gid = DEFAULT_QUOTA_GID(handle); - ret = SMB_VFS_NEXT_SET_QUOTA(handle, conn, SMB_GROUP_QUOTA_TYPE, qid, dq); + ret = SMB_VFS_NEXT_SET_QUOTA(handle, SMB_GROUP_QUOTA_TYPE, qid, dq); } break; #endif /* HAVE_GROUP_QUOTA */ -- cgit From 55ed1d59455566d90a03e7123fbf7a05a4bd4539 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 19 Dec 2006 20:16:52 +0000 Subject: r20261: merge 20260 from samba_3_0_24 clean up a bunch of no previous prototype warnings (This used to be commit c60687db112405262adf26dbf267804b04074e67) --- source3/modules/vfs_default_quota.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 55dc287b88..772c91dc47 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.c @@ -224,6 +224,7 @@ static vfs_op_tuple default_quota_ops[] = { {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} }; +NTSTATUS vfs_default_quota_init(void); NTSTATUS vfs_default_quota_init(void) { return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, DEFAULT_QUOTA_NAME, default_quota_ops); -- 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/modules/vfs_default_quota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index 772c91dc47..d8e5009b0c 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.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 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/modules/vfs_default_quota.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/modules/vfs_default_quota.c') diff --git a/source3/modules/vfs_default_quota.c b/source3/modules/vfs_default_quota.c index d8e5009b0c..6dbbad75fa 100644 --- a/source3/modules/vfs_default_quota.c +++ b/source3/modules/vfs_default_quota.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 . */ /* -- cgit