Set permissions for role.
function setRolePermissions($rid, $access_comments = FALSE, $search_content = TRUE) {
$permissions = array(
'access comments' => $access_comments,
'search content' => $search_content,
);
user_role_change_permissions($rid, $permissions);
}