From patchwork Thu Jan 13 18:41:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 36766 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 3958327BBEA; Sun, 23 Jan 2022 12:59:26 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS 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 AF1B127BBE9 for ; Sun, 23 Jan 2022 12:59:25 +0000 (GMT) Received: from localhost ([::1]:47560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBcSq-0004gY-Qq for patchwork@mira.cbaines.net; Sun, 23 Jan 2022 07:59:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBcSU-0004fR-8t for guix-patches@gnu.org; Sun, 23 Jan 2022 07:59:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nBcST-0007uy-Tz for guix-patches@gnu.org; Sun, 23 Jan 2022 07:59:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nBcST-0004P6-U8 for guix-patches@gnu.org; Sun, 23 Jan 2022 07:59:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53468] [RFC PATCH] gnu: linux-pam: Change path to unix_chkpwd helper. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 23 Jan 2022 12:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53468 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53468@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164294273316912 (code B ref -1); Sun, 23 Jan 2022 12:59:01 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jan 2022 12:58:53 +0000 Received: from localhost ([127.0.0.1]:38798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBcSK-0004Oi-Vr for submit@debbugs.gnu.org; Sun, 23 Jan 2022 07:58:53 -0500 Received: from lists.gnu.org ([209.51.188.17]:49620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nBcSJ-0004Oa-JG for submit@debbugs.gnu.org; Sun, 23 Jan 2022 07:58:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBcSI-0004cW-S1 for guix-patches@gnu.org; Sun, 23 Jan 2022 07:58:51 -0500 Received: from [2a00:1450:4864:20::130] (port=43955 helo=mail-lf1-x130.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nBcS0-0007r0-FD for guix-patches@gnu.org; Sun, 23 Jan 2022 07:58:40 -0500 Received: by mail-lf1-x130.google.com with SMTP id u6so12066362lfm.10 for ; Sun, 23 Jan 2022 04:58:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=SK5aNTWu9RpKykSevqqAaVMFq0kRQ0Fag83cwlf82Qg=; b=EPyKgWWXtPOkExSSgDaeRhAOnesu8dEwEY/zKeeGtCVzMnQsA+VULg19W8xzK9oCS6 b8rztS9/vLAvlTEtVUHuRs0cSRPxihwPHJ24RPr0AOv1m5CUFG2aRZkunrzAg5uzePBx ZldsN4Q0obh8YYUPzoWt81O6CbeV1A0ecBjfoYkEItDDxacdBVYHdutufxLmE2MVF6+o dQFMdghUO8fyrPZ9yOgt1l6MsP0n1B6mfX5HZ/b1axyDi5maeoCBJMMevriLuZ2O3zWU rjhiKkV2LEuHhPfLUaa3DLg1JmcbGHMFn53sqahlU5fcahIgLDF5kQYwpPZZxj3OsnGi wrIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=SK5aNTWu9RpKykSevqqAaVMFq0kRQ0Fag83cwlf82Qg=; b=xraQtk51t5U8wMeCuRnD+AW2BVHy3lP5jenyrMj+nb2UDhGDRV3IEnyEZKEA5qRont JNK2Jk18EGKWxq5SToeNrx3g/9qhohIFsCgMBkSNel8HNyODbveGtAlfGVX88NInWduO OWATFnIXRnugt6/Q2Drr7Yq6UIy3uA5Gx5aDSUZNH2H4ZhzltNSnKBFCtuAQd09k/3n+ XmREQLEArsP0ksCxcwZ6QaExVQn9Hogn5Oop6J7MzMs3yWTvAgakYv+uG+yfELyDECH2 B0eYUUReQyBIfp1wXDg44dNM/ZiR5rxa01VEUvSQRYwSncVKoPHel6TWJ6b3kckAqyfd c/ng== X-Gm-Message-State: AOAM533SWkRxtCFBQfUY/B8XrJF7lWuSnEwrm4buqd3l5uUr/pxwz2HR XmmEtz668xXtq75XuX6+4JPcUr0WBfa+pQ== X-Google-Smtp-Source: ABdhPJxzG574nUfe2gv3X0wkjsYiC0RYtw2/uvsys5YGcYGAufosh2WBf4CE1lLUA+fIhy/maA8WBg== X-Received: by 2002:ac2:5c1b:: with SMTP id r27mr7063576lfp.438.1642942680620; Sun, 23 Jan 2022 04:58:00 -0800 (PST) Received: from localhost (109-252-135-33.dynamic.spd-mgts.ru. [109.252.135.33]) by smtp.gmail.com with ESMTPSA id bu4sm858713lfb.6.2022.01.23.04.57.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 04:57:59 -0800 (PST) From: Andrew Tropin Date: Thu, 13 Jan 2022 21:41:58 +0300 Message-ID: <87tudu38yz.fsf@trop.in> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::130 (failed) Received-SPF: none client-ip=2a00:1450:4864:20::130; envelope-from=andrew@trop.in; helo=mail-lf1-x130.google.com X-Spam_score_int: 23 X-Spam_score: 2.3 X-Spam_bar: ++ X-Spam_report: (2.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/patches/change-path-to-unix_chkpwd.patch: New file * gnu/packages/linux.scm (linux-pam): Add patch. * gnu/system/pam.scm (pam-root-service-type): Add unix_chkpwd to setuid binaries. --- The quote from unix_chkpwd.c: > * This program is designed to run setuid(root) or with sufficient > * privilege to read all of the unix password databases. It is designed > * to provide a mechanism for the current user (defined by this > * process's uid) to verify their own password. Without suid bit it will fail in various use cases: for example utilities like xlock or swaylock compiled with pam support won't be able to unlock the screen. To fix it I added unix_chkpwd binary to list of Guix System's setuid programs and added a patch, which hardcodes /run/setuid-programs/unix_chkpwd path in pam_unix module source code of linux-pam package. However, I'm not sure if it's a proper solution, please share your thoughts and conserns. gnu/packages/linux.scm | 3 +- .../patches/change-path-to-unix_chkpwd.patch | 54 +++++++++++++++++++ gnu/system/pam.scm | 8 ++- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 gnu/packages/patches/change-path-to-unix_chkpwd.patch diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 7b12cb8ec1..ee0df3c625 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -1590,7 +1590,8 @@ (define-public linux-pam (sha256 (base32 "1z4jayf69qyyxln1gl6ch4qxfd66ib1g42garnrv2d8i1drl0790")) - (patches (search-patches "linux-pam-no-setfsuid.patch")))) + (patches (search-patches "change-path-to-unix_chkpwd.patch" + "linux-pam-no-setfsuid.patch")))) (build-system gnu-build-system) (native-inputs diff --git a/gnu/packages/patches/change-path-to-unix_chkpwd.patch b/gnu/packages/patches/change-path-to-unix_chkpwd.patch new file mode 100644 index 0000000000..90a8b639f6 --- /dev/null +++ b/gnu/packages/patches/change-path-to-unix_chkpwd.patch @@ -0,0 +1,54 @@ +From f314ab148b488e23a2e48e7222964e46d0d03447 Mon Sep 17 00:00:00 2001 +From: Andrew Tropin +Date: Wed, 12 Jan 2022 17:17:42 +0300 +Subject: [PATCH] Change path to unix_chkpwd. + +--- + modules/pam_unix/pam_unix_acct.c | 4 ++-- + modules/pam_unix/support.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/modules/pam_unix/pam_unix_acct.c b/modules/pam_unix/pam_unix_acct.c +index 8f5ed3e0..2fdec6c7 100644 +--- a/modules/pam_unix/pam_unix_acct.c ++++ b/modules/pam_unix/pam_unix_acct.c +@@ -122,12 +122,12 @@ int _unix_run_verify_binary(pam_handle_t *pamh, unsigned long long ctrl, + } + + /* exec binary helper */ +- args[0] = CHKPWD_HELPER; ++ args[0] = "/run/setuid-programs/unix_chkpwd"; + args[1] = user; + args[2] = "chkexpiry"; + + DIAG_PUSH_IGNORE_CAST_QUAL; +- execve(CHKPWD_HELPER, (char *const *) args, envp); ++ execve("/run/setuid-programs/unix_chkpwd", (char *const *) args, envp); + DIAG_POP_IGNORE_CAST_QUAL; + + pam_syslog(pamh, LOG_ERR, "helper binary execve failed: %m"); +diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c +index 27ca7127..d02f394e 100644 +--- a/modules/pam_unix/support.c ++++ b/modules/pam_unix/support.c +@@ -523,7 +523,7 @@ static int _unix_run_helper_binary(pam_handle_t *pamh, const char *passwd, + } + + /* exec binary helper */ +- args[0] = CHKPWD_HELPER; ++ args[0] = "/run/setuid-programs/unix_chkpwd"; + args[1] = user; + if (off(UNIX__NONULL, ctrl)) { /* this means we've succeeded */ + args[2]="nullok"; +@@ -532,7 +532,7 @@ static int _unix_run_helper_binary(pam_handle_t *pamh, const char *passwd, + } + + DIAG_PUSH_IGNORE_CAST_QUAL; +- execve(CHKPWD_HELPER, (char *const *) args, envp); ++ execve("/run/setuid-programs/unix_chkpwd", (char *const *) args, envp); + DIAG_POP_IGNORE_CAST_QUAL; + + /* should not get here: exit with error */ +-- +2.34.0 + diff --git a/gnu/system/pam.scm b/gnu/system/pam.scm index 2574e019f1..48cd2ebf2c 100644 --- a/gnu/system/pam.scm +++ b/gnu/system/pam.scm @@ -375,8 +375,12 @@ (define (extend-configuration initial extensions) (define pam-root-service-type (service-type (name 'pam) - (extensions (list (service-extension etc-service-type - /etc-entry))) + (extensions + (list (service-extension etc-service-type /etc-entry) + (service-extension + setuid-program-service-type + (list (file-like->setuid-program + (file-append linux-pam "/sbin/unix_chkpwd")))))) ;; Arguments include as well as procedures. (compose concatenate)