[debian-edu-commits] debian-edu/pkg-team/ 01/02: debian/patches: Add 1001_fix-renaming-hosts.patch. Correctly update NIS netgroup memberships when a system gets renamed. (Closes: #741434).

Mike Gabriel sunweaver at debian.org
Wed Oct 21 04:21:37 UTC 2015


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository gosa-plugin-netgroups.

commit 632c98eb4c6114bf964960560db45272cbf23537
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Oct 21 06:17:03 2015 +0200

    debian/patches: Add 1001_fix-renaming-hosts.patch. Correctly update NIS netgroup memberships when a system gets renamed. (Closes: #741434).
---
 debian/patches/1001_fix-renaming-hosts.patch | 57 ++++++++++++++++++++++++++++
 debian/patches/series                        |  1 +
 2 files changed, 58 insertions(+)

diff --git a/debian/patches/1001_fix-renaming-hosts.patch b/debian/patches/1001_fix-renaming-hosts.patch
new file mode 100644
index 0000000..9688723
--- /dev/null
+++ b/debian/patches/1001_fix-renaming-hosts.patch
@@ -0,0 +1,57 @@
+Description: Correctly pertain NIS netgroup memberships when renaming a system
+Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+
+--- a/admin/systems/netgroups/class_netgroupSystem.inc
++++ b/admin/systems/netgroups/class_netgroupSystem.inc
+@@ -248,9 +248,21 @@
+  	 * */
+ 	function save() 
+ 	{
++
++		$orig_cn= $this->cn;
++
++		/* Set cn if we have been created or renamed */
++		if ($this->is_new){
++			$this->cn= preg_replace('/^cn=([^,]+),.*/', '$1', $this->dn);
++		}
++
+ 		// If nothing has changed, just return
+-		if(! (array_diff(array_keys($this->initial_netgroups), array_keys($this->netgroups)) ||
+-			array_diff(array_keys($this->netgroups), array_keys($this->initial_netgroups)))){
++		if(
++		   (! (array_diff(array_keys($this->initial_netgroups), array_keys($this->netgroups)) ||
++		       array_diff(array_keys($this->netgroups), array_keys($this->initial_netgroups)))) &&
++		    ($this->cn===$orig_cn)
++		   )
++		{
+ 			return;
+ 		}
+ 
+@@ -266,6 +278,27 @@
+ 		foreach($to_add as $dn){
+ 			$ng = new netgroup($this->config, $dn);
+ 			$ng->addTriple($this->cn, NULL, "", $this->attrs);
++			if($orig_cn!==$this->cn) {
++				/* The below code handles correct removal of NIS netgroup triples
++				 * when a system's hostname gets renamed.
++				 *
++				* FIXME: This will fail if hostname and DNS zone get changed
++				* at the same time.
++				*/
++				if(strpos($orig_cn, ".") === FALSE){
++					$domain = $this->getDNSZoneForHost($this->cn);
++					if(!$domain){
++						msg_dialog::display(_("Failure when modifying NIS netgroup memberships for renamed system"), sprintf(_("Unable to detect FQDN for host '%s'!"), $this->cn), WARNING_DIALOG);
++					}
++					$host= $orig_cn;
++				}else{
++					$domain = preg_replace("/^[^\.]*+\./", "", $this->cn);
++					$host = preg_replace("/\..*/", "", $orig_cn);
++				}
++				if($domain) {
++					$ng->removeTriple($host.".".$domain);
++				}
++			}
+ 			$ng->save();
+ 		}
+ 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..1d693e7
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+1001_fix-renaming-hosts.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/gosa-plugin-netgroups.git



More information about the debian-edu-commits mailing list