[vhffs-dev] [2009] Reworked Vhffs::Functions and Vhffs::Robots |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2009
Author: gradator
Date: 2012-02-15 22:39:36 +0100 (Wed, 15 Feb 2012)
Log Message:
-----------
Reworked Vhffs::Functions and Vhffs::Robots
Moved functions only used by robots from Vhffs::Functions to Vhffs::Robots
Fixed some change required due to AutoTrue enabling in Config::General object
Removed useless Vhffs::Debug
Removed system() from Vhffs::Robots
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Conf.pm
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Makefile.am
trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
trunk/vhffs-api/src/Vhffs/Robots/Git.pm
trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
trunk/vhffs-api/src/Vhffs/Robots/Web.pm
trunk/vhffs-api/src/Vhffs/Robots.pm
trunk/vhffs-api/src/Vhffs/Services/MailUser.pm
trunk/vhffs-robots/src/mail_createboxes.pl
trunk/vhffs-robots/src/repository_stats.pl
trunk/vhffs-robots/src/web_stats.pl
Removed Paths:
-------------
trunk/vhffs-api/src/Vhffs/Debug.pm
Modified: trunk/vhffs-api/src/Vhffs/Conf.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Conf.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Conf.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -66,6 +66,9 @@
'default_language' => 'en_US',
'available_languages' => 'en_US'
},
+ 'panel' => {
+ 'mail_obfuscation' => 'none'
+ },
'users' => {
'available_shells' => '/bin/false',
'default_shell' => '/bin/false'
Deleted: trunk/vhffs-api/src/Vhffs/Debug.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Debug.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Debug.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -1,62 +0,0 @@
-# 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.
-
-package Vhffs::Debug;
-require Exporter;
-@ISA = qw( Exporter );
-@EXPORT = qw( debuglog );
-
-use strict;
-use utf8;
-
-use constant
-{
- LOGFILE => "/tmp/vhffs-debug",
- LOG => 1,
-};
-
-
-sub debuglog
-{
- my $str;
- my $fname;
- $str = shift;
- $fname = ">>" . LOGFILE ;
- return 0 if( LOG != 1 );
- open( FIC , $fname ) or return 1;
-
- print FIC $str . "\n";
-
- close( FIC ) or return( 3 );
-
- return( 0 );
-}
-
-1;
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -52,87 +52,37 @@
srand(time ^ $$);
-sub create_dir
-{
- my $dir = shift;
+=head2 create_dir
- my $value;
+Vhffs::Functions::create_dir( $dir );
- my @subdirs = split( /\// , $dir );
+Recursively create a directory. Returns 0 on success, otherwise returns < 0.
+
+=cut
+sub create_dir {
+ my $dir = shift;
+
+ my @subdirs = split( /\//, $dir );
@subdirs = reverse @subdirs;
-
- my $path = "";
-
- while( defined ( $value = pop ( @subdirs ) ) )
- {
- $path .= "/".$value if( $value ne '' );
- mkdir( $path ) if( ! -d $path );
+
+ my $path = '';
+ while( defined(my $value = pop(@subdirs)) ) {
+ $path .= '/'.$value if $value ne '';
+ mkdir( $path ) unless -d $path;
}
return -1 unless -d $dir;
return 0;
}
+=head2 send_mail
+my $ret = Vhffs::Functions::send_mail( $vhffs, $from, $to, $mailtag, $subject, $message, $precedence );
-=head2 chmod_recur
+Send an email.
- Vhffs::Functions::chmod_recur($dir, $fmod, $dmod);
-
-Changes permissions on files and directories recursively.
-C<$fmod> and C<$dmod> are the mod to apply to files and
-directory, respectively. See the documentation of the
-original C<chmod> function for more information.
-
=cut
-
-sub chmod_recur {
- my ($dir, $fmod, $dmod) = @_;
-
- my @files = ( $dir );
- while( defined(my $file = shift @files) ) {
- if( -d $file ) {
- chmod( $dmod, $file );
- opendir( my $dh, $file );
- while( defined(my $item = readdir($dh)) ) {
- next if( $item eq '' or $item eq '..' or $item eq '.' );
- push @files, $file.'/'.$item;
- }
- closedir( $dh );
- }
- else {
- chmod( $fmod, $file );
- }
- }
-}
-
-# Change the owner and groupe recursivly for a dir
-sub change_owner_recur
-{
- my $dir = shift;
- my $uid = shift;
- my $gid = shift;
-
- my @files = ($dir);
- while( defined(my $file = shift @files) ) {
- chown( $uid, $gid, $file );
- if( -d $file ) {
- opendir( my $dh, $file );
- while( defined(my $item = readdir($dh)) ) {
- next if( $item eq '' or $item eq '..' or $item eq '.' );
- push @files, $file.'/'.$item;
- }
- closedir( $dh );
- }
- }
-
- return 1;
-}
-
-
-
-sub send_mail
-{
+sub send_mail {
use MIME::Lite;
use MIME::Base64;
use Encode;
@@ -149,7 +99,7 @@
chomp $message;
$message .= "\n";
- my ( $gpgbin , $gpgconf );
+ my ( $gpgbin, $gpgconf );
if( defined $vhffs->get_config->get_gpg && defined $vhffs->get_config->get_gpg->{'gpg_bin'} ) {
$gpgbin = $vhffs->get_config->get_gpg->{'gpg_bin'};
my ( $cleanfrom ) = ( $from =~ /<(.+)>/ );
@@ -219,206 +169,217 @@
return 1;
}
+=head2 obfuscate_email
+my $obfuscated = Vhffs::Functions::obfuscate_email( $mail );
+
+Returns an obfuscated mail.
+
+=cut
sub obfuscate_email($$) {
- my ($vhffs, $mail) = @_;
+ my ($vhffs, $mail) = @_;
- my $tech = $vhffs->get_config->get_panel->{'mail_obfuscation'} || 'none';
-
- return $mail if($tech eq 'none');
- if($tech eq 'simple') {
- $mail =~ s/@/ AT REMOVEME /g;
- $mail =~ s/\./ DOT /g;
- return $mail;
- }
- if($tech eq 'entities') {
- my @chars = split //, $mail;
- $mail = '';
- foreach(@chars) {
- if($_ eq '@') {
- $mail .= '@';
- } else {
- my $ord = ord($_);
- if( ($ord >= ord('a') && $ord <= ord('z') )
- || ($ord >= ord('A') && $ord <= ord('Z') ) ) {
- $mail .= "&#$ord;";
- } else {
- $mail .= $_;
- }
- }
- }
- return $mail;
- }
- if($tech eq 'javascript') {
- return js_encode_mail($mail);
- }
+ my $tech = $vhffs->get_config->get_panel->{'mail_obfuscation'};
+
+ return $mail if $tech eq 'none';
+
+ if($tech eq 'simple') {
+ $mail =~ s/@/ AT REMOVEME /g;
+ $mail =~ s/\./ DOT /g;
+ return $mail;
+ }
+
+ if($tech eq 'entities') {
+ my @chars = split //, $mail;
+ $mail = '';
+ foreach(@chars) {
+ if($_ eq '@') {
+ $mail .= '@';
+ } else {
+ my $ord = ord($_);
+ if( ($ord >= ord('a') && $ord <= ord('z') )
+ || ($ord >= ord('A') && $ord <= ord('Z') ) ) {
+ $mail .= "&#$ord;";
+ } else {
+ $mail .= $_;
+ }
+ }
+ }
+ return $mail;
+ }
+
+ if($tech eq 'javascript') {
+ return js_encode_mail($mail);
+ }
+
if($tech eq 'swap') {
my @both = split /@/, $mail;
return $both[1].'/'.$both[0];
}
- return "Unsupported email obfuscation method !\n";
+ return 'Unsupported email obfuscation method !'."\n";
}
=head2 js_encode_mail
+my $encoded = Vhffs::Functions::js_encode_mail( $mail );
+
This function does the opposite of the JS function decode_mail.
=cut
-
sub js_encode_mail($) {
- my $clear = shift;
- my $crypted = '';
- my @chars = split //, $clear;
- foreach(@chars) {
- my $c = chr(ord($_) + 1);
- if($c eq "'") {
- $crypted .= '\\\'';
- } else {
- $crypted .= $c;
- }
- }
+ my $clear = shift;
+ my $crypted = '';
+ my @chars = split //, $clear;
+ foreach(@chars) {
+ my $c = chr(ord($_) + 1);
+ if($c eq "'") {
+ $crypted .= '\\\'';
+ } else {
+ $crypted .= $c;
+ }
+ }
- return '<script type="text/javascript">document.write(decode_mail(\''.$crypted.'\'));</script>';
+ return '<script type="text/javascript">document.write(decode_mail(\''.$crypted.'\'));</script>';
}
+=pod
-sub generate_random_password
-{
- my $password;
- for (0 .. 7) { $password .= ('a'..'z', 'A'..'Z', '0'..'9')[int rand 62] ; }
- return $password;
+=head2 generate_random_password
+
+my $pass = Vhffs::Functions::generate_random_password();
+
+Returns a randomized plain text password.
+
+=cut
+sub generate_random_password {
+ my $password;
+ for (0 .. 7) { $password .= ('a'..'z', 'A'..'Z', '0'..'9')[int rand 62]; }
+ return $password;
}
+=pod
-sub password_encrypt
-{
- use Crypt::PasswdMD5;
+=head2 password_encrypt
- my $password = shift;
+my $encryptedpass = Vhffs::Functions::password_encrypt( $pass );
- my $salt = join "", ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[map {rand 64} (1..8)];
- return unix_md5_crypt($password, $salt);
+Returns a md5 crypt password from plain text password. Salt is randomized.
+
+=cut
+sub password_encrypt {
+ use Crypt::PasswdMD5;
+ my $password = shift;
+
+ my $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[map {rand 64} (1..8)];
+ return unix_md5_crypt($password, $salt);
}
-sub valid_mail
-{
+=pod
+
+=head2 valid_mail
+
+die "mail is invalid" unless Vhffs::Functions::valid_mail( $mail );
+
+Checks for mail validity.
+
+=cut
+sub valid_mail {
my $mail = shift;
- my ( $localpart , $domain ) = ( $mail =~ /(.+)\@(.+)/ );
+ my ( $localpart, $domain ) = ( $mail =~ /(.+)\@(.+)/ );
return 0 unless Vhffs::Functions::check_domain_name( $domain );
use Email::Valid;
- return 1 if( Email::Valid->rfc822 ( $mail ) );
+ return 1 if Email::Valid->rfc822( $mail );
return 0;
}
+=pod
+
+=head2 status_string_from_status_id
+
+ my $statusstr = Vhffs::Functions::status_string_from_status_id( $id );
+
+Returns status string from status id.
+
+=cut
sub status_string_from_status_id($) {
my $status = shift;
- return gettext( Vhffs::Constants::STATUS_STRINGS->{$status} or 'Unknown');
+ return gettext( Vhffs::Constants::STATUS_STRINGS->{$status} or 'Unknown' );
}
+=pod
+
+=head2 type_string_from_type_id
+
+ my $typestr = Vhffs::Functions::type_string_from_type_id( $id );
+
+Returns type string from type id.
+
+=cut
sub type_string_from_type_id($) {
my $type = shift;
- return gettext( Vhffs::Constants::TYPES_STRINGS->{$type} or 'Unknown');
+ return gettext( Vhffs::Constants::TYPES_STRINGS->{$type} or 'Unknown' );
}
+=pod
+
+=head2 type_string_fs_from_type_id
+
+ my $typestrfs = Vhffs::Functions::type_string_fs_from_type_id( $id );
+
+Returns type string for filesystem from type id.
+
+=cut
sub type_string_fs_from_type_id($) {
my $type = shift;
- return gettext( Vhffs::Constants::TYPES_STRINGS_FS->{$type} or 'unknown');
+ return gettext( Vhffs::Constants::TYPES_STRINGS_FS->{$type} or 'unknown' );
}
=pod
=head2 check_domain_name
- die "Domain name is invalid (you can't use FQDN)\n" unless(Vhffs::Function::check_domain_name($name));
- die "Domain name is invalid (could be FQDN or not)\n" unless(Vhffs::Function::check_domain_name($name, 1));
+ die "Domain name is invalid (you can't use FQDN)\n" unless Vhffs::Functions::check_domain_name($name);
+ die "Domain name is invalid (could be FQDN or not)\n" unless Vhffs::Functions::check_domain_name($name, 1);
Checks for domain name validity.
=cut
-
sub check_domain_name($;$) {
- my $domain_name = shift;
- my $fqdn = shift;
- $domain_name =~ s/\.$// if($fqdn);
- return (defined $domain_name && length($domain_name) >= 5 && $domain_name =~ /^(?:[a-z0-9\-]{1,63}[.])+([a-z0-9]{2,10})$/);
+ my $domain_name = shift;
+ my $fqdn = shift;
+ $domain_name =~ s/\.$// if($fqdn);
+ return (defined $domain_name and length($domain_name) >= 5 and $domain_name =~ /^(?:[a-z0-9\-]{1,63}[.])+([a-z0-9]{2,10})$/);
}
-sub check_ip($) {
- my $ip = shift;
- return (defined $ip && $ip =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/);
-}
+=pod
-sub check_ipv6($) {
- my $ip = shift;
- return (defined $ip && $ip =~ /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/);
-}
+=head2 check_ip
-sub rotate_log
-{
- use File::Basename;
+die "IPv4 is invalid" unless Vhffs::Functions::check_ip( $name );
- my $path = shift;
- my $rotation = shift;
- my $compress = shift;
- my $dir = dirname ( $path );
- my $file = basename ( $path );
+Checks for IPv4 validity.
- return if ( ! -f $path );
+=cut
+sub check_ip($) {
+ my $ip = shift;
+ return (defined $ip and $ip =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/);
+}
- # remove files out of the rotation
- opendir ( DIR , $dir );
- my @files = readdir( DIR );
- foreach ( @files )
- {
- next if( $file ne substr($_, 0, length( $file ) ) );
- my $suffix = substr($_, length( $file ) );
- $suffix =~ s/^.//;
- $suffix =~ s/.gz$//;
- next if( ! ( $suffix =~ /\d+/ ) );
- unlink $dir."/".$_ if( $suffix >= $rotation-1 );
- }
+=pod
- # rotate logs
- my $i;
- for ( $i = $rotation-2 ; $i >= 0 ; $i-- ) {
- my $j = $i +1;
+=head2 check_ipv6
- # found a file which is not compressed
- if ( -f $dir."/".$file.".".$i ) {
+die "IPv6 is invalid" unless Vhffs::Functions::check_ipv6( $name );
- # rotate it
- rename $dir."/".$file.".".$i , $dir."/".$file.".".$j ;
-
- # compress it if compression is enabled
- if ( $compress ) {
- my $cmd = "gzip ".$dir."/".$file.".".$j;
- system ( $cmd );
- }
- }
- # found a file which is already compressed
- elsif ( -f $dir."/".$file.".".$i.".gz" ) {
+Checks for IPv6 validity.
- # rotate it
- rename $dir."/".$file.".".$i.".gz" , $dir."/".$file.".".$j.".gz" ;
-
- # uncompress it if compression is disabled
- if ( ! $compress ) {
- my $cmd = "gzip -d ".$dir."/".$file.".".$j.".gz";
- system ( $cmd );
- }
- }
- }
-
- # last rotate, log -> log.0
- rename $dir."/".$file , $dir."/".$file.".0" ;
-
- # create an empty file (prevent re-using of file .0 in stats parser)
- open( EMPTYFILE , "> ".$dir."/".$file );
- print EMPTYFILE "";
- close( EMPTYFILE );
+=cut
+sub check_ipv6($) {
+ my $ip = shift;
+ return (defined $ip and $ip =~ /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/);
}
1;
Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am 2012-02-15 21:39:36 UTC (rev 2009)
@@ -7,7 +7,6 @@
Acl.pm \
Conf.pm \
Constants.pm \
- Debug.pm \
Functions.pm \
Group.pm \
Listengine.pm \
Modified: trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -54,8 +54,8 @@
}
Vhffs::Functions::create_dir( $dir );
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $bazaar->get_owner_uid , $bazaar->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $bazaar->get_owner_uid , $bazaar->get_owner_gid );
$bazaar->add_history('Ok, robots find the empty directory and will create bazaar repository');
system('cd '.$dir.' && bzr init > /dev/null');
@@ -67,8 +67,8 @@
return -1;
}
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $bazaar->get_owner_uid , $bazaar->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $bazaar->get_owner_uid , $bazaar->get_owner_gid );
$bazaar->add_history('The Robots created the bazaar repository');
$bazaar->set_status( Vhffs::Constants::ACTIVATED );
Modified: trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -54,8 +54,8 @@
}
Vhffs::Functions::create_dir( $dir );
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $cvs->get_owner_uid , $cvs->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $cvs->get_owner_uid , $cvs->get_owner_gid );
$cvs->add_history('Ok, robots find the empty directory and will create cvs repository');
system('cvs -d '.$dir.' init');
@@ -67,8 +67,8 @@
return -1;
}
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $cvs->get_owner_uid , $cvs->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $cvs->get_owner_uid , $cvs->get_owner_gid );
$cvs->add_history('The Robots created the cvs repository');
$cvs->set_status( Vhffs::Constants::ACTIVATED );
Modified: trunk/vhffs-api/src/Vhffs/Robots/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Git.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Git.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -55,8 +55,8 @@
}
Vhffs::Functions::create_dir( $dir );
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $git->get_owner_uid , $git->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $git->get_owner_uid , $git->get_owner_gid );
$git->add_history('Ok, robots find the empty directory and will create git repository');
system('cd '.$dir.' && git init --shared=all --bare > /dev/null');
@@ -73,12 +73,12 @@
print DESCRIPTION $git->get_reponame."\n";
close DESCRIPTION;
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $git->get_owner_uid , $git->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $git->get_owner_uid , $git->get_owner_gid );
# './hooks' directory must be owned by root to prevent abuse of servers
- Vhffs::Functions::chmod_recur( $dir.'/hooks' , 0644 , 0755 );
- Vhffs::Functions::change_owner_recur( $dir.'/hooks' , 0 , 0 );
+ Vhffs::Robots::chmod_recur( $dir.'/hooks' , 0644 , 0755 );
+ Vhffs::Robots::chown_recur( $dir.'/hooks' , 0 , 0 );
$git->add_history('The Robots created the git repository');
$git->set_status( Vhffs::Constants::ACTIVATED );
Modified: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -54,8 +54,8 @@
}
Vhffs::Functions::create_dir( $dir );
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $mercurial->get_owner_uid , $mercurial->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $mercurial->get_owner_uid , $mercurial->get_owner_gid );
$mercurial->add_history('Ok, robots find the empty directory and will create mercurial repository');
system('cd '.$dir.' && hg init > /dev/null');
@@ -67,8 +67,8 @@
return -1;
}
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $mercurial->get_owner_uid , $mercurial->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $mercurial->get_owner_uid , $mercurial->get_owner_gid );
change_conf( $mercurial );
Modified: trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Repository.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Repository.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -76,7 +76,7 @@
# remove the link in group directory
my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_owner_gid );
- Vhffs::Robots::unlink_from_group( $group, $repo->get_name.'-repository', $vhffs );
+ Vhffs::Robots::unlink_from_group( $group, $repo->get_name.'-repository' );
$repo->delete;
}
@@ -104,8 +104,7 @@
my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_owner_gid );
- if(Vhffs::Robots::link_to_group( $repodir, $group, $repo->get_name.'-repository', $vhffs ) < 0)
- {
+ if(Vhffs::Robots::link_to_group( $group, $repo->get_name.'-repository', $repodir ) < 0) {
$repo->add_history( "Can't link the download repository to the specified group");
return -3;
}
Modified: trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Svn.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Svn.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -130,8 +130,8 @@
}
Vhffs::Functions::create_dir( $dir );
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $svn->get_owner_uid , $svn->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $svn->get_owner_uid , $svn->get_owner_gid );
$svn->add_history('Ok, robots find the empty directory and will create svn repository');
system('svnadmin create --fs-type fsfs '.$dir);
@@ -143,12 +143,12 @@
return -1;
}
- Vhffs::Functions::chmod_recur( $dir , 0664 , 02775 );
- Vhffs::Functions::change_owner_recur( $dir , $svn->get_owner_uid , $svn->get_owner_gid );
+ Vhffs::Robots::chmod_recur( $dir , 0664 , 02775 );
+ Vhffs::Robots::chown_recur( $dir , $svn->get_owner_uid , $svn->get_owner_gid );
# './hooks' directory must be owned by root to prevent abuse of servers
- Vhffs::Functions::chmod_recur( $dir.'/hooks' , 0644 , 0755 );
- Vhffs::Functions::change_owner_recur( $dir.'/hooks' , 0 , 0 );
+ Vhffs::Robots::chmod_recur( $dir.'/hooks' , 0644 , 0755 );
+ Vhffs::Robots::chown_recur( $dir.'/hooks' , 0 , 0 );
change_conf( $svn );
Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -66,12 +66,10 @@
chmod( 02775 , $webdir . "/tmp" );
my $group = Vhffs::Group::get_by_gid( $main , $web->get_owner_gid );
- if(Vhffs::Robots::link_to_group( $webdir,$group,$web->get_servername.'-web',$main) < 0)
- {
+ if(Vhffs::Robots::link_to_group( $group, $web->get_servername.'-web', $webdir ) < 0) {
$web->add_history( "Can't link the webdirectory to the specified group");
}
- else
- {
+ else {
$web->add_history( "Ok, robots finished to create webdir. Webdir is now linked to the group directory");
}
$web->set_status( Vhffs::Constants::ACTIVATED );
@@ -94,12 +92,10 @@
$web->add_history( "Ok, the robot will delete this object. Web directory will be removed");
my $webdir = $web->get_dir;
my $group = $web->get_group;
- if(Vhffs::Robots::unlink_from_group( $group,$web->get_servername.'-web',$main) < 0)
- {
+ if(Vhffs::Robots::unlink_from_group( $group, $web->get_servername.'-web' ) < 0) {
$web->add_history( "Can't unlink the webdirectory from the specified group");
}
- else
- {
+ else {
$web->add_history( "Webdir is now unlinked from the group directory");
}
Modified: trunk/vhffs-api/src/Vhffs/Robots.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Robots.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -40,104 +40,163 @@
my @EXPORT = qw(vhffs_log lock unlock);
use Cwd;
+use File::Basename;
+use Vhffs::Main;
use Vhffs::Functions;
-use Vhffs::Main;
-use LockFile::Simple qw(lock trylock unlock);
-use constant
-{
- LOCKFILE => "/var/lock/vhffs",
- LOGFILE => "/var/log/vhffs"
-};
+use LockFile::Simple;
+=pod
-sub lock
-{
+=head1 NAME
+
+Vhffs::Robots - common interface for VHFFS Robots
+
+=head1 SYNOPSIS
+
+ use Vhffs::Robots;
+
+ Vhffs::Robots::lock();
+
+ Vhffs::Robots::unlock();
+
+ Vhffs::Robots::vhffs_log( "My log message" );
+
+ Vhffs::Robots::link_to_group( "/path/to" , Vhffs::Group , "linkname" , Vhffs::Main);
+
+ Vhffs::Robots::unlink_from_group( Vhffs::Group , "linkname" , Vhffs::Main);
+
+=head1 DESCRIPTION
+
+This class contains static methods commonly used by VHFFS robots.
+
+=head1 METHODS
+
+=cut
+
+=pod
+
+=head2 lock
+
+Vhffs::Robots::lock( $vhffs, 'lockname' );
+
+Creates a lockfile. Other process that call lock method are stalled until unlock is deleted.
+
+=cut
+sub lock {
my $vhffs = shift;
my $name = shift;
- return 1 unless defined $vhffs;
+ return 1 unless defined $vhffs and defined $name;
my $robotconf = $vhffs->get_config->get_robots;
- return 0 if( $robotconf->{'use_lock'} ne 'yes' );
+ return 0 unless $robotconf->{'use_lock'} and defined $robotconf->{'lockfile'};
- my $lockfile = LOCKFILE.'.'.$name;
- $lockfile = $robotconf->{'lockfile'}.'.'.$name if( $robotconf->{'lockfile'} );
-
- LockFile::Simple::lock( $lockfile ) or exit( 1 );
+ LockFile::Simple::lock( $robotconf->{'lockfile'}.'.'.$name ) or exit( 1 );
return 0;
}
+=pod
-sub unlock
-{
+=head2 unlock
+
+Vhffs::Robots::unlock( $vhffs, 'lockname' );
+
+Delete a lock file. Locked processes can continue.
+
+=cut
+sub unlock {
my $vhffs = shift;
my $name = shift;
- return 1 unless defined $vhffs;
+ return 1 unless defined $vhffs and defined $name;
my $robotconf = $vhffs->get_config->get_robots;
- return 0 if( $robotconf->{'use_lock'} ne 'yes' );
+ return 0 unless $robotconf->{'use_lock'} and defined $robotconf->{'lockfile'};
- my $lockfile = LOCKFILE.'.'.$name;
- $lockfile = $robotconf->{'lockfile'}.'.'.$name if( $robotconf->{'lockfile'} );
-
- LockFile::Simple::unlock( $lockfile );
+ LockFile::Simple::unlock( $robotconf->{'lockfile'}.'.'.$name );
return 0;
}
-sub vhffs_log
-{
- my $sent = shift;
+=pod
+
+=head2 vhffs_log
+
+Vhffs::Robots::vhffs_log( $vhffs, 'Message' );
+
+Add a line to the VHFFS logfile.
+
+=cut
+sub vhffs_log {
+ my $message = shift;
my $vhffs = shift;
- my $logfile;
- return 1 unless defined $vhffs;
+ return 1 unless defined $vhffs and defined $message;
my $robotconf = $vhffs->get_config->get_robots;
- return 0 if( $robotconf->{'use_logging'} ne 'yes' );
+ return 0 unless $robotconf->{'use_logging'} and defined $robotconf->{'logfile'};
my ($seconds,$minutes,$hours,$day,$month,$year) = localtime(time);
- my $timestamp = sprintf ('[ %.4u/%.2u/%.2u %.2u:%.2u:%.2u ]',$year+1900,$month + 1,$day,$hours,$minutes,$seconds);
+ my $timestamp = sprintf ('[ %.4u/%.2u/%.2u %.2u:%.2u:%.2u ]', $year+1900, $month+1, $day, $hours, $minutes, $seconds);
- $logfile = $robotconf->{'logfile'};
- $logfile = LOGFILE unless defined $logfile;
- open( FILE , ">>$logfile" ) or return -1;
- print FILE $timestamp." - ".$sent."\n";
- close FILE ;
+ open( my $logfile, '>>', $robotconf->{'logfile'} ) or return -1;
+ print $logfile $timestamp.' - '.$message."\n";
+ close $logfile;
return 0;
}
-sub link_to_group
-{
- my $dir = shift;
+=pod
+
+=head2 link_to_group
+
+Vhffs::Robots::link_to_group( $group, $linkname, $dir );
+
+Create a symbolic link in C<$group> home directory named $linkname which contains string $dir.
+
+=cut
+sub link_to_group {
my $group = shift;
my $linkname = shift;
- my $main = shift;
+ my $dir = shift;
+ return -1 unless defined $group;
- return -1 unless( defined $group );
+ return 1 if $group->get_main->get_config->use_vhffsfs;
- return 1 if( $main->get_config->use_vhffsfs );
-
- return -1 if ( symlink( $dir , $group->get_dir.'/'.$linkname ) == 0 );
+ return -1 unless symlink( $dir , $group->get_dir.'/'.$linkname );
return 1;
}
+=pod
-sub unlink_from_group
-{
+=head2 unlink_from_group
+
+Vhffs::Robots::unlink_from_group( $group, $linkname );
+
+Delete a symbolic link in C<$group> home directory named $linkname.
+
+=cut
+sub unlink_from_group {
my $group = shift;
my $linkname = shift;
- my $main = shift;
+ return -1 unless defined $group;
- return -1 unless( defined $group );
+ return 1 if $group->get_main->get_config->use_vhffsfs;
- return 1 if( $main->get_config->use_vhffsfs );
-
- return -1 if ( unlink( $group->get_dir.'/'.$linkname ) == 0 );
+ return -1 unless unlink( $group->get_dir.'/'.$linkname );
return 1;
}
+=pod
+
+=head2 archive_targz
+
+Vhffs::Robots::archive_targz( $object, $dir, \@namepart );
+
+Create a tar.gz archive of C<$object> directory $dir.
+
+Additionnal path elements (separed by _) can be added through \@namepart.
+
+=cut
sub archive_targz {
my $object = shift;
my $dir = shift;
@@ -156,7 +215,7 @@
$label =~ s/\//_/g; # workaround for SCM which use / in object name
my $tarfile = $robotconf->{'archive_deleted_path'}.'/'.time().'_'.$object->get_group->get_groupname.'_'.Vhffs::Functions::type_string_fs_from_type_id( $object->get_type ).'_'.$label.( defined $namepart ? '_'.join('_', @$namepart) : '' ).'.tar.gz';
my $childpid = open( my $output, '-|', 'tar', 'czf', $tarfile, '.' );
- if ($childpid) {
+ if($childpid) {
# read process output then discard
while(<$output>) {}
@@ -176,7 +235,15 @@
return not defined $ret and -f $tarfile ? 1 : undef;
}
-# Return an opened tmpfile (with its path)
+=pod
+
+=head2 tmpfile
+
+my $tmpfile = Vhffs::Robots::tmpfile( $vhffs );
+
+Returns an opened temporary file and its associated path.
+
+=cut
sub tmpfile {
my $vhffs = shift;
my $robotconf = $vhffs->get_config->get_robots;
@@ -194,46 +261,158 @@
return ( $file, $path );
}
-1;
+=pod
-__END__
+head2 rotate_log
-=head1 NAME
+Vhffs::Robots::rotate_log( $logfile, $rotation, $compress );
-Vhffs::Robots - common interface for VHFFS Robots
+Rotate $logfile, $rotation rotation maximum, $compress(ed) or not,
+then create a new empty $logfile.
-=head1 SYNOPSIS
+=cut
+sub rotate_log {
+ my $logfile = shift;
+ my $rotation = shift;
+ my $compress = shift;
+ return unless -f $logfile;
- use Vhffs::Robots;
+ my ( $file, $dirname ) = File::Basename::fileparse( $logfile );
- Vhffs::Robots::link_to_group( "/path/to" , Vhffs::Group , "linkname" , Vhffs::Main);
+ # remove files out of the rotation
+ opendir( my $dh, $dirname );
+ return unless defined $dh;
- Vhffs::Robots::unlink_from_group( Vhffs::Group , "linkname" , Vhffs::Main);
+ while( defined(my $item = readdir($dh)) ) {
+ my ( $rotatenumber ) = ( $item =~ /^$file\.(\d+)(?:\..*)?$/ );
+ unlink $dirname.'/'.$item if defined $rotatenumber and $rotatenumber >= $rotation-1;
+ }
+ closedir( $dh );
- Vhffs::Robots::lock();
+ # rotate logs
+ for( my $i = $rotation-2 ; $i >= 0 ; $i-- ) {
- Vhffs::Robots::unlock();
+ # found a file which is not compressed
+ if ( -f $logfile.'.'.$i ) {
- Vhffs::Robots::vhffs_log( "My log message" );
+ # rotate it
+ rename $logfile.'.'.$i, $logfile.'.'.($i+1);
+
+ # compress it if compression is enabled
+ if ( $compress ) {
-=head1 DESCRIPTION
+ my $childpid = open( my $output, '-|', 'gzip', $logfile.'.'.($i+1) );
+ if($childpid) {
+ # read process output then discard
+ while(<$output>) {}
-This class contains static methods commonly used by VHFFS robots.
+ # wait for the child to finish
+ waitpid( $childpid, 0 );
-=head1
+ # we don't care whether gzip succedded
+ }
+ }
+ }
-lock() : Creates a lockfile. Other process that call lock method are stalled until unlock is created.
+ # found a file which is already compressed
+ elsif ( -f $logfile.'.'.$i.'.gz' ) {
-unlock() : Delete the lock file. Other process, whose are stalled due to the lock file can continue the execution
+ # rotate it
+ rename $logfile.'.'.$i.'.gz', $logfile.'.'.($i+1).'.gz';
-link_to_group() : create a symlink from a directory to a group directory.
+ # decompress it if compression is disabled
+ unless( $compress ) {
+ my $childpid = open( my $output, '-|', 'gzip', '-d', $logfile.'.'.($i+1).'.gz' );
+ if($childpid) {
+ # read process output then discard
+ while(<$output>) {}
-unlink_from_group() : unlink a symlink in a group directory
+ # wait for the child to finish
+ waitpid( $childpid, 0 );
-=head1 AUTHOR
+ # we don't care whether gzip succedded
+ }
+ }
+ }
+ }
- Julien Delange <julien at gunnm dot org>
+ # last rotate, log -> log.0
+ rename $logfile, $logfile.'.0';
-=head1 COPYRIGHT
+ # create an empty file
+ open( my $emptyfile, '>', $logfile );
+ close( $emptyfile ) if defined $emptyfile;
+}
- (c) Julien Delange
+=pod
+
+=head2 chmod_recur
+
+ Vhffs::Functions::chmod_recur($dir, $fmod, $dmod);
+
+Changes permissions on files and directories recursively.
+C<$fmod> and C<$dmod> are the mod to apply to files and
+directory, respectively. See the documentation of the
+original C<chmod> function for more information.
+
+=cut
+sub chmod_recur {
+ my ($dir, $fmod, $dmod) = @_;
+
+ my @files = ( $dir );
+ while( defined(my $file = shift @files) ) {
+ if( -d $file ) {
+ chmod( $dmod, $file );
+ opendir( my $dh, $file );
+ if( defined $dh ) {
+ while( defined(my $item = readdir($dh)) ) {
+ next if( $item eq '' or $item eq '..' or $item eq '.' );
+ push @files, $file.'/'.$item;
+ }
+ closedir( $dh );
+ }
+ }
+ else {
+ chmod( $fmod, $file );
+ }
+ }
+
+ return 1;
+}
+
+=pod
+
+=head2 chmod_recur
+
+ Vhffs::Functions::chown_recur($dir, $uid, $gid);
+
+Changes the owner and group on files and directories recursively.
+C<$uid> and C<$gid> are the uid and gid to apply to files and
+directory, respectively. See the documentation of the
+original C<chown> function for more information.
+
+=cut
+sub chown_recur {
+ my ($dir, $uid, $gid) = @_;
+
+ my @files = ($dir);
+ while( defined(my $file = shift @files) ) {
+ chown( $uid, $gid, $file );
+ if( -d $file ) {
+ opendir( my $dh, $file );
+ if( defined $dh ) {
+ while( defined(my $item = readdir($dh)) ) {
+ next if( $item eq '' or $item eq '..' or $item eq '.' );
+ push @files, $file.'/'.$item;
+ }
+ closedir( $dh );
+ }
+ }
+ }
+
+ return 1;
+}
+
+1;
+
+__END__
Modified: trunk/vhffs-api/src/Vhffs/Services/MailUser.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailUser.pm 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-api/src/Vhffs/Services/MailUser.pm 2012-02-15 21:39:36 UTC (rev 2009)
@@ -62,7 +62,7 @@
my $mail_service = Vhffs::Services::Mail::get_by_mxdomain( $vhffs, $config->{domain} );
return undef unless defined $mail_service;
- return undef unless( $config->{groupneeded} ne 'yes' || $user->have_activegroups > 0 || $mail_service->exists( $user->get_username ) );
+ return undef unless( not $config->{groupneeded} || $user->have_activegroups > 0 || $mail_service->exists( $user->get_username ) );
my $this = {};
$this->{main} = $vhffs;
Modified: trunk/vhffs-robots/src/mail_createboxes.pl
===================================================================
--- trunk/vhffs-robots/src/mail_createboxes.pl 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-robots/src/mail_createboxes.pl 2012-02-15 21:39:36 UTC (rev 2009)
@@ -60,8 +60,8 @@
Vhffs::Functions::create_dir( $dir.'/Maildir/cur' );
Vhffs::Functions::create_dir( $dir.'/Maildir/new' );
Vhffs::Functions::create_dir( $dir.'/Maildir/tmp' );
- Vhffs::Functions::chmod_recur( $dir , 0600 , 0700 );
- Vhffs::Functions::change_owner_recur( $dir , $mailconf->{'boxes_uid'} , $mailconf->{'boxes_gid'} );
+ Vhffs::Robots::chmod_recur( $dir , 0600 , 0700 );
+ Vhffs::Robots::chown_recur( $dir , $mailconf->{'boxes_uid'} , $mailconf->{'boxes_gid'} );
$mail->set_box_status( $b->{local_part} , Vhffs::Constants::ACTIVATED );
} else {
Modified: trunk/vhffs-robots/src/repository_stats.pl
===================================================================
--- trunk/vhffs-robots/src/repository_stats.pl 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-robots/src/repository_stats.pl 2012-02-15 21:39:36 UTC (rev 2009)
@@ -102,7 +102,7 @@
foreach ( @files ) {
if( /.*\.log$/ ) {
- Vhffs::Functions::rotate_log( $log_incoming_root."/".$downloadserver."/".$_ , $log_incoming_rotations , $log_incoming_compress );
+ Vhffs::Robots::rotate_log( $log_incoming_root."/".$downloadserver."/".$_ , $log_incoming_rotations , $log_incoming_compress );
}
}
@@ -227,7 +227,7 @@
system( $cmd );
# Rotate logs for this website
- Vhffs::Functions::rotate_log( $logpath , $log_parsed_rotation , $log_parsed_compress );
+ Vhffs::Robots::rotate_log( $logpath , $log_parsed_rotation , $log_parsed_compress );
}
Vhffs::Robots::unlock( $vhffs , "repositorystats" );
Modified: trunk/vhffs-robots/src/web_stats.pl
===================================================================
--- trunk/vhffs-robots/src/web_stats.pl 2012-02-12 20:25:28 UTC (rev 2008)
+++ trunk/vhffs-robots/src/web_stats.pl 2012-02-15 21:39:36 UTC (rev 2009)
@@ -103,7 +103,7 @@
foreach ( @files ) {
if( /.*\.log$/ ) {
- Vhffs::Functions::rotate_log( $log_incoming_root."/".$webserver."/".$_ , $log_incoming_rotations , $log_incoming_compress );
+ Vhffs::Robots::rotate_log( $log_incoming_root."/".$webserver."/".$_ , $log_incoming_rotations , $log_incoming_compress );
}
}
@@ -217,7 +217,7 @@
system( $cmd );
# Rotate logs for this website
- Vhffs::Functions::rotate_log( $logpath , $log_parsed_rotation , $log_parsed_compress );
+ Vhffs::Robots::rotate_log( $logpath , $log_parsed_rotation , $log_parsed_compress );
}
Vhffs::Robots::unlock( $vhffs , "webstats" );