Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 92800129

Von Moritz Bunkus vor fast 13 Jahren hinzugefügt

  • ID 9280012969a290c0e31d1d8a109e68c09e3019f3
  • Vorgänger 6285b052
  • Nachfolger 9f39adff

Anlegen der Auth-DB fixen

Auth.pms Session-Management kam nicht damit zurecht, wenn die Auth-DB
bzw. das "auth"-Schema darin noch nicht existiert haben. Das passiert
z.B., wenn die Auth-DB gerade über den Admin-Bereich angelegt werden
soll.

Unterschiede anzeigen:

SL/Auth.pm
525 525

  
526 526
  $form   = $main::form;
527 527

  
528
  $dbh    = $self->dbconnect();
528
  # Don't fail if the auth DB doesn't yet.
529
  if (!( $dbh = $self->dbconnect(1) )) {
530
    $::lxdebug->leave_sub;
531
    return SESSION_NONE;
532
  }
533

  
534
  # Don't fail if the "auth" schema doesn't exist yet, e.g. if the
535
  # admin is creating the session tables at the moment.
529 536
  $query  = qq|SELECT *, (mtime < (now() - '$self->{session_timeout}m'::interval)) AS is_expired FROM auth.session WHERE id = ?|;
530 537

  
531
  $cookie = selectfirst_hashref_query($form, $dbh, $query, $session_id);
538
  if (!($sth = $dbh->prepare($query)) || !$sth->execute($session_id)) {
539
    $sth->finish if $sth;
540
    $::lxdebug->leave_sub;
541
    return SESSION_NONE;
542
  }
543

  
544
  $cookie = $sth->fetchrow_hashref;
545
  $sth->finish;
532 546

  
533 547
  if (!$cookie || $cookie->{is_expired} || ($cookie->{ip_address} ne $ENV{REMOTE_ADDR})) {
534 548
    $self->destroy_session();
......
703 717

  
704 718
  $dbh->begin_work unless $provided_dbh;
705 719

  
706
  do_query($::form, $dbh, qq|LOCK auth.session_content|);
720
  # If this fails then the "auth" schema might not exist yet, e.g. if
721
  # the admin is just trying to create the auth database.
722
  if (!$dbh->do(qq|LOCK auth.session_content|)) {
723
    $dbh->rollback unless $provided_dbh;
724
    $::lxdebug->leave_sub;
725
    return;
726
  }
707 727

  
708 728
  my @unfetched_keys = map     { $_->{key}        }
709 729
                       grep    { ! $_->{fetched}  }

Auch abrufbar als: Unified diff