Skip to content

Commit

Permalink
debug: collect message on a SessionNotAvailableException case
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Oct 18, 2024
1 parent 69070bf commit b76b5f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ public static function initSession(): void {

$cryptoWrapper = Server::get(\OC\Session\CryptoWrapper::class);
$session = $cryptoWrapper->wrapSession($session);
$e = new \Exception('Stacktrace for initializing Internal/Encrypted session');
\OCP\Log\logger('core')->warning('SnaeDebug: Updating UserSession with persistent Internal/Encrypted backend', [ 'exception' => $e ]);
self::$server->setSession($session);

// if session can't be started break with http 500 error
Expand Down
8 changes: 8 additions & 0 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use OC\AppConfig;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\ServerNotAvailableException;
use OC\Session\CryptoSessionData;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\AppPathNotFoundException;
use OCP\App\Events\AppDisableEvent;
Expand Down Expand Up @@ -210,6 +211,13 @@ public function loadApps(array $types = []): bool {
foreach ($apps as $app) {
if (!$this->isAppLoaded($app) && ($types === [] || $this->isType($app, $types))) {
try {
if (in_array('session', $types, true)) {
$e = new \Exception('Stacktrace for loading session-type app');
\OCP\Log\logger('core')->warning('SnaeDebug: Loading session app ' . $app, [ 'exception' => $e ]);
} else if (method_exists($this->userSession, 'getSession') && !$this->userSession->getSession() instanceof CryptoSessionData) {
$e = new \Exception('Stacktrace for early loading of non session-type app');
\OCP\Log\logger('core')->warning('SnaeDebug: Loading app early: ' . $app, [ 'exception' => $e, 'session' => get_class($this->userSession->getSession()) ]);
}
$this->loadApp($app);
} catch (\Throwable $e) {
$this->logger->emergency('Error during app loading: ' . $e->getMessage(), [
Expand Down
9 changes: 8 additions & 1 deletion lib/private/legacy/OC_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,14 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
'filesystem' => true,
]);
$tokenProvider->updateToken($token);
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException) {
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException $e) {
// swallow the exceptions as we do not deal with them here
// simply skip updating the token when is it missing
\OCP\Log\logger('core')->warning('SnaeDebug: Potential error case', [
'uid' => $uid,
'session_class' => get_class($userSession->getSession()),
'exception' => $e,
]);
}
}

Expand Down Expand Up @@ -255,6 +260,8 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
* null: not handled / no backend available
*/
public static function handleApacheAuth() {
$e = new \Exception('Stacktrace for invoking apache auth');
\OCP\Log\logger('core')->warning('SnaeDebug: ApacheAuth was invoked', [ 'exception' => $e ]);
$backend = self::findFirstActiveUsedBackend();
if ($backend) {
OC_App::loadApps();
Expand Down

0 comments on commit b76b5f9

Please sign in to comment.