setuid.scm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (gnu system setuid)
  19. #:use-module (guix records)
  20. #:export (setuid-program
  21. setuid-program?
  22. setuid-program-program
  23. setuid-program-setuid?
  24. setuid-program-setgid?
  25. setuid-program-user
  26. setuid-program-group
  27. file-like->setuid-program))
  28. ;;; Commentary:
  29. ;;;
  30. ;;; Data structures representing setuid/setgid programs. This is meant to be
  31. ;;; used both on the host side and at run time--e.g., in activation snippets.
  32. ;;;
  33. ;;; Code:
  34. (define-record-type* <setuid-program>
  35. setuid-program make-setuid-program
  36. setuid-program?
  37. ;; Path to program to link with setuid permissions
  38. (program setuid-program-program) ;file-like
  39. ;; Whether to set user setuid bit
  40. (setuid? setuid-program-setuid? ;boolean
  41. (default #t))
  42. ;; Whether to set group setgid bit
  43. (setgid? setuid-program-setgid? ;boolean
  44. (default #f))
  45. ;; The user this should be set to (defaults to root)
  46. (user setuid-program-user ;integer or string
  47. (default 0))
  48. ;; Group we want to set this to (defaults to root)
  49. (group setuid-program-group ;integer or string
  50. (default 0)))
  51. (define (file-like->setuid-program program)
  52. (setuid-program (program program)))