Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBhwT-0003d2-FG for pgsql-general@arkaria.postgresql.org; Thu, 26 Apr 2018 14:32:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fBhwS-0002oc-Bj for pgsql-general@arkaria.postgresql.org; Thu, 26 Apr 2018 14:32:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBhsm-0005si-7j for pgsql-general@lists.postgresql.org; Thu, 26 Apr 2018 14:28:25 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fBhsg-0005kX-Ac for pgsql-general@postgresql.org; Thu, 26 Apr 2018 14:28:23 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E50A520F94; Thu, 26 Apr 2018 10:28:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 26 Apr 2018 10:28:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=goGQ35XT9aRETDvYbqKVO3atHvleU z590MpoNKr1CKE=; b=GFtioF61RUSoJ1qtSApqc12INfdmBEaN8VLi8/3qwx/EH zWP0KlA0CgkgRwSJvYh++sPwum8ZtzL76erNvB26tg0tF+rj8Yl5AZuw4s1oszKi f6BWGcpTRdf4orQ9FxART3pvxkrPqZDEGZd3TOH93UvZriMbVfxW2cxB5OUM3a4J sG1CTwleCMYzvkru4FTbiy++if1S1VrRar0PdfT1lRugYmQx524zKoxMv9Om/1vz 7AnxD0KXr1AE8gAHlkvsFHa59jXP1ZSH5kpv8saykz3n3pACgnFRwt1wBQjma/yg /NWpZl0T8yfLnDEyBUm0+HsJCxzSo0eh9F5tJ8bMQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=goGQ35 XT9aRETDvYbqKVO3atHvleUz590MpoNKr1CKE=; b=FyuHemTYTqTDWQyxZ5PI0u eOkpMr88zVqJ6GPHgGKOF0bPXeZBTjhkYR2nv+030Jd/h4m8+PWMqnALQrRZ7aGh +RrhQ6xoB3cLQOFMSh49KkGOGstOZC9fpxjsHIsOvwKEyVOhnjRCNNAGo4RIDCdl E0tV6maQsUtNzqrAbRszbgTq+9is9boZ0BkzlM9Rp2TJ86WGvZWy0Ahs2BK1v7Pv Rq3FCzAyi99xRHdBeXf5+/1mjtNaQYQl//XyGFJm8NqXqqjwxHD06IQ8T7CwM8mR ZgC+XPKOaoq7TAJNpPz+0ZUy9ra9iMVln38Eh2yFCkMWxDhDTyM4VBz/toWtGyUw == X-ME-Sender: Received: from [192.168.1.2] (unknown [71.212.135.74]) by mail.messagingengine.com (Postfix) with ESMTPA id 45DB71028F; Thu, 26 Apr 2018 10:28:15 -0400 (EDT) Subject: =?UTF-8?Q?Re:_Issue_on_public_sch=c3=a9ma_with_Pg=5frestore?= To: Thomas Poty Cc: "pgsql-general@postgresql.org >> PG-General Mailing List" References: <53ffe598-eb73-0ed1-36db-057b7ca0572c@aklaver.com> From: Adrian Klaver Message-ID: Date: Thu, 26 Apr 2018 07:28:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04/26/2018 12:03 AM, Thomas Poty wrote: > Hi, Comments in line below. > > *About version :* > > This is the same on both server > > _ + source  server  :_ > > > [[local]] thomasproot@serverconfig=# select version(); > ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐ > │ > version                                                  │ > ├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤ > │ PostgreSQL 9.6.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 > 20150623 (Red Hat 4.8.5-16), 64-bit │ > └──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ > (1 row) > > Time: 0.183 ms > > _+ target server_ > > [[local]] thomasproot@postgres=# select version(); > ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐ > │ > version                                                  │ > ├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤ > │ PostgreSQL 9.6.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 > 20150623 (Red Hat 4.8.5-16), 64-bit │ > └──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ > (1 row) > > Time: 4.711 ms The latest 9.6 version is 9.6.8 and it has changes to deal with this: https://wiki.postgresql.org/wiki/A_Guide_to_CVE-2018-1058:_Protect_Your_Search_Path Not sure if it would cover your issues, but worth the ugrade anyway. > > > > _+ pg_restore :_ > > /command :/ > /bin/pg_restore --username=backup --host=VM38 --port=5432 > --dbname=postgres --no-password --disable-triggers --verbose --clean > --create --if-exists > /mnt/backupPostgreSQL/serverconfig_prod/backup_in_progress/serverconfig_prod_thomasp.sql FYI, --disable-triggers in this context is a no-op. > > /version :/ > pg_restore (PostgreSQL) 9.6.7 > > > *About privileges: > > * > _+ source db :_ > > [[local]] thomasproot@serverconfig=# \dn+ >                                            List of schemas > ┌──────────┬────────────────────┬──────────────────────────────────────────┬────────────────────────┐ > │   Name            │       Owner                             │ >                                                Access > privileges             │      Description                                │ > ├──────────┼────────────────────┼──────────────────────────────────────────┼────────────────────────┤ > │ public              │ serverconfig_owner                │ > serverconfig_owner=UC/serverconfig_owner↵                           │ > standard public schema                   │ > │                       │                                              │ > toolboxsysadmin=U/serverconfig_owner > │                                                      │ > │ public_h          │ serverconfig_owner                 │ > serverconfig_owner=UC/serverconfig_owner↵ > │                                                      │ > │                       │                                              │ > toolboxsysadmin=U/serverconfig_owner > │                                                      │ > └──────────┴────────────────────┴──────────────────────────────────────────┴────────────────────────┘ > (2 rows) > So how did you revoke the privileges for PUBLIC in the above? > > _+ target db _ > > /schema of template1 :/ > > thomasproot@template1=# \dn+ >                  List of schemas > ┌──────┬───────┬───────────────────┬─────────────┐ > │ Name     │ Owner      │ Access privileges                │ Description >            │ > ├──────┼───────┼───────────────────┼─────────────┤ > └──────┴───────┴───────────────────┴─────────────┘ > (0 rows) > > > /after restore:/* > > * > [[local]] thomasproot@serverconfig=# \dn+ >                                            List of schemas > ┌──────────┬────────────────────┬──────────────────────────────────────────┬────────────────────────┐ > │ Name            │       Owner                             │ >                                  Access privileges             │ > Description │ > ├──────────┼────────────────────┼──────────────────────────────────────────┼────────────────────────┤ > │ public              │ serverconfig_owner                │ > serverconfig_owner=UC/serverconfig_owner                           ↵│ > standard public schema                   │ > │                       │ > │*=UC/postgres * >                     ↵│ >                  │ > │ │                                              │ > toolboxsysadmin=U/serverconfig_owner │ >                    │ > │ public_h          │ serverconfig_owner                 │ > serverconfig_owner=UC/serverconfig_owner↵ │ >                         │ > │           │                                              │ > toolboxsysadmin=U/serverconfig_owner │ >                    │ > └──────────┴────────────────────┴──────────────────────────────────────────┴────────────────────────┘ > (2 rows) > > > It seems pg_restore automtically add privileges usage and create for > public role on schema public  if it found it. Is that correct? > > Regards > > Thomas > ** -- Adrian Klaver adrian.klaver@aklaver.com