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 1pcOeI-0005NF-QY for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Mar 2023 10:46:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pcOeH-00027g-Co for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Mar 2023 10:46:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcOeH-00025N-2d for pgsql-bugs@lists.postgresql.org; Wed, 15 Mar 2023 10:46:25 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcOeE-0004P3-0H for pgsql-bugs@lists.postgresql.org; Wed, 15 Mar 2023 10:46:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=UQEfh8N2MMK6CHbsELezgW6DQ7KJs0rmS/sOlKSS2Fk=; b=KPkY+yFqD9X3xoXiqi0ukH/SLF 1NWX0nv79Dpv9j3XN5hJcgHfqP5ybXp+/rHXL0x/Oky025hJSrBi88pZaumjzouvG0r1q+sqq5AXf 8zxG5DZLSymlIN3yJpqWN+EJ2QgaenekAVSR1qaJNvacSB1pm5mY9BGIK7oV8LCGQcLI=; Received: from depesz by depesz.com with local (Exim 4.94.2) (envelope-from ) id 1pcOe9-00EMQc-UG; Wed, 15 Mar 2023 11:46:18 +0100 Date: Wed, 15 Mar 2023 11:46:17 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Kyotaro Horiguchi Cc: pgsql-bugs@lists.postgresql.org Subject: Re: pg_read_server_files doesn't let me use pg_ls_dir() or pg_read_file? Message-ID: Reply-To: depesz@depesz.com References: <20230315.111011.205480166041302286.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230315.111011.205480166041302286.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 15, 2023 at 11:10:11AM +0900, Kyotaro Horiguchi wrote: > At Tue, 14 Mar 2023 20:33:10 +0100, hubert depesz lubaczewski wrote in > > 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. > > > $ select * from pg_ls_dir('.'); > > ERROR: permission denied for function pg_ls_dir > > "GRANT EXECUTE ON FUNCTION pg_ls_dir(text) TO test" might work for you. > > The doc section you are referring to also describes that on a > per-function basis like this. OK, I get it, but then, what is the point of mentioning pg_read_server_files in the doc? I can just as well grant execute on the functions to someone. And, I tested, they don't need to be in pg_read_server_files. Best regards, depesz