When LDAP SSO is enabled with "Turn on automated single sign-on" turned on, each drush command that bootstraps Drupal caused the error

Drush command terminated abnormally due to an unrecoverable error

The error is triggered by the drupal_goto() during the boot phase when user 0 is loaded in ldap_sso_user() in

if(variable_get('ldap_sso_seamless_login', 0) == 1 && ($_COOKIE['seamless_login_attempted'] != 'true')){
  setcookie("seamless_login_attempted", 'true', time()+variable_get('ldap_sso_cookie_expire', (315360000)), base_path(), "");
  $_SESSION['seamless_login_attempted'] = $_COOKIE['seamless_login_attempted'];
  $destination = 'destination='. rawurlencode($_GET['q']);
  drupal_goto('user/login/sso', $destination);
}

Comments

sutharsan’s picture

It also causes cron job to fail when called like wget -O - -q -t 1 http://example.com/cron.php

zanix’s picture

Add this function somewhere in ldap_sso.module

function ldap_sso_verify_cli() {
  return ((!isset($_SERVER['SERVER_SOFTWARE']) || $_SERVER['SERVER_SOFTWARE'] == 'PHP CLI')
      && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
}

Find this line

if($account->uid == 0 && $GLOBALS['user']->uid == $account->uid){

Change to

if(!ldap_sso_verify_cli() && $account->uid == 0 && $GLOBALS['user']->uid == $account->uid){
zanix’s picture

Here is a real patch for this issue

grahl’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

CLI checks were added in the 7.x release, I believe this is already fixed. Please reopen if you believe otherwise.