From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cF8VOVjoGGJK5wAAgWs5BA (envelope-from ) for ; Fri, 25 Feb 2022 15:31:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id SC1oNljoGGLhFQEA9RJhRA (envelope-from ) for ; Fri, 25 Feb 2022 15:31:52 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9F8282E946 for ; Fri, 25 Feb 2022 15:31:52 +0100 (CET) Received: from localhost ([::1]:39464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNbdP-0006V8-OI for larch@yhetil.org; Fri, 25 Feb 2022 09:31:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNbIM-0003dj-22 for guix-devel@gnu.org; Fri, 25 Feb 2022 09:10:06 -0500 Received: from mail-4323.proton.ch ([185.70.43.23]:50961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNbIA-0000FG-3X for guix-devel@gnu.org; Fri, 25 Feb 2022 09:09:57 -0500 Date: Fri, 25 Feb 2022 14:09:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lendvai.name; s=protonmail3; t=1645798183; bh=fRBqLqm+Imel3a40xqyiS80McgFteozblHdi4S8FhKw=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=mV37k1DeM1fE6ubA1BG1BCezBOD4B9BYEL+S9fs4DUs4rZJT35wPwueodclQjhpn4 Tu7Df7Ds6mR56IjHsolXnNBXnWayFn+N5l2dHtCejisUBsLNe7+dMP5iv8PrBGI+hz A5d5F93gGNpEU8rD36QoHDmNYNm6ayFCezZgviDZPNgTB9L9xWehbfN2TwKl/0z8ly uo4JEGET68Pa8ZD3ow0917LlsP5Xwvtrh5/7QpzLzmRKfabic43gXu/g6Ec8IaHrec NgMowASCInf77S7jvdHylYPlR1qWe05LzI0pwY0l80p8IeEfPH4H8AmT6RWmVktkql 51s2JhGuLu+bA== To: Maxime Devos From: Attila Lendvai Subject: Re: setting open files limit for daemon processes Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.43.23; envelope-from=attila@lendvai.name; helo=mail-4323.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Attila Lendvai Cc: guix-devel Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1645799512; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=fRBqLqm+Imel3a40xqyiS80McgFteozblHdi4S8FhKw=; b=Cl1TcjT1ie2tHanvXjhr6/54uVyRmqRdZC9pA1tH6navH3LkcqRh5k5E8IQNlkbYzWY4sS X7jPSEU6WVbSLLRkvWDE+i0Xj5H96E0fDldqgAfxxqVCSCHQHhwVYANksUgIV3mqKTYGXI gEkQwaW10ly184nxhDYnuG4Qs7Js7WrYUykQHKQWX6EvtTONppsiAcEh5v7AL2+kDjnoTY OrmVafbOYb+B3eWO/kqSr0vlkNfU2eMkKS+N64sjbfM1hduleJkp6D7iP8JHApUZC6Riaa 1oCv7ikz5mhGWjW1Q/I8g49DLLLdap1gU2rFgNt3jyEZn/Q0v+6bnaHMYfI6Qw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1645799512; a=rsa-sha256; cv=none; b=W9A1GS6RaO9H/2dNcTkTxdEkIMNx9/MXJgXO4Z1Mf62PVl4yAjjri4UT5ebeFd4jn8dEe/ j5nsUCzynLr0GW1ubOk+L9kqnNtwUZaMMr96v9XIbgHairBbS1twQUB5yN+dJPoUKlK/RV 2fW6tbFgo56AB+t1xuAHODN/XlYkTqhoOHfqu2LwVp22ZztxpLjdKyIqBIOH7/vvWGJtLn EWEKhagJKTHFsNLFrTqZM2lSF5EWu0U2ljw7oZ3nFrdi6rVEeYhHiAPoRGu7MrVM1X2kEe bVOJQgAZJsjcRpBeOZI7FupVOq0GSMoyq9ZaTygDce6GVsjgKG7Ubv00JFM2jw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lendvai.name header.s=protonmail3 header.b=mV37k1De; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.83 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lendvai.name header.s=protonmail3 header.b=mV37k1De; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9F8282E946 X-Spam-Score: -3.83 X-Migadu-Scanner: scn0.migadu.com X-TUID: cpMh5RlhjA3n > > su - [daemon user] -c 'ulimit -aHS' -s `which bash` > > That might set the limit of the user when that user logins (and hence, > PAM things are run), but I don't see how this changes the limit of > shepherd itself. I don't think that shepherd interacts with PAM at > all? my understanding of PAM is rather limited, but i guess it cannot hook into setuid(), and as such it has no means to affect the ulimits of processes sp= awned by Shepherd. > My suggestion is to do (setrlimit RLIMIT_NOFILE [...]) inside shepherd > itself -- when shepherd starts, or between 'fork' and 'exec'. Maybe looking at the code, it'd be nice if we factored out a variant of fork (may= be called CALL-IN-FORK) that took a thunk and called it in the forked path. th= at would allow me to use that abstraction in user code to easily insert a call= to setrlimit before the EXEC-COMMAND, or whatever else is needed. maybe using that abstraction we could straight out move EXEC-COMMAND to the= guix side? my thinking here is that toching/testing/updating the Shepherd codeba= se seems to be much more trouble than the Guix codebase. i'd be happy to play with this, but i don't know how to run a Guix VM that = is built using my modified Shepherd; i.e. i have no idea how to test what i'm doing. > an '#:open-file-limit' argument could be added to 'fork+exec-command'? that would be the safest/simplest way to resolve this, but then what about = all the other limits? -- =E2=80=A2 attila lendvai =E2=80=A2 PGP: 963F 5D5F 45C7 DFCD 0A39 -- =E2=80=9CThere can be no keener revelation of a society=E2=80=99s soul than= the way in which it treats its children.=E2=80=9D =09=E2=80=94 Nelson Mandela (1918=E2=80=932013)