cleanup to work on new server
This commit is contained in:
parent
a0bf0ebcdf
commit
5ddee41d8a
15
auth.py
15
auth.py
|
@ -1,22 +1,33 @@
|
|||
import MySQLdb
|
||||
import hashlib
|
||||
import config
|
||||
import bcrypt
|
||||
import traceback
|
||||
|
||||
class NoopAuth(object):
|
||||
def FAuthorized(self, user, passwd):
|
||||
return True
|
||||
|
||||
class DrupalAuth(object):
|
||||
def FHashMatches(self, md5, dbhash):
|
||||
return md5 == dbhash
|
||||
def FAuthorized(self, user, passwd):
|
||||
conn = MySQLdb.connect(host = config.drupaldb_host, user = config.drupaldb_user, passwd = config.drupaldb_password, db = config.drupaldb)
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute("SELECT name, pass FROM users WHERE name = %s AND pass = %s", (user, hashlib.md5(passwd).hexdigest()))
|
||||
return cursor.fetchone() != None
|
||||
firsthash = hashlib.md5(passwd).hexdigest()
|
||||
cursor.execute("SELECT pass FROM users WHERE name = %s", (user,))
|
||||
row = cursor.fetchone()
|
||||
return row and self.FHashMatches(firsthash, row[0])
|
||||
finally:
|
||||
cursor.close()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
return False
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
class DrupalBcryptAuth(DrupalAuth):
|
||||
def FHashMatches(self, md5, dbhash):
|
||||
return bcrypt.checkpw(md5, dbhash)
|
|
@ -8,8 +8,9 @@ BIND_HOSTNAME = ""
|
|||
W = 80
|
||||
H = 25
|
||||
# directory to save ANSI pictures to. leave as "." for current directory. no trailing slash required. "" == /
|
||||
DIR_ANSI = "."
|
||||
# authorization. Options are "Noop" (make up a username, no password), "Drupal" (fetches from MySQL Drupal database)
|
||||
DIR_ANSI = "/home/jeremy/sites/marmots/ansi"
|
||||
# authorization. Options are "Noop" (make up a username, no password), "Drupal" (fetches from MySQL Drupal database),
|
||||
#"DrupalBcrypt" (fetches from MySQL Drupal database hacked to bcrypt the md5 hash - basically just Glorious Trainwrecks)
|
||||
AUTH = "Noop"
|
||||
# if Drupal, configure these options:
|
||||
#drupaldb = "database"
|
||||
|
|
2
savecycle.sh
Normal file → Executable file
2
savecycle.sh
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
|||
|
||||
fnnew="whiteboard.marm.`date "+%F_%H-%M"`"
|
||||
|
||||
cd /home/jeremy/marmots
|
||||
cd /home/jeremy/src/marmots
|
||||
|
||||
save ()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue