Beispiel #1
0
	def go(self):	
		## Initialise the main controller, load static file
		self.data = PyffleData()
		self.data.toolMode = True 	## Turn on Tool Mode so that we override security restrictions
		
		static = PyffleStatic()		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		self.data.static = static

		## Setup the DB connection
		Session = sessionmaker()
		engine = create_engine(static.options["pyffle.dburl"], echo=False) ### FIXME pull this out of static
		Session.configure(bind=engine)	
		self.session = Session()
		self.data.session = self.session
		
		## Setup up the utility class
		util = PyffleUtil()
		util.data = self.data
		self.data.util = util

		entries = self.data.getLog(num=10000,level=-1)
		for entry in entries:
			outs = ""
			for s in entry:
				if len(str(s)) > 2:
					outs = outs + "{0:20} ".format(str(s))
				else:
					outs = outs + "{0:5} ".format(str(s))
			print outs
Beispiel #2
0
	def go(self,cmd):	
		## Initialise the main controller, load static file
		self.data = PyffleData()
		self.data.toolMode = True 	## Turn on Tool Mode so that we override security restrictions
		static = PyffleStatic()		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		self.data.static = static

		## Setup the DB connection
		Session = sessionmaker()
		engine = create_engine(static.options["pyffle.dburl"], echo=False) ### FIXME pull this out of static
		Session.configure(bind=engine)	
		self.session = Session()
		self.data.session = self.session
		
		## Setup up the utility class
		util = PyffleUtil()
		util.data = self.data
		self.data.util = util
		self.data.toolMode = True	
		## Load the MTA plugins
		mtalist = [["pyffle_mta_uucp","Pyffle UUCP","UUCP MTA for Pyffle"]]
		self.data.loadMtaList(mtalist)
			
		if cmd == "listmsgs":
			self.listmsgs()

		if cmd == "listusers":
			self.listusers()
Beispiel #3
0
	def go(self):	
		## Initialise the main controller, load static file
		self.data = PyffleData()
		self.data.toolMode = True 	## Turn on Tool Mode so that we override security restrictions
		
		static = PyffleStatic()		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		self.data.static = static

		## Setup the DB connection
		Session = sessionmaker()
		engine = create_engine(static.options["pyffle.dburl"], echo=False) ### FIXME pull this out of static
		Session.configure(bind=engine)	
		self.session = Session()
		self.data.session = self.session
		self.data.loglevel = self.data.LOGCRIT
		## Setup up the utility class
		util = PyffleUtil()
		util.data = self.data
		self.data.util = util
		if self.purgeType == "msgs":
			self.purgeMessages()
		elif self.purgeType == "logs":
			self.purgeLogs()
		elif self.purgeType == "acls":
			self.purgeAcls()
Beispiel #4
0
    def go(self, cmd):
        ## Initialise the main controller, load static file
        self.data = PyffleData()
        self.data.toolMode = True  ## Turn on Tool Mode so that we override security restrictions
        static = PyffleStatic()  ## FIXME read this from a env var or something
        static.parse("/pyffle/static")
        self.data.static = static

        ## Setup the DB connection
        Session = sessionmaker()
        engine = create_engine(static.options["pyffle.dburl"],
                               echo=False)  ### FIXME pull this out of static
        Session.configure(bind=engine)
        self.session = Session()
        self.data.session = self.session

        ## Setup up the utility class
        util = PyffleUtil()
        util.data = self.data
        self.data.util = util
        self.data.toolMode = True
        ## Load the MTA plugins
        mtalist = [["pyffle_mta_uucp", "Pyffle UUCP", "UUCP MTA for Pyffle"]]
        self.data.loadMtaList(mtalist)

        if cmd == "listmsgs":
            self.listmsgs()

        if cmd == "listusers":
            self.listusers()
Beispiel #5
0
	def go(self):	
		msgString = sys.stdin.read()
		print "RNEWS got msg: " + msgString
		## Initialise the main controller, load static file
		self.data = PyffleData()
		self.data.toolMode = True 	## Turn on Tool Mode so that we override security restrictions
		static = PyffleStatic()		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		self.data.static = static

		## Setup the DB connection
		Session = sessionmaker()
		engine = create_engine(static.options["pyffle.dburl"], echo=False) ### FIXME pull this out of static
		Session.configure(bind=engine)	
		self.session = Session()
		self.data.session = self.session
		self.data.LOGLEVEL = self.data.LOGNORMAL;
		## Setup up the utility class
		util = PyffleUtil()
		util.data = self.data
		self.data.util = util
		self.data.toolMode = True	
		## Load the MTA plugins
		mtalist = [["pyffle_mta_uucp","Pyffle UUCP","UUCP MTA for Pyffle"]]
		self.data.loadMtaList(mtalist)

		print "RNEWS got connected to Pyffle"
			
		## parse the incoming message
		
		rfcMsg = self.parseNews(msgString)

		payload = rfcMsg['payload']		
		newsgrouphdr = rfcMsg['Newsgroups']
		newsgroups = []
		if newsgrouphdr.count(",") > 0:
			## multiple groups specified
			for e in newsgrouphdr.split(","):
				newsgroups.append(e.strip())
		else:
			newsgroups = [newsgrouphdr]

		for newsgroup in newsgroups:		
			newsgroup = newsgroup.lower()
			destBoard = self.data.getBoardByExternalname(newsgroup)
			if not destBoard == None:
				internalName = destBoard.name
				msgid = self.data.createMessage(rfcMsg['From'],None,rfcMsg['Subject'],payload,board=internalName)		
				self.data.setMessageRead(msgid) ## mark it as read so we don't export it again
				self.data.logEntry(self.data.LOGINFO,"IMPORT/MESSAGE/NEWS",str("RNEWS"),"Received news on %s from %s" % (str(destBoard.externalname),str(rfcMsg['From'])))		
			else: 
				print "We don't carry " + newsgroup
Beispiel #6
0
	def go(self,finalDestination):	
		## Initialise the main controller, load static file
		self.data = PyffleData()
		self.data.toolMode = True 	## Turn on Tool Mode so that we override security restrictions
		static = PyffleStatic()		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		self.data.static = static

		## Setup the DB connection
		Session = sessionmaker()
		engine = create_engine(static.options["pyffle.dburl"], echo=False) ### FIXME pull this out of static
		Session.configure(bind=engine)	
		self.session = Session()
		self.data.session = self.session
		
		## Setup up the utility class
		util = PyffleUtil()
		util.data = self.data
		self.data.util = util
		
		## Load the MTA plugins
		mtalist = [["pyffle_mta_uucp","Pyffle UUCP","UUCP MTA for Pyffle"]]
		self.data.loadMtaList(mtalist)

		## parse the incoming message
		msgString = sys.stdin.read()
		rfcMsg = email.message_from_string(msgString)
		payload = rfcMsg.get_payload()		
		
		toAddress = finalDestination

		## is this a local message?
		if self.incomingAddressIsLocal(toAddress):
			toname,hostname = self.parseIncomingAddress(toAddress)
			## Ask an MTA to parse the incoming address
			if (not toname == "") and (not toname == None):
				##print "F=%s T=%s S=%s\n" % (rfcMsg['From'],toname,rfcMsg['Subject'])
				## Store the message
				self.data.createMessage(rfcMsg['From'],toname,rfcMsg['Subject'],payload)		
				self.data.logEntry(self.data.LOGINFO,"IMPORT/MESSAGE/RMAIL",str(toname),"Received mail for %s from %s" % (str(toname),str(rfcMsg['From'])))		

		else: 
			pass
			print "Sending to external rmail"
			## Pass to external rmail
			with warnings.catch_warnings(record=True) as warn:
				## FIXME CRITICAL: need to sanitize the To header here...Shell injection
				rmail = self.data.static.options["pyffle.extrmail"] + " " + finalDestination
				mailin, mailout = os.popen2(rmail)
				mailin.write(msgString)
				mailout.close()
				mailin.close()
Beispiel #7
0
class PyffleStatic:
	## Parses a STATIC file that configures Pyffle
	
	options = {}
	util = PyffleUtil()
	def parse(self,filename):
		f = open(filename,'r')
		lines = f.readlines()
		for line in lines:
			if not (line[0] == ';' or line == ""):
				elements = line.strip().split(":")
				key = elements[0].strip()
				if not key == '':
					value = ""
				
					if len(elements) > 1:
	
						if len(elements) > 2:
							## FIXME this is retarded 
							firstItem = 1;
							lastItem = len(elements) 	
							self.util.debugln(str(firstItem) + " " + str(lastItem))
							for i in range(firstItem,lastItem):
								value = value + elements[i]
								if not i == lastItem - 1:
									value = value + ":"
						else:
							value = elements[1].strip()
						value=value.strip()
						self.options[key] = value
		self.util.debugln(str(self.options))
Beispiel #8
0
    def go(self, nntp):
        self.doNntp = nntp
        ## Initialise the main controller, load static file
        self.data = PyffleData()
        self.data.toolMode = True  ## Turn on Tool Mode so that we override security restrictions
        static = PyffleStatic()  ## FIXME read this from a env var or something
        static.parse("/pyffle/static")
        self.data.static = static

        ## Setup the DB connection
        Session = sessionmaker()
        engine = create_engine(static.options["pyffle.dburl"], echo=False)  ### FIXME pull this out of static
        Session.configure(bind=engine)
        self.session = Session()
        self.data.session = self.session

        ## Setup up the utility class
        util = PyffleUtil()
        util.data = self.data
        self.data.util = util
        self.data.toolMode = True
        ## Load the MTA plugins
        mtalist = [["pyffle_mta_uucp", "Pyffle UUCP", "UUCP MTA for Pyffle"]]
        self.data.loadMtaList(mtalist)

        ## pick the boards to loop and feeds
        boards = self.uucpboards
        feeds = self.uucpfeeds
        if nntp:
            boards = self.nntpboards
            feeds = self.nntpfeeds

        for boardextname in boards:
            board = self.data.getBoardByExternalname(boardextname)
            print "*** Processing " + board.externalname
            msgids = self.data.getNewMessagesAllUsers(boardname=board.name)
            for msgid in msgids:
                msg = self.data.getMessage(msgid)
                self.sendMessage(msg, feeds)
                self.data.logEntry(
                    self.data.LOGINFO, "EXPORT/MESSAGE/NEWS", "sendnews", "sendnews POSTED msgid " + str(msgid)
                )

        return
Beispiel #9
0
	def go(self,nntp):	
		self.doNntp = nntp
		## Initialise the main controller, load static file
		self.data = PyffleData()
		self.data.toolMode = True 	## Turn on Tool Mode so that we override security restrictions
		static = PyffleStatic()		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		self.data.static = static

		## Setup the DB connection
		Session = sessionmaker()
		engine = create_engine(static.options["pyffle.dburl"], echo=False) ### FIXME pull this out of static
		Session.configure(bind=engine)	
		self.session = Session()
		self.data.session = self.session
		
		## Setup up the utility class
		util = PyffleUtil()
		util.data = self.data
		self.data.util = util
		self.data.toolMode = True	
		## Load the MTA plugins
		mtalist = [["pyffle_mta_uucp","Pyffle UUCP","UUCP MTA for Pyffle"]]
		self.data.loadMtaList(mtalist)
			
		## pick the boards to loop and feeds
		boards = self.uucpboards
		feeds = self.uucpfeeds
		if nntp:
			boards = self.nntpboards
			feeds = self.nntpfeeds
	
		for boardextname in boards:
			board = self.data.getBoardByExternalname(boardextname)
			print "*** Processing " + board.externalname
			msgids = self.data.getNewMessagesAllUsers(boardname=board.name)
			for msgid in msgids:
				msg = self.data.getMessage(msgid)
				self.sendMessage(msg,feeds)
		return
Beispiel #10
0
	def setupPyffleConnection(self):
		static = PyffleStatic()
		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
	
		Session = sessionmaker()
	
		##		engine = create_engine('postgresql://*****:*****@localhost/pyffledev', echo=False)
		engine = create_engine(static.options['pyffle.dburl'], echo = False)
		Session.configure(bind=engine)
	
		self.session = Session()
		util = PyffleUtil()
		self.data = PyffleData()
		self.data.static = static
		self.data.session = self.session
		self.data.util = util
		util.data = self.data
		dispatcher = PyffleDispatch()
		dispatcher.setup(self.data,{},{})
		self.data.setDispatcher(dispatcher)
		self.data.stateChange("startup")
	
		self.words =  util.loadWords("WORDS")		## FIXME should be from static
		self.info =   util.loadWords("INFO")
		self.help =   util.loadWords("HELP")
		self.menus =  util.loadWords("MENUS")
		self.text =   util.loadWords("TEXT")
		self.system = util.loadWords("SYSTEM")
		util.texts["WORDS"] = self.words
		util.texts["INFO"] = self.info
		util.texts["HELP"] = self.help
		util.texts["MENUS"] = self.menus
		util.texts["TEXT"] = self.text
		util.texts["SYSTEM"] = 	self.system	
		self.data.stateChange("wordsloaded")
	
		mtalist = [["pyffle_mta_uucp","Pyffle UUCP","UUCP MTA for Pyffle"],
			["pyffle_mta_ftn","Pyffle FTN","FTN MTA for Pyffle"]]
		self.data.loadMtaList(mtalist)
		self.data.stateChange("mtasloaded")
		self.lastCheck = datetime.now()
Beispiel #11
0
	def go(self):
		static = PyffleStatic()
		## FIXME read this from a env var or something
		static.parse("/pyffle/static")
		
		Session = sessionmaker()
		
		##		engine = create_engine('postgresql://*****:*****@localhost/pyffledev', echo=False)
		engine = create_engine(static.options['pyffle.dburl'], echo = False)
		Session.configure(bind=engine)
		
		self.session = Session()
		util = PyffleUtil()
		self.data = PyffleData()
		self.data.static = static
		self.data.session = self.session
		self.data.util = util
		util.data = self.data
		dispatcher = PyffleDispatch()
		dispatcher.setup(self.data,self.modules,self.modulelist)
		self.data.setDispatcher(dispatcher)
		self.data.stateChange("startup")

		self.words =  util.loadWords("WORDS")		## FIXME should be from static
		self.info =   util.loadWords("INFO")
		self.help =   util.loadWords("HELP")
		self.menus =  util.loadWords("MENUS")
		self.text =   util.loadWords("TEXT")
		self.system = util.loadWords("SYSTEM")
		util.texts["WORDS"] = self.words
		util.texts["INFO"] = self.info
		util.texts["HELP"] = self.help
		util.texts["MENUS"] = self.menus
		util.texts["TEXT"] = self.text
		util.texts["SYSTEM"] = 	self.system	
		self.data.stateChange("wordsloaded")

		mtalist = [["pyffle_mta_uucp","Pyffle UUCP","UUCP MTA for Pyffle"]]
		self.data.loadMtaList(mtalist)
		#msg1 = self.data.createMessage("fooble","sampsa","Test from py","Hello earth")
		#msg2 = self.data.createMessage("*****@*****.**","sampsa","Test to outside","Hello sky")
		self.data.stateChange("mtasloaded")

		
		choice = self.data.util.prompt("\n[P]ETSCII / [A]SCII?")
		choice = choice.lower().strip()
		if choice == "p":
			self.data.util.petsciiMode = True
			## Enable shift on the remote terminal
			print chr(0x0e)
			
		self.data.stateChange("prelogin")
		self.login()
		
		self.data.stateChange("premainmenu")
		self.mainmenu()
		self.data.stateChange("postmainmenu")
		self.data.stateChange("exit")
Beispiel #12
0
    def go(self):
        static = PyffleStatic()
        ## FIXME read this from a env var or something
        static.parse("/pyffle/static")

        Session = sessionmaker()

        ##		engine = create_engine('postgresql://*****:*****@localhost/pyffledev', echo=False)
        engine = create_engine(static.options['pyffle.dburl'], echo=False)
        Session.configure(bind=engine)

        self.session = Session()
        util = PyffleUtil()
        self.data = PyffleData()
        self.data.static = static
        self.data.session = self.session
        self.data.util = util
        util.data = self.data
        dispatcher = PyffleDispatch()
        dispatcher.setup(self.data, self.modules, self.modulelist)
        self.data.setDispatcher(dispatcher)
        self.data.stateChange("startup")

        self.words = util.loadWords("WORDS")  ## FIXME should be from static
        self.info = util.loadWords("INFO")
        self.help = util.loadWords("HELP")
        self.menus = util.loadWords("MENUS")
        self.text = util.loadWords("TEXT")
        self.system = util.loadWords("SYSTEM")
        util.texts["WORDS"] = self.words
        util.texts["INFO"] = self.info
        util.texts["HELP"] = self.help
        util.texts["MENUS"] = self.menus
        util.texts["TEXT"] = self.text
        util.texts["SYSTEM"] = self.system
        self.data.stateChange("wordsloaded")

        mtalist = [["pyffle_mta_uucp", "Pyffle UUCP", "UUCP MTA for Pyffle"]]
        self.data.loadMtaList(mtalist)
        #msg1 = self.data.createMessage("fooble","sampsa","Test from py","Hello earth")
        #msg2 = self.data.createMessage("*****@*****.**","sampsa","Test to outside","Hello sky")
        self.data.stateChange("mtasloaded")

        choice = self.data.util.prompt("\n[P]ETSCII / [A]SCII?")
        choice = choice.lower().strip()
        if choice == "p":
            self.data.util.petsciiMode = True
            ## Enable shift on the remote terminal
            print chr(0x0e)

        self.data.stateChange("prelogin")
        self.login()

        self.data.stateChange("premainmenu")
        self.mainmenu()
        self.data.stateChange("postmainmenu")
        self.data.stateChange("exit")
Beispiel #13
0
    def go(self, finalDestination):
        ## Initialise the main controller, load static file
        ##self.data.util.debugln("in go with final destination " + str(finalDestination))
        self.data = PyffleData()
        util = PyffleUtil()
        self.data.util = util
        self.words = self.data.util.loadWords("WORDS")  ## FIXME should be from static
        self.info = self.data.util.loadWords("INFO")
        self.help = self.data.util.loadWords("HELP")
        self.menus = self.data.util.loadWords("MENUS")
        self.text = self.data.util.loadWords("TEXT")
        self.system = self.data.util.loadWords("SYSTEM")
        self.data.util.texts["WORDS"] = self.words
        self.data.util.texts["INFO"] = self.info
        self.data.util.texts["HELP"] = self.help
        self.data.util.texts["MENUS"] = self.menus
        self.data.util.texts["TEXT"] = self.text
        self.data.util.texts["SYSTEM"] = self.system
        self.data.toolMode = True  ## Turn on Tool Mode so that we override security restrictions
        static = PyffleStatic()  ## FIXME read this from a env var or something
        static.parse("/pyffle/static")
        self.data.static = static

        ## Setup the DB connection
        Session = sessionmaker()
        engine = create_engine(static.options["pyffle.dburl"], echo=False)  ### FIXME pull this out of static
        Session.configure(bind=engine)
        self.session = Session()
        self.data.session = self.session

        ## Setup up the utility class
        util = PyffleUtil()
        util.data = self.data
        self.data.util = util

        ## Load the MTA plugins
        mtalist = [["pyffle_mta_uucp", "Pyffle UUCP", "UUCP MTA for Pyffle"]]
        self.data.loadMtaList(mtalist)

        ## parse the incoming message
        msgString = sys.stdin.read()
        rfcMsg = email.message_from_string(msgString)
        payload = rfcMsg.get_payload()

        toAddress = finalDestination

        ## is this a local message?
        self.data.util.debugln("*******************------------------------****************")
        self.data.util.debugln("Checking in the incoming address is local or not" + str(finalDestination))
        if self.incomingAddressIsLocal(toAddress):
            self.data.util.debugln("it is, let's parse the address")
            toname, hostname = self.parseIncomingAddress(toAddress)
            self.data.util.debugln(str([toname, hostname]))
            ## Ask an MTA to parse the incoming address
            if (not toname == "") and (not toname == None):
                self.data.util.debugln("RMAIL F=%s T=%s S=%s\n" % (rfcMsg["From"], toname, rfcMsg["Subject"]))
                self.data.util.debugln("Creating message")
                ## Store the message
                if rfcMsg.is_multipart():
                    parts = rfcMsg.get_payload()
                    payload = ""
                    partnum = 1
                    for part in parts:
                        payload = payload + part.get_payload()
                        payload = payload + "\nMIME segment %s begins: \n" % (str(partnum))
                        partnum = partnum + 1
                        # os.system("Sending message to " + toname + " >> /tmp/rmail ")
                self.data.util.debugln("Sending message")
                self.data.createMessage(rfcMsg["From"], toname, rfcMsg["Subject"], payload)
                self.data.logEntry(
                    self.data.LOGINFO,
                    "IMPORT/MESSAGE/RMAIL",
                    str(toname),
                    "Received mail for %s from %s" % (str(toname), str(rfcMsg["From"])),
                )

        else:
            pass
            self.data.util.debugln("RMAIL Sending to external rmail")
            ## Pass to external rmail
            with warnings.catch_warnings(record=True) as warn:
                ## FIXME CRITICAL: need to sanitize the To header here...Shell injection
                rmail = self.data.static.options["pyffle.extrmail"] + " " + finalDestination
                mailin, mailout = os.popen2(rmail)
                mailin.write(msgString)
                mailout.close()
                mailin.close()