[vhffs-dev] [1406] Fixes bug #0000255 and avoid recursion |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1406
Author: beuss
Date: 2009-05-26 09:44:35 +0200 (Tue, 26 May 2009)
Log Message:
-----------
Fixes bug #0000255 and avoid recursion
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Functions.pm
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm 2009-05-24 18:02:10 UTC (rev 1405)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm 2009-05-26 07:44:35 UTC (rev 1406)
@@ -229,27 +229,25 @@
my $dir = shift;
my $uid = shift;
my $gid = shift;
+
+ my @files = ($dir);
+ my $f;
- my $value;
- if( -f $dir )
- {
- chown( $uid , $gid , $dir );
+ while( defined($f = shift @files) ) {
+ if( -f $f ) {
+ chown( $uid, $gid, $f );
+ } elsif( -d $f ) {
+ chown( $uid, $gid, $f );
+ opendir( DIRECTORY, $f );
+ my @content = readdir( DIRECTORY );
+ closedir( DIRECTORY );
+ foreach my $item ( @content ) {
+ next if( $item eq '' or $item eq '..' or $item eq '.' );
+ push @files, $f.'/'.$item;
+ }
+ }
}
- elsif( -d $dir )
- {
- chown( $uid , $gid , $dir );
- opendir( DIRECTORY , $dir );
- my @files = readdir( DIRECTORY );
- foreach $value ( @files )
- {
- next if( $value eq "" );
- next if( $value eq ".." );
- next if( $value eq "." );
- change_owner_recur( $dir . "/" . $value , $uid , $gid);
- }
- closedir( DIRECTORY );
- }
-
+
return 1;
}