aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu system setuid)
  #:use-module (gnu system privilege)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)
  #:export (setuid-program
            setuid-program?
            setuid-program-program
            setuid-program-setuid?
            setuid-program-setgid?
            setuid-program-user
            setuid-program-group

            file-like->setuid-program))

;;; Commentary:
;;;
;;; 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-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)))
2022-03-18home: services: Fix bash aliases without guix-defaults....angryrectangle 2022-03-18home: services: Export record type accessors....Ludovic Courtès 2022-03-10home: symlink-manager: Rename "path" to "file" where appropriate....Ludovic Courtès 2022-03-10home: symlink-manager: 'create-symlinks' uses 'file-system-fold'....Ludovic Courtès 2022-03-10home: symlink-manager: 'cleanup-symlinks' uses 'file-system-fold'....Ludovic Courtès 2022-03-10home: symlink-manager: Avoid extra 'lstat' call....Ludovic Courtès 2022-03-10home: symlink-manager: Remove 'empty-directory?' and avoid TOCTTOU race....Ludovic Courtès 2022-03-10home: symlink-manager: Use 'file-is-directory?'....Ludovic Courtès 2022-03-10home: symlink-manager: Use 'for-each' when used for effects....Ludovic Courtès 2022-03-10home: symlink-manager: Move helper procedures as top-level defines....Ludovic Courtès 2022-03-10home: symlink-manager: Clarify module imports....Ludovic Courtès 2022-03-01home: xdg: Fix xdg-desktop-entry config field serialization....Andrew Tropin 2022-02-07home: Add redshift service....Ludovic Courtès 2022-01-03home: services: Make strings in Gexps translateble....Xinglu Chen 2021-11-24home: services: bash: Only source /etc/bashrc if it exists....Tobias Geerinckx-Rice 2021-11-16home: services: bash: Emit 'extra-content' first again....Ludovic Courtès 2021-11-14gnu: home: services: Fix typo....Vagrant Cascadian 2021-11-14gnu: home: services: Fix typo....Vagrant Cascadian 2021-11-14gnu: home: services: Fix typo....Vagrant Cascadian 2021-11-07doc: Improve documentation of the Bash home service...Xinglu Chen 2021-11-07home: services: bash: Add ‘aliases’ field....Xinglu Chen 2021-10-16home: services: shells: Fix documentation about file-like objects....Oleg Pykhalov 2021-10-09home: services: configuration: Support file-like objects....Oleg Pykhalov 2021-10-09Move (gnu home-services) to (gnu home services)....Oleg Pykhalov 2021-10-08gnu: Move (gnu home-services) to (gnu home services)....Oleg Pykhalov