Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.40
diff -u -p -r1.40 user.admin.inc
--- modules/user/user.admin.inc	26 Feb 2009 07:30:28 -0000	1.40
+++ modules/user/user.admin.inc	7 Mar 2009 16:32:42 -0000
@@ -589,6 +589,10 @@ function user_admin_perm($form_state, $r
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
 
+  // Custom roles inherit checked permissions from authenticated users.
+  drupal_add_js(drupal_get_path('module', 'user') . '/user.js');
+  drupal_add_js(array('user' => array('accessControl' => array())), 'setting');
+  
   return $form;
 }
 
Index: modules/user/user.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.js,v
retrieving revision 1.10
diff -u -p -r1.10 user.js
--- modules/user/user.js	18 Feb 2009 13:46:55 -0000	1.10
+++ modules/user/user.js	7 Mar 2009 16:32:42 -0000
@@ -173,4 +173,53 @@ Drupal.behaviors.userSettings = {
   }
 };
 
+/**
+ * On the admin/user/permissions page, check and disable permissions for 
+ * custom roles when the authenticated user role is given a permission.
+ */
+Drupal.behaviors.permissions = {
+  attach: function(context) {
+    var settings = Drupal.settings.user.accessControl;
+
+    // Store the state of checked permissions for custom roles.
+    $('#permissions input').each(function() {
+      var matches = this.id.match(/^edit-(\d+?)-(.*)$/i);
+      if (matches[1] > 2) { // all custom roles
+        if (!settings[matches[2]]) settings[matches[2]] = {};
+        settings[matches[2]][matches[1]] = this.checked; 
+        $(this).change(Drupal.accessControlUpdate);
+      }
+    });
+    
+    // Check and disable custom permissions when authenticated permission is checked.
+    $('#permissions input[@id^="edit-2-"]').each(function() {
+      $(this).change(Drupal.accessControlToggle);
+      Drupal.accessControlToggle.apply(this);
+    });
+  }
+}
+
+/**
+ * Callback function that is attached to a change of a checkbox of the "authenticated user" column.
+ * It changes the state of all custom roles to either checked or the previous state.
+ */
+Drupal.accessControlToggle = function() {
+  var matches = this.id.match(/^edit-(\d+?)-(.*)$/i), roles = Drupal.settings.user.accessControl[matches[2]];
+  
+  for (var i in roles) {
+    var checkbox = document.getElementById('edit-' + i + '-' + matches[2]);
+    checkbox.disabled = this.checked;
+    checkbox.checked = this.checked ? true : roles[i];
+  }
+};
+
+/**
+ * Updates the status of a custom role in the array when the user changes the permission checkbox.
+ * This allows the status to persist if the authenticated permission is checked and then unchecked.
+ */
+Drupal.accessControlUpdate = function() {
+  var matches = this.id.match(/^edit-(\d+?)-(.*)$/i);
+  Drupal.settings.user.accessControl[matches[2]][matches[1]] = this.checked;
+}
+
 })(jQuery);
