Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ucGc3-00Ay7z-Ff for pgsql-general@arkaria.postgresql.org; Thu, 17 Jul 2025 04:52:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ucGc0-00GOEV-OS for pgsql-general@arkaria.postgresql.org; Thu, 17 Jul 2025 04:52:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ucGc0-00GOEL-Bp for pgsql-general@lists.postgresql.org; Thu, 17 Jul 2025 04:52:53 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ucGby-008Bwy-2p for pgsql-general@lists.postgresql.org; Thu, 17 Jul 2025 04:52:52 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-60702d77c60so979576a12.3 for ; Wed, 16 Jul 2025 21:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752727969; x=1753332769; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EE0ZiJVdtwgXQ9MQnOJSKoV05qTVAo2Go0heGFRx3VY=; b=Uib7IBkCRVtSfvnGzNqba5YlriylRP1L467yqOmKe4rd5B+48c9HT6p6cKw5E5G3fN qpWSn20Du9rVG9jdAQf+FTQfl9BwRRieB8sdjrCzJHAALHtiNtVSiNO0JaQI+7cDqmno RZ9spB9DRFfJLOppG/gn5td6tp7/XJs//fwmTKwm9e7zwlke7SQ1gb2T/7YwogEaRWIK RUzFNq7TM4XQeRqdGH8oBp/QwdhduBQotwRPae81qJ+M8pPQeYbrO7jV6DBOVi+H+qde mnZ8x8L4T5tfqXH9ICEtiQb3Zbt2b/ZXstso8++yAcOe8agBpyXbtRq+hI/kiBr0Ukqb sEjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752727969; x=1753332769; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EE0ZiJVdtwgXQ9MQnOJSKoV05qTVAo2Go0heGFRx3VY=; b=qDTa1pLlstjPD5kIri1o+czyXUgQid1oGMI2W7HdrwRMg2CfYhX5Jv1AtRQDd/mWDw 29ItbQragIyvPQRifHTMxPjHrqSBv8w9yKYQrb/CfdKFSbbaN0amMRBtWKymBO3v6vly HWyZwsKoHeq3Pri4lqFs8MJDPDDbXy5DIu3xzPRmVavcs9mXjSHMxxxtjA8LcGrwzba2 N5K2B+z0/M45bkdapQU64wBwXwh84a74MdsZBTzK19jKwId3avbMdeOgoC7hKU5ajV3t +UfWh35AF9zTpZEDjallzC2FENtSs/+eFgCeo7SEbmwIRInb6JvxZMHIjCQtdoC0VQXa xwlw== X-Forwarded-Encrypted: i=1; AJvYcCWMUSRhDj2umRQGNX5NNT2LIaErCur7edfmDuo16BiNe+HuOppQAxo6G+rAYqYMPz4zmgc3+oVxaSFyi9oW@lists.postgresql.org X-Gm-Message-State: AOJu0YxW+SRhmy27pdD4jLnVnAb51m5vmP0q6g87WVsw4Ug8vgMtbz0f U41dwJ3Ip0SNPs/lz035WKkWz9YaRD9IrUDGpXnU7+a1qwPDQaa8yocGVu/nwtfSoWMYaaQINgc q2Fv+i/EyRXAZQwmV2iGa1lAtZpuovygbrseyuwA= X-Gm-Gg: ASbGncsXg1Bmxs2H5GH/6+zMEkDdnN/dzsQgCUhoqx8QXxCBNo/7jreuemlsF7Xz4+m TAAyk9d/ipownQs2BcCitzJNBsNTELnnwbxiWPA/tooGpSz2neJLR+CoMBkcubIvEbLR5uKKFbm QkVX0/hTg7KZTQSgiLuzxb77WFutjtVd9JAMUoSsJReAUNxxaipck6a7opDDOWe+cdIzTT+Wkek PpZJvJezgGOQIZqgseY0AnXQwpPMuATb5HD8UoC/GmLMkH/p5Q= X-Google-Smtp-Source: AGHT+IH4QEpI/LocnEv/Ujp09qRz4nptkkVltpJHKli5tNXsPvaJvsA81KzIB9CVQtWMWX+tbnrzhlOQw5IEvn5wTgI= X-Received: by 2002:a17:907:9625:b0:ae3:7022:b210 with SMTP id a640c23a62f3a-ae9c99812e3mr586397766b.12.1752727969043; Wed, 16 Jul 2025 21:52:49 -0700 (PDT) MIME-Version: 1.0 References: <13e3100fc7c7d14919c37943dcfd76b263cecce2.camel@cybertec.at> <609925.1752502040@sss.pgh.pa.us> <62b420e1c9500c68c1bc135810d4cf9f3289fb8c.camel@cybertec.at> In-Reply-To: <62b420e1c9500c68c1bc135810d4cf9f3289fb8c.camel@cybertec.at> From: Amol Inamdar Date: Thu, 17 Jul 2025 10:22:37 +0530 X-Gm-Features: Ac12FXzBAlzxQ-F1nQZSh-IMPJ5XtWPrmRWD5gzwfjsALlhdpHzJXoZ_jPxj7vo Message-ID: Subject: Re: Bypassing Directory Ownership Check in PostgreSQL 16.6 with Secure z/OS NFS (AT-TLS) To: Laurenz Albe Cc: Tom Lane , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000fb9c05063a18c7e9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000fb9c05063a18c7e9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable @Laurenz Albe If you pre-create the data directory with the appropriate permissions, what keeps you from giving ownership to the correct user too? Our NFS server is not a regular linux based server, it's on zOS (Mainframes) with AT-TLS security enabled, hence it doesn't allow changing of ownership. Basically, we have tried everything we could to change the directory ownership to match with the postgres user and that as of now looks impossible, unless we make changes in the environment. To summarize*, we are not able to change the ownership of the data directory * *due to the Mainframe NFS server limitations when enabled with AT-TLS security * *Hence we wanted to check if bypassing this check is ok if it could be assured * *that only the postgres user can write here (NFS-AT-TLS ensures that). * I wouldn't get into details of explaining why changing ownership is not possible, as that would take this discussion to another context, hence avoiding. Thanks in advance On Wed, Jul 16, 2025 at 9:18=E2=80=AFPM Laurenz Albe wrote: > On Wed, 2025-07-16 at 18:54 +0530, Amol Inamdar wrote: > > I would like to rephrase the question a little bit, below is how our > setup going to be > > 1. NFS mount point is for /nfs-mount/postgres (and permissions locke= d > down so > > that Postgres cannot create directories in here) > > 2. Postgres data directory is /nfs-mount/postgres/db > > 3. With secured NFS + AT-TLS setup Postgres will be able to write to > data directory > > but not parent dir, however the file ownership information > Postgres sees from the > > stat() call will not match the Postgres user in the container > (even though the > > AT-TLS strict access control will ensure only the Posgres user ca= n > read/write to > > this directory) > > Considering the above scenario/setup, what is the danger of removing th= e > ownership check > > in miscinit.c checkDataDir() function ? > > The danger is that somebody else than the PostgreSQL user has permissions > on > the data directory. You will argue that that somebody is root, and root > has > these permissions anyway. > > But there is another reason why PostgreSQL insists that the PostgreSQL us= er > owns the data directory: at startup, the postmaster checks if the data > directory belongs to the current user and fails if not. This is a > protection > against starting the postmaster with the wrong user. > > There are certainly ways to do it differently, but I'd argue that they > would > be more complicated, and the current simple solution is robust. > > If you pre-create the data directory with the appropriate permissions, > what keeps you from giving ownership to the correct user too? > > Yours, > Laurenz Albe > --=20 -regards Amol --000000000000fb9c05063a18c7e9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
@Laurenz Albe=C2= =A0
If you pre-create the data directory with the appropriate permi= ssions,
what keeps you from giving ownership to the correct user too?
Our NFS server is not a regular linux based server,=C2=A0<= /div>
it's on zOS (Mainframes) with AT-TLS security enabled,=C2=A0<= /div>
hence it doesn't allow changing of ownership.=C2=A0

Basically, we have tried everything we could=C2=A0
to change the directory ownership to match with the postgres user
and that as of now looks impossible, unless we make changes in the envir= onment.

To summarize, we are not able to change= the ownership of the data directory=C2=A0
due to the Main= frame NFS server limitations when enabled with AT-TLS security=C2=A0
Hence we wanted to check if bypassing this check is ok if it cou= ld be assured=C2=A0
that only the postgres user can write = here (NFS-AT-TLS ensures that).=C2=A0

I wouldn= 't get into details of=C2=A0explaining why changing ownership is not po= ssible,=C2=A0
as that would take this discussion to another conte= xt, hence avoiding.

Thanks in advance=C2=A0
<= /div>

On Wed, Jul 16, 2025 at 9:18=E2=80=AFPM Laurenz = Albe <laurenz.albe@cybertec.= at> wrote:

--
-regards
Amol
--000000000000fb9c05063a18c7e9--