~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to sql/sql_view.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1281
1281
    if (!table->prelocking_placeholder &&
1282
1282
        (old_lex->sql_command == SQLCOM_SELECT && old_lex->describe))
1283
1283
    {
1284
 
      if (check_table_access(thd, SELECT_ACL, view_tables, FALSE,
1285
 
                             UINT_MAX, TRUE) &&
1286
 
          check_table_access(thd, SHOW_VIEW_ACL, table, FALSE, UINT_MAX, TRUE))
 
1284
      /*
 
1285
        The user we run EXPLAIN as (either the connected user who issued
 
1286
        the EXPLAIN statement, or the definer of a SUID stored routine
 
1287
        which contains the EXPLAIN) should have both SHOW_VIEW_ACL and
 
1288
        SELECT_ACL on the view being opened as well as on all underlying
 
1289
        views since EXPLAIN will disclose their structure. This user also
 
1290
        should have SELECT_ACL on all underlying tables of the view since
 
1291
        this EXPLAIN will disclose information about the number of rows in it.
 
1292
 
 
1293
        To perform this privilege check we create auxiliary TABLE_LIST object
 
1294
        for the view in order a) to avoid trashing "table->grant" member for
 
1295
        original table list element, which contents can be important at later
 
1296
        stage for column-level privilege checking b) get TABLE_LIST object
 
1297
        with "security_ctx" member set to 0, i.e. forcing check_table_access()
 
1298
        to use active user's security context.
 
1299
 
 
1300
        There is no need for creating similar copies of TABLE_LIST elements
 
1301
        for underlying tables since they just have been constructed and thus
 
1302
        have TABLE_LIST::security_ctx == 0 and fresh TABLE_LIST::grant member.
 
1303
 
 
1304
        Finally at this point making sure we have SHOW_VIEW_ACL on the views
 
1305
        will suffice as we implicitly require SELECT_ACL anyway.
 
1306
      */
 
1307
        
 
1308
      TABLE_LIST view_no_suid;
 
1309
      bzero(static_cast<void *>(&view_no_suid), sizeof(TABLE_LIST));
 
1310
      view_no_suid.db= table->db;
 
1311
      view_no_suid.table_name= table->table_name;
 
1312
 
 
1313
      DBUG_ASSERT(view_tables == NULL || view_tables->security_ctx == NULL);
 
1314
 
 
1315
      if (check_table_access(thd, SELECT_ACL, view_tables,
 
1316
                             FALSE, UINT_MAX, TRUE) ||
 
1317
          check_table_access(thd, SHOW_VIEW_ACL, &view_no_suid,
 
1318
                             FALSE, UINT_MAX, TRUE))
1287
1319
      {
1288
1320
        my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0));
1289
1321
        goto err;