Bug 265255 - net-mgmt/unbound_exporter rc.d script causes failure to start when ssl configuration is empty
Summary: net-mgmt/unbound_exporter rc.d script causes failure to start when ssl config...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-16 20:56 UTC by Joël Bohnes
Modified: 2022-12-20 12:46 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (aduitsis)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joël Bohnes 2022-07-16 20:56:09 UTC
In our configuration we have have unbound and unbound_exporter running in the same jail. The unbound remote-control is listening on a plain (unencrypted) tcp socket.

Section in unbound.conf looks something like this:
--- unbound.conf ---
remote-control:
        control-enable: yes
        control-interface: 127.0.0.1
        control-use-cert: "no"
---

This configuration is supported by unbound_exporter, but it's a bit awkward because it requires passing an empty string in the command line. The correct, working command line looks like this:

  unbound_exporter -unbound.cert "" -unbound.ca "" <...>

If we try to use the rc.d script provided by the unbound_exporter port, we can try using following settings:
--- /etc/rc.conf ---
unbound_exporter_enable="YES"
unbound_exporter_ca=""
unbound_exporter_cert=""
unbound_exporter_key=""
---

However this will fail with the following error:

--- /var/log/unbound_exporter.log ---
time="2022-07-16T22:12:56+02:00" level=info msg="Starting unbound_exporter" source="unbound_exporter.go:478"
panic: open -unbound.cert: no such file or directory

goroutine 1 [running]:
main.main()
        github.com/kumina/unbound_exporter/unbound_exporter.go:481 +0x485
---

The failing command that the init script executes looks like this:
  unbound_exporter -unbound.cert -unbound.ca <...>

When using command_args in the init script, it seems a bit difficult to pass empty strings
along (which is a feature of shellscript).

We used to following (nasty?) patch to fix the rc.d script.
---
--- /usr/local/etc/rc.d/unbound_exporter.original    2022-07-16 22:12:50.062388470 +0200
+++ /usr/local/etc/rc.d/unbound_exporter      2022-07-16 22:12:09.073708468 +0200
@@ -46,9 +46,9 @@
 command=/usr/sbin/daemon
 procname="/usr/local/bin/unbound_exporter"
 command_args="-p ${pidfile} /usr/bin/env ${procname} \
-                               -unbound.ca ${unbound_exporter_ca} \
-                               -unbound.cert ${unbound_exporter_cert} \
-                               -unbound.key ${unbound_exporter_key} \
+                               -unbound.ca '\"'${unbound_exporter_ca}'\"' \
+                               -unbound.cert '\"'${unbound_exporter_cert}'\"' \
+                               -unbound.key '\"'${unbound_exporter_key}'\"' \
                                -web.listen-address ${unbound_exporter_bind} \
                                 ${unbound_exporter_args} > ${unbound_exporter_log_file} 2>&1"
---
Comment 1 commit-hook freebsd_committer freebsd_triage 2022-12-20 12:44:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3574d6718e7ff5f064960914f963801708d21cfd

commit 3574d6718e7ff5f064960914f963801708d21cfd
Author:     Thomas Morper <thomas@beingboiled.info>
AuthorDate: 2022-12-20 12:35:55 +0000
Commit:     Dmitri Goutnik <dmgk@FreeBSD.org>
CommitDate: 2022-12-20 12:43:59 +0000

    net-mgmt/unbound_exporter: Update to 0.4.1

    * Update to 0.4.1
    * Update repo location
    * Simplify Makefile by using GO_MODULE rather than GH_TUPLE
    * Add missing SUB_LIST to Makefile
    * Re-factor init script

    Changes:        https://github.com/letsencrypt/unbound_exporter/releases/tag/v0.4.1

    PR:             267609
    PR:             265255
    Approved by:    aduitsis@cpan.org (maintainer timeout, > 1 month)

 UPDATING                                           |  8 +++
 net-mgmt/unbound_exporter/Makefile                 | 24 ++------
 net-mgmt/unbound_exporter/distinfo                 | 28 ++-------
 .../unbound_exporter/files/pkg-message.in (new)    | 11 ++++
 .../unbound_exporter/files/unbound_exporter.in     | 66 +++++++++-------------
 5 files changed, 57 insertions(+), 80 deletions(-)
Comment 2 Dmitri Goutnik freebsd_committer freebsd_triage 2022-12-20 12:46:09 UTC
Fixed by bug #267609