Skip to content

don't alter configuration on package updates#2338

Merged
BareosBot merged 19 commits intomasterfrom
dev/joergs/master/config-once
Oct 10, 2025
Merged

don't alter configuration on package updates#2338
BareosBot merged 19 commits intomasterfrom
dev/joergs/master/config-once

Conversation

@joergsteffens
Copy link
Member

@joergsteffens joergsteffens commented Aug 6, 2025

Thank you for contributing to the Bareos Project!

Currently, how Bareos is handling configuration files differs between platforms.
On most platform, the default configuration is stored in a configtemplatedirectory, like /usr/lib/bareos/defaultconfigs/ (Debian, macOS, Windows). Until now, RPM-based systems have the configuration directly stored at /etc/bareos.

This PR also stores the default configuration in /usr/lib/bareos/defaultconfigs/.
Currently it uses deploy_config to initially deply the configuration, but this will change soon.

See bareos/internal#318

  • when packages contain additional configuration file for other packages (or example configuration files), it is not guaranteed that these packages are copied into the live configuration. In doubt, they are only available in the defaultconfigs directory. => doc: don't alter configuration on package updates #2392
  • documentation needs to be adapted => doc: don't alter configuration on package updates #2392
  • breaking change needs to be documented in release-notes, also mention that configuration files may seem changed even when they are not (because of the copying during upgrade)

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Required backport PRs have been created
  • Correct milestone is set
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

@joergsteffens joergsteffens self-assigned this Aug 6, 2025
@joergsteffens joergsteffens force-pushed the dev/joergs/master/config-once branch from 98f143c to 169a66f Compare August 26, 2025 15:41
@joergsteffens joergsteffens force-pushed the dev/joergs/master/config-once branch 2 times, most recently from 6c0a0fb to 3a21ba9 Compare September 5, 2025 17:48
@joergsteffens joergsteffens marked this pull request as ready for review September 5, 2025 17:51
@joergsteffens joergsteffens requested a review from arogge September 8, 2025 20:23
@arogge arogge added this to the 25.0.0 milestone Sep 9, 2025
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks pretty weird, but good.
I have a few remarks, that should be addressed and I haven't yet tried it.

Comment on lines +19 to +20
BAREOS_DIRECTOR_USER=${BAREOS_DIRECTOR_USER-@dir_user@}
BAREOS_DIRECTOR_GROUP=${BAREOS_DIRECTOR_GROUP-@dir_group@}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that doesn't look right

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? After I changed some cmake settings, @dir_user@ etc. is set also for the systemtests directory. Therefore it has been required to set them to "". However, these scripts still set the configured @dir_user@ and only use "", if :- was changed to -
So there is a reason to make this change. Do you propose another approach?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed to keep it like this for now and change it in some other PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand what was agreed to be kept, the proposed changes?
If we keep the actual code :-VAR I'm ok.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we keep the change from this PR, so ${BAREOS_DIRECTOR_GROUP-@dir_group@}.
We need it, as BAREOS_DIRECTOR_GROUP (and others) can be set to "". With :- it would use the default value (@dir_group@), with : it will use "". The need the second behavior. However, once #2383 is implemented, this is no longer required.

Comment on lines +2 to +3
lib/bareos/defaultconfigs/bareos-dir.d/storage/NULL.conf.example
lib/bareos/defaultconfigs/bareos-sd.d/device/NULL.conf.example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use %%BAREOS_CONFIG_TEMPLATE_DIR%%

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +9 to +11
lib/bareos/defaultconfigs/bareos-dir.d/storage/Tape.conf.example
lib/bareos/defaultconfigs/bareos-sd.d/autochanger/autochanger-0.conf.example
lib/bareos/defaultconfigs/bareos-sd.d/device/tapedrive-0.conf.example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use %%BAREOS_CONFIG_TEMPLATE_DIR%%

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -1,3 +1,3 @@
/usr/local/lib/libbareossd-fifo.so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have an absolute path here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@joergsteffens joergsteffens force-pushed the dev/joergs/master/config-once branch 2 times, most recently from bc9401a to 85a51e2 Compare October 3, 2025 18:03
@joergsteffens joergsteffens requested a review from arogge October 3, 2025 18:10
@joergsteffens joergsteffens force-pushed the dev/joergs/master/config-once branch 3 times, most recently from 55abd0c to 962664d Compare October 4, 2025 08:43
Copy link
Contributor

@bruno-at-bareos bruno-at-bareos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work, I found a few possible improvements, like rpm variables.

On testing on Debian there's a few issue like warning that pop-up due to missing files

chmod: cannot access '/etc/bareos/bareos-dir-export//*/*.conf': No such file or directory

(there's a double / we should fix everywhere in bareos-config-libs

 /usr/lib/bareos/scripts/bareos-config deploy_config --add-missing bareos-fd
'/usr/lib/bareos/defaultconfigs/bareos-fd.d//./director/bareos-dir.conf' -> '/etc/bareos/bareos-fd.d/./director/bareos-dir.conf'
'/usr/lib/bareos/defaultconfigs/bareos-fd.d//./messages/Standard.conf' -> '/etc/bareos/bareos-fd.d/./messages/Standard.conf'Info: replacing 'XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX' in /etc/bareos/bareos-fd.d/director/bareos-dir.conf

To be documented:

  • All use case like the removal of a component will not remove the whole configuration.

Re-Adding a component will not by default check if there's a missing or changed file, you will have to run the command manually

/usr/lib/bareos/scripts/bareos-config deploy_config --add-missing bareos-fd

see also internal/issue/467


# check if variables are set via cmdline else set them to default values

include(GNUInstallDirs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that will also work on Windows, as we had an if contrib/CMakeLists.txt before ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my tests, this seams to work well. Have you any specific doubt what could break? I've seen, these has be used differently at different places in the code. I tried to use it only once.

Comment on lines +19 to +20
BAREOS_DIRECTOR_USER=${BAREOS_DIRECTOR_USER-@dir_user@}
BAREOS_DIRECTOR_GROUP=${BAREOS_DIRECTOR_GROUP-@dir_group@}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand what was agreed to be kept, the proposed changes?
If we keep the actual code :-VAR I'm ok.

%define backend_dir %{_libdir}/%{name}/backends
%define plugin_dir %{_libdir}/%{name}/plugins
%define script_dir /usr/lib/%{name}/scripts
%define working_dir /var/lib/%{name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
%define working_dir /var/lib/%{name}
%define working_dir %{_sharedstatedir}/%{name}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not using libdir is valid not using sharedstatedir doesn't rely on something valid from my point of view.
Of course we still can skip boyscout rule and let that in place for another decade ;-)

@bruno-at-bareos bruno-at-bareos linked an issue Oct 7, 2025 that may be closed by this pull request
@bruno-at-bareos
Copy link
Contributor

It would be the good time to fix also the don't set address with localhost under debian, so pg connection will be using socket instead tcp

diff --git i/core/scripts/bareos-config-lib.sh.in w/core/scripts/bareos-config-lib.sh.in
index 2e34b4018..81fc0aba6 100644
--- i/core/scripts/bareos-config-lib.sh.in
+++ w/core/scripts/bareos-config-lib.sh.in
@@ -1137,7 +1137,10 @@ apply_dbconfig_settings()
   [ "${dbc_install}" = "true" ] && [ "${dbc_upgrade}" = "true" ] || return 0

   if [ -n "${dbc_dbserver}" ]; then
-    set_config_param "bareos-dir" "Catalog" "MyCatalog" "dbaddress" "${dbc_dbserver}"
+    # Set the address only if not localhost, so local connection use socket
+    if [ "${dbc_dbserver}" != "localhost" ]; then
+      set_config_param "bareos-dir" "Catalog" "MyCatalog" "dbaddress" "${dbc_dbserver}"
+    fi
   fi

   if [ -n "${dbc_dbuser}" ]; then

@bruno-at-bareos
Copy link
Contributor

Last point on FreeBSD (maybe other) running an --add-missing on bareos-dir component show a missing line return

...
/usr/local/etc/bareos/bareos-dir.d/./storage/File.conf not overwrittenchmod: /usr/local/etc/bareos/bareos-dir-export//*/*.conf: No such file or directory

Copy link
Contributor

@bruno-at-bareos bruno-at-bareos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I would have enjoyed to see applying some variables changes like _rundir and _sharedstatedir
All the tests made have worked.

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

based on FreeBSD man page pkg-script the script order on upgrade is:
     1.   new pre-install
     2.   old pre-deinstall
     3.   replace binaries
     4.   new post-install

Based on this, we implemented saving the old configuration
(@sample files that are no longer defined) before they got deleted by
post-deinstall.

Spoiler:
this does not work, as on upgrade the old package gots complete removed,
including running post-deinstall, before any script of the new package
is called.
Config files in Bareos <= 24 are marked as @sample files.
With Bareos 25 we use "bareos-config deploy_config --init" instead
to initially populate the config directory.
Unfortenatly, unmodified @sample files get removed during the upgrade
process.
FreeBSD first fully removes the old package and than install
the new new.
The order is (at least on FreeBSD 14):
* pkg-pre-deinstall — from old package
* Remove files from old package
* pkg-post-deinstall — from old package
* pkg-pre-install — from new package
* Install files of the new package
* pkg-post-install — from new package

As workaround, when upgrading from Bareos < 24,
the redeploy missing files from the new package.
To keep track of this, a marker file is created:
"${BAREOS_CONFIG_DIR}/.${COMPONENT}.deploy_config.version"
deploy_config --add-missing is only called (in pkg-post-install)
when either this file does not exist
or the version number in there is < 25.
When communicating with a local PostgreSQL database server,
it is advised to use a socket connection instead of TCP.
When dbaddress is not set in the Bareos Catalog configuration,
Bareos tries connects via sockets. If it is set, it connects via TCP.
As dbconfig-common by default specifies "localhost"
for a local PostgreSQL database, we ignore this setting.
@joergsteffens joergsteffens force-pushed the dev/joergs/master/config-once branch from 436434d to 7d7f995 Compare October 10, 2025 08:30
@joergsteffens joergsteffens added the requires no backport This will not be backported label Oct 10, 2025
@BareosBot BareosBot merged commit 7f7c510 into master Oct 10, 2025
3 of 4 checks passed
@BareosBot BareosBot deleted the dev/joergs/master/config-once branch October 10, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires no backport This will not be backported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bareos-filedaemon: Debian package re-creates deleted config file during upgrade

5 participants