~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/chat.py

  • Committer: me at id
  • Date: 2009-02-02 04:42:36 UTC
  • Revision ID: svn-v4:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1190
www/apps/userservice#get_user: Fix fallout from the Storm migration.
    ivle.auth.authenticate.authenticate now wants a store, so we give it one.
    We also perform the old password check before we set attributes on the
    user, as otherwise the new password will always succeed (as the hash has
    already been updated).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import cjson
23
23
import cStringIO
24
 
import hashlib
 
24
import md5
25
25
import sys
26
26
import os
27
27
import socket
53
53
            os._exit(0) # kill off parent again.
54
54
        os.umask(077)
55
55
 
56
 
        try:
57
 
            MAXFD = os.sysconf("SC_OPEN_MAX")
58
 
        except:
59
 
            MAXFD = 256
60
 
 
61
 
        # Close all file descriptors, except the socket.
62
 
        for i in xrange(MAXFD):
63
 
            if i == s.fileno():
64
 
                continue
65
 
            try:
66
 
                os.close(i)
67
 
            except OSError:
68
 
                pass
69
 
 
70
 
        si = os.open(os.devnull, os.O_RDONLY)
71
 
        os.dup2(si, sys.stdin.fileno())
72
 
 
73
 
        so = os.open(os.devnull, os.O_WRONLY)
74
 
        os.dup2(so, sys.stdout.fileno())
75
 
 
76
 
        se = os.open(os.devnull, os.O_WRONLY)
77
 
        os.dup2(se, sys.stderr.fileno())
78
 
 
79
56
    if initializer:
80
57
        initializer()
81
58
 
97
74
            env = cjson.decode(inp)
98
75
            
99
76
            # Check that the message is 
100
 
            digest = hashlib.md5(env['content'] + magic).hexdigest()
 
77
            digest = md5.new(env['content'] + magic).digest().encode('hex')
101
78
            if env['digest'] != digest:
102
79
                conn.close()
103
80
                continue
134
111
    sok = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
135
112
    sok.connect((host, port))
136
113
    content = cjson.encode(msg)
137
 
    digest = hashlib.md5(content + magic).hexdigest()
 
114
    digest = md5.new(content + magic).digest().encode("hex")
138
115
    env = {'digest':digest,'content':content}
139
116
    sok.send(cjson.encode(env))
140
117