Skip to content

Commit

Permalink
[backend] we just need to create/chown /srv/obs
Browse files Browse the repository at this point in the history
All other dirs are created by us and thus have the correct owner.
With the exception of the repoid, which we now also create correctly.
  • Loading branch information
mlschroe committed May 2, 2016
1 parent 88d0993 commit ff28d03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/backend/bs_repserver
Expand Up @@ -4405,9 +4405,6 @@ if ($BSConfig::workerreposerver) {
$conf->{'port2'} = $wport if $wport != $port;
}

# Ensure that all directories we need at runtime are existant and owned by $bsuser:$bsgroup
# before root privileges are dropped
for my $dir_to_check ($BSConfig::bsdir, $reporoot, $workersdir, $jobsdir, $eventdir, $infodir, $uploaddir, $rundir, $extrepodir, $extrepodb) {
BSUtil::mkdir_p_chown($dir_to_check, $BSConfig::bsuser, $BSConfig::bsgroup);
}
# create bsdir before root privileges are dropped
BSUtil::mkdir_p_chown($BSConfig::bsdir, $BSConfig::bsuser, $BSConfig::bsgroup);
BSStdServer::server('bs_repserver', \@ARGV, $conf, $aconf);
23 changes: 11 additions & 12 deletions src/backend/bs_srcserver
Expand Up @@ -101,7 +101,7 @@ my $uploaddir = "$srcrep/:upload";
my @binsufs = qw{rpm deb pkg.tar.gz pkg.tar.xz};
my $binsufsre = join('|', map {"\Q$_\E"} @binsufs);

my $repoid;
my $datarepoid;
my %packagequota;

# remote getrev cache
Expand Down Expand Up @@ -2968,7 +2968,7 @@ sub getprojpack {
push @res, $jinfo;
}
$frozenlinks_cache = undef;
my $ret = {'repoid' => $repoid, 'project' => \@res};
my $ret = {'repoid' => $datarepoid, 'project' => \@res};
if ($remotemap) {
delete $remotemap->{':partition'};
delete $remotemap->{':partitions'};
Expand Down Expand Up @@ -7720,8 +7720,8 @@ sub notify_plugins {

sub hello {
my ($cgi) = @_;
return "<hello name=\"Source Repository Ajax Server\" repoid=\"$repoid\" />\n" if $BSStdServer::isajax;
return "<hello name=\"Source Repository Server\" repoid=\"$repoid\" />\n";
return "<hello name=\"Source Repository Ajax Server\" repoid=\"$datarepoid\" />\n" if $BSStdServer::isajax;
return "<hello name=\"Source Repository Server\" repoid=\"$datarepoid\" />\n";
}

####################################################################
Expand Down Expand Up @@ -7920,17 +7920,16 @@ if ($BSConfig::workersrcserver) {
$conf->{'port2'} = $wport if $wport != $port;
}

# Ensure that all directories we need at runtime are existant and owned by $bsuser:$bsgroup
# before root privileges are dropped
for my $dir_to_check ($BSConfig::bsdir, $projectsdir, $eventdir, $srcrep, $treesdir, $requestsdir, $rundir, $diffcache, "$BSConfig::bsdir/db", $remotecache, $notificationpayloaddir) {
BSUtil::mkdir_p_chown($dir_to_check, $BSConfig::bsuser, $BSConfig::bsgroup);
}
# create bsdir before root privileges are dropped
BSUtil::mkdir_p_chown($BSConfig::bsdir, $BSConfig::bsuser, $BSConfig::bsgroup);

# set a repoid for identification of this data repository
if (! -e "$projectsdir/_repoid") {
my $randomid = int(rand(1000000000));
writestr("$projectsdir/._repoid", "$projectsdir/_repoid", sprintf("%09d", $randomid));
BSUtil::mkdir_p_chown($projectsdir, $BSConfig::bsuser, $BSConfig::bsgroup);
$datarepoid = sprintf("%09d", int(rand(1000000000)));
writestr("$projectsdir/._repoid$$", "$projectsdir/_repoid", $datarepoid);
}
$repoid = readstr("$projectsdir/_repoid");
$datarepoid = readstr("$projectsdir/_repoid");

BSStdServer::server('bs_srcserver', \@ARGV, $conf, $aconf);

0 comments on commit ff28d03

Please sign in to comment.