This commit breaks Nginx support by reverting the settings.php to the cloaked version on backup task: http://git.aegirproject.org/?p=provision.git;a=commitdiff;h=87a405afdf2e...

CommentFileSizeAuthor
#15 955184.patch620 bytesmig5
#14 955184.patch646 bytesmig5
#11 955184.patch632 bytesmig5

Comments

Anonymous’s picture

Can I get some more information? / an example?

It only reverts the settings.php back to being cloaked if cloaking was previously enabled.

If cloaking was not enabled at all, it won't re-cloak.

omega8cc’s picture

The bug is introduced by forcing cloaking.
I just tested it a few times with Nginx.
The logic must be wrong somehow.
I'm trying to debug it now.

Anonymous’s picture

It of course assumes cloaking, because that is TRUE by default.

So it will only ignore all that if you had cloaking turned off in your drushrc.php

I can't see where I've gone wrong, staring at the code.

It also doesn't make sense why would this only break nginx? I did a LOT of testing on Apache.

But I trust you! So do let me know what you find.

omega8cc’s picture

The problem is, the provision_db_cloaking is not stored anywhere.
So you can't fetch it using drush_get_option() probably.

Anonymous’s picture

I still don't follow.

It's enabled by default, and has been for a long time.

that's why the code says 'if (drush_get_option('provision_db_cloaking', TRUE)'

eg: 'if it's enabled, and if it's not been set, then consider it enabled'

You have to set '$options['provision_db_cloaking'] = FALSE;' in your drushrc.php for it to consider this 'off' and not cloak.

This is by design

But if you didn't have it set in your drushrc.php, your settings.php *must* have been cloaked already, so that is why I'm confused by what you mean.

omega8cc’s picture


  function cloaked_db_creds() {
    return TRUE;
  }

This is how it is set, but only in the apache_service.inc

In the nginx_service.inc it is not used (there is no return FALSE).

No idea how it should be fetched correctly.

Anonymous’s picture

Maybe what you're saying is that nginx bypasses the cloaking altogether.

If that's the case, then nginx should also patch the drushrc.php to inject '$options['provision_db_cloaking'] = FALSE' into every site drushrc.php, in my opinion

(the alternative is to have the backup task check whether nginx or apache is in use, and i don't think that's the correct way to do it. If nginx is a special case, nginx should make a special exception) (Edit: that said, I don't know how to do that)

omega8cc’s picture

No, it worked fine and I don't need to set it to OFF because it is set to ON only in the Apache service context.
It was *never* set/wrote in drushrc.php

Anonymous’s picture

Right, so it means I was right in #7. (bypasses it completely).

I'll look into how to force cloaking off in nginx. i still think making a clause in the backup task itself is wrong

Anonymous’s picture

Got a patch ready, standby..

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new632 bytes

Please test. (reverify the nginx sites. 'provision_db_cloaking' should be then set to FALSE in the drushrc.php)

Anonymous’s picture

Hold up on that, sorry.

I don't like the idea of injecting FALSE into the drushrc.php (what if the site gets migrated to an apache server, then its credentials are exposed).

I'll have another patch shortly.

omega8cc’s picture

It wrote $options['provision_db_cloaking'] = false; in drushrc.php but it didn't help. Cloaking is still forced on/after backup. Also, it shouldn't be required to verify the site before it will work, so I'm not sure if writing it to drushrc.php is the correct way to fix it.

Anonymous’s picture

StatusFileSize
new646 bytes

new patch! sorry again.

Now we load whether cloaking is enabled or disabled based on the service, but we don't write anything to the drushrc.php, that's smarter I think.

It now matches the way the settings.php is written on verifies, installs etc.

Anonymous’s picture

StatusFileSize
new620 bytes

And another patch, I was on crack with that service check

This one *has* to work, cloaked is TRUE or FALSE here, simple as that :)

omega8cc’s picture

It didn't help, sorry, it still rewrites settings.php with cloaked credentials.

Anonymous’s picture

Wow ok. Totally not what I'm seeing.

Can you make sure that $options['provision_db_cloaking'] = false; it injected earlier is removed? and try another backup.

I guess if it still doesn't help I'll just revert this one, despite the fact I can't reproduce.

omega8cc’s picture

Wait! I tried it again on the clean install and it worked! http://drupal.org/files/issues/955184_1.patch

Anonymous’s picture

Yep so I think I basically just screwed you over with the earlier patch.

If you don't mind, please run a couple more tests until you're confident with it, I don't want to commit it and mess you up again

omega8cc’s picture

Just tested it again on another clean install. Works! Many thanks, Miguel!

Just to confirm twice, the working patch is http://drupal.org/files/issues/955184_1.patch

Anonymous’s picture

Status: Needs review » Needs work

Now I am seeing weird results too.

If I edit the drushrc.php and put false, and backup, it rewrites the settings.php with cloaked.

If i edit the drushrc.php, and put false, and VERIFY, and backup, it leaves them uncloaked.

so a verify is required in between. weird

omega8cc’s picture

I don't know if/how that works with Apache now, but with your latest patch (one patch only) I don't need to verify the site or put anything in drushrc.php, it just works on the backup task as expected.

Anonymous’s picture

I have definitely broken it for Apache unless I verify first. I don't understand what difference the verify makes, so I'm just going to revert this.

You can keep the patch in yours I guess.

Sorry, another migression out of a migression

omega8cc’s picture

Doh, so we fixed it for Nginx by breaking it for Apache? I believe it is worth to debug it so it will work for both. Please don't revert anything yet, I will try to find a workaround.

Anonymous’s picture


  // Check if we are currently cloaking credentials
  $cloaked = d()->service('http')->cloaked_db_creds();
  $cloaked = drush_get_option('provision_db_cloaking', $cloaked);
  dlm($cloaked);
  if ($cloaked) {
    drush_set_option('cloaking_off_temp', TRUE);
    // Disable the cloaking of credentials temporarily
    drush_log(dt("Temporarily uncloaking database credentials for backup"));
    drush_set_option('provision_db_cloaking', FALSE);

    // Write the uncloaked credentials to the settings.php
    _provision_drupal_create_settings_file();
  }

Where that dlm is, it should return false here because $options['provision_db_cloaking'] = FALSE; is in the drushrc.php of the site.

But it returns true, as if it doesn't care, or because the default is TRUE (apache), it overrides that. that is not how I understand drush_get_option to work.

you say it isn't the same for you but earlier in #16 you said you continued to try and backup the site you were testing with and it kept writing the cloaks. I believe you also encountered this here, that's the same issue. (it only started working for you on new sites).

omega8cc’s picture

Hmm.. in #16 I wrote it didn't work because I tried it on the instance where I tried previous patches without reverting them, so the results could be messed. Now it appears it works for Nginx with your latest patch only because it stopped to work for Apache. I must admit I'm a bit lost with all this cascading context stuff (see http://drupal.org/node/955224) and I believe it should be just written in the server options, like it is now for other options we have for Nginx:

  'nginx_has_gzip' => 1,
  'nginx_has_upload_progress' => 1,
  'nginx_has_new_version' => 1,

Then we could fetch cloaking flag just by drush_get_option() as you did initially.

Well, let me add this for Nginx so it will work with your backup stuff for Apache.

Anonymous’s picture

The point is that I *should* be able to fetch drush_set_option from the site context and see it's false, but it returns true.

it returned false before, so it should still.

I wonder if it doesn't like the two definitions of $cloaked. I just don't know what to believe anymore :)

Anonymous’s picture

Status: Needs work » Fixed

Oh!

I just realised why this is occurring.

If you :

1) install site
2) set provision_db_cloaking off in the settings.php
3) backup site

I thought it was *re-cloaking* the settings.php here, but in fact it works: it sees the drushrc saying 'we don't cloak!' and so it completely ignores the settings.php and doesn't rewrite it. It leaves it as it is: and it is still cloaked because it was cloaked on install (default = TRUE in apache service)

So I think it's the correct behaviour. It can only assume what drushrc says matches what the site is (if it says its false, it ought to assume the settings.php is uncloaked and not tamper with it).

Thats why a verify helped: the settings.php got rewritten on verify to match what was in the drushrc. I thought from thereon that the backup worked as normal, but it's the same story again: saw that it's not meant to be cloaked, so didn't tamper with the settings.php

with such a setting as cloaking, if you are setting it to false in the drushrc, you *must* reverify the site to apply that change (otherwise what's the point), and then you'll see correct behaviour.

So I was wrong about being wrong (!). I'll commit that fix.

Mig

Anonymous’s picture

Status: Fixed » Needs work

Edit: removed, I am on crack and keep being wrong about being wrong.

Avoiding the computer for a while..

Anonymous’s picture

Status: Needs work » Fixed
adrian’s picture

i put in that patch a while ago to make it possible to override even what the web service required about cloaking.

it only happens when the config is regenerated though, and i dont believe that backup generates a config by itself.

the code i had was like this :

    $cloaked = $this->context->service('http')->cloaked_db_creds();
    $cloaked = drush_get_option('provision_db_cloaking', $cloaked);

so it would get what http service said, then it would try to use drush_get_option to override that with the http service' return
value used as the default.

Once again, this was only happening when _provision_drupal_create_settings_file() is called, as it's built into the config class.

Anonymous’s picture

Yes I ended up making the backup logic the same as that.

All good I think. Sigh

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 519ca74 on debian, dev-koumbit, dev-migrate_aliases, dev-multiserver-install, dev-simplerinstaller, prod-koumbit, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x by mig5:
    #955184 - fix backup so that it inherits the cloaking policy of the...