-
Notifications
You must be signed in to change notification settings - Fork 148
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
symlink local_secret_token.rb to /etc/foreman #2143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does make sense to me, but should we also move an existing local_secret_token.rb to /etc/foreman? Should the current ghost in the datadir be removed? I'm not sure how this can be handled safely though.
6d84f86
to
90dd830
Compare
Thanks @ekohl, I've added a migration
I don't think so, |
90dd830
to
473a205
Compare
rebased |
@@ -1144,6 +1145,17 @@ if [ ! -f %{_datadir}/%{name}/config/initializers/local_secret_token.rb ]; then | |||
chgrp foreman %{_datadir}/%{name}/config/initializers/local_secret_token.rb | |||
%{foreman_rake} security:generate_token >/dev/null 2>&1 || : | |||
chmod 0640 %{_datadir}/%{name}/config/initializers/local_secret_token.rb | |||
mv %{_datadir}/%{name}/config/initializers/local_secret_token.rb %{_sysconfdir}/%{name}/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we ensure the symlink is in place before running the token generation, would that also ensure it's generated in the right place? Ideally that means we can ship a symlink inside the package. We'd need to ensure the current token isn't overwritten though.
85a764c
to
65cee41
Compare
hows that @ekohl ? |
Apologies for the long delay. In b0bc45f I implemented a similar change. By going the Below is my explicit thought process so you can check if I've missed anything.
So: if [ ! -e %{_datadir}/%{name}/config/initializers/local_secret_token.rb ] ; then
touch %{_datadir}/%{name}/config/initializers/local_secret_token.rb
chmod 0660 %{_datadir}/%{name}/config/initializers/local_secret_token.rb
chgrp foreman %{_datadir}/%{name}/config/initializers/local_secret_token.rb
%{foreman_rake} security:generate_token >/dev/null 2>&1 || :
chmod 0640 %{_datadir}/%{name}/config/initializers/local_secret_token.rb
fi
if [ -f %{_datadir}/%{name}/config/initializers/local_secret_token.rb ] ; then
mv %{_datadir}/%{name}/config/initializers/local_secret_token.rb %{_sysconfdir}/%{name}/
fi
if [ ! -e %{_datadir}/%{name}/config/initializers/local_secret_token.rb -a \
-e %{_sysconfdir}/%{name}/local_secret_token.rb ]; then
ln -s %{_sysconfdir}/%{name}/local_secret_token.rb %{_datadir}/%{name}/config/initializers/
fi |
https://projects.theforeman.org/issues/16508 is also interesting to consider in this context but I'd be happy with just implementing this now. |
65cee41
to
90e13b3
Compare
Yup - thanks does make sense, thanks @ekohl 👍 |
touch %{_datadir}/%{name}/config/initializers/local_secret_token.rb | ||
chmod 0660 %{_datadir}/%{name}/config/initializers/local_secret_token.rb | ||
chgrp foreman %{_datadir}/%{name}/config/initializers/local_secret_token.rb | ||
%{foreman_rake} security:generate_token >/dev/null 2>&1 || : | ||
chmod 0640 %{_datadir}/%{name}/config/initializers/local_secret_token.rb | ||
fi | ||
if [ -f %{_datadir}/%{name}/config/initializers/local_secret_token.rb ] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 796febe I fixed an oversight I had: -f
dereferences symlinks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you have a look at the -f
comment?
Thanks for the reminder, updated.. |
So I think the only thing I don't like here is that the token is still generated in datadir and then moved to sysconfdir, but such is life. ACK |
theforeman/foreman#5553 should make that easier. |
Thanks! |
Looks like this caused an issue with building. From http://koji.katello.org/kojifiles/work/tasks/8811/98811/build.log:
|
Currently we have:
It'd would be nice to also have
local_secret_token.rb