Skip to content

Commit

Permalink
support repositories that require authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
hadfl committed Mar 9, 2019
1 parent b7cc6c2 commit 3464a85
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions etc/pkgmgr.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
"dst_repo" : "<path/URL>",
"publisher" : "extra.omnios",
"release" : "r151023"
},
"security" : {
"signing" : "yes",
"restricted" : "yes",
"src_repo" : "<path/URL>",
"dst_repo" : "<path/URL>",
"publisher" : "omnios",
"release" : "r151028"
}
}
}
14 changes: 11 additions & 3 deletions lib/PkgMgr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ sub fetchPackages {

my $repoPath = $self->getRepoPath($config, $repo, $opts);

my @cmd = ($PKGREPO, qw(list -F json -s), $repoPath, @$fmri);
my @cert = $config->{REPOS}->{$repo}->{restricted} ne 'yes' ? ()
: ('--key', $config->{GENERAL}->{key_file},
'--cert', $config->{GENERAL}->{cert_file});

my @cmd = ($PKGREPO, qw(list -F json -s), $repoPath, @cert, @$fmri);
open my $cmd, '-|', @cmd or die "ERROR: executing '$PKGREPO': $!\n";

my ($release, $publisher) = $getReleasePublisher->($config, $repo);
Expand All @@ -124,7 +128,7 @@ sub fetchPackages {
grep { $_->{branch} =~ /^(?:$release\.\d+|\d+\.$release)$/
&& $extractPublisher->($_) eq $publisher
&& $getEpoch->($_->{timestamp}) > $epoch
} @{JSON::PP->new->decode(<$cmd>)}
} @{JSON::PP->new->decode(<$cmd> // '[]')}
];

if ($opts->{long}) {
Expand Down Expand Up @@ -241,6 +245,10 @@ sub publishPackages {
: ('--dkey', $config->{GENERAL}->{key_file},
'--dcert', $config->{GENERAL}->{cert_file});

push @cert, $config->{REPOS}->{$repo}->{restricted} ne 'yes' ? ()
: ('--key', $config->{GENERAL}->{key_file},
'--cert', $config->{GENERAL}->{cert_file});

# set timeout env variables
$ENV{PKG_CLIENT_CONNECT_TIMEOUT} = $config->{GENERAL}->{connect_timeout};
$ENV{PKG_CLIENT_LOWSPEED_TIMEOUT} = $config->{GENERAL}->{lowspeed_timeout};
Expand Down Expand Up @@ -328,7 +336,7 @@ __END__
=head1 COPYRIGHT
Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
=head1 LICENSE
Expand Down
7 changes: 7 additions & 0 deletions lib/PkgMgr/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ my $SCHEMA = sub {
},
},
},
restricted => {
optional => 1,
description => 'restricted repository; authentication needed (yes/no)',
example => '"restricted" : "no"',
default => 'no',
validator => $sv->elemOf(qw(yes no)),
},
},
},
},
Expand Down

0 comments on commit 3464a85

Please sign in to comment.