Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
7a9a9a8f
Commit
7a9a9a8f
authored
Nov 26, 2011
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 368250: collectstats.pl creates files with wrong ownership
r/a=mkanat
parent
c9aaffd4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
20 deletions
+41
-20
Filesystem.pm
Bugzilla/Install/Filesystem.pm
+27
-0
collectstats.pl
collectstats.pl
+14
-20
No files found.
Bugzilla/Install/Filesystem.pm
View file @
7a9a9a8f
...
@@ -46,6 +46,7 @@ our @EXPORT = qw(
...
@@ -46,6 +46,7 @@ our @EXPORT = qw(
update_filesystem
update_filesystem
create_htaccess
create_htaccess
fix_all_file_permissions
fix_all_file_permissions
fix_dir_permissions
fix_file_permissions
fix_file_permissions
)
;
)
;
...
@@ -645,6 +646,26 @@ sub _update_old_charts {
...
@@ -645,6 +646,26 @@ sub _update_old_charts {
}
}
}
}
sub
fix_dir_permissions
{
my
(
$dir
)
=
@_
;
return
if
ON_WINDOWS
;
# Note that _get_owner_and_group is always silent here.
my
(
$owner_id
,
$group_id
)
=
_get_owner_and_group
();
my
$perms
;
my
$fs
=
FILESYSTEM
();
if
(
$perms
=
$fs
->
{
recurse_dirs
}
->
{
$dir
})
{
_fix_perms_recursively
(
$dir
,
$owner_id
,
$group_id
,
$perms
);
}
elsif
(
$perms
=
$fs
->
{
all_dirs
}
->
{
$dir
})
{
_fix_perms
(
$dir
,
$owner_id
,
$group_id
,
$perms
);
}
else
{
# Do nothing. We know nothing about this directory.
warn
"Unknown directory $dir"
;
}
}
sub
fix_file_permissions
{
sub
fix_file_permissions
{
my
(
$file
)
=
@_
;
my
(
$file
)
=
@_
;
return
if
ON_WINDOWS
;
return
if
ON_WINDOWS
;
...
@@ -843,6 +864,12 @@ Params: C<$output> - C<true> if you want this function to print
...
@@ -843,6 +864,12 @@ Params: C<$output> - C<true> if you want this function to print
Returns: nothing
Returns: nothing
=item C<fix_dir_permissions>
Given the name of a directory, its permissions will be fixed according to
how they are supposed to be set in Bugzilla's current configuration.
If it fails to set the permissions, a warning will be printed to STDERR.
=item C<fix_file_permissions>
=item C<fix_file_permissions>
Given the name of a file, its permissions will be fixed according to
Given the name of a file, its permissions will be fixed according to
...
...
collectstats.pl
View file @
7a9a9a8f
...
@@ -41,6 +41,7 @@ use Bugzilla::Search;
...
@@ -41,6 +41,7 @@ use Bugzilla::Search;
use
Bugzilla::
User
;
use
Bugzilla::
User
;
use
Bugzilla::
Product
;
use
Bugzilla::
Product
;
use
Bugzilla::
Field
;
use
Bugzilla::
Field
;
use
Bugzilla::Install::
Filesystem
qw(fix_dir_permissions)
;
my
%
switch
;
my
%
switch
;
GetOptions
(
\%
switch
,
'help|h'
,
'regenerate'
);
GetOptions
(
\%
switch
,
'help|h'
,
'regenerate'
);
...
@@ -139,32 +140,28 @@ my $tstart = time;
...
@@ -139,32 +140,28 @@ my $tstart = time;
my
@myproducts
=
Bugzilla::
Product
->
get_all
;
my
@myproducts
=
Bugzilla::
Product
->
get_all
;
unshift
(
@myproducts
,
"-All-"
);
unshift
(
@myproducts
,
"-All-"
);
foreach
(
@myproducts
)
{
my
$dir
=
"$datadir/mining"
;
my
$dir
=
"$datadir/mining"
;
if
(
!-
d
$dir
)
{
mkdir
$dir
or
die
"mkdir $dir failed: $!"
;
&
check_data_dir
(
$dir
);
fix_dir_permissions
(
$dir
);
}
foreach
(
@myproducts
)
{
if
(
$switch
{
'regenerate'
})
{
if
(
$switch
{
'regenerate'
})
{
regenerate_stats
(
$dir
,
$_
,
\%
bug_resolution
,
\%
bug_status
,
\%
removed
);
regenerate_stats
(
$dir
,
$_
,
\%
bug_resolution
,
\%
bug_status
,
\%
removed
);
}
else
{
}
else
{
&
collect_stats
(
$dir
,
$_
);
&
collect_stats
(
$dir
,
$_
);
}
}
}
}
# Fix permissions for all files in mining/.
fix_dir_permissions
(
$dir
);
my
$tend
=
time
;
my
$tend
=
time
;
# Uncomment the following line for performance testing.
# Uncomment the following line for performance testing.
#
print "Total time taken " . delta_time($tstart, $tend) . "\n"
;
#
say "Total time taken " . delta_time($tstart, $tend)
;
CollectSeriesData
();
CollectSeriesData
();
sub
check_data_dir
{
my
$dir
=
shift
;
if
(
!
-
d
$dir
)
{
mkdir
$dir
,
0755
;
chmod
0755
,
$dir
;
}
}
sub
collect_stats
{
sub
collect_stats
{
my
$dir
=
shift
;
my
$dir
=
shift
;
my
$product
=
shift
;
my
$product
=
shift
;
...
@@ -250,7 +247,6 @@ FIN
...
@@ -250,7 +247,6 @@ FIN
}
}
print
DATA
(
join
'|'
,
@row
)
.
"\n"
;
print
DATA
(
join
'|'
,
@row
)
.
"\n"
;
close
DATA
;
close
DATA
;
chmod
0644
,
$file
;
}
}
sub
get_old_data
{
sub
get_old_data
{
...
@@ -406,14 +402,12 @@ FIN
...
@@ -406,14 +402,12 @@ FIN
foreach
(
@resolutions
)
{
print
DATA
"|$bugcount{$_}"
;
}
foreach
(
@resolutions
)
{
print
DATA
"|$bugcount{$_}"
;
}
print
DATA
"\n"
;
print
DATA
"\n"
;
}
}
# Finish up output feedback for this product.
# Finish up output feedback for this product.
my
$tend
=
time
;
my
$tend
=
time
;
print
"\rRegenerating $product \[100.0\%] - "
.
say
"\rRegenerating $product \[100.0\%] - "
.
delta_time
(
$tstart
,
$tend
);
delta_time
(
$tstart
,
$tend
)
.
"\n"
;
close
DATA
;
close
DATA
;
chmod
0640
,
$file
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment