Skip to content

/ Zope / gocept svn checkins / Archive / 2008 / 2008-10 / SVN: r6903 - in gocept.infrastructure/feature_networking_66071: . portage-gocept/app-backup/gocept-backup portage-gocept/app-backup/gocept-backup/files puppet/manifests/classes puppet/modules/app_admin/files puppet/modules/app_admin/manifests puppet/modules/app_admin/templates puppet/modules/net_analyzer/files/nagios puppet/modules/net_analyzer/files/nagios/globals puppet/modules/net_analyzer/manifests puppet/modules/net_analyzer/templates puppet/modules/sys_apps/files puppet/modules/sys_apps/manifests puppet/modules/sys_apps/templates puppet/modules/sys_fs puppet/modules/sys_fs/files puppet/modules/sys_fs/manifests puppet/modules/sys_fs/templates puppet/modules/sys_portage/files puppet/plugins/puppet/parser/functions util/backup util/backup/doc util/backup/src/gocept/backup util/backup/src/gocept/backup/share

[ << ] [ >> ]

[ SVN: r6894 - gocept.vendo/branches/paypal / ... ] [ SVN: r6914 - in gocept.infrastructure/testing: . ... ]

SVN: r6903 - in gocept.infrastructure/feature_networking_66071: . portage-gocept/app-backup/gocept-backup portage-gocept/app-backup/gocept-backup/files puppet/manifests/classes puppet/modules/app_admin/files puppet/modules/app_admin/manifests puppet/modules/app_admin/templates puppet/modules/net_analyzer/files/nagios puppet/modules/net_analyzer/files/nagios/globals puppet/modules/net_analyzer/manifests puppet/modules/net_analyzer/templates puppet/modules/sys_apps/files puppet/modules/sys_apps/manifests puppet/modules/sys_apps/templates puppet/modules/sys_fs puppet/modules/sys_fs/files puppet/modules/sys_fs/manifests puppet/modules/sys_fs/templates puppet/modules/sys_portage/files puppet/plugins/puppet/parser/functions util/backup util/backup/doc util/backup/src/gocept/backup util/backup/src/gocept/backup/share
Christian Kauhaus <kc(at)gocept.com>
2008-10-24 13:40:15 [ FULL ]
Author: ckauhaus
Date: Fri Oct 24 13:40:10 2008
New Revision: 6903

Log:
- Merged back testing updates into feature_networking_66071
- fixed public_address



Added:
  
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/gocept-backup-0.9.ebuild
      - copied unchanged from r6901,
gocept.infrastructure/testing/portage-gocept/app-backup/gocept-backup/gocept-backup-0.9.ebuild
  
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/files/init.d_puppetmaster
      - copied unchanged from r6901,
gocept.infrastructure/testing/puppet/modules/app_admin/files/init.d_puppetmaster
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/templates/resolv.conf.erb
  
gocept.infrastructure/feature_networking_66071/puppet/plugins/puppet/parser/functions/public_address.rb
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_shellcmd.py
      - copied unchanged from r6901,
gocept.infrastructure/testing/util/backup/src/gocept/backup/test_shellcmd.py
Removed:
  
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/gocept-backup-0.7.ebuild
  
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/conf.d_puppetmaster.erb
   gocept.infrastructure/feature_networking_66071/util/backup/doc/hosts.cfg
Modified:
   gocept.infrastructure/feature_networking_66071/   (props changed)
  
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/Manifest
  
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/files/gocept-backup.cron
  
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/gocept-backup-0.8.ebuild
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/location.pp
  (contents, props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/node_types.pp
  (contents, props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/manifests/puppet.pp
  
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/fileserver.conf.erb
  
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/puppet.conf.erb
  
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/files/nagios/cgi.cfg
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/files/nagios/globals/templates.cfg
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/files/nagios/nagios.cfg
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/files/nagios/nrpe.cfg
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/manifests/defines.pp
  
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/templates/nagios_host.cfg.erb
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/files/  
(props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/manifests/baselayout.pp
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/templates/
  (props changed)
   gocept.infrastructure/feature_networking_66071/puppet/modules/sys_fs/  
(props changed)
   gocept.infrastructure/feature_networking_66071/puppet/modules/sys_fs/files/ 
 (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_fs/manifests/
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_fs/templates/
  (props changed)
  
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_portage/files/make.conf
   gocept.infrastructure/feature_networking_66071/util/backup/buildout.cfg
   gocept.infrastructure/feature_networking_66071/util/backup/doc/README.txt
   gocept.infrastructure/feature_networking_66071/util/backup/doc/server.cfg.in
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/config.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/errors.txt
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/expire.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/restore.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/run.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.txt
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/README.client.txt
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/client.sh
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/shellcmd.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/sshkeys.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_config.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_expire.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_metadata.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_run.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_sshkeys.py
  
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/version.py

Modified:
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/Manifest
==============================================================================
---
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/Manifest	(original)
+++
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/Manifest	Fri
Oct 24 13:40:10 2008
(at)(at) -1,7 +1,7 (at)(at)
-AUX gocept-backup.cron 128 RMD160 2218457b50eb57219077fa83b33a4cd54fbfbf9e
SHA1 92c33dc4a95d308daf59a38d3061e839c9e76f59 SHA256
c400d029910530f19fb2e84ee7a520c482d8dc9d7734cee8ed3052ac9642d429
-DIST gocept.backup-0.7.tar.gz 26679 RMD160
9a03fc12af8cad768babe0ce708d43417f2ac4b2 SHA1
d51ddd27cae2d2a7685060e698570551395d30ed SHA256
9dd558eb9bc77637063da80ba0fcabf45d3807af17458ecb3e60d0a87d151089
+AUX gocept-backup.cron 115 RMD160 ab62e64bbe22b533ed2e8a8f734724759a61af00
SHA1 a59a4c0f6b2a38ffc2d381722855c54301775439 SHA256
86b214e92332e9782b358a632323e70f22b4cc41bbeeb57391e2051c7625bce8
 DIST gocept.backup-0.8.tar.gz 26768 RMD160
e78079982ce57509687259c05083f8db7afcf316 SHA1
6b1608ebea79b3e5b7f372cd2359ddf5451c9900 SHA256
df9ce8babe03c78ecb748a8455fe862c454d9dbb7339d0b35520492df14ce28e
-EBUILD gocept-backup-0.7.ebuild 1343 RMD160
1f1d6d7d6025b0bc9e9e09bc582c013cc51c035c SHA1
5f5b9723190954a9993e3cd53aad13c6a6d7cd5d SHA256
ecc8dbd58017380c5308c8c4782fd29f30d361feffe366abfa53332ffba95e58
+DIST gocept.backup-0.9.tar.gz 28386 RMD160
89978b01e5bb1d779e48e547017c76a12ff2dafa SHA1
68a43a2e41c454ea82c802fbfce54ba5bf685436 SHA256
bed98920352b9cefaf6be11d35f2f0411537358799015571e85c613e8e8a766a
 EBUILD gocept-backup-0.8.ebuild 1343 RMD160
46902af3e59271d481e19424e4d88276c95334a5 SHA1
bcad9caa411e0deb8876dfa06c49963568b08afe SHA256
ea5861d391b9acd47bc5562e8dbd5ed2face15a4c172bfd6dcdedf69d468a4f4
+EBUILD gocept-backup-0.9.ebuild 1326 RMD160
569f4d7c0ee06f0d1a1b7ef94973461aa2df08cc SHA1
9d0ebed23ad09070824ea6e15dcf305bd7f23b6b SHA256
76b012fe6259de6c0710e4ad32cd1ca4d8a8b45f45686bba61f2c946ddf5cf4a
 MISC ChangeLog 1181 RMD160 9ae32d859312f20a36e1eac94c1d2c8db7d9b781 SHA1
6a084d3a75a95cc8ba7e37d8f2cf88d9e5920533 SHA256
72ceba21526fb5ba8a59dc6bec473e4d03292acabc71637b8f4c52f1f5e588a0
 MISC metadata.xml 218 RMD160 958e011374ddfa7f75e36e1dac7d05b664288a40 SHA1
a88a4994979e6591d092a03249c1f27286cd6e1a SHA256
c7cf3413d937c023b0de4a026ba8f9f13614d8196b71bd53b3d636494c108773

Modified:
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/files/gocept-backup.cron
==============================================================================
---
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/files/gocept-backup.cron	(original)
+++
gocept.infrastructure/feature_networking_66071/portage-gocept/app-backup/gocept-backup/files/gocept-backup.cron	Fri
Oct 24 13:40:10 2008
(at)(at) -3,4 +3,4 (at)(at)
 # See also LICENSE.txt
 set -e
 
-su -c /usr/bin/gocept-backup-server backup
+/usr/bin/gocept-backup-server

Modified:
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/location.pp
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/location.pp	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/location.pp	Fri
Oct 24 13:40:10 2008
(at)(at) -1,16 +1,18 (at)(at)
 class location {
     case $location {
         "rzl": {
-	    $suffix = "rzl.gocept.net"
+	        $suffix = "rzl.gocept.net"
             $puppetmaster = "stampy.srv.rzl.gocept.net"
-            $nagios_server = $puppetmaster
             $ldap_server = "ldap.gocept.com"
+	        $nameservers = "213.187.85.129 195.62.106.5"
         }
         "whq": {
-	    $suffix = "whq.gocept.com"
+	        $suffix = "whq.gocept.com"
             $puppetmaster = "uter.whq.gocept.com"
-            $nagios_server = $puppetmaster
             $ldap_server = "ldap.whq.gocept.com"
+	        $nameservers = "195.62.106.5 213.187.85.129"
         }
     }
+
+    $nagios_server = $puppetmaster
 }

Modified:
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/node_types.pp
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/node_types.pp	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/manifests/classes/node_types.pp	Fri
Oct 24 13:40:10 2008
(at)(at) -15,8 +15,6 (at)(at)
 
     User <| tag == "admin" |>
 
-    net_analyzer::host { $fqdn:
-        shortname => $hostname
-    }
+    net_analyzer::host { $fqdn: }
 
 }

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/manifests/puppet.pp
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/manifests/puppet.pp	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/manifests/puppet.pp	Fri
Oct 24 13:40:10 2008
(at)(at) -47,12 +47,13 (at)(at)
     Service["puppetmaster"] {
         ensure => true,
         enable => true,
-        subscribe +> File["/etc/conf.d/puppetmaster"]
+        subscribe +> File["/etc/init.d/puppetmaster"]
     }
 
     file {
-        "/etc/conf.d/puppetmaster":
-            content => template("app_admin/conf.d_puppetmaster.erb");
+        "/etc/init.d/puppetmaster":
+            source => "puppet:///app_admin/init.d_puppetmaster",
+            mode => 0755;
         "/var/lib/puppet/state":
             owner => "puppet";
         "/usr/local/bin/update-puppet":

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/fileserver.conf.erb
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/fileserver.conf.erb	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/fileserver.conf.erb	Fri
Oct 24 13:40:10 2008
(at)(at) -6,14 +6,15 (at)(at)
 # for allow/deny does not matter, allow always takes precedence
 # over deny
 [files]
-  path /var/lib/puppet/files
-#  allow *.example.com
-#  deny *.evil.example.com
-#  allow 192.168.0.0/24
+    path /var/lib/puppet/files
+#   allow *.example.com
+#   deny *.evil.example.com
+#   allow 192.168.0.0/24
 
 [plugins]
-    path /home/puppet/<%= environment %>/puppet/plugins
+    path <%= puppet_root %>/<%= environment %>/puppet/plugins
     allow 127.0.0.0/8
     allow 192.168.0.0/16
     allow 195.62.106.0/25
     allow 213.187.85.128/26
+    allow 217.69.239.128/25

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/puppet.conf.erb
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/puppet.conf.erb	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/app_admin/templates/puppet.conf.erb	Fri
Oct 24 13:40:10 2008
(at)(at) -39,7 +39,7 (at)(at)
 <% end %>
 
 [puppetd]
-    environment = <%= environment %>
+    environment = <%= File.basename(environment) %>
 
     # The file in which puppetd stores a list of the classes
     # associated with the retrieved configuratiion.  Can be loaded in

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/manifests/defines.pp
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/manifests/defines.pp	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/manifests/defines.pp	Fri
Oct 24 13:40:10 2008
(at)(at) -1,6 +1,6 (at)(at)
 # Macros for easy definition of Nagios checks
 
-define net_analyzer::host($shortname, $hostalias = false) {
+define net_analyzer::host($hostalias = false) {
     $directory = "/etc/nagios/hosts/$hostname"
     $address = $title
     $alias_ = $hostalias ? {
(at)(at) -12,7 +12,7 (at)(at)
         $directory:
             tag => "nagios_server",
             ensure => directory;
-        "$directory/host.cfg":
+        "$directory/_host.cfg":
             tag => "nagios_server",
             mode => "0644",
             content => template("net_analyzer/nagios_host.cfg.erb"),

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/templates/nagios_host.cfg.erb
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/templates/nagios_host.cfg.erb	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/net_analyzer/templates/nagios_host.cfg.erb	Fri
Oct 24 13:40:10 2008
(at)(at) -1,5 +1,5 (at)(at)
 define host {
-    host_name <%= shortname %>
+    host_name <%= hostname %>
     alias <%= alias_ %>
     address <%= address %>
     use generic-host

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/manifests/baselayout.pp
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/manifests/baselayout.pp	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/manifests/baselayout.pp	Fri
Oct 24 13:40:10 2008
(at)(at) -7,56 +7,64 (at)(at)
 # is a mac address but no IP address given, create a bridge but do not assign
 # any addresses to it.
 define network_interface($mac = false, $ip4 = false, $shortalias = false,
-			 $mtu = false) {
+                         $mtu = false) {
     $iface = $name
     $fullname = "$hostname.$name.$location::suffix"
 
     if $mac {
-	sys_fs::interface_name { $iface: mac => $mac }
+        sys_fs::interface_name { $iface: mac => $mac }
 
-	file {
-	    "/etc/conf.d/net.d/$iface.sh":
-		content => template("sys_apps/conf.d_net_host.erb"),
-		require => File["/etc/conf.d/net.d"],
-		notify => Exec["rc-update net $iface"];
-	    "/etc/init.d/net.br$iface":
-		ensure => "net.lo",
-		notify => Exec["rc-update net $iface"];
-	    "/etc/init.d/net.eth$iface":
-		ensure => "net.lo",
-		notify => Exec["rc-update net $iface"];
-	}
-
-	if $ip4 {
-	    (at)(at)host { $fullname:
-		ip => strip_netmask($ip4)
-	    }
-	    if $shortalias {
-		Host[$fullname] {
-		    alias => [$hostname, "$hostname.$location::suffix"]
-		}
-	    }
-
-	    # Define ping checks. We assume that the Nagios server has connectivity
-	    # to all interfaces
-	    $ip4_addr = strip_netmask($ip4)
-
-	    net_analyzer::direct_service { "ping $iface":
-		command => "icmp!-w 100,20% -c 200,40% -H $ip4_addr"
-	    }
-	}
-
-	# register init scripts with rc
-	exec { "rc-update net $iface":
-	    command => "\
-		rc-update add net.br$iface default; \
-		rc-update del net.eth$iface; \
-		/etc/init.d/net.eth$iface stop; \
-		/etc/init.d/net.br$iface start; \
-	    ",
-	    creates => "/etc/runlevels/default/net.br$iface",
-	    logoutput => true
-	}
+        file {
+            "/etc/conf.d/net.d/$iface.sh":
+                content => template("sys_apps/conf.d_net_host.erb"),
+                require => File["/etc/conf.d/net.d"],
+                notify => Exec["rc-update net $iface"];
+            "/etc/init.d/net.br$iface":
+                ensure => "net.lo",
+                notify => Exec["rc-update net $iface"];
+            "/etc/init.d/net.eth$iface":
+                ensure => "net.lo",
+                notify => Exec["rc-update net $iface"];
+        }
+
+        if $ip4 {
+            (at)(at)host { $fullname:
+                ip => strip_netmask($ip4)
+            }
+            if $shortalias {
+                Host[$fullname] {
+                    alias => [$hostname, "$hostname.$location::suffix"]
+                }
+            }
+
+            # Define ping checks. We assume that the Nagios server has
connectivity
+            # to all interfaces
+            $ip4_addr = strip_netmask($ip4)
+
+            net_analyzer::direct_service { "ping $iface":
+                command => "icmp!-w 100,20% -c 200,40% -H $ip4_addr"
+            }
+
+            # Check nameserver
+            if public_address($ip4) {
+                net_analyzer::direct_service {
+                    "dns $fullname/A":
+                        command => "dig!-H ns1 -l $fullname -a $ip4_addr";
+                }
+            }
+        }
+
+        # register init scripts with rc
+        exec { "rc-update net $iface":
+            command => "\
+                rc-update add net.br$iface default; \
+                rc-update del net.eth$iface; \
+                /etc/init.d/net.eth$iface stop; \
+                /etc/init.d/net.br$iface start; \
+            ",
+            creates => "/etc/runlevels/default/net.br$iface",
+            logoutput => true
+        }
     }
 }
 
(at)(at) -64,22 +72,23 (at)(at)
 class sys_apps::baselayout {
 
     file {
-	"/etc/conf.d/net.d": ensure => directory;
-	"/etc/conf.d/net": source => "puppet:///sys_apps/conf.d_net"
+        "/etc/conf.d/net.d": ensure => directory;
+        "/etc/conf.d/net": source => "puppet:///sys_apps/conf.d_net";
+        "/etc/resolv.conf": content => template("sys_apps/resolv.conf.erb")
     }
 
     network_interface {
-	"srv":
-	    mac => $mac_srv,
-	    ip4 => $ip4_srv,
-	    shortalias => true;
-	"sto":
-	    mac => $mac_sto,
-	    ip4 => $ip4_sto,
-	    mtu => 9000;
-	"fe":
-	    mac => $mac_fe,
-	    ip4 => $ip4_fe
+        "srv":
+            mac => $mac_srv,
+            ip4 => $ip4_srv,
+            shortalias => true;
+        "sto":
+            mac => $mac_sto,
+            ip4 => $ip4_sto,
+            mtu => 9000;
+        "fe":
+            mac => $mac_fe,
+            ip4 => $ip4_fe
     }
 
     Host <<| |>>

Added:
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/templates/resolv.conf.erb
==============================================================================
--- (empty file)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_apps/templates/resolv.conf.erb	Fri
Oct 24 13:40:10 2008
(at)(at) -0,0 +1,7 (at)(at)
+# Managed by Puppet: do not edit this file directly. It will be overwritten!
+search <%= domain %> <%= scope.lookupvar('location::suffix')
+	%> gocept.com gocept.net
+options ndots:3
+<% scope.lookupvar('location::nameservers').split.each do |ns| -%>
+nameserver <%= ns %>
+<% end -%>

Modified:
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_portage/files/make.conf
==============================================================================
---
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_portage/files/make.conf	(original)
+++
gocept.infrastructure/feature_networking_66071/puppet/modules/sys_portage/files/make.conf	Fri
Oct 24 13:40:10 2008
(at)(at) -11,4 +11,5 (at)(at)
 MAKEOPTS="-j5"
 FEATURES="ccache buildpkg usersandbox"
 USE="acpi apache2 bash-completion bzip2 device-mapper gnutls jpeg kvm ldap \
-    logrotate png sqlite3 sse sse2 symlink vim-syntax"
+    logrotate png sqlite3 sse sse2 symlink vim-syntax nagios-dns nagios-ntp \
+    nagios-ping nagios-ssh"

Added:
gocept.infrastructure/feature_networking_66071/puppet/plugins/puppet/parser/functions/public_address.rb
==============================================================================
--- (empty file)
+++
gocept.infrastructure/feature_networking_66071/puppet/plugins/puppet/parser/functions/public_address.rb	Fri
Oct 24 13:40:10 2008
(at)(at) -0,0 +1,38 (at)(at)
+# Copyright (c) 2008 gocept gmbh & co. kg
+# See also LICENSE.txt
+
+require 'ipaddr'
+
+
+module Puppet::Parser::Functions
+
+    # Determine public/non-public state of a given IP address.
+    # See RFC3330 for IPv4 and RFC4291 for IPv6.
+    newfunction(:public_address, :type => :rvalue, :doc => "\
+            Decide if the given address (IPv4 or IPv6) is public unicast."
+            ) do |args|
+        return false unless args[0]
+        addr = IPAddr.new args[0]
+        if addr.ipv4?
+            case addr
+            when IPAddr.new('0.0.0.0/8') then return false
+            when IPAddr.new('10.0.0.0/8') then return false
+            when IPAddr.new('127.0.0.0/8') then return false
+            when IPAddr.new('169.254.0.0/16') then return false
+            when IPAddr.new('172.16.0.0/12') then return false
+            when IPAddr.new('192.0.2.0/24') then return false
+            when IPAddr.new('192.168.0.0/16') then return false
+            when IPAddr.new('224.0.0.0/4') then return false
+            when IPAddr.new('240.0.0.0/4') then return false
+            else return true
+            end
+        elsif addr.ipv6?
+            case addr
+            when IPAddr.new('2000::/3') then return true
+            else return false
+            end
+        else
+            raise "cannot determine IP address familiy for '#{addr}'"
+        end
+    end
+end

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/buildout.cfg
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/buildout.cfg	(original)
+++ gocept.infrastructure/feature_networking_66071/util/backup/buildout.cfg	Fri
Oct 24 13:40:10 2008
(at)(at) -1,5 +1,5 (at)(at)
 [buildout]
-parts = server test hosts.cfg server.cfg
+parts = server test server.cfg
 develop = .
 prefer-final = true
 template-directory = doc
(at)(at) -22,13 +22,6 (at)(at)
 recipe = inquant.recipe.textfile
 template-directory = ${buildout:template-directory}
 template = server.cfg.in
-etc-directory = ${buildout:etc-directory}
 var-directory = ${buildout:var-directory}
 backup-directory = ${buildout:backup-directory}
 location = ${buildout:parts-directory}/server.cfg
-
-[hosts.cfg]
-recipe = inquant.recipe.textfile
-template-directory = ${buildout:template-directory}
-template = hosts.cfg
-location = ${buildout:parts-directory}/hosts.cfg

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/doc/README.txt
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/doc/README.txt	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/doc/README.txt	Fri
Oct 24 13:40:10 2008
(at)(at) -29,11 +29,9 (at)(at)
 ------------------
 
 The server script reads a configuration file (default:
-/etc/gocept-backup/server.cfg) on startup. The following settings in the
-[server] section are taken into account:
-
-hostcfg
-  Location of the host configuration file.
+/etc/gocept-backup/server.cfg) on startup. The configuration file consists for
+several sections, one for each host being backed up. Global configuration
+parameters reside in a [DEFAULT] section:
 
 statedir
   Location of the metadata directory. The statedir generally contains small
(at)(at) -46,6 +44,9 (at)(at)
 expire
   Backup retention period in days.
 
+user
+  User to perform backup runs as. Requires root privileges.
+
 timeout
   Maximum time that the backup of a single partition of a host is allowed to
   run. A value of 0 means 'no timeout'.
(at)(at) -54,3 +55,13 (at)(at)
   Default list of exclude expressions (see man page rdiff-backup(1)). All
   exclude expressions should begin with either ``/`` (absolute paths) or
``**``
   (relative paths).
+
+After the global section, a section must be added for each host. By default,
all
+global parameters are included. Individual parameters can be overridden for
+specific host by setting them in the host section. For example, consider the
+host `laptop.example.com` for which another user id should be used::
+
+  [laptop.example.com]
+  user = joe
+
+Client hosts without specific settings must be written as empty sections.

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/doc/server.cfg.in
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/doc/server.cfg.in	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/doc/server.cfg.in	Fri
Oct 24 13:40:10 2008
(at)(at) -1,8 +1,10 (at)(at)
 # gocept backup server configuration
-[server]
-hostcfg = %(etc-directory)s/hosts.cfg
+[DEFAULT]
 statedir = %(var-directory)s
 backupdir = %(backup-directory)s
+#user =
 #expire = 90
-#timeout = 28800
-#exclude = **/lost+found **/core **/*~ /tmp/*
+#timeout = 7200
+#exclude = **/lost+found **/core **/*~ /tmp/* /var/tmp/*
+
+[localhost]

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/config.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/config.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/config.py	Fri
Oct 24 13:40:10 2008
(at)(at) -1,8 +1,9 (at)(at)
 # Copyright (c) 2008 gocept gmbh & co. kg
 # See also LICENSE.txt
 
-import os
 import ConfigParser
+import os
+import pwd
 
 
 class Config(object):
(at)(at) -14,17 +15,18 (at)(at)
     """
 
     DEFAULTS = {
-        u'hostcfg': u'hosts.cfg',
-        u'statedir': u'var',
-        u'backupdir': u'backup',
-        u'expire': 90,
-        u'timeout': 28800,
-        u'exclude': u'**/lost+found **/core **/*~ /tmp/*'}
+        'statedir': 'var',
+        'backupdir': 'backup',
+        'expire': '90',
+        'user': '',
+        'timeout': '7200',
+        'exclude': '**/lost+found **/core **/*~ /tmp/* /var/tmp/*'}
 
     def __init__(self, input=None):
-        self.settings = dict(self.DEFAULTS)
+        self.cp = ConfigParser.SafeConfigParser()
+        for key in self.DEFAULTS.keys():
+            self.cp.set('DEFAULT', key, self.DEFAULTS[key])
         if input:
-            self.cp = ConfigParser.SafeConfigParser()
             if isinstance(input, basestring):
                 if not os.path.exists(input):
                     raise RuntimeError, u"cannot find config file '%s'" % (
(at)(at) -32,32 +34,67 (at)(at)
                 self.cp.read(input)
             else:
                 self.cp.readfp(input)
-            for key, value in self.cp.items(u'server'):
-                self.settings[key] = value
+
+    def hosts(self):
+        return self.cp.sections()
+
+    def __getitem__(self, hostname):
+        return HostConfig(dict(self.cp.items(hostname)))
+
+    def default(self):
+        return self['DEFAULT']
+
+    def add_host(self, hostname):
+        try:
+            self.cp.add_section(hostname)
+        except ConfigParser.DuplicateSectionError:
+            pass
+
+
+class HostConfig(object):
+    """Specialised configuration for a particular host.
+
+    In the configuration file, we allow [HOST] sections to overwrite defaults
on
+    a host-by-host basis. To declare a host which inherits only the default,
+    create an empty [HOST] section in the configuration file.
+
+    """
+
+    def __init__(self, values):
+        self.settings = values
+        self._uid = None
 
     def __getattr__(self, name):
+        """Accessor for string values."""
         try:
             return self.settings[name]
         except KeyError:
             raise AttributeError, "'%s' object has no attribute '%s'" % (
-                __class__, name)
+                self.__class__, name)
 
     (at)property
     def sshconf(self):
         """Location of the ssh_config file."""
-        return os.path.join(self.statedir, u'ssh_config')
+        return os.path.join(self.statedir, 'ssh_config')
 
     (at)property
     def expire(self):
         """Backup expiry duration in days."""
-        return int(self.settings[u'expire'])
+        return int(self.settings['expire'])
 
     (at)property
     def timeout(self):
         """Maximum run time for backing up a single partition in seconds."""
-        return int(self.settings[u'timeout'])
+        return int(self.settings['timeout'])
 
     (at)property
     def exclude(self):
-        """Maximum run time for backing up a single partition in seconds."""
-        return unicode(self.settings[u'exclude']).split()
+        """List of rdiff-backup exclude patterns applied to every
partition."""
+        return unicode(self.settings['exclude']).split()
+
+    (at)property
+    def uid(self):
+        """Look up numerical user id for self.user."""
+        if not self._uid:
+            self._uid = pwd.getpwnam(self.settings['user']).pw_uid
+        return self._uid

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/errors.txt
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/errors.txt	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/errors.txt	Fri
Oct 24 13:40:10 2008
(at)(at) -89,20 +89,23 (at)(at)
    >>> import gocept.backup.shellcmd
    >>> import gocept.backup.expire
 
-   To make the server initialize correctly, we provide a fake host file:
+   We name our test hosts in the config file:
 
-   >>> file(u'hosts.cfg', 'w').write(u'host-a\nhost-b\n')
+   >>> file(u'server.cfg', 'w').write("""\
+   ... [host-a]
+   ...
+   ... [host-b]
+   ... """)
 
 .. [#setup] Before each test, we create fresh server and mocker objects:
 
-   >>> s = gocept.backup.server.Server()
+   >>> s = gocept.backup.server.Server('server.cfg')
    >>> mock = mocker.Mocker()
 
 .. [#teardown] After each test, we verify the mocker and clean up.
 
    >>> mock.restore()
    >>> mock.verify()
-   >>> shutil.rmtree(u'hosts.cfg', True)
    >>> shutil.rmtree(u'var', True)
    >>> shutil.rmtree(u'backup', True)
 

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/expire.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/expire.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/expire.py	Fri
Oct 24 13:40:10 2008
(at)(at) -25,7 +25,8 (at)(at)
                 target]
 
     def remove_old(self, args):
-        out, err, ret = gocept.backup.shellcmd.shellcmd(u'rdiff-backup', args)
+        out, err, ret = gocept.backup.shellcmd.shellcmd(
+            u'rdiff-backup', args, user=self.conf.user)
         if out or err:
             self.log.info(u'rdiff-backup %s: %s%s',
                 u' '.join(args), out, err)

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/restore.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/restore.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/restore.py	Fri
Oct 24 13:40:10 2008
(at)(at) -28,7 +28,6 (at)(at)
         self.log = gocept.backup.log.Log().create(
             self.opts.quiet, self.opts.verbose*2)
         self.conf = gocept.backup.config.Config(self.opts.conffile)
-        self.meta = gocept.backup.metadata.Metadata(self.opts.host, self.conf)
 
     def parse_options(self, conffile=None):
         """Extract own options from argv, passing others to rdiff-backup."""
(at)(at) -60,6 +59,9 (at)(at)
 
     def run(self):
         """Perform restore operation."""
+        self.conf.add_host(self.opts.host)
+        conf = self.conf[self.opts.host]
+        self.meta = gocept.backup.metadata.Metadata(self.opts.host, conf)
         args = [u'--remote-schema', self.meta.remote_schema(u'restore')
             ] + self.rb_opts
         if self.opts.host == 'localhost':

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/run.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/run.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/run.py	Fri
Oct 24 13:40:10 2008
(at)(at) -2,6 +2,7 (at)(at)
 # See also LICENSE.txt
 
 import os
+import os.path
 import sys
 import glob
 import re
(at)(at) -25,18 +26,24 (at)(at)
         self.log = gocept.backup.log.Log().get()
         self.partition = partition
         self.meta = meta
+        self.conf = meta.conf
         self.target = os.path.join(self.meta.hostbackupdir,
                                    self.partition.lstrip(u'/'))
         lockfile = os.path.join(self.meta.hoststatedir, u'run.lck')
         self.flock = gocept.backup.flock.flock(lockfile)
 
     def prepare(self):
-        """Set up directories for backup run. Construct argument list.
-        """
+        """Set up directories for backup run. Construct argument list."""
         try:
             os.makedirs(self.target)
+            self.log.debug('Creating directory %s', self.target)
         except OSError:
             pass
+        if self.conf.user:
+            try:
+                os.chown(self.target, self.conf.uid, -1)
+            except OSError:
+                pass
         args = [u'--force', u'--remote-schema',
                 self.meta.remote_schema(u'rdiff-backup')]
         incl = self.meta.include(self.partition)
(at)(at) -54,11 +61,12 (at)(at)
         return args
 
     def rdiff_backup(self, args):
-        """Do the actual rdiff-backup call with ``args``.
-        """
-        timeout = self.meta.conf.timeout
+        """Do the actual rdiff-backup call with ``args``."""
+        timeout = self.conf.timeout
+        user = self.conf.user
         out, err, ret = gocept.backup.shellcmd.shellcmd(
-            u'rdiff-backup', args, accept_failure=True, timeout=timeout)
+            u'rdiff-backup', args, accept_failure=True, timeout=timeout,
+            user=user)
         if ret > 0:
             self.log.error(u'%s: returncode %i\nstdout:\n%s\nstderr:\n%s',
                            self.meta.host, ret, out, err)

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.py	Fri
Oct 24 13:40:10 2008
(at)(at) -31,9 +31,8 (at)(at)
         self.parse_options()
         self.log = gocept.backup.log.Log().create(self.quiet, self.verbose)
         self.read_config()
-        self.parse_hostfile()
-        self.backupdir = self.conf.backupdir
-        self.sshkeys = gocept.backup.sshkeys.SshKeyCollection(self.conf)
+        self.sshkeys = gocept.backup.sshkeys.SshKeyCollection(
+            self.conf.default())
 
     def parse_options(self):
         """Get options from command line and save them to attributes."""
(at)(at) -83,39 +82,26 (at)(at)
     def read_config(self):
         """Read the configuration file and create conf object."""
         self.conf = gocept.backup.config.Config(self.conffile)
-
-    def parse_hostfile(self):
-        """Read the host configuration and put it into an array.
-
-        If the host list has been overridden on the command line, skip this
-        step.
-
-        """
-        if not self.hosts == []:
-            return
-        self.log.debug(u"Parsing hosts from '%s'", self.conf.hostcfg)
-        for line in file(self.conf.hostcfg):
-            host = re.sub(r'\s*#.*', '', line.strip())
-            if not host:
-                continue
-            self.hosts.append(unicode(host))
+        if not self.hosts: # not explicitely set via command line
+            self.hosts = self.conf.hosts()
 
     def run(self):
         """Perform backups."""
         keyfiles = self.sshkeys.check(self.hosts)
-        for host in self.hosts:
-            meta = gocept.backup.metadata.Metadata(host, self.conf)
+        for hostname in self.hosts:
+            meta = gocept.backup.metadata.Metadata(
+                hostname, self.conf[hostname])
             if meta.host_skippable():
                 self.log.info(u'Skipping %s since we have a recent backup',
-                              host)
+                              hostname)
                 continue
             if not meta.host_reachable():
-                self.log.info(u'Skipping %s because of failed ping', host)
+                self.log.info(u'Skipping %s because of failed ping', hostname)
                 continue
             try:
                 meta.load()
                 if not meta.client_active():
-                    self.log.info(u'Client %s is not active', host)
+                    self.log.info(u'Client %s is not active', hostname)
                     continue
                 for partition in meta.partitions():
                     runner = gocept.backup.run.Run(partition, meta)
(at)(at) -123,11 +109,11 (at)(at)
                         runner.run()
                     except gocept.backup.RemoteWarning, e:
                         self.log.warn(
-                            u'%s: skipping partition (%s)', host, e)
+                            u'%s: skipping partition (%s)', hostname, e)
                     expirer = gocept.backup.expire.Expire(partition, meta)
                     expirer.expire()
             except gocept.backup.RemoteError, e:
-                self.log.warn(u'%s: skipping host (%s)', host, e)
+                self.log.warn(u'%s: skipping host (%s)', hostname, e)
             else:
                 meta.mark_success()
 
(at)(at) -135,19 +121,20 (at)(at)
         client = client or self.client # method argument overrides attribute
         checkhosts = list(self.hosts)
         if not client in self.hosts:
-            self.log.warn(
-                u"Host '%s' is not mentioned in host config file '%s'!",
-                client, self.conf.hostcfg)
+            self.log.warn(u"Host '%s' is not mentioned in the config file!",
+                          client)
             checkhosts.append(client)
+            self.conf.add_host(client)
         self.sshkeys.check(checkhosts)
+        conf = self.conf[client]
         cconf = gocept.backup.clientconfig.ClientConfig(
-            client, self.conf.statedir)
+            client, conf.statedir)
         cconf.tarball(u'backup_%s.tar.gz' % client)
         self.log.info(u"""\
-Install client and check it using 
+Install client and check it using
 'echo version | ssh -F %s/ssh_config -o BatchMode=no %s backupclient'\
 """,
-                      self.conf.statedir, client)
+                      conf.statedir, client)
 
 
 def main(configfile='/etc/gocept-backup/server.cfg'):

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.txt
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.txt	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/server.txt	Fri
Oct 24 13:40:10 2008
(at)(at) -7,31 +7,26 (at)(at)
 We set up a fake configuration and a host file for testing purposes
[#imports]_:
 
 >>> file(u'server.cfg', 'w').write(u"""\
-... [server]
+... [DEFAULT]
 ... statedir = server
 ... backupdir = backup
-... hostcfg = hosts.cfg
-... """)
->>> file(u'hosts.cfg', 'w').write("""\
-... hostname # host comment
-...       
-... # this is a comment after a whitespace line
+...
+... [hostname]
+... # host comment
 ... """)
 
 Then, we create a backup server object [#setup]_:
 
 >>> s = Server(u'server.cfg')
->>> show_log()
-Parsing hosts from 'hosts.cfg'
 
 The server should parse the host file correctly:
 
 >>> s.hosts
-[u'hostname']
+['hostname']
 
 Note that the backup client does not use ssh for localhost access, but relies
 on the ability to sudo without password instead. So better provide an
-/etc/sudoers entry before using 'localhost' in hosts.cfg.
+/etc/sudoers entry before using 'localhost' in server.cfg.
 
 
 How to set up a client
(at)(at) -64,11 +59,11 (at)(at)
 ssh/authorized_keys
 
 If we request a configuration package for a client which is not listed in
-hosts.cfg, a warning is emitted:
+server.cfg, a warning is emitted:
 
 >>> s.configure_client(u'grampa.whq.gocept.com')
 >>> show_log()
-Host 'grampa.whq.gocept.com' is not mentioned in host config file 'hosts.cfg'!
+Host 'grampa.whq.gocept.com' is not mentioned in the config file!
 Checking SSH ...
 
 
(at)(at) -84,6 +79,7 (at)(at)
 Loading metadata from 'hostname'
 Unpacking metadata into '...server/hostname'
 Calling backup on host 'hostname' for partition '/etc'
+Creating directory backup/hostname/etc
 Acquiring lock: server/hostname/...
 Releasing lock: server/hostname/...
 
(at)(at) -221,7 +217,6 (at)(at)
 
 Delete test files:
 
->>> os.unlink(u'hosts.cfg')
 >>> os.unlink(u'backup_hostname.tar.gz')
 >>> os.unlink(u'backup_grampa.whq.gocept.com.tar.gz')
 >>> shutil.rmtree(u'server')

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/README.client.txt
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/README.client.txt	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/README.client.txt	Fri
Oct 24 13:40:10 2008
(at)(at) -46,7 +46,7 (at)(at)
 The result is that only /usr/local is backed up and nothing else in /usr.
 
 Individual files can also be excluded. For example, to exclude all editor
backup
-files (ending with ``~``), we specify:
+files (ending with ``~``), we specify::
 
   **/*~
 
(at)(at) -69,3 +69,18 (at)(at)
   /etc/gocept-backup/nobackup
 
 and no backups will be run. To resume backup activity, delete the file.
+
+
+Restoring
+---------
+
+If the user can access data on the backup server, restores should preferably
+be performed using normal ``rdiff-backup`` calls. For example, if backup data
+from the user's laptop at laptop.example.com is stored below
+/var/gocept-backup/laptop.example.com on the backup server, the following
+command can be used to restore the contents of the ``/lib64`` directory as of
+yesterday to ``/var/tmp/lib64``::
+
+  rdiff-backup -r 1D \
+    user(at)backupserver::/var/gocept-backup/laptop.example.com/lib64/ \
+    /var/tmp/lib64/

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/client.sh
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/client.sh	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/share/client.sh	Fri
Oct 24 13:40:10 2008
(at)(at) -4,7 +4,7 (at)(at)
 # further actions.
 set -e
 
-VERSION="0.8"
+VERSION="0.9"
 ETCDIR="${ROOTDIR}/etc"
 CONFDIR="${ETCDIR}/gocept-backup"
 

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/shellcmd.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/shellcmd.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/shellcmd.py	Fri
Oct 24 13:40:10 2008
(at)(at) -1,12 +1,16 (at)(at)
-import subprocess
+# Copyright (c) 2008 gocept gmbh & co. kg
+# See also LICENSE.txt
+
 import os
-import signal
+import pwd
 import select
+import signal
+import subprocess
 
 import gocept.backup.log
 
 
-def shellcmd(cmd, args, input=None, accept_failure=False, timeout=0):
+def shellcmd(cmd, args, input=None, accept_failure=False, timeout=0,
user=None):
     """Generic shell command wrapper.
 
     The command is separated from the arguments to allow for better testing by
(at)(at) -16,16 +20,22 (at)(at)
     log = gocept.backup.log.Log().get()
     command = [cmd]+list(args)
     log.debug(u'Running %s', u' '.join(command))
-    p = subprocess.Popen(command, stdin=subprocess.PIPE,
-                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    if input:
-        log.debug(u'stdin: %s', input)
-    stdout, stderr = None, None
-    install_alarm(p, timeout)
+    saved_uid = os.getuid()
+    if user:
+        os.seteuid(pwd.getpwnam(user).pw_uid)
     try:
-        stdout, stderr = p.communicate(input)
-    except select.error:
-        p.returncode = -1
+        p = subprocess.Popen(command, stdin=subprocess.PIPE,
+                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        if input:
+            log.debug(u'stdin: %s', input)
+        stdout, stderr = None, None
+        install_alarm(p, timeout)
+        try:
+            stdout, stderr = p.communicate(input)
+        except select.error:
+            p.returncode = -1
+    finally:
+        os.seteuid(saved_uid)
     if not accept_failure and not p.returncode == 0:
         log.debug(fmt(p.returncode, stdout, stderr))
         raise RuntimeError(u"command '%s' failed with %s" % (

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/sshkeys.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/sshkeys.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/sshkeys.py	Fri
Oct 24 13:40:10 2008
(at)(at) -51,6 +51,7 (at)(at)
     BatchMode yes
     EscapeChar none
     Compression yes
+    CheckHostIP no
     ServerAliveInterval 60
     IdentityFile %s
 

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_config.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_config.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_config.py	Fri
Oct 24 13:40:10 2008
(at)(at) -3,6 +3,7 (at)(at)
 
 import unittest
 import tempfile
+import pwd
 import StringIO
 import ConfigParser
 
(at)(at) -12,55 +13,74 (at)(at)
 class ConfigTest(unittest.TestCase):
 
     def test_defaults(self):
-        c = Config()
-        self.assertEqual(u'hosts.cfg', c.hostcfg)
-        self.assertEqual(u'var', c.statedir)
-        self.assertEqual(u'backup', c.backupdir)
+        c = Config().default()
+        self.assertEqual('var', c.statedir)
+        self.assertEqual('backup', c.backupdir)
+        self.assertEqual('', c.user)
         self.assertEqual(90, c.expire)
-        self.assertEqual(28800, c.timeout)
-        self.assertEqual([u'**/lost+found', u'**/core', u'**/*~', u'/tmp/*'],
+        self.assertEqual(7200, c.timeout)
+        self.assertEqual(['**/lost+found', '**/core', '**/*~', '/tmp/*',
+                          '/var/tmp/*'],
                          c.exclude)
 
     def test_parse(self):
         io = StringIO.StringIO("""
-[server]
-hostcfg = a
+[hostname]
 exclude = **/*.o **/*~
 statedir = b
 backupdir = c
+user = user
 expire = 1
 timeout = 2
 """)
-        c = Config(io)
-        self.assertEqual('a', c.hostcfg)
+        c = Config(io)['hostname']
         self.assertEqual([u'**/*.o', u'**/*~'], c.exclude)
         self.assertEqual('b', c.statedir)
         self.assertEqual('c', c.backupdir)
         self.assertEqual(u'b/ssh_config', c.sshconf)
+        self.assertEqual('user', c.user)
         self.assertEqual(1, c.expire)
         self.assertEqual(2, c.timeout)
 
     def test_read_stream(self):
-        io = StringIO.StringIO(u'[server]\n')
+        io = StringIO.StringIO(u'[hostname]\n')
         c = Config(io)
-        self.assert_(c.cp.has_section(u'server'),
-                     u'cannot find server section in ConfigParser')
+        self.assert_('hostname' in c.hosts(),
+                     u'cannot find host section in ConfigParser')
 
     def test_read_file(self):
         tf = tempfile.NamedTemporaryFile(prefix=u'config_read_file')
-        tf.write(u'[server]\n')
+        tf.write(u'[hostname]\n')
         tf.flush()
         c = Config(tf.name)
-        self.assert_(c.cp.has_section(u'server'),
-                     u'cannot find server section in ConfigParser')
-
-    def test_invalid_section(self):
-        io = StringIO.StringIO(u'[foo]\nbar =\n')
-        self.assertRaises(ConfigParser.NoSectionError, Config, io)
+        self.assert_('hostname' in c.hosts(),
+                     u'cannot find host section in ConfigParser')
 
     def test_invalid_filename(self):
         self.assertRaises(RuntimeError, Config, u'/no/such/file')
 
+    def test_add_host(self):
+        c = Config()
+        self.assertEqual([], c.hosts())
+        c.add_host('host1')
+        self.assertEqual(['host1'], c.hosts())
+
+    def test_add_host_twice_should_be_ok(self):
+        c = Config()
+        self.assertEqual([], c.hosts())
+        c.add_host('host')
+        c.add_host('host')
+        self.assertEqual(['host'], c.hosts())
+
+    def test_uid(self):
+        uid = pwd.getpwnam('adm').pw_uid
+        io = StringIO.StringIO("""\
+[DEFAULT]
+user = adm
+""")
+        c = Config(io).default()
+        self.assertEqual(uid, c.uid)
+
 
 def test_suite():
     suite = unittest.TestSuite()

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_expire.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_expire.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_expire.py	Fri
Oct 24 13:40:10 2008
(at)(at) -14,7 +14,9 (at)(at)
 
     def setUp(self):
         self.conf = gocept.backup.config.Config()
-        self.meta = gocept.backup.metadata.Metadata(u'localhost', self.conf)
+        self.conf.add_host('localhost')
+        self.meta = gocept.backup.metadata.Metadata(
+            u'localhost', self.conf['localhost'])
         self.e = gocept.backup.expire.Expire(u'/etc', self.meta)
 
     def test_init(self):

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_metadata.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_metadata.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_metadata.py	Fri
Oct 24 13:40:10 2008
(at)(at) -16,7 +16,9 (at)(at)
 class MetadataTestBase(mocker.MockerTestCase):
 
     def setUp(self):
-        self.conf = gocept.backup.config.Config()
+        config = gocept.backup.config.Config()
+        config.add_host('localhost')
+        self.conf = config['localhost']
         self.statedir = self.conf.statedir
         self.hoststate = os.path.join(self.statedir, u'hostname')
         self.partfile = os.path.join(self.hoststate, u'partitions')

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_run.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_run.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_run.py	Fri
Oct 24 13:40:10 2008
(at)(at) -16,7 +16,9 (at)(at)
 class RunTestBase(mocker.MockerTestCase):
 
     def setUp(self):
-        self.conf = gocept.backup.config.Config()
+        config = gocept.backup.config.Config()
+        config.add_host('localhost')
+        self.conf = config['localhost']
         self.meta = gocept.backup.metadata.Metadata(u'localhost', self.conf)
 
     def tearDown(self):
(at)(at) -94,13 +96,22 (at)(at)
 
     def test_run_should_use_a_timeout(self):
         shellcmd = self.mocker.replace('gocept.backup.shellcmd.shellcmd')
-        shellcmd(u'rdiff-backup', mocker.ARGS, mocker.KWARGS, timeout=28800)
+        shellcmd(u'rdiff-backup', mocker.ARGS, mocker.KWARGS, timeout=7200)
         self.mocker.result(('', '', -1))
         self.mocker.replay()
         self.runner.log.setLevel(100)
         self.assertRaises(gocept.backup.RemoteError, self.runner.rdiff_backup,
                           [])
 
+    def test_run_should_drop_privileges(self):
+        shellcmd = self.mocker.replace('gocept.backup.shellcmd.shellcmd')
+        shellcmd(u'rdiff-backup', mocker.ARGS, mocker.KWARGS, user='adm')
+        self.mocker.result(('', '', 0))
+        self.mocker.replay()
+        self.runner.meta.conf.settings['user'] = 'adm'
+        self.runner.log.setLevel(100)
+        self.runner.rdiff_backup([])
+
     def test_check_should_succeed_when_no_errors_in_session_file(self):
         file(self.session_stats, 'w').write("""\
 SourceFiles 30

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_sshkeys.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_sshkeys.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/test_sshkeys.py	Fri
Oct 24 13:40:10 2008
(at)(at) -15,7 +15,7 (at)(at)
 class SshKeyCollectionTest(mocker.MockerTestCase):
 
     def setUp(self):
-        self.conf = gocept.backup.config.Config()
+        self.conf = gocept.backup.config.Config().default()
         self.c = SshKeyCollection(self.conf)
 
     def tearDown(self):
(at)(at) -38,6 +38,7 (at)(at)
     BatchMode yes
     EscapeChar none
     Compression yes
+    CheckHostIP no
     ServerAliveInterval 60
     IdentityFile %s
 

Modified:
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/version.py
==============================================================================
---
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/version.py	(original)
+++
gocept.infrastructure/feature_networking_66071/util/backup/src/gocept/backup/version.py	Fri
Oct 24 13:40:10 2008
(at)(at) -1,4 +1,4 (at)(at)
 # Copyright (c) 2008 gocept gmbh & co. kg
 # See also LICENSE.txt
 
-VERSION = u'0.8'
+VERSION = u'0.9'

MailBoxer