mirrors: move ocfstats db password to a file#925
Merged
Conversation
OCFSTATS_PWD was showing up in fallingrocks' root crontab as an environment variable and got leaked on stream. This change moves it to a file which protects it from these kinds of leaks. The __FILE suffix for environment variables is borrowed from Grafana's convention. Tested and working on fallingrocks.
Contributor
Errored hosts (0)Changed hosts (1)Unaffected hosts (130)Changed hostsdiff for fallingrocks.ocf.berkeley.edu*******************************************
Cron[mirrors-stats] =>
parameters =>
environment =>
- ["OCFSTATS_PWD=dummypassword"]
+ ["OCFSTATS_PWD__FILE=/opt/ocfstats-password"]
*******************************************
+ File[/opt/ocfstats-password] =>
parameters =>
"backup": "main",
"content": "dummypassword",
"group": "root",
"mode": "0600",
"owner": "root",
"show_diff": false
*******************************************
File[/usr/local/sbin/collect-mirrors-stats] =>
parameters =>
content =>
@@ -16,5 +16,5 @@
from ocflib.lab.stats import humanize_bytes
_
-OCFSTATS_PWD = os.environ.get('OCFSTATS_PWD', None)
+OCFSTATS_PWD = open(os.environ.get('OCFSTATS_PWD__FILE')).read().strip()
MIRRORS_DATA_PATH = Path('/opt/mirrors/ftp')
APACHE_LOG_PATH = Path('/var/log/apache2')
*******************************************Unaffected hosts |
jvperrin
approved these changes
Mar 28, 2020
Member
jvperrin
left a comment
There was a problem hiding this comment.
IMO just hardcoding the path in the script would be fine too, it doesn't need to be this dynamic, but this is fine too.
ja5087
approved these changes
Mar 28, 2020
cg505
approved these changes
Mar 28, 2020
Member
cg505
left a comment
There was a problem hiding this comment.
imo you may as well use ocf::privatefile here, but it doesn't matter either way really. I also agree that the path may as well be hardcoded.
abizer
approved these changes
Apr 16, 2020
Contributor
Errored hosts (1)Changed hosts (1)Unaffected hosts (130)Errored hostserror for nyx.ocf.berkeley.eduChanged hostsdiff for fallingrocks.ocf.berkeley.edu*******************************************
Cron[mirrors-stats] =>
parameters =>
environment =>
- ["OCFSTATS_PWD=dummypassword"]
+ ["OCFSTATS_PWD__FILE=/opt/ocfstats-password"]
*******************************************
+ File[/opt/ocfstats-password] =>
parameters =>
"backup": "main",
"content": "dummypassword",
"group": "root",
"mode": "0600",
"owner": "root",
"show_diff": false
*******************************************
File[/usr/local/sbin/collect-mirrors-stats] =>
parameters =>
content =>
@@ -16,5 +16,5 @@
from ocflib.lab.stats import humanize_bytes
_
-OCFSTATS_PWD = os.environ.get('OCFSTATS_PWD', None)
+OCFSTATS_PWD = open(os.environ.get('OCFSTATS_PWD__FILE')).read().strip()
MIRRORS_DATA_PATH = Path('/opt/mirrors/ftp')
APACHE_LOG_PATH = Path('/var/log/apache2')
*******************************************Unaffected hosts |
Contributor
Errored hosts (1)Changed hosts (2)Unaffected hosts (129)Errored hostserror for nyx.ocf.berkeley.eduChanged hostsdiff for fallingrocks.ocf.berkeley.edu*******************************************
Cron[mirrors-stats] =>
parameters =>
environment =>
- ["OCFSTATS_PWD=dummypassword"]
+ ["OCFSTATS_PWD__FILE=/opt/ocfstats-password"]
*******************************************
+ File[/opt/ocfstats-password] =>
parameters =>
"backup": "main",
"content": "dummypassword",
"group": "root",
"mode": "0600",
"owner": "root",
"show_diff": false
*******************************************
File[/usr/local/sbin/collect-mirrors-stats] =>
parameters =>
content =>
@@ -16,5 +16,5 @@
from ocflib.lab.stats import humanize_bytes
_
-OCFSTATS_PWD = os.environ.get('OCFSTATS_PWD', None)
+OCFSTATS_PWD = open(os.environ.get('OCFSTATS_PWD__FILE')).read().strip()
MIRRORS_DATA_PATH = Path('/opt/mirrors/ftp')
APACHE_LOG_PATH = Path('/var/log/apache2')
*******************************************diff for pestilence.ocf.berkeley.edu*******************************************
Exec[systemctl-daemon-reload] =>
parameters =>
path =>
- /opt/puppetlabs/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+ /opt/share/utils/bin:/opt/share/utils/sbin:/usr/local/sbin:/usr/local/bin:/opt/puppetlabs/bin:/usr/sbin:/usr/bin:/sbin:/bin
*******************************************Unaffected hosts |
Contributor
Errored hosts (0)Changed hosts (1)Unaffected hosts (130)Changed hostsdiff for fallingrocks.ocf.berkeley.edu*******************************************
Cron[mirrors-stats] =>
parameters =>
environment =>
- ["OCFSTATS_PWD=dummypassword"]
+ ["OCFSTATS_PWD__FILE=/opt/ocfstats-password"]
*******************************************
+ File[/opt/ocfstats-password] =>
parameters =>
"backup": "main",
"content": "dummypassword",
"group": "root",
"mode": "0600",
"owner": "root",
"show_diff": false
*******************************************
File[/usr/local/sbin/collect-mirrors-stats] =>
parameters =>
content =>
@@ -16,5 +16,5 @@
from ocflib.lab.stats import humanize_bytes
_
-OCFSTATS_PWD = os.environ.get('OCFSTATS_PWD', None)
+OCFSTATS_PWD = open(os.environ.get('OCFSTATS_PWD__FILE')).read().strip()
MIRRORS_DATA_PATH = Path('/opt/mirrors/ftp')
APACHE_LOG_PATH = Path('/var/log/apache2')
*******************************************Unaffected hosts |
ethanwu10
added a commit
that referenced
this pull request
Jan 17, 2023
* fix(mirrors): reload nginx when certs change Previously, nginx was not picking up renewed certs. * refactor(mirrors): move+use variable for ocfstats password Some history: the variable was introduced in #169 when stat tracking was added, but #925 changed the implementation and didn't use the variable any more (probably because it was so far away from where it was used). This commit moves it next to where it is used now.
singingtelegram
pushed a commit
that referenced
this pull request
Apr 30, 2023
* fix(mirrors): reload nginx when certs change Previously, nginx was not picking up renewed certs. * refactor(mirrors): move+use variable for ocfstats password Some history: the variable was introduced in #169 when stat tracking was added, but #925 changed the implementation and didn't use the variable any more (probably because it was so far away from where it was used). This commit moves it next to where it is used now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OCFSTATS_PWDwas showing up in fallingrocks' root crontab as an environment variable and got leaked on stream. This change moves it to a file which protects it from these kinds of leaks. The__FILEsuffix for environment variables is borrowed from Grafana's convention.Tested and working on fallingrocks.