Message-ID: Date: Wed, 6 Apr 2022 15:34:02 +0200 MIME-Version: 1.0 Content-Language: en-US References: <20220329192934.1415-1-timo@...2669...> <20220330205536.139-1-timo@...2669...> <67b5b48f-619a-b344-9f51-e1bba55aa3d2@...2181...> From: David Sommerseth In-Reply-To: Subject: Re: [Openvpn-devel] [PATCH v2] Retain CAP_NET_ADMIN when dropping privileges List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit To: Antonio Quartulli Cc: Timo Rothenpieler , openvpn-devel@lists.sourceforge.net On 06/04/2022 14:44, Timo Rothenpieler wrote: >>> >> >> 'man cap_change_id' does not mention setting errno at all. >> What do we expect to see with M_ERRNO? > > Every function it internally calls sets errno, so in case of failure > errno will reflect what went wrong. Like, for example EPERM will be the > most common cause of failure. capng_change_id() does several other lower level calls, like prctl(), setgroups(), setresgid() and setresuid(). They all set errno if an error occurs. The return code of capng_change_id() just reflects in which phase of dropping privileges/uid/gid it failed. For more details of the capng_change_id(), the implementation itself isn't that hard to read (but it does a several steps to harden the privilege drop): -- kind regards, David Sommerseth OpenVPN Inc