Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1199
diff -u -p -r1.1199 user.module
--- modules/user/user.module	7 Sep 2010 22:38:30 -0000	1.1199
+++ modules/user/user.module	15 Sep 2010 16:27:48 -0000
@@ -1763,12 +1763,12 @@ function user_menu_site_status_alter(&$m
         case 'user/login':
         case 'user/password':
           // Disable offline mode.
-          $menu_site_status = MENU_SITE_ONLINE;
+          $menu_site_status = MENU_SITE_ONLINE_MAINTENANCE_TPL;
           break;
         default:
           if (strpos($path, 'user/reset/') === 0) {
             // Disable offline mode.
-            $menu_site_status = MENU_SITE_ONLINE;
+            $menu_site_status = MENU_SITE_ONLINE_MAINTENANCE_TPL;
           }
           break;
       }
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.408
diff -u -p -r1.408 menu.inc
--- includes/menu.inc	1 Sep 2010 02:59:04 -0000	1.408
+++ includes/menu.inc	15 Sep 2010 16:27:49 -0000
@@ -244,6 +244,14 @@ define('MENU_SITE_OFFLINE', 4);
 define('MENU_SITE_ONLINE', 5);
 
 /**
+ * Internal menu status code -- Site is offline, but show this content using the
+ * "maintenance" page template anyway. Useful for showing the user login and
+ * password retrieval forms while the site is in maintenance mode, but not
+ * showing any other page content besides that (such as sidebar content, etc).
+ */
+define('MENU_SITE_ONLINE_MAINTENANCE_TPL', 6);
+
+/**
  * @} End of "Menu status codes".
  */
 
@@ -457,16 +465,16 @@ function menu_get_item($path = NULL, $ro
  */
 function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
   // Check if site is offline.
-  $page_callback_result = _menu_site_is_offline() ? MENU_SITE_OFFLINE : MENU_SITE_ONLINE;
+  $offline_status = _menu_site_is_offline() ? MENU_SITE_OFFLINE : MENU_SITE_ONLINE;
 
   // Allow other modules to change the site status but not the path because that
   // would not change the global variable. hook_url_inbound_alter() can be used
   // to change the path. Code later will not use the $read_only_path variable.
   $read_only_path = !empty($path) ? $path : $_GET['q'];
-  drupal_alter('menu_site_status', $page_callback_result, $read_only_path);
+  drupal_alter('menu_site_status', $offline_status, $read_only_path);
 
   // Only continue if the site status is not set.
-  if ($page_callback_result == MENU_SITE_ONLINE) {
+  if ($offline_status == MENU_SITE_ONLINE || $offline_status == MENU_SITE_ONLINE_MAINTENANCE_TPL) {
     // Rebuild if we know it's needed, or if the menu masks are missing which
     // occurs rarely, likely due to a race condition of multiple rebuilds.
     if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
@@ -487,12 +495,26 @@ function menu_execute_active_handler($pa
       $page_callback_result = MENU_NOT_FOUND;
     }
   }
+  else {
+    $page_callback_result = $offline_status;
+  }
 
   // Deliver the result of the page callback to the browser, or if requested,
   // return it raw, so calling code can do more processing.
   if ($deliver) {
-    $default_delivery_callback = (isset($router_item) && $router_item) ? $router_item['delivery_callback'] : NULL;
-    drupal_deliver_page($page_callback_result, $default_delivery_callback);
+    if ($offline_status == MENU_SITE_ONLINE_MAINTENANCE_TPL && !is_int($page_callback_result)) {
+      // A special exception for the login form and similar things which need
+      // to be accessible when the site is offline, but for which we don't want
+      // to show regions/blocks, etc. Basically, we slip the result of the
+      // callback into the maintenance page.
+      drupal_maintenance_theme();
+      print theme('maintenance_page', array('content' => drupal_render($page_callback_result)));
+    }
+    else {
+      // Deliver the page as normal.
+      $default_delivery_callback = (isset($router_item) && $router_item) ? $router_item['delivery_callback'] : NULL;
+      drupal_deliver_page($page_callback_result, $default_delivery_callback);
+    }
   }
   else {
     return $page_callback_result;
Index: modules/simpletest/tests/menu.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/menu.test,v
retrieving revision 1.34
diff -u -p -r1.34 menu.test
--- modules/simpletest/tests/menu.test	8 Aug 2010 19:35:49 -0000	1.34
+++ modules/simpletest/tests/menu.test	15 Sep 2010 16:27:50 -0000
@@ -83,6 +83,12 @@ class MenuRouterTestCase extends DrupalW
     $this->drupalGet('menu-test/theme-callback/use-admin-theme');
     $this->assertRaw('bartik/css/style.css', t("The maintenance theme's CSS appears on the page."));
 
+    // Assure that the user login and password reset pages are using the
+    // maintenance theme too (in Drupal 6, the main site theme was used). The
+    // presence of the form itself is tested in modules/system/system.test.
+    $this->drupalGet('user/login');
+    $this->assertRaw('bartik/css/maintenance-page.css', t("The maintenance theme is being used to display the login form."));
+
     // An administrator, however, should continue to see the requested theme.
     $admin_user = $this->drupalCreateUser(array('access site in maintenance mode'));
     $this->drupalLogin($admin_user);
