From patchwork Fri May 12 18:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Lechner X-Patchwork-Id: 49972 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 824DD27BBEE; Fri, 12 May 2023 19:53:42 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A8A9127BBF0 for ; Fri, 12 May 2023 19:53:40 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxXt8-0006x4-6P; Fri, 12 May 2023 14:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxXt2-0006vT-3h for guix-patches@gnu.org; Fri, 12 May 2023 14:53:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxXt1-0007mr-R7 for guix-patches@gnu.org; Fri, 12 May 2023 14:53:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pxXt1-0003as-NG for guix-patches@gnu.org; Fri, 12 May 2023 14:53:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63383] [PATCH v2 2/4] Drop limits.conf from /etc/security; use directly in pam-limits-service-type. Resent-From: Felix Lechner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 12 May 2023 18:53:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63383 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63383@debbugs.gnu.org Cc: Felix Lechner Received: via spool by 63383-submit@debbugs.gnu.org id=B63383.168391757813758 (code B ref 63383); Fri, 12 May 2023 18:53:03 +0000 Received: (at 63383) by debbugs.gnu.org; 12 May 2023 18:52:58 +0000 Received: from localhost ([127.0.0.1]:32981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxXsv-0003Zq-Hu for submit@debbugs.gnu.org; Fri, 12 May 2023 14:52:57 -0400 Received: from sail-ipv4.us-core.com ([208.82.101.137]:38686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxXst-0003ZR-MD for 63383@debbugs.gnu.org; Fri, 12 May 2023 14:52:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=dP9G5Ny4UxL1dix 5Pe+7Rp79X6H7e9XQQXcZJdrlIrg=; h=references:in-reply-to:date:subject: cc:to:from; d=lease-up.com; b=bNhENMZeiYjFFABkUYVqrQwykCThZ8YXJovdF0sy kaXXGXLJEfTNQkS36//31xPrLwCn3nxATdgc68Phw4ULZcApMk3kbEPtR5xVsoAVhTnpXg VqiAsEuk80uOP9I3ABcZwRFpy+5O4pZMiWi76+QuKO/XWOktxwsaqy8BmHt1w= Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id 7d17977e (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Fri, 12 May 2023 18:52:55 +0000 (UTC) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 5edbc1d3; Fri, 12 May 2023 18:52:54 +0000 (UTC) Date: Fri, 12 May 2023 11:52:48 -0700 Message-Id: <664a326ae17afabd71301893f1c56ff4e9d01c68.1683917556.git.felix.lechner@lease-up.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <1d5c51bdf283c808ff65a3cedbdd1078fb45a05b.1683917556.git.felix.lechner@lease-up.com> References: <1d5c51bdf283c808ff65a3cedbdd1078fb45a05b.1683917556.git.felix.lechner@lease-up.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Felix Lechner X-ACL-Warn: , Felix Lechner via Guix-patches X-Patchwork-Original-From: Felix Lechner via Guix-patches via From: Felix Lechner Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This commit was tested and is already deployed in production. * gnu/services/base.scm: Drop config file limits.conf from /etc; use absolute path in store instead. --- gnu/services/base.scm | 63 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index fdc2c8c764..4bef781977 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1603,38 +1603,36 @@ (define-deprecated (syslog-service #:optional (config (syslog-configuration))) (define pam-limits-service-type (let ((pam-extension - (pam-extension - (transformer - (lambda (pam) - (let ((pam-limits (pam-entry - (control "required") - (module "pam_limits.so") - (arguments - '("conf=/etc/security/limits.conf"))))) - (if (member (pam-service-name pam) - '("login" "greetd" "su" "slim" "gdm-password" - "sddm" "sudo" "sshd")) - (pam-service - (inherit pam) - (session (cons pam-limits - (pam-service-session pam)))) - pam)))))) - - ;; XXX: Using file-like objects is deprecated, use lists instead. - ;; This is to be reduced into the list? case when the deprecated - ;; code gets removed. - ;; Create /etc/security containing the provided "limits.conf" file. - (security-limits + (lambda (limits-file) + (pam-extension + (transformer + (lambda (pam) + (let ((pam-limits (pam-entry + (control "required") + (module "pam_limits.so") + (arguments + (list #~(string-append "conf=" #$limits-file)))))) + (if (member (pam-service-name pam) + '("login" "greetd" "su" "slim" "gdm-password" "sddm" + "sudo" "sshd")) + (pam-service + (inherit pam) + (session (cons pam-limits + (pam-service-session pam)))) + pam))))))) + (make-limits-file (match-lambda + ;; XXX: Using file-like objects is deprecated, use lists instead. + ;; This is to be reduced into the list? case when the deprecated + ;; code gets removed. ((? file-like? obj) (warning (G_ "Using file-like value for \ 'pam-limits-service-type' is deprecated~%")) - `(("security/limits.conf" ,obj))) + obj) ((? list? lst) - `(("security/limits.conf" - ,(plain-file "limits.conf" - (string-join (map pam-limits-entry->string lst) - "\n" 'suffix))))) + (plain-file "limits.conf" + (string-join (map pam-limits-entry->string lst) + "\n" 'suffix))) (_ (raise (formatted-message (G_ "invalid input for 'pam-limits-service-type'~%"))))))) @@ -1642,13 +1640,12 @@ (module "pam_limits.so") (service-type (name 'limits) (extensions - (list (service-extension etc-service-type security-limits) - (service-extension pam-root-service-type - (lambda _ (list pam-extension))))) + (list (service-extension pam-root-service-type + (lambda (config) + (list (pam-extension (make-limits-file config))))))) (description - "Install the specified resource usage limits by populating -@file{/etc/security/limits.conf} and using the @code{pam_limits} -authentication module.") + "Use the @code{pam_limits} authentication module to set the specified +resource usage limits.") (default-value '())))) (define-deprecated (pam-limits-service #:optional (limits '()))