diff options
| -rwxr-xr-x | bin/standardskriver | 18 | ||||
| -rw-r--r-- | debian/changelog | 9 | ||||
| -rw-r--r-- | debian/control | 1 | 
3 files changed, 23 insertions, 5 deletions
| diff --git a/bin/standardskriver b/bin/standardskriver index e7128f8..db71976 100755 --- a/bin/standardskriver +++ b/bin/standardskriver @@ -25,6 +25,7 @@  CFG_FILE = '/etc/standardskriver.cfg'  CFG_FILE_EXAMPLE = '''[settings] +enable = yes  order = machine groups  delete lpoptions = yes @@ -33,6 +34,7 @@ delete lpoptions = yes  # hostname.domain = printer  # LTSP client IP = printer  # (globbing works) +  [machine]  00:01:02:03:04:05 = printer01  172.16.34.64 = printer02 @@ -41,6 +43,7 @@ hostname.domain = printer02  # group name = printer  # (globbing works) +  [groups]  group1 = printer01  group2 = printer02 @@ -53,6 +56,7 @@ import os  import subprocess  import re  from socket import gethostname, getfqdn +import netaddr  from optparse import OptionParser  from ConfigParser import RawConfigParser @@ -99,7 +103,7 @@ try:      ipaddrs.append(os.environ['SSH_CLIENT'].split()[0])  except KeyError:      pass -p = subprocess.Popen(['/sbin/ifconfig'], stdout=subprocess.PIPE) +p = subprocess.Popen(['/sbin/ifconfig'], env={'LANG': 'C'}, stdout=subprocess.PIPE)  for line in p.stdout:      m = re_ipaddr.search(line)      if m: @@ -118,10 +122,15 @@ def get_group_match():  def get_machine_match():      for machine, printer in cfg.items('machine'): -        if any(fnmatchcase(macaddr, machine.replace('-', '').replace(':', '')) for macaddr in macaddrs) or \ -        any(fnmatchcase(ipaddr, machine) for ipaddr in ipaddrs) or \ -        any(fnmatchcase(hostname, machine) for hostname in hostnames): +        if any(fnmatchcase(macaddr, machine.replace('-', '').replace(':', '')) for macaddr in macaddrs): +            return printer +        elif any(fnmatchcase(hostname, machine) for hostname in hostnames):              return printer +        else: +            machines = netaddr.IPSet(machine.split(',')) +            myaddrs = netaddr.IPSet(ipaddrs) +            if machines & myaddrs: +                return printer      return None  matches = [] @@ -150,4 +159,3 @@ if options.dryrun:  else:      subprocess.call(args) - diff --git a/debian/changelog b/debian/changelog index 68bee46..c71da3c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +itzks-systems (2013.11.13.2) UNRELEASED; urgency=low + +  * Use python-netaddr in standardskriver to make it recognize +    network addresses, as well. +  * debian/control: +    + Add dependency for bin:package itzks-systems-common: python-netaddr. + + -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de>  Wed, 13 Nov 2013 15:39:41 +0100 +  itzks-systems (2013.11.13.1) squeeze-backports; urgency=low    * Add standardskriver script, provided by linuxavdelingen.no. diff --git a/debian/control b/debian/control index ada7857..d85a6c1 100644 --- a/debian/control +++ b/debian/control @@ -21,6 +21,7 @@ Breaks:  Depends:   ${misc:Depends},   python, + python-netaddr,  Description: Configuration for ITZkS Systems   Set of configuration parameters and common files   relevant to ITZkS systems. | 
