1. 29 12月, 2010 1 次提交
    • M
      Add REPLICATION privilege for ROLEs · 9b8aff8c
      Magnus Hagander 提交于
      This privilege is required to do Streaming Replication, instead of
      superuser, making it possible to set up a SR slave that doesn't
      have write permissions on the master.
      
      Superuser privileges do NOT override this check, so in order to
      use the default superuser account for replication it must be
      explicitly granted the REPLICATION permissions. This is backwards
      incompatible change, in the interest of higher default security.
      9b8aff8c
  2. 28 12月, 2010 2 次提交
  3. 24 12月, 2010 1 次提交
  4. 21 9月, 2010 1 次提交
  5. 17 8月, 2010 1 次提交
    • T
      Arrange to fsync the contents of lockfiles (both postmaster.pid and the · ee0e525b
      Tom Lane 提交于
      socket lockfile) when writing them.  The lack of an fsync here may well
      explain two different reports we've seen of corrupted lockfile contents,
      which doesn't particularly bother the running server but can prevent a
      new server from starting if the old one crashes.  Per suggestion from
      Alvaro.
      
      Back-patch to all supported versions.
      ee0e525b
  6. 21 4月, 2010 1 次提交
    • T
      Arrange for client authentication to occur before we select a specific · ea46000a
      Tom Lane 提交于
      database to connect to. This is necessary for the walsender code to work
      properly (it was previously using an untenable assumption that template1 would
      always be available to connect to).  This also gets rid of a small security
      shortcoming that was introduced in the original patch to eliminate the flat
      authentication files: before, you could find out whether or not the requested
      database existed even if you couldn't pass the authentication checks.
      
      The changes needed to support this are mainly just to treat pg_authid and
      pg_auth_members as nailed relations, so that we can read them without having
      to be able to locate real pg_class entries for them.  This mechanism was
      already debugged for pg_database, but we hadn't recognized the value of
      applying it to those catalogs too.
      
      Since the current code doesn't have support for accessing toast tables before
      we've brought up all of the relcache, remove pg_authid's toast table to ensure
      that no one can store an out-of-line toasted value of rolpassword.  The case
      seems quite unlikely to occur in practice, and was effectively unsupported
      anyway in the old "flatfiles" implementation.
      
      Update genbki.pl to actually implement the same rules as bootstrap.c does for
      not-nullability of catalog columns.  The previous coding was a bit cheesy but
      worked all right for the previous set of bootstrap catalogs.  It does not work
      for pg_authid, where rolvaliduntil needs to be nullable.
      
      Initdb forced due to minor catalog changes (mainly the toast table removal).
      ea46000a
  7. 26 2月, 2010 1 次提交
  8. 15 2月, 2010 1 次提交
    • R
      Wrap calls to SearchSysCache and related functions using macros. · e26c539e
      Robert Haas 提交于
      The purpose of this change is to eliminate the need for every caller
      of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists,
      GetSysCacheOid, and SearchSysCacheList to know the maximum number
      of allowable keys for a syscache entry (currently 4).  This will
      make it far easier to increase the maximum number of keys in a
      future release should we choose to do so, and it makes the code
      shorter, too.
      
      Design and review by Tom Lane.
      e26c539e
  9. 08 2月, 2010 1 次提交
    • T
      Create a "relation mapping" infrastructure to support changing the relfilenodes · b9b8831a
      Tom Lane 提交于
      of shared or nailed system catalogs.  This has two key benefits:
      
      * The new CLUSTER-based VACUUM FULL can be applied safely to all catalogs.
      
      * We no longer have to use an unsafe reindex-in-place approach for reindexing
        shared catalogs.
      
      CLUSTER on nailed catalogs now works too, although I left it disabled on
      shared catalogs because the resulting pg_index.indisclustered update would
      only be visible in one database.
      
      Since reindexing shared system catalogs is now fully transactional and
      crash-safe, the former special cases in REINDEX behavior have been removed;
      shared catalogs are treated the same as non-shared.
      
      This commit does not do anything about the recently-discussed problem of
      deadlocks between VACUUM FULL/CLUSTER on a system catalog and other
      concurrent queries; will address that in a separate patch.  As a stopgap,
      parallel_schedule has been tweaked to run vacuum.sql by itself, to avoid
      such failures during the regression tests.
      b9b8831a
  10. 03 1月, 2010 1 次提交
  11. 10 12月, 2009 1 次提交
    • T
      Prevent indirect security attacks via changing session-local state within · 62aba765
      Tom Lane 提交于
      an allegedly immutable index function.  It was previously recognized that
      we had to prevent such a function from executing SET/RESET ROLE/SESSION
      AUTHORIZATION, or it could trivially obtain the privileges of the session
      user.  However, since there is in general no privilege checking for changes
      of session-local state, it is also possible for such a function to change
      settings in a way that might subvert later operations in the same session.
      Examples include changing search_path to cause an unexpected function to
      be called, or replacing an existing prepared statement with another one
      that will execute a function of the attacker's choosing.
      
      The present patch secures VACUUM, ANALYZE, and CREATE INDEX/REINDEX against
      these threats, which are the same places previously deemed to need protection
      against the SET ROLE issue.  GUC changes are still allowed, since there are
      many useful cases for that, but we prevent security problems by forcing a
      rollback of any GUC change after completing the operation.  Other cases are
      handled by throwing an error if any change is attempted; these include temp
      table creation, closing a cursor, and creating or deleting a prepared
      statement.  (In 7.4, the infrastructure to roll back GUC changes doesn't
      exist, so we settle for rejecting changes of "search_path" in these contexts.)
      
      Original report and patch by Gurjeet Singh, additional analysis by
      Tom Lane.
      
      Security: CVE-2009-4136
      62aba765
  12. 08 10月, 2009 1 次提交
    • A
      Make it possibly to specify GUC params per user and per database. · 2eda8dfb
      Alvaro Herrera 提交于
      Create a new catalog pg_db_role_setting where they are now stored, and better
      encapsulate the code that deals with settings into its realm.  The old
      datconfig and rolconfig columns are removed.
      
      psql has gained a \drds command to display the settings.
      
      Backwards compatibility warning: while the backwards-compatible system views
      still have the config columns, they no longer completely represent the
      configuration for a user or database.
      
      Catalog version bumped.
      2eda8dfb
  13. 28 8月, 2009 1 次提交
    • T
      Make it reasonably safe to use pg_ctl to start the postmaster from a boot-time · 8f5500e6
      Tom Lane 提交于
      script.
      
      To do this, have pg_ctl pass down its parent shell's PID in an environment
      variable PG_GRANDPARENT_PID, and teach CreateLockFile() to disregard that PID
      as a false match if it finds it in postmaster.pid.  This allows us to cope
      with one level of postgres-owned shell process even with pg_ctl in the way,
      so it's just as safe as starting the postmaster directly.  You still have to
      be careful about how you write the initscript though.
      
      Adjust the comments in contrib/start-scripts/ to not deprecate use of
      pg_ctl.  Also, fix the ROTATELOGS option in the OSX script, which was
      indulging in exactly the sort of unsafe coding that renders this fix
      pointless :-(.  A pipe inside the "sudo" will probably result in more
      than one postgres-owned process hanging around.
      8f5500e6
  14. 13 8月, 2009 1 次提交
    • T
      Allow backends to start up without use of the flat-file copy of pg_database. · 04011cc9
      Tom Lane 提交于
      To make this work in the base case, pg_database now has a nailed-in-cache
      relation descriptor that is initialized using hardwired knowledge in
      relcache.c.  This means pg_database is added to the set of relations that
      need to have a Schema_pg_xxx macro maintained in pg_attribute.h.  When this
      path is taken, we'll have to do a seqscan of pg_database to find the row
      we need.
      
      In the normal case, we are able to do an indexscan to find the database's row
      by name.  This is made possible by storing a global relcache init file that
      describes only the shared catalogs and their indexes (and therefore is usable
      by all backends in any database).  A new backend loads this cache file,
      finds its database OID after an indexscan on pg_database, and then loads
      the local relcache init file for that database.
      
      This change should effectively eliminate number of databases as a factor
      in backend startup time, even with large numbers of databases.  However,
      the real reason for doing it is as a first step towards getting rid of
      the flat files altogether.  There are still several other sub-projects
      to be tackled before that can happen.
      04011cc9
  15. 11 6月, 2009 1 次提交
  16. 08 4月, 2009 1 次提交
    • H
      Tell gettext which codeset to use by calling bind_textdomain_codeset(). We · 1fe50205
      Heikki Linnakangas 提交于
      already did that on Windows, but it's needed on other platforms too when
      LC_CTYPE=C. With other locales, we enforce (or trust) that the codeset of
      the locale matches the server encoding so we don't need to bind it
      explicitly. It should do no harm in that case either, but I don't have
      full faith in the PG encoding -> OS codeset mapping table yet. Per recent
      discussion on pgsql-hackers.
      1fe50205
  17. 09 3月, 2009 1 次提交
  18. 05 1月, 2009 1 次提交
  19. 04 1月, 2009 1 次提交
  20. 02 1月, 2009 1 次提交
  21. 11 12月, 2008 1 次提交
  22. 10 10月, 2008 1 次提交
  23. 28 3月, 2008 1 次提交
  24. 04 1月, 2008 1 次提交
    • T
      Make standard maintenance operations (including VACUUM, ANALYZE, REINDEX, · eedb068c
      Tom Lane 提交于
      and CLUSTER) execute as the table owner rather than the calling user, using
      the same privilege-switching mechanism already used for SECURITY DEFINER
      functions.  The purpose of this change is to ensure that user-defined
      functions used in index definitions cannot acquire the privileges of a
      superuser account that is performing routine maintenance.  While a function
      used in an index is supposed to be IMMUTABLE and thus not able to do anything
      very interesting, there are several easy ways around that restriction; and
      even if we could plug them all, there would remain a risk of reading sensitive
      information and broadcasting it through a covert channel such as CPU usage.
      
      To prevent bypassing this security measure, execution of SET SESSION
      AUTHORIZATION and SET ROLE is now forbidden within a SECURITY DEFINER context.
      
      Thanks to Itagaki Takahiro for reporting this vulnerability.
      
      Security: CVE-2007-6600
      eedb068c
  25. 02 1月, 2008 1 次提交
  26. 11 9月, 2007 1 次提交
    • T
      Arrange for SET LOCAL's effects to persist until the end of the current top · 82a47982
      Tom Lane 提交于
      transaction, unless rolled back or overridden by a SET clause for the same
      variable attached to a surrounding function call.  Per discussion, these
      seem the best semantics.  Note that this is an INCOMPATIBLE CHANGE: in 8.0
      through 8.2, SET LOCAL's effects disappeared at subtransaction commit
      (leading to behavior that made little sense at the SQL level).
      
      I took advantage of the opportunity to rewrite and simplify the GUC variable
      save/restore logic a little bit.  The old idea of a "tentative" value is gone;
      it was a hangover from before we had a stack.  Also, we no longer need a stack
      entry for every nesting level, but only for those in which a variable's value
      actually changed.
      82a47982
  27. 03 9月, 2007 1 次提交
  28. 16 2月, 2007 1 次提交
    • A
      Restructure autovacuum in two processes: a dummy process, which runs · 18206509
      Alvaro Herrera 提交于
      continuously, and requests vacuum runs of "autovacuum workers" to postmaster.
      The workers do the actual vacuum work.  This allows for future improvements,
      like allowing multiple autovacuum jobs running in parallel.
      
      For now, the code keeps the original behavior of having a single autovac
      process at any time by sleeping until the previous worker has finished.
      18206509
  29. 02 2月, 2007 1 次提交
    • B
      Wording cleanup for error messages. Also change can't -> cannot. · 8b4ff8b6
      Bruce Momjian 提交于
      Standard English uses "may", "can", and "might" in different ways:
      
              may - permission, "You may borrow my rake."
      
              can - ability, "I can lift that log."
      
              might - possibility, "It might rain today."
      
      Unfortunately, in conversational English, their use is often mixed, as
      in, "You may use this variable to do X", when in fact, "can" is a better
      choice.  Similarly, "It may crash" is better stated, "It might crash".
      8b4ff8b6
  30. 06 1月, 2007 1 次提交
  31. 04 10月, 2006 1 次提交
  32. 16 8月, 2006 2 次提交
    • T
      Seems some C compilers think 'restrict' is a fully reserved word. · d6ac61cd
      Tom Lane 提交于
      Per buildfarm results from warthog.
      d6ac61cd
    • T
      Add server support for "plugin" libraries that can be used for add-on tasks · abc3120e
      Tom Lane 提交于
      such as debugging and performance measurement.  This consists of two features:
      a table of "rendezvous variables" that allows separately-loaded shared
      libraries to communicate, and a new GUC setting "local_preload_libraries"
      that allows libraries to be loaded into specific sessions without explicit
      cooperation from the client application.  To make local_preload_libraries
      as flexible as possible, we do not restrict its use to superusers; instead,
      it is restricted to load only libraries stored in $libdir/plugins/.  The
      existing LOAD command has also been modified to allow non-superusers to
      LOAD libraries stored in this directory.
      
      This patch also renames the existing GUC variable preload_libraries to
      shared_preload_libraries (after a suggestion by Simon Riggs) and does some
      code refactoring in dfmgr.c to improve clarity.
      
      Korry Douglas, with a little help from Tom Lane.
      abc3120e
  33. 09 8月, 2006 1 次提交
    • T
      Add a feature for automatic initialization and finalization of dynamically · b09bfcaa
      Tom Lane 提交于
      loaded libraries: call functions _PG_init() and _PG_fini() if the library
      defines such symbols.  Hence we no longer need to specify an initialization
      function in preload_libraries: we can assume that the library used the
      _PG_init() convention, instead.  This removes one source of pilot error
      in use of preloaded libraries.  Original patch by Ralf Engelschall,
      preload_libraries changes by me.
      b09bfcaa
  34. 14 7月, 2006 1 次提交
  35. 05 3月, 2006 1 次提交
  36. 05 1月, 2006 2 次提交
  37. 23 11月, 2005 1 次提交