Skip to content

Commit

Permalink
fix: screenshot image anonymous (#1022)
Browse files Browse the repository at this point in the history
- on list_base_anonymous add bind similar to list_machine_user so list_base_ng.html.ep parse don't fail
- add check $USER is not defined on '/img/screenshots/:file'

fix #1016
  • Loading branch information
serk authored and frankiejol committed Mar 14, 2019
1 parent f9d8c2b commit be4ff40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions lib/Ravada/Front.pm
Original file line number Diff line number Diff line change
Expand Up @@ -885,13 +885,29 @@ sub list_bases_anonymous {

my $net = Ravada::Network->new(address => $ip);

my $sth = $CONNECTOR->dbh->prepare("SELECT id, name, id_base, is_public FROM domains where is_base=1 AND is_public=1");
my $sth = $CONNECTOR->dbh->prepare(
"SELECT id, name, id_base, is_public, file_screenshot "
."FROM domains where is_base=1 "
."AND is_public=1");
$sth->execute();

my @bases = ();
while ( my $row = $sth->fetchrow_hashref) {
next if !$net->allowed_anonymous($row->{id});
push @bases, ($row);
my ($id, $name, $id_base, $is_public, $screenshot);
$sth->bind_columns(\($id, $name, $id_base, $is_public, $screenshot));

my @bases;
while ( $sth->fetch) {
next if !$net->allowed_anonymous($id);
my %base = ( id => $id, name => $name
, is_public => ($is_public or 0)
, screenshot => ($screenshot or '')
, is_active => 0
, id_clone => undef
, name_clone => undef
, is_locked => undef
, can_hibernate => 0
);
$base{screenshot} =~ s{^/var/www}{};
lock_hash(%base);
push @bases, (\%base);
}
$sth->finish;

Expand Down
2 changes: 1 addition & 1 deletion rvd_front.pl
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ sub user_settings {
warn"ERROR : no id domain in $path";
return $c->reply->not_found;
}
if (!$USER->is_admin) {
if ($USER && !$USER->is_admin) {
my $domain = $RAVADA->search_domain_by_id($id_domain);
return $c->reply->not_found if !$domain;
unless ($domain->is_base && $domain->is_public) {
Expand Down

0 comments on commit be4ff40

Please sign in to comment.