con.data=con.data[len(cmd)+1:]
cmdname=cmd[:4]
if not con.authorized and cmdname not in ('linp', 'linc', 'name'):
- raise BailOut
+ raise BailOut()
# TODO: log unauthorized access
if cmdname in cmdlist_noargs:
if len(cmd)==4:
pass
# TODO: log malicious msg
else:
- raise BailOut
+ raise BailOut()
# TODO: log this
-
def lock(con, arg, hard):
if arg not in locks:
locks[arg]={'hard': hard, 'name': con.name, 'time': int(time.time())}
con.sock.send("HARD") # Hard lock - you can go get a cup of tea
else:
con.sock.send("SOFT") # Soft lock - try in a second or two
-
-
+
def cmd_unlock(con, arg):
if arg in locks:
del locks[arg]
def cmd_show_locks(con):
cmd_log(con, "Dumping locks data:");
if len(locks):
- for lockdata in locks.iteritems():
+ res = ""
+ for lockdata in locks.items():
tree, data = lockdata
- cmd_log(con, "Tree: %s, Conn name: %s, Hard Lock: %s, Time: %s"
- % (tree, data['name'], data['hard'], time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data['time']))))
+ msg = "Tree: %s, Conn name: %s, Hard Lock: %s, Time: %s" % (
+ tree, data['name'], data['hard'], time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data['time'])))
+ cmd_log(con, msg)
+ res = res + msg
+# con.sock.send("BLOB:%d" % len(res))
+ con.sock.send(res)
else:
cmd_log(con, "No locks found.");
+ con.sock.send("NLCK");
def cmd_log(con, msg):
- logfile.write('%s [%s] -- %s\n' % (time.strftime('%Y-%m-%d %H:%M:%S'),
- con.name, msg))
+ logfile.write('%s [%s] -- %s\n' % (time.strftime('%Y-%m-%d %H:%M:%S'), con.name, msg))
logfile.flush()
def cmd_name(con, name):
def cmd_login_passwd(con, data):
tmp=data.split('\n')
if len(tmp)!=2:
- raise BailOut
+ raise BailOut()
login=tmp[0]
passwd=tmp[1]
md5pass=md5.new(passwd).hexdigest()
else:
# TODO: log this
con.sock.send('FAIL')
- raise BailOut
+ raise BailOut()
def cmd_login_cookie(con, cookie):
if cookie in cookies: