Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.307
diff -u -p -r1.307 update.php
--- update.php	9 Oct 2009 07:48:06 -0000	1.307
+++ update.php	24 Oct 2009 01:22:28 -0000
@@ -386,6 +386,11 @@ else {
   $output = update_access_denied_page();
 }
 if (isset($output) && $output) {
+  // Explicitly start a session and force it to stay open for 10 minutes. This
+  // ensures that update.php can be run as the anonymous user.
+  drupal_session_start();
+  drupal_session_keep(300);
+
   // We defer the display of messages until all updates are done.
   $progress_page = ($batch = batch_get()) && isset($batch['running']);
   print theme('update_page', array('content' => $output, 'show_messages' => !$progress_page));
Index: includes/session.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/session.inc,v
retrieving revision 1.72
diff -u -p -r1.72 session.inc
--- includes/session.inc	28 Sep 2009 22:22:54 -0000	1.72
+++ includes/session.inc	24 Oct 2009 01:22:29 -0000
@@ -235,6 +235,11 @@ function drupal_session_commit() {
     return;
   }
 
+  // Expire the keep if possible.
+  if (isset($_SESSION['drupal_keep']) && ($_SESSION['drupal_keep'] > REQUEST_TIME)) {
+    unset($_SESSION['drupal_keep']);
+  }
+
   if (empty($user->uid) && empty($_SESSION)) {
     // There is no session data to store, destroy the session if it was
     // previously started.
@@ -265,6 +270,25 @@ function drupal_session_started($set = N
 }
 
 /**
+ * Keep the current user's session open for a given length of time.
+ *
+ * @param $duration The length the session needs to remain open, in seconds.
+ */
+function drupal_session_keep($duration) {
+  $new_timestamp = REQUEST_TIME + $duration;
+  if (!isset($_SESSION['drupal_keep']) || ($new_timestamp > $_SESSION['drupal_keep'])) {
+    $_SESSION['drupal_keep'] = $new_timestamp;
+  }
+}
+
+/**
+ * Stop keeping the current user's session open.
+ */
+function drupal_session_keep_reset() {
+  unset($_SESSION['drupal_keep']);
+}
+
+/**
  * Called when an anonymous user becomes authenticated or vice-versa.
  *
  * @ingroup php_wrappers
