From a8a3cc00fdad74029966c057e078d89c6444c8a7 Mon Sep 17 00:00:00 2001 From: Sergey Mironov Date: Sun, 31 Mar 2013 12:27:46 +0400 Subject: [PATCH] wicd: fix dhclient interaction wicd used to write dhclient config file into $out/var/lib/wicd directory attempting to change nix-store. That didn't work and thats why we couldn't use dhclient. With this patch wicd will generate temporary file name for this purpose. File is generated each time the daemon starts. --- pkgs/tools/networking/wicd/default.nix | 9 +- pkgs/tools/networking/wicd/dhclient.patch | 101 ++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/networking/wicd/dhclient.patch diff --git a/pkgs/tools/networking/wicd/default.nix b/pkgs/tools/networking/wicd/default.nix index 6cacfc14ffc..9bb4d6461fa 100644 --- a/pkgs/tools/networking/wicd/default.nix +++ b/pkgs/tools/networking/wicd/default.nix @@ -16,7 +16,14 @@ stdenv.mkDerivation rec { buildInputs = [ python ]; - patches = [ ./no-var-install.patch ./no-trans.patch ./mkdir-networks.patch ./pygtk.patch ./no-optimization.patch ]; + patches = [ + ./no-var-install.patch + ./no-trans.patch + #./mkdir-networks.patch + ./pygtk.patch + ./no-optimization.patch + ./dhclient.patch + ]; # Should I be using pygtk's propogated build inputs? # !!! Should use makeWrapper. diff --git a/pkgs/tools/networking/wicd/dhclient.patch b/pkgs/tools/networking/wicd/dhclient.patch new file mode 100644 index 00000000000..52d91846518 --- /dev/null +++ b/pkgs/tools/networking/wicd/dhclient.patch @@ -0,0 +1,101 @@ +diff -ruN wicd-1.7.2.4.orig/wicd/wnettools.py wicd-1.7.2.4/wicd/wnettools.py +--- wicd-1.7.2.4.orig/wicd/wnettools.py 2013-03-30 21:47:19.804907552 +0000 ++++ wicd-1.7.2.4/wicd/wnettools.py 2013-03-31 08:44:37.572792110 +0000 +@@ -37,6 +37,7 @@ + import time + from string import maketrans, translate + ++import tempfile + import wpath + import misc + from misc import find_path +@@ -216,6 +217,7 @@ + self.flush_tool = None + self.link_detect = None + self.dhcp_object = None ++ self.dhclient_conf_path = None; + + def SetDebugMode(self, value): + """ If True, verbose output is enabled. """ +@@ -277,12 +279,6 @@ + cmd = "" + return (client, cmd) + +- # probably /var/lib/wicd/dhclient.conf with defaults +- dhclient_conf_path = os.path.join( +- wpath.varlib, +- 'dhclient.conf' +- ) +- + client_dict = { + "dhclient" : + {'connect' : r"%(cmd)s -cf %(dhclientconf)s %(iface)s", +@@ -307,41 +303,44 @@ + } + (client_name, cmd) = get_client_name(self.DHCP_CLIENT) + +- # cause dhclient doesn't have a handy dandy argument +- # for specifing the hostname to be sent +- if client_name == "dhclient" and flavor: +- if hostname == None: +- # will use the system hostname +- # we'll use that if there is hostname passed +- # that shouldn't happen, though +- hostname = '' +- print 'attempting to set hostname with dhclient' +- print 'using dhcpcd or another supported client may work better' +- dhclient_template = \ +- open(os.path.join(wpath.etc, 'dhclient.conf.template'), 'r') +- +- output_conf = open(dhclient_conf_path, 'w') +- +- for line in dhclient_template.readlines(): +- line = line.replace('$_HOSTNAME', hostname) +- output_conf.write(line) +- +- output_conf.close() +- dhclient_template.close() +- os.chmod(dhclient_conf_path, 0644) +- + if not client_name or not cmd: + print "WARNING: Failed to find a valid dhcp client!" + return "" + + if flavor == "connect": ++ # cause dhclient doesn't have a handy dandy argument ++ # for specifing the hostname to be sent ++ if client_name == "dhclient" and flavor: ++ if hostname == None: ++ # will use the system hostname ++ # we'll use that if there is hostname passed ++ # that shouldn't happen, though ++ hostname = '' ++ print 'attempting to set hostname with dhclient' ++ print 'using dhcpcd or another supported client may work better' ++ if not self.dhclient_conf_path: ++ _,self.dhclient_conf_path = tempfile.mkstemp() ++ print 'New dhclient conf path: %s ' % self.dhclient_conf_path ++ dhclient_template = \ ++ open(os.path.join(wpath.etc, 'dhclient.conf.template'), 'r') ++ ++ output_conf = open(self.dhclient_conf_path, 'w') ++ ++ for line in dhclient_template.readlines(): ++ line = line.replace('$_HOSTNAME', hostname) ++ output_conf.write(line) ++ ++ output_conf.close() ++ dhclient_template.close() ++ os.chmod(self.dhclient_conf_path, 0644) ++ + if not hostname: + hostname = os.uname()[1] + return client_dict[client_name]['connect'] % \ + { "cmd" : cmd, + "iface" : self.iface, + "hostname" : hostname, +- 'dhclientconf' : dhclient_conf_path } ++ 'dhclientconf' : self.dhclient_conf_path } + elif flavor == "release": + return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface} + else: