From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CPCcLtlQ6WNDnAAAbAwnHQ (envelope-from ) for ; Sun, 12 Feb 2023 21:49:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YAS5LdlQ6WOnKwEAG6o9tA (envelope-from ) for ; Sun, 12 Feb 2023 21:49:29 +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 80B0FDF41 for ; Sun, 12 Feb 2023 21:49:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRJHW-0003qC-6G; Sun, 12 Feb 2023 15:49:06 -0500 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 1pRJHU-0003ov-R6 for guix-patches@gnu.org; Sun, 12 Feb 2023 15:49:04 -0500 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 1pRJHU-0001fj-E3 for guix-patches@gnu.org; Sun, 12 Feb 2023 15:49:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pRJHU-0004i0-Aq for guix-patches@gnu.org; Sun, 12 Feb 2023 15:49:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61462] [PATCH 06/10] system: (gnu system setuid) wraps (gnu system privilege). Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 12 Feb 2023 20:49:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61462 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 61462@debbugs.gnu.org Received: via spool by 61462-submit@debbugs.gnu.org id=B61462.167623493818023 (code B ref 61462); Sun, 12 Feb 2023 20:49:04 +0000 Received: (at 61462) by debbugs.gnu.org; 12 Feb 2023 20:48:58 +0000 Received: from localhost ([127.0.0.1]:46989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRJHN-0004gb-HY for submit@debbugs.gnu.org; Sun, 12 Feb 2023 15:48:57 -0500 Received: from tobias.gr ([80.241.217.52]:56712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRJHB-0004fL-3Z for 61462@debbugs.gnu.org; Sun, 12 Feb 2023 15:48:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=2018; bh=Gimrxke5k7zXk 9AqjKCbfsMiVv2jvCsoa8oU48wIIl8=; h=references:in-reply-to:date: subject:to:from; d=tobias.gr; b=XdXqCqz0o/i4fyfYCAhhs+26uoID9qlK8OCNfM wX6p5JhT+Zj0hsaqmbEUBDBCzUJwXA4RaWQz1khxKMyX3HO+GETp5DE2Ag2emEg4lHsAII o2oaT2iFowoMfM5wUBlZmlMSv8BciG83aUEvUtWGPhZ6FKVu5swTZEMuxddj+RRaB20ALC 7ABnW44ReLhi0OAPp8jVSSzDqUIPUHkV0giTSVrvZ3qmK8jzNSYK72nyrsC+cp9deOtqZH pOj6nKrdrbRIQxaITBMdam0TnAKqpeLd9WBX1DjacNzZ9XDhG89Geiwqt7XDHUvkvn+U3L +PkRqXpF/D/pD7+Mf7z934Wg== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 897b2e73 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <61462@debbugs.gnu.org>; Sun, 12 Feb 2023 20:48:38 +0000 (UTC) Date: Sun, 5 Feb 2023 01:00:15 +0100 Message-Id: <20230205000019.6259-6-me@tobias.gr> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230205000019.6259-1-me@tobias.gr> References: <20230205000019.6259-1-me@tobias.gr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Tobias Geerinckx-Rice X-ACL-Warn: , Tobias Geerinckx-Rice via Guix-patches From: Tobias Geerinckx-Rice via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1676234969; a=rsa-sha256; cv=none; b=AqjhGPDVDsQW2kuuXfbC9eyBILHhP0zH8TVWpHGTvp+6WNSsGMIV896R8Pmh8TTKJXicap 4pC7XKJAIC/RDpP/TGr+CDHMFRhQd7t6byLSMzxpMlWFs0JZKuxHnK2VXMZgBhjXjghYyT uT1mEOem6yj9FfNCPnFUsRtnGJut6SBSrjRdJeC/tYFh7iAMFyUM+iotR5+L+k5WyIq+YW YEXRMSgaQgU3pC1ueGNAVSVJ+UX38Df0v7qHi0HgXF5akl+0tgt45qhO9EcozkgeKJuQRF I9PdueS+wwC/YVW43ZHjYZZANXbhHPtr8kMHMq8PS4wAbLp4YvLVTHlNGApGzg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tobias.gr header.s=2018 header.b=XdXqCqz0; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676234969; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Gimrxke5k7zXk9AqjKCbfsMiVv2jvCsoa8oU48wIIl8=; b=LwSLctYl/ouAO5trds73EVfmJG+8CrBSAPIYI81u0LAdzCJYQb8/n+ZDV5A3eznJ6AJeo/ gJgN2n63qwB+en4E61LM8Xxlkcuj2PPF4bEIdFrAvQwOMgFRfwHF1NKP34S1kIInSFIwD1 uCxbYCEp8pCsbVbM82WTOMzW0y+BzNkyQeFLnH1stNSO9lXHKlaZzBlnsviCJoWUvGvFaT vQONv4zcDwOiH35tEUbkb306cYtX0Y+IoC0fgOA3aJ0Nih64f6Pd9j3fUTMoAstgwDoeIt 9z6FxGvm7vW/b9bHNVNYkUYVeV+lkavmMQhpO4mEmm8Xafv45RjQrA3FYvR4+w== X-Migadu-Queue-Id: 80B0FDF41 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tobias.gr header.s=2018 header.b=XdXqCqz0; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -1.92 X-Spam-Score: -1.92 X-TUID: 4YdoB1N9RmCe * gnu/system/setuid.scm (setuid-program): Rewrite as syntax to create a record that is setuid by default. (setuid-program?, setuid-program-program, setuid-program-setuid?) (setuid-program-setgid?, setuid-program-user, setuid-program-group): Alias their privileged-program equivalent. --- gnu/system/setuid.scm | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/gnu/system/setuid.scm b/gnu/system/setuid.scm index 83111d932c..4dd0cc8962 100644 --- a/gnu/system/setuid.scm +++ b/gnu/system/setuid.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Brice Waegeneire +;;; Copyright © 2022 Tobias Geerinckx-Rice ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,7 +18,9 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu system setuid) - #:use-module (guix records) + #:use-module (gnu system privilege) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) #:export (setuid-program setuid-program? setuid-program-program @@ -30,28 +33,29 @@ (define-module (gnu system setuid) ;;; Commentary: ;;; -;;; Data structures representing setuid/setgid programs. This is meant to be -;;; used both on the host side and at run time--e.g., in activation snippets. +;;; Do not use this module in new code. It used to define data structures +;;; representing setuid/setgid programs, but is now a mere compatibility shim +;;; wrapping a subset of (gnu system privilege). ;;; ;;; Code: -(define-record-type* - setuid-program make-setuid-program - setuid-program? - ;; Path to program to link with setuid permissions - (program setuid-program-program) ;file-like - ;; Whether to set user setuid bit - (setuid? setuid-program-setuid? ;boolean - (default #t)) - ;; Whether to set group setgid bit - (setgid? setuid-program-setgid? ;boolean - (default #f)) - ;; The user this should be set to (defaults to root) - (user setuid-program-user ;integer or string - (default 0)) - ;; Group we want to set this to (defaults to root) - (group setuid-program-group ;integer or string - (default 0))) +(define-syntax setuid-program + (lambda (fields) + (syntax-case fields () + ((_ (field value) ...) + #`(privileged-program + (setuid? (match (assoc-ref '((field value) ...) 'setuid?) + ((#f) #f) + (_ #t))) + #,@(remove (match-lambda ((f _) (eq? (syntax->datum f) 'setuid?))) + #'((field value) ...))))))) + +(define setuid-program? privileged-program?) +(define setuid-program-program privileged-program-program) +(define setuid-program-setuid? privileged-program-setuid?) +(define setuid-program-setgid? privileged-program-setgid?) +(define setuid-program-user privileged-program-user) +(define setuid-program-group privileged-program-group) (define (file-like->setuid-program program) (setuid-program (program program))) -- 2.39.1