How to Set up Tomcat 6 with CGIs
No, I haven't transitioned from developer to system administrator, but I am at work on Sunday, with nobody else trying to figure out what's up with this package that includes CGI. Seems that tomcat does indeed have CGI support which isn't enabled by default (you need to comment out the CGIServlet block in conf/web.xml). Fair enough, I did that. Next thing I realised is that the linked-to instructions are written for an older version, the new one has CGIServlet in catalina.jar, so no renaming is required. You do still need to map the CGIServlet to the url pattern, though.
How to Implement User Authentication
The code after the flip will write apache formatted password files and in an sqlite table.
class htpasswd(object):
def __init__(self, user):
self.user = user
self.password = None
self.sqlstatement = 'INSERT into Users (name, password) VALUES (?,?)'
def __str__(self):
import pysqlite2.dbapi2 as sqlite
sql=sqlite.connect('user')
cursor = sql.cursor()
res=cursor.execute(self.sqlstatement, (self.user, self.password,))
sql.commit()
cursor.close()
sql.close()
return '%s:%s' % (self.user, self.password)
def set_password(self, passwd):
import crypt
self.password = crypt.crypt(passwd, passwd[0:1])
if __name__ == '__main__':
import sys
outfile = open('httppass', mode='a')
o=htpasswd(sys.argv[1])
o.set_password(sys.argv[2])
outfile.write(str(o)+'\n')
outfile.close()
Memetrac Going Dynamic!
Either this week's drop or the next week, I plan to make memetrac dynamic. Meaning that, it won't run as a cronjob every 15 minutes, rather it will be generated just-in-time. I've found a note on the modpython mailing list to help make this a reality.
