birdc configure exits with 0 on error
Ondrej Zajicek
santiago at crfreenet.org
Fri Mar 11 04:07:41 CET 2022
On Thu, Mar 10, 2022 at 07:38:56PM +0100, Vincent Bernat wrote:
> Hey!
>
> "birdc configure" (or any command in fact) exits with 0 on error. This
> is a bit annoying as when using "systemctl reload bird", we get no
> notification there is an error.
>
> Looking at the source code, it seems there is no easy way to hack around
> that. Commands do not report an error code and messages printed are not
> tagged as errors.
Hi
There are reply codes that signal errors, but they are not propagated to
birdc exit code, which is silly. Here is a quick fix:
https://gitlab.nic.cz/labs/bird/-/commit/9b0b2c0d410fd26e1b48d158a667e42f4bbec52c
Perhaps it would make sense to have multiple exit codes to distinguish
classes of errors (socket errors / syntax errors / runtime errors).
With this, we likely do not need "ExecReload=/usr/sbin/bird -p" from your patch?
(But the remaining changes for RPM are ok.)
> >From 5cbc487c4d54033c688258a5361377f72f53c264 Mon Sep 17 00:00:00 2001
> From: Vincent Bernat <vincent at bernat.ch>
> Date: Thu, 10 Mar 2022 19:36:53 +0100
> Subject: [PATCH] Pkg: check configuration before reloading with systemd
>
> Also, update the RPM version to use "birdc configure" instead of "kill
> -HUP".
> ---
> distro/pkg/deb/bird2.bird.service | 1 +
> distro/pkg/rpm/bird.service | 4 +++-
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/distro/pkg/deb/bird2.bird.service b/distro/pkg/deb/bird2.bird.service
> index 37e75fb41c6a..ae48f7f46cfa 100644
> --- a/distro/pkg/deb/bird2.bird.service
> +++ b/distro/pkg/deb/bird2.bird.service
> @@ -6,6 +6,7 @@ After=network.target
> EnvironmentFile=/etc/bird/envvars
> ExecStartPre=/usr/lib/bird/prepare-environment
> ExecStartPre=/usr/sbin/bird -p
> +ExecReload=/usr/sbin/bird -p
> ExecReload=/usr/sbin/birdc configure
> ExecStart=/usr/sbin/bird -f -u $BIRD_RUN_USER -g $BIRD_RUN_GROUP $BIRD_ARGS
> Restart=on-abort
> diff --git a/distro/pkg/rpm/bird.service b/distro/pkg/rpm/bird.service
> index fa203c781905..aa6e12dc5489 100644
> --- a/distro/pkg/rpm/bird.service
> +++ b/distro/pkg/rpm/bird.service
> @@ -5,8 +5,10 @@ After=network.target
>
> [Service]
> Type=simple
> +ExecStartPre=/usr/sbin/bird -p
> ExecStart=/usr/sbin/bird -f -u bird -g bird
> -ExecReload=/bin/kill -HUP $MAINPID
> +ExecReload=/usr/sbin/bird -p
> +ExecReload=/usr/sbin/birdc configure
> Restart=on-failure
>
> [Install]
> --
> 2.35.1
>
> --
> Keep it simple to make it faster.
> - The Elements of Programming Style (Kernighan & Plauger)
--
Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
More information about the Bird-users
mailing list