Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed when/where the pidfile of daemons gets created #928

Conversation

alaaeddineelamri
Copy link
Contributor

@alaaeddineelamri alaaeddineelamri commented Sep 17, 2021

Description:

Fix for CVE-2017-14610 vulnerability, where PID files could be exploited on certain systems under certain circumstances.

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)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
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
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing

@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 3 times, most recently from 030b322 to c4367dd Compare September 17, 2021 15:49
@pstorz pstorz force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 2 times, most recently from 9b0bb1f to b4aaab5 Compare September 19, 2021 18:06
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

Good work. We should check if we want to switch the man page creation for the daemons also to be created by sphinx.

core/src/dird/dird.cc Outdated Show resolved Hide resolved
core/src/lib/daemon.h Outdated Show resolved Hide resolved
core/src/stored/stored.cc Outdated Show resolved Hide resolved
core/src/stored/stored.cc Outdated Show resolved Hide resolved
core/src/stored/stored.cc Outdated Show resolved Hide resolved
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from 752dae7 to fb73c9b Compare September 21, 2021 10:50
CHANGELOG.md Outdated Show resolved Hide resolved
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 3 times, most recently from a382e73 to 57abb93 Compare September 21, 2021 14:51
@alaaeddineelamri alaaeddineelamri marked this pull request as ready for review September 22, 2021 09:05
@alaaeddineelamri alaaeddineelamri marked this pull request as draft September 23, 2021 08:56
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from c43af60 to 9c638e7 Compare October 4, 2021 15:34
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.

This looks good and very much like what we had discussed.
I have two main areas of concern left:

  • when running with -f we still accept -p but ignore it, we should either write the pidfile correctly or deny a combination of -f and -p.
  • on Windows we accept -p and then simply ignore it. Maybe we shouldn't accept it in the first place.

Other than that, I would delegate writing the file to daemon_start() and DeletePidFile() can be made even simpler.

core/src/lib/bsys.cc Outdated Show resolved Hide resolved
core/src/lib/region_locking.cc Outdated Show resolved Hide resolved
core/src/lib/region_locking.h Outdated Show resolved Hide resolved
core/src/stored/stored.cc Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 3 times, most recently from 55ef5eb to 699eba8 Compare October 12, 2021 11:52
@alaaeddineelamri alaaeddineelamri marked this pull request as ready for review October 14, 2021 09:16
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 6 times, most recently from 50451d1 to 9b8892d Compare October 21, 2021 11:35
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 2 times, most recently from 2edef52 to 72a2407 Compare October 25, 2021 10:59
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.

I have two minor remarks, mostly concerning messages and documentation.

Before merging the PR, we should also create a matching security advisory in GitHub that we can link to from the CHANGELOG.md. (I'll take care of that)

core/src/filed/filed.cc Outdated Show resolved Hide resolved
core/src/lib/bsys.cc Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from 4f528a6 to 37bcc7b Compare November 9, 2021 11:57
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.

This looks great.
I think we should change the docs, so the user knows that the directive Pid Directory won't have an effect anymore.
Other than that, I hope I can finish the Security Advise tomorrow, so we can finally merge this.

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.

I think we can go one step further with the documentation. I think it is enough if the modern (i.e. 21+) documentation states that this has no effect anymore and tells you how to do it with the parameter.

Comment on lines 1 to 7
This directive is optional and specifies a directory in which the Director may put its process Id file. The process Id file is used to shut down Bareos and to prevent multiple copies of Bareos from running simultaneously. Standard shell expansion of the Directory is done when the configuration file is read so that values such as $HOME will be properly expanded.

The PID directory specified must already exist and be readable and writable by the Bareos daemon referencing it.

Typically on Linux systems, you will set this to: :file:`/var/run`. If you are not installing Bareos in the system directories, you can use the Working Directory as defined above.

As of bareos 21, this directive is deprecated. The way to set up a pid file is to do it as an option to the Director binary with the ``-p <file>`` option, where <file> is the path to a pidfile of your choosing. By default, no pidfile is created.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This directive is optional and specifies a directory in which the Director may put its process Id file. The process Id file is used to shut down Bareos and to prevent multiple copies of Bareos from running simultaneously. Standard shell expansion of the Directory is done when the configuration file is read so that values such as $HOME will be properly expanded.
The PID directory specified must already exist and be readable and writable by the Bareos daemon referencing it.
Typically on Linux systems, you will set this to: :file:`/var/run`. If you are not installing Bareos in the system directories, you can use the Working Directory as defined above.
As of bareos 21, this directive is deprecated. The way to set up a pid file is to do it as an option to the Director binary with the ``-p <file>`` option, where <file> is the path to a pidfile of your choosing. By default, no pidfile is created.
Since :sinceVersion:`21.0.0` this directive has no effect anymore. The way to set up a pid file is to do it as an option to the Director binary with the ``-p <file>`` option, where <file> is the path to a pidfile of your choosing. By default, no pidfile is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, but shouldn't we keep the old description for users of previous versions?

@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch 3 times, most recently from ad7d2f3 to 8f8884e Compare November 17, 2021 10:27
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.

The headers in daemon.cc and daemon.h need the newer year.
But the elephant in the room is all the occurances of "Pid Directory" in test- and example-configurations.
I'll take a look at that if you don't mind.

@@ -38,7 +38,10 @@

Copy link
Member

Choose a reason for hiding this comment

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

year in the header is 2020, should be 2021

@@ -21,6 +21,6 @@
#ifndef BAREOS_LIB_DAEMON_H_
Copy link
Member

Choose a reason for hiding this comment

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

year in the header is 2020, should be 2021

@arogge arogge force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from 8f8884e to 9978b97 Compare November 22, 2021 14:37
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

I have some comments that may be discussed.

core/platforms/slackware/functions.bareos.in Outdated Show resolved Hide resolved
core/scripts/bareos-ctl-funcs Outdated Show resolved Hide resolved
core/src/dird/dird_conf.cc Outdated Show resolved Hide resolved
core/src/dird/dird.cc Outdated Show resolved Hide resolved
core/src/filed/filed.cc Outdated Show resolved Hide resolved
core/manpages/bareos-fd.8 Show resolved Hide resolved
core/manpages/bareos-dir.8 Outdated Show resolved Hide resolved
core/manpages/bareos-fd.8 Outdated Show resolved Hide resolved
core/manpages/bareos-sd.8 Outdated Show resolved Hide resolved
core/manpages/bareos-sd.8 Show resolved Hide resolved
@arogge arogge requested a review from pstorz November 29, 2021 15:27
@arogge arogge force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from 1577092 to b5fbe68 Compare November 30, 2021 11:13
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

Good work!

alaaeddineelamri and others added 10 commits November 30, 2021 20:40
The default is now not to create a pidfile. Daemons can be run with
parameter `-p <file>` where <file> is the full path to a pidfile that
should be created.

Previously pidfiles were created in a rather unsafe manner in a location
determined by Bareos' parameters.
This patch deprecates the now unused `Pid Directory` directives and
removes the default value.
this patch removes all occurences of Pid Directory from every
configuration file and template.
@arogge arogge force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from b5fbe68 to dc0b568 Compare November 30, 2021 20:08
@arogge arogge force-pushed the dev/alaaeddineelamri/master/issue-847-pid-file-creation branch from dc0b568 to 9764f61 Compare November 30, 2021 20:10
@arogge arogge merged commit 421078e into bareos:master Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants