[vhffs-dev] [818] You can now define the quota allowed for files which belong to the user primary group (ie.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 818
Author:   gradator
Date:     2007-08-30 02:26:40 +0000 (Thu, 30 Aug 2007)

Log Message:
-----------
You can now define the quota allowed for files which belong to the user primary group (ie. file in its home directory)

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-backend/conf/vhffs.conf.dist.in
    trunk/vhffs-robots/Makefile.am
    trunk/vhffs-robots/src/group_setquota.pl

Added Paths:
-----------
    trunk/vhffs-robots/src/user_setquota.pl


Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2007-08-30 02:04:01 UTC (rev 817)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2007-08-30 02:26:40 UTC (rev 818)
@@ -217,6 +217,7 @@
         my $group = Vhffs::Group::create($main, $username, $uid, $gid);
         die('Error creating group') unless (defined $group);
         $group->set_status(Vhffs::Constants::ACTIVATED);
+	$group->set_quota( $userconf->{'default_quota'} || 1 );
         $group->commit;
 
         $dbh->commit;

Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in	2007-08-30 02:04:01 UTC (rev 817)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in	2007-08-30 02:26:40 UTC (rev 818)
@@ -161,6 +161,7 @@
 	bad_groupname_file	=	@CONFDIR@/bl_groupname
 	available_shells	=	/bin/bash /bin/tcsh /bin/zsh /bin/tuxshell
 	default_shell		=	/bin/bash
+	default_quota		=	10
 
 	# URL to the documentation (optional)
 	url_doc			=	http://help.myhoster.net/user

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2007-08-30 02:04:01 UTC (rev 817)
+++ trunk/vhffs-robots/Makefile.am	2007-08-30 02:26:40 UTC (rev 818)
@@ -64,6 +64,7 @@
 	src/user_create.pl \
 	src/user_delete.pl \
 	src/user_group.pl \
+	src/user_setquota.pl \
 	src/web_create.pl \
 	src/web_delete.pl \
 	src/web_refused.pl \

Modified: trunk/vhffs-robots/src/group_setquota.pl
===================================================================
--- trunk/vhffs-robots/src/group_setquota.pl	2007-08-30 02:04:01 UTC (rev 817)
+++ trunk/vhffs-robots/src/group_setquota.pl	2007-08-30 02:26:40 UTC (rev 818)
@@ -40,23 +40,17 @@
 use Vhffs::Robots;
 use Vhffs::Group;
 
-
 my $vhffs = init Vhffs::Main;
 
-Vhffs::Robots::lock( $vhffs , "setquota" );
+Vhffs::Robots::lock( $vhffs , "setquotagroup" );
 
-my $groups = Vhffs::Group::getall( $vhffs , Vhffs::Constants::ACTIVATED );
-my $group;
-my $blocks;
-my $user;
-my $users;
-my $inodes;
 my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
 
-foreach $group ( @{$groups} )
+my $groups = Vhffs::Group::getall( $vhffs , Vhffs::Constants::ACTIVATED );
+foreach my $group ( @{$groups} )
 {
-	$blocks = $group->get_quota * 1024;
-	$inodes = $group->get_quota * 1126400 / 100;
+	my $blocks = $group->get_quota * 1024;
+	my $inodes = $group->get_quota * 1126400 / 100;
 
 	unless( Quota::setqlim($dev, $group->get_gid, $blocks, $blocks, $inodes, $inodes, 0, 1) )
 	{
@@ -68,23 +62,6 @@
 	}
 }
 
-$users = Vhffs::User::getall( $vhffs , Vhffs::Constants::ACTIVATED );
+Vhffs::Robots::unlock( $vhffs , "setquotagroup" );
 
-foreach $user ( @{$users} )
-{
-    $blocks = 1024;
-	$inodes = 1126400 / 100;
-
-    unless( Quota::setqlim($dev, $user->get_gid, $blocks, $blocks, $inodes, $inodes, 0, 1) )
-	{
-			Vhffs::Robots::vhffs_log( sprintf( "Update quota for user group %s set 1" , $user->get_username ) , $vhffs);
-	}
-	else
-	{
-		printf("Cannot update quota for group %s, reason: %s\n", $user->get_username, Quota::strerr);
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "setquota" );
-
 exit 0;

Added: trunk/vhffs-robots/src/user_setquota.pl
===================================================================
--- trunk/vhffs-robots/src/user_setquota.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/user_setquota.pl	2007-08-30 02:26:40 UTC (rev 818)
@@ -0,0 +1,68 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+require 5.004;
+use strict;
+use POSIX;
+use locale;
+use Locale::gettext;
+use Quota;
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Main;
+use Vhffs::Robots;
+use Vhffs::Group;
+
+my $vhffs = init Vhffs::Main;
+
+Vhffs::Robots::lock( $vhffs , "setquotauser" );
+
+my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
+
+my $users = Vhffs::User::getall( $vhffs , Vhffs::Constants::ACTIVATED );
+foreach my $user ( @{$users} )
+{
+	my $group = $user->get_group;
+	my $blocks = $group->get_quota * 1024;
+	my $inodes = $group->get_quota * 1126400 / 100;
+
+	unless( Quota::setqlim($dev, $group->get_gid, $blocks, $blocks, $inodes, $inodes, 0, 1) )
+	{
+		Vhffs::Robots::vhffs_log( sprintf( "Update quota for user group %s set 1" , $user->get_username ) , $vhffs);
+	}
+	else
+	{
+		printf("Cannot update quota for group %s, reason: %s\n", $user->get_username, Quota::strerr);
+	}
+}
+
+Vhffs::Robots::unlock( $vhffs , "setquotauser" );
+
+exit 0;


Property changes on: trunk/vhffs-robots/src/user_setquota.pl
___________________________________________________________________
Name: svn:executable
   + *


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/