This commit in my git HEAD clone on GitHub should fix that: http://github.com/omega8cc/hostmaster/commit/983a0ee8aeca7e079453a88543d...

Comments

omega8cc’s picture

To create broken site or duplicate simply use DOMAIN.COM instead of domain.com in the site create form. This commit is trying to add strtolower(trim(domain)) also for aliases. Maybe there is too many strtolower(trim(domain)) now, please review this if possible.

anarcat’s picture

Priority: Normal » Critical

Indeed, that's a bug. Not sure we need to fix it in all those places, but I don't think it would hurt and it would be safer. I think this is a critical bug, marking as such.

Anonymous’s picture

Terrifyingly, I don't even have to change the capitalisation to duplicate a site node with the same name.

I can install '4.mig5-forge.net' and '4.mig5-forge.net' (identical) and get a duplicate entry error and a new site node + site install task.

Yikes. This definitely did not use to be the case.

adrian’s picture

this actually works fine for me on head, but this puzzles me :

function hosting_site_allow_domain($url, $params = array()) {
  $query = "SELECT COUNT(n.nid) FROM {node} n 
    JOIN {hosting_site} h ON n.nid = h.nid
    WHERE type='site' AND title='%s' AND h.status <> %d ";
  $args[] = $url;
  $args[] = HOSTING_SITE_DELETED;

 // WTF IS THIS DOING ?  
  if (isset($params['client'])) {
    $query .= ' AND h.client <> %d';
    $args[] = $params['client'];
  }

  if (isset($params['nid'])) {
    $query .= ' AND n.nid <> %d';
    $args[] = $params['nid'];
  }
  $result = !db_result(db_query($query, $args));
  return $result;
}

The client bit is basically saying that the client can create the same site twice, as long as the site belongs to him ?
this code comes from pre-git days.

adrian’s picture

Status: Active » Fixed

confirmed that was the error.

my test site was owned by a different client, but it was allowing you to create multiple copies of the site for the same client.

[master 842e252] Logic error allowing a client to create multiple copies of the same site. #949044
1 files changed, 0 insertions(+), 5 deletions(-)

it was also being done for aliases. there it was even stranger. the logic was allowing the user to create an alias for a site, that is the same value as the that for one of the other sites it owns, including the site proper. Meaning it was attempting to allow you to have the vhost loading to have a crapshoot about which alias was used, based on the alphabetical precedence of the parent site.

[master e90196d] incorrect logic for clients and aliases. same issue as #949044
1 files changed, 0 insertions(+), 5 deletions(-)

This seems to have come in with the old ports stuff - http://is.gd/gAeVX , which has since been changed significantly.

I believe the original intention was something along the lines of not allowing another site to create an alias or a new site running on a different port from yours.
ie: another client couldnt create clientsite.com:8080 on top of the existing site clientsite.com.

That's all irrelevant now, with the new port system.

Anonymous’s picture

Holy cow!

Thanks for figuring all that out :)

Status: Fixed » Closed (fixed)

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

anarcat’s picture

omega8cc’s picture

Status: Closed (fixed) » Needs review

I found even more missing strtolower(trim(domain)) allowing to still create duplicates or causing errors on tasks instead of denying the task to be queued:

Force lowercase also in the hosting_task_clone_form_validate()
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/1683056

Force lowercase also in the hosting_task_migrate_form_validate()
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/a176911

Force lowercase also in the hosting_site_drush_context_import()
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/b5cd953

anarcat’s picture

Status: Needs review » Needs work

Some of those are weird for me:

   $url = strtolower(trim($form_state['values']['parameters']['new_uri'])); // domain names are case-insensitive
-  if ($url != $site->title) {
+  $form_state['values']['parameters']['new_uri'] = $url; // force lowercase

Why assign the url back to the form values?! Why not just:

if (strtolower($url) != $site->title) {

?

omega8cc’s picture

One of those patches may look weird, but it was for readability, and it did fixed the problem, I tested it, but maybe it should be changed.

anarcat’s picture

The patches should be fixed - i think they shouldn't modify the $forms array, and the comment is wrong (the assignment doesn't turn into lowercase). I do not feel the resulting code is more readable, for me at least.

omega8cc’s picture

OK, I will fix that asap.

omega8cc’s picture

Status: Needs work » Needs review

Fixed - I hope!

Force lowercase comparison also in the clone and migrate forms:
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/7243837

Force lowercase also in the hosting_site_drush_context_import()
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/b5cd953

anarcat’s picture

Status: Needs review » Fixed

imported both commits in stable and master branches. please don't include the "BOA" prefix or "(grace)" suffix in commit logs, as then i can't cherry-pick them directly...

Status: Fixed » Closed (fixed)

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

omega8cc’s picture

Status: Closed (fixed) » Needs work

I just discovered that it is again possible to create broken site with CAPS in the domain name on Clone and/or Migrate. So my weird initial patches fixed this but I failed to test it again after I changed the patches later, as suggested.

omega8cc’s picture

The problem is that currently the domain name is converted to lowercase only in the front-end, while CAPS are still send as-is to the backend, which results with CAPS in the site directory name, in the drush alias etc. This ends with "successful" Clone task, but then immediately fails on Import/Verify, because of lower/CAPS mismatch between frontend and backend.

omega8cc’s picture

Status: Needs work » Needs review

Finally it is fixed properly:

Add strtolower(trim(domain)) also in function drush_hosting_migrate_pre_hosting_task()
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/51a5423c700f68...

Add strtolower(trim(domain)) also in function drush_hosting_clone_pre_hosting_task()
http://drupalcode.org/sandbox/omega8cc/1074912.git/commit/9ad2655681e22e...

anarcat’s picture

Status: Needs review » Fixed

merged in 2.x and 1.x

Status: Fixed » Closed (fixed)

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

  • Commit c9ad4f5 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    Logic error allowing a client to create multiple copies of the same site...
  • Commit 2adaef6 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    incorrect logic for clients and aliases. same issue as #949044
    

  • Commit c9ad4f5 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    Logic error allowing a client to create multiple copies of the same site...
  • Commit 2adaef6 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    incorrect logic for clients and aliases. same issue as #949044