Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcAOa-00043l-MU for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 19:33:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pcAOZ-0001Be-Di for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 19:33:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcAOZ-0001BV-1j for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 19:33:15 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcAOW-00087I-11 for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 19:33:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Reply-To: Message-ID:Subject:To:Sender:From:Date:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DFciefRHC6QwnMdsUAO3J9VjOcVC4/6HgHKHZ8BhZ2w=; b=gXHevzegphXN6qNQul7p+ZtpWz j3LkDc2af1UVBu5b73jqGwxKyHGkCPtnnumYbtT5FIaynOaxnBRX2X0w6tGP2HFoSi7KaEOKe1pOW 0+eKE2mk+CLBad1MkzijJmNpW0lMUBlWrEmHNThb3E5gK/BeFUI5jViqDBhbdsJ9ykSw=; Received: from depesz by depesz.com with local (Exim 4.94.2) (envelope-from ) id 1pcAOU-009NvM-4R for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 20:33:10 +0100 Date: Tue, 14 Mar 2023 20:33:10 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: PostgreSQL mailing lists Subject: pg_read_server_files doesn't let me use pg_ls_dir() or pg_read_file? Message-ID: Reply-To: depesz@depesz.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Tested it now on built today Pg 16devel, straight from repo. In docs (https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-GENFILE), I found: > The functions shown in Table 9.99 provide native access to files on > the machine hosting the server. Only files within the database cluster > directory and the log_directory can be accessed, unless the user is > a superuser or is granted the role pg_read_server_files. Use > a relative path for files in the cluster directory, and a path > matching the log_directory configuration setting for log files. which I understand that if I'll grant pg_read_server_files to some user, then this user should be able to use the generic file access functions. So I tried: #v+ $ select current_user; current_user ────────────── test (1 row) $ \du+ test List of roles Role name │ Attributes │ Member of │ Description ───────────┼────────────┼───────────────────────────────────────────────────────────────┼───────────── test │ │ {pg_read_all_settings,pg_read_all_stats,pg_read_server_files} │ $ select * from pg_ls_dir('.'); ERROR: permission denied for function pg_ls_dir $ select * from pg_ls_dir('log'); ERROR: permission denied for function pg_ls_dir $ select * from pg_ls_dir('/etc'); ERROR: permission denied for function pg_ls_dir $ select * from pg_read_file('PG_VERSION'); ERROR: permission denied for function pg_read_file $ select * from pg_read_file('/etc/passwd'); ERROR: permission denied for function pg_read_file #v- After I additionally granted EXECUTE on the functions, I was able to run them, even when I revoked pg_read_server_files. Am I missing something in there, or is this a bug? Best regards, depesz