Commit 6c88ba24 authored by anarcat's avatar anarcat

fix migration to ip-per-cert

we are now associating with the server IP correctly
parent 0f5c071e
...@@ -265,37 +265,28 @@ function hosting_server_update_6201() { ...@@ -265,37 +265,28 @@ function hosting_server_update_6201() {
/** /**
* Migrate site-specific IPs to server-specific IPs. * Migrate site-specific IPs to server-specific IPs.
* *
* This is the meat of the migration path. * We inject into the new certificate to IP mapping table the correct
* associations, by looking at the server IPs matching the IPs allocated to
* sites.
*/ */
function hosting_server_update_6202() { function hosting_server_update_6202() {
$ret = array(); $ret = array();
/* now we need to insert a IP/ssl cert mapping in here
here's a request that gives a list of IP/site/key mapping:
SELECT n.nid,ip_address, site.status, title, ssl_enabled, cid, c.ssl_key /* this is rather complicated:
FROM hosting_ssl_site s *
INNER JOIN hosting_ssl_cert c ON c.cid = s.ssl_key * we need to first find the SSL certificate of the site, then look at the
INNER JOIN node n ON n.nid = s.nid * IP of the sites with SSL certs, match that IP with the IP of a server (we
INNER JOIN hosting_ip_addresses ip ON ip.nid = n.nid * assume it's the same server!).
INNER JOIN hosting_site site ON site.nid = n.nid */
WHERE site.status > 0 $ret[] = update_sql("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address)
ORDER BY c.cid, n.nid; SELECT cid, server_ip.nid FROM {hosting_ssl_site} ssl_site
INNER JOIN {hosting_ssl_cert} cert ON cert.cid = ssl_site.ssl_key
SELECT ip_address, cid, c.ssl_key FROM hosting_ssl_site s INNER JOIN hosting_ssl_cert c ON c.cid = s.ssl_key INNER JOIN hosting_ip_addresses ip ON ip.nid = s.nid INNER JOIN hosting_site site ON site.nid = s.nid WHERE site.status > 0 GROUP BY cid ORDER BY c.cid, s.nid; INNER JOIN {hosting_ip_addresses} site_ip ON site_ip.nid = ssl_site.nid
INNER JOIN {hosting_site} site ON site.nid = ssl_site.nid
*/ INNER JOIN {hosting_ip_addresses} server_ip ON server_ip.ip_address = site_ip.ip_address
INNER JOIN {node} servers ON server_ip.nid = servers.nid
// XXX: this is broken, as it inserts the site-specific IP instead of the WHERE ssl_enabled > %d AND site.status > %d AND servers.type = 'server'
// server-level IP. that IP gets removed in the next update, so this fucks GROUP BY cid ORDER BY cert.cid, site.nid",
// up.
$ret[] = update_sql("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address)
SELECT cid, ip.id FROM {hosting_ssl_site} s
INNER JOIN {hosting_ssl_cert} c ON c.cid = s.ssl_key
INNER JOIN {hosting_ip_addresses} ip ON ip.nid = s.nid
INNER JOIN {hosting_site} site ON site.nid = s.nid
INNER JOIN {hosting_platform} p ON p.nid = site.platform
WHERE ssl_enabled > %d AND site.status > %d
GROUP BY cid ORDER BY c.cid, s.nid",
HOSTING_SSL_DISABLED, HOSTING_SITE_DELETED); HOSTING_SSL_DISABLED, HOSTING_SITE_DELETED);
return $ret; return $ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment