/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2012-05-12 16:37:14 UTC
  • Revision ID: teddy@recompile.se-20120512163714-eug8vcuzd6kd8i1m
* mandos (IPv6_TCPServer.server_bind): Bug fix: handle non-existing
                                       interface name.  Use new .errno
                                       attribute of socket.error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
                                 self.server_state_changed)
380
380
        self.server_state_changed(self.server.GetState())
381
381
 
 
382
 
382
383
class AvahiServiceToSyslog(AvahiService):
383
384
    def rename(self):
384
385
        """Add the new name to the syslog messages"""
389
390
                                .format(self.name)))
390
391
        return ret
391
392
 
 
393
 
392
394
def timedelta_to_milliseconds(td):
393
395
    "Convert a datetime.timedelta() to milliseconds"
394
396
    return ((td.days * 24 * 60 * 60 * 1000)
395
397
            + (td.seconds * 1000)
396
398
            + (td.microseconds // 1000))
397
399
 
 
400
 
398
401
class Client(object):
399
402
    """A representation of a client host served by this server.
400
403
    
1925
1928
                                           str(self.interface
1926
1929
                                               + '\0'))
1927
1930
                except socket.error as error:
1928
 
                    if error[0] == errno.EPERM:
 
1931
                    if error.errno == errno.EPERM:
1929
1932
                        logger.error("No permission to"
1930
1933
                                     " bind to interface %s",
1931
1934
                                     self.interface)
1932
 
                    elif error[0] == errno.ENOPROTOOPT:
 
1935
                    elif error.errno == errno.ENOPROTOOPT:
1933
1936
                        logger.error("SO_BINDTODEVICE not available;"
1934
1937
                                     " cannot bind to interface %s",
1935
1938
                                     self.interface)
 
1939
                    elif error.errno == errno.ENODEV:
 
1940
                        logger.error("Interface %s does not"
 
1941
                                     " exist, cannot bind",
 
1942
                                     self.interface)
1936
1943
                    else:
1937
1944
                        raise
1938
1945
        # Only bind(2) the socket if we really need to.