Following http://drupal.org/node/336431, we have thought important to allow the administrator to control how users are created. Right now, users are created like 'site_N'@'%' (where N is the site id), we want to allow the admin to control that '%', which we'll call the 'Mysql client'. There are a few possibilities here:
1. status quo: % by default, not configurable
2. enter a host (% or localhost or whatever.example.com) (current situation in AlternC)
3. configurable list of hosts (% or localhost or localhost,whatever.example.com,web2.example.com...)
4. (3.) + automatically generated list of hosts based on the active webserver nodes, or even depending on where the site is
We'd like to have (4), ideally, but we can settle for (2) or (3) for now.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | aegir_provision_grant.patch | 2.21 KB | anarcat |
| #10 | aegir_hosting_dbclient.patch | 5.77 KB | anarcat |
| #10 | aegir_provision_dbclient.patch | 2.25 KB | anarcat |
| #9 | aegir_hosting_dbclient.patch | 5.85 KB | anarcat |
| #8 | aegir_provision_dbclient.patch | 2.69 KB | anarcat |
Comments
Comment #1
anarcat commentedTrying to push this through the agenda, by trying to make the allowed host customizable per database server. This would be an extra field in the dbserver configuration and would be implemented by 0.2.
Comment #2
adrian commentedthe host shouldn't be configured in the db server
it's per web server.
the database server needs access rules for each of the web servers connecting to it.
Comment #3
anarcat commentedYeah well, that's step 4. I'm merely proposing we implement step 2, in the webserver, right now, so that admins can configure it manually for now. Then, we can make that list automatically generated.
Comment #4
anarcat commentedIn which context would this be stored? In what would would that be passed to the context the first time round?
Comment #5
anarcat commentedI'm going to start work, at least on the frontend. I would welcome advice on where to pass this to the backend.
Comment #6
anarcat commentedSo here's my first stab at it. I was about to hack at the
hook_pre_hosting_task()(inhosting_db_server.drush.inc) to propagatedb_clientsdown to the backend, but actually, this is too messy. I think it's much cleaner to do this the proper way and create the users based on the webserver hostname... So I'm just uploading this to share a temporary patch, but I'm basically not taking the path of option 2 here.Comment #7
anarcat commentedSo we will be creating grants based on the webserver hostname or the IP, depending on wether or not the DB server supports DNS, which should be a setting that gets propagated to the backend. Right now I think it's safer to assume that the db server does *not* support DNS and resolve the webserver hostname (gethostbyname()) before creating the GRANT.
Basically, then, when a site_N is created on webserver A (ip 10.0.0.1) and db server D (ip 10.0.0.10), the following GRANT is created on D:
Then we will stumble again upon this issue in 0.3, with multiple server support. The typical problematic use cases are this:
migrating from a single-server to multiple-server setup
By default, the first "webserver" discovered by Aegir is called "localhost". This will be highly problematic if we base GRANT on the webserver hostname in split web/db server environment.
So say we're migrating the database from localhost to dbserver D, we'll first need to rename the webserver node to its FQDN (`hostname -f`). Then we need to fix the following grants on D:
And remove the grants on localhost:
migrating a site to another web server
Apart from the regular migrate, we'll also need to REVOKE the old GRANT and create a new one. Maybe a direct manipulation of the "mysql" database would be simpler.
So say we're migrating from webserver A to webserver B (10.0.0.2), the following will need to be ran on dbserver D:
migrating a site to another database server
Less common, but still possible, this will be more tricky. A full database dump will be required, which should include GRANTs for the new site. Furthermore, the old GRANT should be removed.
So say we're migrating site N from dbserver D to E, this will need to be ran on E (assuming the site is now on webserver B):
This will need to be ran on D:
Comment #8
anarcat commentedSo here's another way to put it. This patch will create grants solely for the webserver associated with the site (the "web_host"). I tested it on my localhost server, I still need to test it on a split server.
The trick here is that some database servers (most highend servers in fact) will not resolve hostnames so while "localhost" will work "www.example.com" will not and we need to create grants based on the IP. I have code for that in the frontend and the backend, but I still have to figure out how to pass it in between. I know it's somewhere in
hosting_db_server.drush.incbut I don't think i can access the DB settings from there...Comment #9
anarcat commentedActually, i think i figured it out. The patch on provision is unchanged.
Comment #10
anarcat commentedActually, I messed up both patches, so I'm uploading new clean copies.
Adrian brought up the good point that the webserver IP should probably be stored in the webserver itself and passed along, but I consider that an optimization that could be outside this patch.
Comment #11
anarcat commentedSo i was wrong: mysql doesn't care about DNS if you provide the IP. So all that resolve_dns cruft should be removed. The lookups then can be moved upwards to platform verification.
Comment #12
anarcat commentedSo here's a reroll of the patch, without the resolvedns kludges. It only applies to provision now, and assumes that the webserver will somehow resolve the IP eventually, which would need to be rolled into another patch.
Comment #13
anarcat commentedActually, there's already a web_ip field, oddly enough. We just need to make the default resolve it. I have made it resolve in the hook_load() instead of the hook_validate() (because the latter wasn't working, for some reason). This has the disadvantage of trying to resolve the hostname numerous times if it doesn't resolve the first time the webserver is configured, but it's a good stopgap measure for now.
Comment #14
anarcat commentedSo this is becoming too trivial. I just committed a fix. Needs testing.
http://drupal.org/cvs?commit=205194
http://drupal.org/cvs?commit=205198
Comment #16
anarcat commentedtagging this old issue