READ ONLY FORUM: m23 :: makes software distribution easy Forum Index READ ONLY FORUM: m23 :: makes software distribution easy
The m23 discussion forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Client name resolution of m23 server

 
Post new topic   Reply to topic    READ ONLY FORUM: m23 :: makes software distribution easy Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
TheGuv



Joined: 29 Oct 2010
Posts: 11

PostPosted: Wed Nov 17, 2010 9:32    Post subject: Client name resolution of m23 server Reply with quote

Basically I'm lazy Wink

When adding some remote servers using the assimilate function, I noticed that the clients DNS couldn't resolve the m23 servers FQDN as it was an internal domain resolved within the m23 domain by split-horizon DNS. The m23 server and remote clients are connected via VPN.

I could have manually edited all the clients hosts file to add the appropriate IP address, or...

Code:

--- client.php.bak   2010-11-16 16:09:20.000000000 +0000
+++ client.php   2010-11-17 11:24:25.000000000 +0000
@@ -631,6 +631,7 @@
    else
       {
          SERVER_addEtcHosts($data['client'], $data['ip']);
+                        CLIENT_addSvrEtcHosts($data['ip'], $data['rootpassword'], $_SERVER[SERVER_NAME], gethostbyname($_SERVER[SERVER_NAME]));
          PKG_addJob($data['client'],"m23Assimilate",0,"");
          PKG_addJob($data['client'],"m23Presetup",1,"assimilate");
          PKG_addJob($data['client'],"m23UpdatePackageInfos",2,"");
@@ -3427,4 +3428,27 @@
    
 system($cmd);
 };
+
+
+/**
+**name CLIENT_addSvrEtcHosts($ip, $pw, $s_name, $s_ip)
+**description Connects to a client over the Putty SSH client and add the servers ip
+**            into the clients /etc/hosts file in case the client cannot resolve
+**            the servers ip via DNS.
+**parameter ip: ip address of the client
+**parameter pw: Password for root on the client
+**parameter s_name: Servers FQDN
+**parameter s_ip: Servers IP address
+**/
+function CLIENT_addSvrEtcHosts($ip, $pw, $s_name, $s_ip)
+{
+
+$cmd="
+/m23/bin/plink-no_ask -pw $pw -l root $ip \"if grep -q m23 /etc/hosts; then exit; fi; echo -e '\n# Automatically added by m23\n$s_ip $s_name\n' >> /etc/hosts\"
+";
+
+system($cmd);
+
+
+}
 ?>


This patch adds an additional function CLIENT_addSvrEtcHosts which will use plink-no-ask to run a remote job on the client to add the m23 servers IP into the clients host file, if it does not already exist.

It's pretty ugly but does the job for me. It may be useful to someone else. It should really test the client DNS as well to check if the m23 server is already resolvable by the client, or at least be an option on the assimilate page.

EDIT: Fixup to use the correct key for $data
--
TheGuv


Last edited by TheGuv on Wed Nov 17, 2010 13:20; edited 2 times in total
Back to top
View user's profile Send private message
Hauke



Joined: 02 Mar 2003
Posts: 1072

PostPosted: Wed Nov 17, 2010 11:22    Post subject: Reply with quote

Hi,

thank you for the patch Very Happy

The m23 clients call the m23 server by its IP and this should work on a VPN too. How is HTTP(S) communication possible from m23 client to m23 server, if the FQDN is needed in your shared host environment (that is what you are running m23 on?)?

Did you make other changes too?
_________________
Hauke Goos-Habermann
- project leader m23 (http://m23.sf.net) -
Jabber: dodgerm23@jabber.org

Schulung, Entwicklung und Support zu m23 und anderen OpenSource-Produkten: www.goos-habermann.de

Auch DU kannst etwas gegen Softwarepatente tun! www.patentfrei.de
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TheGuv



Joined: 29 Oct 2010
Posts: 11

PostPosted: Wed Nov 17, 2010 13:10    Post subject: Reply with quote

Hauke wrote:


The m23 clients call the m23 server by its IP

Did you make other changes too?


Ah yes, sorry. Calling the server by its IP Address does not work for a multihomed web server using name-based virtual hosts, so I used a name rather than IP for the server.

--
TheGuv
Back to top
View user's profile Send private message
Hauke



Joined: 02 Mar 2003
Posts: 1072

PostPosted: Wed Nov 17, 2010 16:49    Post subject: Reply with quote

How do you do this?

Did you edit getServerIP to return a FQDN?
_________________
Hauke Goos-Habermann
- project leader m23 (http://m23.sf.net) -
Jabber: dodgerm23@jabber.org

Schulung, Entwicklung und Support zu m23 und anderen OpenSource-Produkten: www.goos-habermann.de

Auch DU kannst etwas gegen Softwarepatente tun! www.patentfrei.de
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TheGuv



Joined: 29 Oct 2010
Posts: 11

PostPosted: Thu Nov 18, 2010 7:34    Post subject: Reply with quote

Hauke wrote:

Did you edit getServerIP to return a FQDN?


Yes exactly. I've currently got it hard coded to what I need, but ideally this could maybe be a config option? On the dedicated m23 server it wouldn't be a problem, but for those like me who installed the .debs onto an existing multi-homed, virtual hosted server, it may well be.

--
TheGuv
Back to top
View user's profile Send private message
Hauke



Joined: 02 Mar 2003
Posts: 1072

PostPosted: Sat Nov 20, 2010 10:43    Post subject: Reply with quote

Ok, I understand. Quick and dirty Cool

Maybe I will add it in a later version, but this would be even more complicated to support Wink
_________________
Hauke Goos-Habermann
- project leader m23 (http://m23.sf.net) -
Jabber: dodgerm23@jabber.org

Schulung, Entwicklung und Support zu m23 und anderen OpenSource-Produkten: www.goos-habermann.de

Auch DU kannst etwas gegen Softwarepatente tun! www.patentfrei.de
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    READ ONLY FORUM: m23 :: makes software distribution easy Forum Index -> Bugs All times are GMT - 2 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group