Example #1
0
def verify_resource (name, minval):
    try:
        x = sysctl.sysctl (name, 1)
    except:
        raise SystemError("Failed to query sysctl MIB '%s': %s" % (name, tb.traceback_string()))
    else:
        if x < minval:
            raise SystemError(
                "The sysctl MIB '%s' has value '%d', which is less than the required minimum value of '%d'" %
                (name, x, minval))
Example #2
0
def verify_resource(name, minval):
    try:
        x = sysctl.sysctl(name, 1)
    except:
        raise SystemError, "Failed to query sysctl MIB '%s': %s" % (
            name, tb.traceback_string())
    else:
        if x < minval:
            raise SystemError, "The sysctl MIB '%s' has value '%d', which is less than the required minimum value of '%d'" % (
                name, x, minval)
Example #3
0
 def runTest (self):
     i = 0
     while 1:
         try:
             data = open (('%08d' % n), 'rb').read()
             try:
                 pprint.pprint (decode (data))
             except:
                 sys.stderr.write ('%4d %r\n' % (n, tb.traceback_string()))
         except IOError:
             break
         else:
             i += 1
Example #4
0
 def thread_manager(self):
     """thread_manager(self) -> None
     This is the deadlock detection thread.
     """
     while 1:
         try:
             coro.sleep_relative(self.deadlock_check_period)
             self.check_for_deadlocks()
         except coro.Interrupted:
             # Exiting.
             self.thread = None
             return
         except:
             coro.print_stderr(tb.traceback_string() + '\n')
Example #5
0
 def thread_manager(self):
     """thread_manager(self) -> None
     This is the deadlock detection thread.
     """
     while 1:
         try:
             coro.sleep_relative(self.deadlock_check_period)
             self.check_for_deadlocks()
         except coro.Interrupted:
             # Exiting.
             self.thread = None
             return
         except:
             coro.print_stderr(tb.traceback_string() + '\n')
Example #6
0
 def run (self):
     try:
         try:
             self._run()
         except coro.Shutdown:
             # We've been asked to shutdown
             return
         except:
             qlog.write('COMMON.APP_FAILURE', tb.traceback_string() + `self`)
     finally:
         if self.user:
             qlog.write('FTPD.LOGOUT', self.session_id, self.user)
         self.close()
         self.server.session_done(self)
         # remove cycle
         del self.stream
Example #7
0
    def _run (self):
        self.thread_id = coro.current().thread_id()
        try:
            # send the greeting
            self.send_greeting()

            while not self.shutdown_flag:
                line, eof = self.read_line_timeout()
                if eof:
                    break
                line = orig_line = line.lstrip()

                parts = line.split()
                if len (parts) < 1:
                    self.command_not_understood ('')
                    continue
                command = parts[0].lower()
                if len(parts) > 1:
                    args = ' '.join (parts[1:])
                    # If command arguments include null character, python path parsing
                    # function will complain. Remove the null characters.
                    line = [command, args.replace('\0', '')]
                else:
                    line = [command]

                # watch especially for 'urgent' abort commands.
                if command.find ('abor') != -1:
                    # strip off telnet sync chars and the like...
                    while command and command[0] not in string.letters:
                        command = command[1:]
                fun_name = 'cmd_%s' % command
                if command != 'pass':
                    qlog.write('FTPD.RECV', self.session_id, repr(orig_line)[1:-1])
                else:
                    qlog.write('FTPD.RECV', self.session_id, line[0]+' <password>')
                self.in_buffer = ''
                if not hasattr (self, fun_name):
                    self.command_not_understood (line[0])
                    continue
                fun = getattr (self, fun_name)
                if (not self.authorized) and (command not in ('user', 'pass', 'help', 'quit')):
                    self.respond ('530 Please log in with USER and PASS')
                elif (not self.check_command_authorization (self.user, command)):
                    self.command_not_authorized (command)
                else:
                    if hasattr (self, '_syntax_%s' % command):
                        r = getattr (self, '_syntax_%s' % command)
                        m = re.match (r, orig_line, re.IGNORECASE)
                        if m is None:
                            self.respond ('501 Syntax error in parameters or arguments')
                            continue
                    try:
                        result = apply (fun, (line,))
                    except OSError, why:
                        if why[0] in self.disconnect_errors:
                            # log it & ignore
                            qlog.write ('FTPD.DISCONNECT', self.session_id, why.strerror)
                            break
                        else:
                            raise
                    except coro.TimeoutError:
                        qlog.write('FTPD.DISCONNECT', self.session_id, 'Remote side timed out')
                        break
                    except coro.Interrupted:
                        raise
                    except:
                        self.server.total_exceptions.increment()
                        qlog.write('COMMON.APP_FAILURE', tb.traceback_string() +
                            ' fun: ' + `fun` + ' line: ' + `line`)
                        self.respond ('451 Server Error')
                        self.close_passive_acceptor()
                    else:
                        if result == 'quit':
                            break