GNU bug report logs -
#69340
[PATCH] system, home: Validate ‘services’ field value.
Previous Next
Reported by: Ludovic Courtès <ludo <at> gnu.org>
Date: Fri, 23 Feb 2024 21:16:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69340 in the body.
You can then email your comments to 69340 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
, guix-patches <at> gnu.org
:
bug#69340
; Package
guix-patches
.
(Fri, 23 Feb 2024 21:16:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
, guix-patches <at> gnu.org
.
(Fri, 23 Feb 2024 21:16:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
This guides newcomers who might stick a single (service …) form
in this field.
* gnu/services.scm (validate-service-list): New macro.
(%validate-service-list): New procedure.
* gnu/system.scm (<operating-system>)[services]: Add ‘sanitize’.
* gnu/home.scm (<home-environment>)[services]: Add ‘sanitize’.
Change-Id: I9e29bd9a078e87b627ab766fd669ba9de79f8473
---
gnu/home.scm | 5 +++--
gnu/services.scm | 19 ++++++++++++++++++-
gnu/system.scm | 5 +++--
3 files changed, 24 insertions(+), 5 deletions(-)
Hi!
The goal here is to recognize this likely pitfall for newcomers
and to guide them.
Thoughts?
Ludo'.
diff --git a/gnu/home.scm b/gnu/home.scm
index 2fefe7ba53..b390c8d534 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew <at> trop.in>
-;;; Copyright © 2022 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2022, 2024 Ludovic Courtès <ludo <at> gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -67,7 +67,8 @@ (define-record-type* <home-environment> home-environment
this-home-environment)))
(services home-environment-user-services
- (default '()))
+ (default '())
+ (sanitize validate-service-list))
(location home-environment-location ; <location>
(default (and=> (current-source-location)
diff --git a/gnu/services.scm b/gnu/services.scm
index 59481af10f..88593e8091 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015-2023 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2015-2024 Ludovic Courtès <ludo <at> gnu.org>
;;; Copyright © 2016 Chris Marusich <cmmarusich <at> gmail.com>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado <at> elephly.net>
@@ -91,6 +91,8 @@ (define-module (gnu services)
for-home
for-home?
+ validate-service-list
+
service-error?
missing-value-service-error?
missing-value-service-error-type
@@ -1271,4 +1273,19 @@ (define-syntax-rule (for-home exp ...)
(syntax-parameterize ((for-home? (identifier-syntax #t)))
exp ...))
+(define-with-syntax-properties (validate-service-list (value properties))
+ (%validate-service-list value properties))
+
+(define (%validate-service-list value properties)
+ (match value
+ (((? service?) ...) value)
+ (_
+ (raise
+ (make-compound-condition
+ (condition
+ (&error-location
+ (location (source-properties->location properties))))
+ (formatted-message
+ (G_ "'services' field must contain a list of services")))))))
+
;;; services.scm ends here.
diff --git a/gnu/system.scm b/gnu/system.scm
index aede35775e..aef81d8ccf 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013-2022 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2013-2022, 2024 Ludovic Courtès <ludo <at> gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw <at> netris.org>
;;; Copyright © 2015, 2016 Alex Kost <alezost <at> gmail.com>
;;; Copyright © 2016 Chris Marusich <cmmarusich <at> gmail.com>
@@ -294,7 +294,8 @@ (define-record-type* <operating-system> operating-system
this-operating-system)))
(services operating-system-user-services ; list of services
(thunked) ;allow for system-dependent services
- (default %base-services))
+ (default %base-services)
+ (sanitize validate-service-list))
(pam-services operating-system-pam-services ; list of PAM services
(default (base-pam-services)))
base-commit: b386c11e7804e0b577411d930b60f1e0a4a0382c
--
2.41.0
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Fri, 22 Mar 2024 10:54:04 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
bug acknowledged by developer.
(Fri, 22 Mar 2024 10:54:04 GMT)
Full text and
rfc822 format available.
Message #10 received at 69340-done <at> debbugs.gnu.org (full text, mbox):
Ludovic Courtès <ludo <at> gnu.org> skribis:
> This guides newcomers who might stick a single (service …) form
> in this field.
>
> * gnu/services.scm (validate-service-list): New macro.
> (%validate-service-list): New procedure.
> * gnu/system.scm (<operating-system>)[services]: Add ‘sanitize’.
> * gnu/home.scm (<home-environment>)[services]: Add ‘sanitize’.
>
> Change-Id: I9e29bd9a078e87b627ab766fd669ba9de79f8473
Pushed as 29de2edfbbed21ac016f73a45d399795fc2e4dfb.
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 19 Apr 2024 11:24:17 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 97 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.