[PATCH 0/2] location in define-configuration

  • Done
  • quality assurance status badge
Details
2 participants
  • Oleg Pykhalov
  • Ludovic Courtès
Owner
unassigned
Submitted by
Oleg Pykhalov
Severity
normal

Debbugs page

O
O
Oleg Pykhalov wrote on 22 Dec 2018 12:38
(address . guix-patches@gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20181222203857.26964-1-go.wigust@gmail.com
This patch series follow up Ludovic's suggestions in #33549 bug report to
implement a ‘location’ record field for ‘define-configuration’ procedure.

Oleg Pykhalov (2):
services: configuration: Add location.
services: zabbix-front-end: Show location in messages.

gnu/services/configuration.scm | 5 +++++
gnu/services/monitoring.scm | 26 +++++++++++++++++---------
2 files changed, 22 insertions(+), 9 deletions(-)

--
2.20.1
O
O
Oleg Pykhalov wrote on 22 Dec 2018 12:42
[PATCH 1/2] services: configuration: Add location.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20181222204207.28505-1-go.wigust@gmail.com
* gnu/services/configuration.scm (define-configuration): Add location.
---
gnu/services/configuration.scm | 5 +++++
1 file changed, 5 insertions(+)

Toggle diff (25 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 707944cbe..9775f91ff 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -22,6 +22,7 @@
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (guix gexp)
+ #:use-module ((guix utils) #:select (source-properties->location))
#:autoload (texinfo) (texi-fragment->stexi)
#:autoload (texinfo serialize) (stexi->texi)
#:use-module (ice-9 match)
@@ -129,6 +130,10 @@
#,(id #'stem #'% #'stem)
#,(id #'stem #'make- #'stem)
#,(id #'stem #'stem #'?)
+ (location configuration-location
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
(field field-getter (default def))
...)
(define #,(id #'stem #'stem #'-fields)
--
2.20.1
O
O
Oleg Pykhalov wrote on 22 Dec 2018 12:42
[PATCH 2/2] services: zabbix-front-end: Show location in messages.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20181222204207.28505-2-go.wigust@gmail.com
* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
gnu/services/monitoring.scm | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

Toggle diff (57 lines)
diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f11..90eda6561 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -29,6 +29,7 @@
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix records)
+ #:use-module (guix utils)
#:use-module ((guix ui) #:select (display-hint))
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
@@ -512,7 +513,7 @@ create it manually.")
(define zabbix-front-end-config
(match-lambda
(($ <zabbix-front-end-configuration>
- _ db-host db-port db-name db-user db-password db-secret-file
+ location _ db-host db-port db-name db-user db-password db-secret-file
zabbix-host zabbix-port)
(mixed-text-file "zabbix.conf.php"
"\
@@ -527,18 +528,25 @@ $DB['DATABASE'] = '" db-name "';
$DB['USER'] = '" db-user "';
$DB['PASSWORD'] = '" (if (string-null? db-password)
(if (string-null? db-secret-file)
- (raise (condition
- (&message
- (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
+ (raise (make-compound-condition
+ (condition
+ (&message
+ (message "\
+you must provide either 'db-secret-file' or 'db-password'")))
+ (condition
+ (&error-location (location location)))))
(string-trim-both
(with-input-from-file db-secret-file
read-string)))
(begin
- (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
- db-password)) "';
+ (display-hint (format #f
+ "~{~a: ~}Consider using
+@code{db-secret-file} instead of @code{db-password} and unset
+@code{db-password} for security in @code{zabbix-front-end-configuration}."
+ (list (location-file location)
+ (location-line location)
+ (location-column location))))
+db-password)) "';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
--
2.20.1
O
O
Oleg Pykhalov wrote on 23 Dec 2018 06:21
Re: [bug#33836] [PATCH 1/2] services: configuration: Add location.
(address . 33836@debbugs.gnu.org)
874lb45nov.fsf@gmail.com
Oleg Pykhalov <go.wigust@gmail.com> writes:

Toggle quote (5 lines)
> * gnu/services/configuration.scm (define-configuration): Add location.
> ---
> gnu/services/configuration.scm | 5 +++++
> 1 file changed, 5 insertions(+)

[…]

After ‘make clean-go’, the ‘make’ command outputs in Guix Git repo:
Toggle snippet (40 lines)
Backtrace:
In ice-9/boot-9.scm:
2994:20 19 (_)
2312:4 18 (save-module-excursion #<procedure a94f060 at ice-9/boo?>)
3014:26 17 (_)
In unknown file:
16 (primitive-load-path "gnu/tests/mail" #<procedure 129f2?>)
In ice-9/eval.scm:
626:19 15 (_ #<directory (gnu tests mail) 16e440a0>)
293:34 14 (_ #<directory (gnu tests mail) 16e440a0>)
163:9 13 (_ #<directory (gnu tests mail) 16e440a0>)
159:9 12 (_ #<directory (gnu tests mail) 16e440a0>)
293:34 11 (_ #<directory (gnu tests mail) 16e440a0>)
214:21 10 (_ #(#(#(#(#(#<directory (gnu tests mail?> ?) ?) ?) ?) ?))
217:50 9 (lp (#<procedure 1103f620 at ice-9/eval.scm:182:7 (e?> ?))
217:50 8 (lp (#<procedure 1103f600 at ice-9/eval.scm:182:7 (e?> ?))
217:50 7 (lp (#<procedure 1103f420 at ice-9/eval.scm:292:11 (?> ?))
217:50 6 (lp (#<procedure 1103f3e0 at ice-9/eval.scm:182:7 (e?> ?))
217:50 5 (lp (#<procedure 1103f3c0 at ice-9/eval.scm:182:7 (e?> ?))
217:50 4 (lp (#<procedure 1103f180 at ice-9/eval.scm:292:11 (?> ?))
217:33 3 (lp (#<procedure 1103f160 at ice-9/eval.scm:182:7 (e?> ?))
155:9 2 (_ #(#(#(#(#(#<directory (gnu tests mail?> ?) ?) ?) ?) ?))
619:8 1 (_ #(#(#(#(#(#(#<directory (gnu tests?> ?) ?) ?) ?) ?) ?))
In ice-9/boot-9.scm:
260:13 0 (for-each #<procedure 11123520 at ice-9/eval.scm:333:1?> ?)

ice-9/boot-9.scm:260:13: In procedure for-each:
Throw to key `srfi-34' with args `(#<condition %compound [message: "Invalid value for field location: #f"] 1106b3e0>)'.

Some deprecated features have been used. Set the environment
variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
program to get more information. Set it to "no" to suppress
this message.
make[2]: *** [Makefile:5576: make-go] Error 1
make[2]: Leaving directory '/home/natsu/src/guix'
make[1]: *** [Makefile:4657: all-recursive] Error 1
make[1]: Leaving directory '/home/natsu/src/guix'
make: *** [Makefile:3273: all] Error 2

Also my GuixSD fails to build. Will try to fix ‘gnu/services/mail.scm’.

Oleg.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAlwfmdAACgkQFn+OpQAa
+pwrpw//ZItpp9I3QDCLDAHomByJzAViMNh+8FGF8IeBwf0OG3qxVN5xlGoKIivM
e977bxYPWbiNjDspnQ1TFfsbxCBcgny1nK4L8M7G4LliIZVizGZec80h5N/MQAMz
ixLNZ3HL0/qSI0XMpvNYqqHKe2fpSKvXY8sMJ37t5Q3A9Eq1MZNzgBjZIrJAZnBd
SaSf1IZmQ+uuAieNCJP9hephBzFqVGqiYOCxQzPfWJIZtyvvk6qwVeGSiiOOXcwn
IbjAR1CndztFot1pGh7gv0nkeh3mZzDCDDtqrCpneZUROqmot8CQtutSLEs88988
nTLiNnVTq6M5ceAwtesRgJLCbCt75eqstcTZ0LZS9SJS0iG7kI0cBslRA8cTiP4Y
yMF4kzfJxrahA6W0BN7QoruZKgC4k/+ABZg9znofNHKGmXSnIbVZX4jf+GlO0hsN
L75NUDVJcB+uOnndYYfeYpmepZRbUsxFp5MbAJCS2zLx1jS1gP2ubdbRrHKwhNny
13G4OhwNAS8O1gdxQRUd55oajyHr/o+3Uv5xBHyFR0jnTmeRvzRvzy/aSZ6stoNG
O5c2+A0Geb+x4m302I2A48v39Q+9AQq0XKQ86WQzhPAqhgWjr16dzzlqwWAdhBIz
J7HEz6HAtE+NzfDbKeFRl/95tVU/MeQoaW0uPvwWCYuiCP+HrG0=
=q19n
-----END PGP SIGNATURE-----

O
O
Oleg Pykhalov wrote on 23 Dec 2018 07:36
[PATCH] services: zabbix-front-end: Show location in messages.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20181223153633.13009-1-go.wigust@gmail.com
* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
gnu/services/monitoring.scm | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

Toggle diff (57 lines)
diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f11..90eda6561 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -29,6 +29,7 @@
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix records)
+ #:use-module (guix utils)
#:use-module ((guix ui) #:select (display-hint))
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
@@ -512,7 +513,7 @@ create it manually.")
(define zabbix-front-end-config
(match-lambda
(($ <zabbix-front-end-configuration>
- _ db-host db-port db-name db-user db-password db-secret-file
+ location _ db-host db-port db-name db-user db-password db-secret-file
zabbix-host zabbix-port)
(mixed-text-file "zabbix.conf.php"
"\
@@ -527,18 +528,25 @@ $DB['DATABASE'] = '" db-name "';
$DB['USER'] = '" db-user "';
$DB['PASSWORD'] = '" (if (string-null? db-password)
(if (string-null? db-secret-file)
- (raise (condition
- (&message
- (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
+ (raise (make-compound-condition
+ (condition
+ (&message
+ (message "\
+you must provide either 'db-secret-file' or 'db-password'")))
+ (condition
+ (&error-location (location location)))))
(string-trim-both
(with-input-from-file db-secret-file
read-string)))
(begin
- (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
- db-password)) "';
+ (display-hint (format #f
+ "~{~a: ~}Consider using
+@code{db-secret-file} instead of @code{db-password} and unset
+@code{db-password} for security in @code{zabbix-front-end-configuration}."
+ (list (location-file location)
+ (location-line location)
+ (location-column location))))
+db-password)) "';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
--
2.20.1
O
O
Oleg Pykhalov wrote on 23 Dec 2018 07:40
[PATCH 1/2] services: configuration: Add location.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20181223154021.14287-1-go.wigust@gmail.com
* gnu/services/configuration.scm (define-configuration): Add location.
* gnu/services/mail.scm (namespace-configuration)[location]: Rename to
'mailbox-location'.
(uglify-field-name): Handle this.
* doc/guix.texi (Mail Services): Document this.
---
doc/guix.texi | 2 +-
gnu/services/configuration.scm | 5 +++++
gnu/services/mail.scm | 11 +++++++----
3 files changed, 13 insertions(+), 5 deletions(-)

Toggle diff (67 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index e254b3859..a6db2461d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14665,7 +14665,7 @@ different for all namespaces. For example @samp{Public/}.
Defaults to @samp{""}.
@end deftypevr
-@deftypevr {@code{namespace-configuration} parameter} string location
+@deftypevr {@code{namespace-configuration} parameter} string mailbox-location
Physical location of the mailbox. This is in the same format as
mail_location, which is also the default for it.
Defaults to @samp{""}.
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 707944cbe..9775f91ff 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -22,6 +22,7 @@
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (guix gexp)
+ #:use-module ((guix utils) #:select (source-properties->location))
#:autoload (texinfo) (texi-fragment->stexi)
#:autoload (texinfo serialize) (stexi->texi)
#:use-module (ice-9 match)
@@ -129,6 +130,10 @@
#,(id #'stem #'% #'stem)
#,(id #'stem #'make- #'stem)
#,(id #'stem #'stem #'?)
+ (location configuration-location
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
(field field-getter (default def))
...)
(define #,(id #'stem #'stem #'-fields)
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index fcaedd038..a8121e5d1 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -75,9 +75,12 @@
(define (uglify-field-name field-name)
(let ((str (symbol->string field-name)))
- (string-join (string-split (if (string-suffix? "?" str)
- (substring str 0 (1- (string-length str)))
- str)
+ (string-join (string-split (cond
+ ((string-suffix? "?" str)
+ (substring str 0 (1- (string-length str))))
+ ((string=? str "mailbox-location")
+ "location")
+ (else str))
#\-)
"_")))
@@ -413,7 +416,7 @@ format.")
"Prefix required to access this namespace. This needs to be
different for all namespaces. For example @samp{Public/}.")
- (location
+ (mailbox-location
(string "")
"Physical location of the mailbox. This is in same format as
mail_location, which is also the default for it.")
--
2.20.1
L
L
Ludovic Courtès wrote on 26 Dec 2018 09:30
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 33836@debbugs.gnu.org)
87d0poci1q.fsf@gnu.org
Hello,

Oleg Pykhalov <go.wigust@gmail.com> skribis:

Toggle quote (6 lines)
> * gnu/services/configuration.scm (define-configuration): Add location.
> * gnu/services/mail.scm (namespace-configuration)[location]: Rename to
> 'mailbox-location'.
> (uglify-field-name): Handle this.
> * doc/guix.texi (Mail Services): Document this.

Nice!

Toggle quote (19 lines)
> --- a/gnu/services/configuration.scm
> +++ b/gnu/services/configuration.scm
> @@ -22,6 +22,7 @@
> #:use-module (guix packages)
> #:use-module (guix records)
> #:use-module (guix gexp)
> + #:use-module ((guix utils) #:select (source-properties->location))
> #:autoload (texinfo) (texi-fragment->stexi)
> #:autoload (texinfo serialize) (stexi->texi)
> #:use-module (ice-9 match)
> @@ -129,6 +130,10 @@
> #,(id #'stem #'% #'stem)
> #,(id #'stem #'make- #'stem)
> #,(id #'stem #'stem #'?)
> + (location configuration-location
> + (default (and=> (current-source-location)
> + source-properties->location))
> + (innate))

What about calling the field ‘%location’ instead? That would avoid the
collision with the other ‘location’ field and it should be fine because
it’s not a field we manually set anyway.

Also, instead of ‘configuration-location’, shouldn’t it be

(id #'stem #'-location)

? That will avoid ending up with one ‘configuration-location’ binding
for each record type.

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 26 Dec 2018 09:31
Re: [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 33836@debbugs.gnu.org)
878t0cchze.fsf@gnu.org
Oleg Pykhalov <go.wigust@gmail.com> skribis:

Toggle quote (3 lines)
> * gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
> messages.

[...]

Toggle quote (7 lines)
> (define zabbix-front-end-config
> (match-lambda
> (($ <zabbix-front-end-configuration>
> - _ db-host db-port db-name db-user db-password db-secret-file
> + location _ db-host db-port db-name db-user db-password db-secret-file
> zabbix-host zabbix-port)

Could you instead use ‘match-record’ here? That way you could avoid
maching the ‘location’ field altogether.

Are there other users of ‘define-configuration’ that match raw records?

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 15 Feb 2019 14:24
Re: [bug#33836] [PATCH 1/2] services: configuration: Add location.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 33836@debbugs.gnu.org)
87k1i0itaj.fsf@gnu.org
Hi Oleg,

A friendly ping! :-)

Ludo’.

Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (44 lines)
> Hello,
>
> Oleg Pykhalov <go.wigust@gmail.com> skribis:
>
>> * gnu/services/configuration.scm (define-configuration): Add location.
>> * gnu/services/mail.scm (namespace-configuration)[location]: Rename to
>> 'mailbox-location'.
>> (uglify-field-name): Handle this.
>> * doc/guix.texi (Mail Services): Document this.
>
> Nice!
>
>> --- a/gnu/services/configuration.scm
>> +++ b/gnu/services/configuration.scm
>> @@ -22,6 +22,7 @@
>> #:use-module (guix packages)
>> #:use-module (guix records)
>> #:use-module (guix gexp)
>> + #:use-module ((guix utils) #:select (source-properties->location))
>> #:autoload (texinfo) (texi-fragment->stexi)
>> #:autoload (texinfo serialize) (stexi->texi)
>> #:use-module (ice-9 match)
>> @@ -129,6 +130,10 @@
>> #,(id #'stem #'% #'stem)
>> #,(id #'stem #'make- #'stem)
>> #,(id #'stem #'stem #'?)
>> + (location configuration-location
>> + (default (and=> (current-source-location)
>> + source-properties->location))
>> + (innate))
>
> What about calling the field ‘%location’ instead? That would avoid the
> collision with the other ‘location’ field and it should be fine because
> it’s not a field we manually set anyway.
>
> Also, instead of ‘configuration-location’, shouldn’t it be
>
> (id #'stem #'-location)
>
> ? That will avoid ending up with one ‘configuration-location’ binding
> for each record type.
>
> Thanks,
> Ludo’.
O
O
Oleg Pykhalov wrote on 28 Feb 2019 14:39
[PATCH 0/2] Apply suggestions.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20190228224001.27182-1-go.wigust@gmail.com
Hello Ludovic,

Apologies for a big delay.

I applied all your suggestions and improved (I hope) text in error and hint.

Oleg Pykhalov (2):
services: configuration: Add '%location'.
services: zabbix-front-end: Show location in messages.

gnu/services/configuration.scm | 5 +++
gnu/services/monitoring.scm | 57 ++++++++++++++++++++--------------
2 files changed, 38 insertions(+), 24 deletions(-)

--
2.20.1
O
O
Oleg Pykhalov wrote on 28 Feb 2019 14:40
[PATCH 1/2] services: configuration: Add '%location'.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20190228224001.27182-2-go.wigust@gmail.com
* gnu/services/configuration.scm (define-configuration): Add '%location'.
---
gnu/services/configuration.scm | 5 +++++
1 file changed, 5 insertions(+)

Toggle diff (25 lines)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 707944cbe0..90f12a8d39 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -22,6 +22,7 @@
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (guix gexp)
+ #:use-module ((guix utils) #:select (source-properties->location))
#:autoload (texinfo) (texi-fragment->stexi)
#:autoload (texinfo serialize) (stexi->texi)
#:use-module (ice-9 match)
@@ -129,6 +130,10 @@
#,(id #'stem #'% #'stem)
#,(id #'stem #'make- #'stem)
#,(id #'stem #'stem #'?)
+ (%location #,(id #'stem #'-location)
+ (default (and=> (current-source-location)
+ source-properties->location))
+ (innate))
(field field-getter (default def))
...)
(define #,(id #'stem #'stem #'-fields)
--
2.20.1
O
O
Oleg Pykhalov wrote on 28 Feb 2019 14:40
[PATCH 2/2] services: zabbix-front-end: Show location in messages.
(address . 33836@debbugs.gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20190228224001.27182-3-go.wigust@gmail.com
* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
gnu/services/monitoring.scm | 57 +++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 24 deletions(-)

Toggle diff (98 lines)
diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f110..101222bf2e 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
;;; Copyright © 2018 Gábor Boskovits <boskovits@gmail.com>
-;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2018, 2019 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,7 +29,8 @@
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix records)
- #:use-module ((guix ui) #:select (display-hint))
+ #:use-module (guix utils)
+ #:use-module ((guix ui) #:select (display-hint G_))
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (srfi srfi-26)
@@ -509,13 +510,12 @@ create it manually.")
(number 10051)
"Zabbix server port."))
-(define zabbix-front-end-config
- (match-lambda
- (($ <zabbix-front-end-configuration>
- _ db-host db-port db-name db-user db-password db-secret-file
- zabbix-host zabbix-port)
- (mixed-text-file "zabbix.conf.php"
- "\
+(define (zabbix-front-end-config config)
+ (match-record config <zabbix-front-end-configuration>
+ (%location db-host db-port db-name db-user db-password db-secret-file
+ zabbix-host zabbix-port)
+ (mixed-text-file "zabbix.conf.php"
+ "\
<?php
// Zabbix GUI configuration file.
global $DB;
@@ -525,20 +525,29 @@ $DB['SERVER'] = '" db-host "';
$DB['PORT'] = '" (number->string db-port) "';
$DB['DATABASE'] = '" db-name "';
$DB['USER'] = '" db-user "';
-$DB['PASSWORD'] = '" (if (string-null? db-password)
- (if (string-null? db-secret-file)
- (raise (condition
- (&message
- (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
- (string-trim-both
- (with-input-from-file db-secret-file
- read-string)))
- (begin
- (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
- db-password)) "';
+$DB['PASSWORD'] = '" (let ((file (location-file %location))
+ (line (location-line %location))
+ (column (location-column %location)))
+ (if (string-null? db-password)
+ (if (string-null? db-secret-file)
+ (raise (make-compound-condition
+ (condition
+ (&message
+ (message
+ (format #f "no '~A' or '~A' field in your '~A' record"
+ 'db-secret-file 'db-password
+ 'zabbix-front-end-configuration))))
+ (condition
+ (&error-location
+ (location %location)))))
+ (string-trim-both
+ (with-input-from-file db-secret-file
+ read-string)))
+ (begin
+ (display-hint (format #f (G_ "~a:~a:~a: ~a:
+Consider using @code{db-secret-file} instead of @code{db-password} for better
+security.") file line column 'zabbix-front-end-configuration))
+ db-password))) "';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
@@ -548,7 +557,7 @@ $ZBX_SERVER_PORT = '" (number->string zabbix-port) "';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
-"))))
+")))
(define %maintenance.inc.php
;; Empty php file to allow us move zabbix-frontend configs to ‘/etc/zabbix’
--
2.20.1
L
L
Ludovic Courtès wrote on 10 Mar 2019 10:21
Re: [bug#33836] [PATCH 0/2] Apply suggestions.
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 33836@debbugs.gnu.org)
87imwq3arw.fsf@gnu.org
Hi Oleg,

Oleg Pykhalov <go.wigust@gmail.com> skribis:

Toggle quote (8 lines)
> Apologies for a big delay.
>
> I applied all your suggestions and improved (I hope) text in error and hint.
>
> Oleg Pykhalov (2):
> services: configuration: Add '%location'.
> services: zabbix-front-end: Show location in messages.

LGTM, thank you!

Ludo’.
O
O
Oleg Pykhalov wrote on 10 Mar 2019 12:51
control message for bug #33836
(address . control@debbugs.gnu.org)
878sxmy0ca.fsf@gmail.com
tags 33836 fixed
close 33836
?
Your comment

This issue is archived.

To comment on this conversation send an email to 33836@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 33836
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch