| 648 | # is created and is added to the FailManager. |
| 649 | |
| 650 | def getFailures(self, filename): |
| 651 | container = self.getFileContainer(filename) |
| 652 | if container is None: |
| 653 | logSys.error("Unable to get failures in " + filename) |
| 654 | return False |
| 655 | # Try to open log file. |
| 656 | try: |
| 657 | has_content = container.open() |
| 658 | # see http://python.org/dev/peps/pep-3151/ |
| 659 | except IOError as e: |
| 660 | logSys.error("Unable to open %s" % filename) |
| 661 | logSys.exception(e) |
| 662 | return False |
| 663 | except OSError as e: # pragma: no cover - requires race condition to tigger this |
| 664 | logSys.error("Error opening %s" % filename) |
| 665 | logSys.exception(e) |
| 666 | return False |
| 667 | except OSError as e: # pragma: no cover - Requires implemention error in FileContainer to generate |
| 668 | logSys.error("Internal errror in FileContainer open method - please report as a bug to https://github.com/fail2ban/fail2ban/issues") |
| 669 | logSys.exception(e) |
| 670 | return False |
| 671 | |
| 672 | # yoh: has_content is just a bool, so do not expect it to |
| 673 | # change -- loop is exited upon break, and is not entered at |
| 674 | # all if upon container opening that one was empty. If we |
| 675 | # start reading tested to be empty container -- race condition |
| 676 | # might occur leading at least to tests failures. |
| 677 | while has_content: |
| 678 | line = container.readline() |
| 679 | if not line or not self.active: |
| 680 | # The jail reached the bottom or has been stopped |
| 681 | break |
| 682 | self.processLineAndAdd(line) |
| 683 | container.close() |
| 684 | db = self.jail.database |
| 685 | if db is not None: |
| 686 | db.updateLog(self.jail, container) |
| 687 | return True |
| 688 | |
| 689 | @property |
| 690 | def status(self): |