1 |
hanno 11/09/04 10:26:35 |
2 |
|
3 |
Added: pymsn-t-initd |
4 |
pymsn-t-0.11.3-use-non-deprecated-hashlib.patch |
5 |
Log: |
6 |
pymsn-t: fix deprecations in python and init-script, port to eapi 3 |
7 |
|
8 |
(Portage version: 2.1.10.13/cvs/Linux x86_64) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 net-im/pymsn-t/files/pymsn-t-initd |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-im/pymsn-t/files/pymsn-t-initd?rev=1.1&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-im/pymsn-t/files/pymsn-t-initd?rev=1.1&content-type=text/plain |
15 |
|
16 |
Index: pymsn-t-initd |
17 |
=================================================================== |
18 |
#!/sbin/runscript |
19 |
# Copyright 1999-2011 Gentoo Foundation |
20 |
# Distributed under the terms of the GNU General Public License v2 |
21 |
# $Header: /var/cvsroot/gentoo-x86/net-im/pymsn-t/files/pymsn-t-initd,v 1.1 2011/09/04 10:26:35 hanno Exp $ |
22 |
|
23 |
depend() { |
24 |
need net |
25 |
use jabber-server |
26 |
} |
27 |
|
28 |
start() { |
29 |
ebegin "Starting MSN Jabber Transport" |
30 |
start-stop-daemon --start --pidfile /var/run/jabber/pymsn-t.pid -u jabber -g jabber \ |
31 |
--exec /usr/bin/python INSPATH/pymsn-t.py -- \ |
32 |
-b -c /etc/jabber/pymsn-t.xml -l /var/log/jabber/pymsn-t.log |
33 |
eend $? |
34 |
} |
35 |
|
36 |
stop() { |
37 |
ebegin "Stopping MSN Jabber Transport" |
38 |
start-stop-daemon --stop --quiet --pidfile /var/run/jabber/pymsn-t.pid |
39 |
eend $? |
40 |
} |
41 |
|
42 |
|
43 |
|
44 |
1.1 net-im/pymsn-t/files/pymsn-t-0.11.3-use-non-deprecated-hashlib.patch |
45 |
|
46 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-im/pymsn-t/files/pymsn-t-0.11.3-use-non-deprecated-hashlib.patch?rev=1.1&view=markup |
47 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-im/pymsn-t/files/pymsn-t-0.11.3-use-non-deprecated-hashlib.patch?rev=1.1&content-type=text/plain |
48 |
|
49 |
Index: pymsn-t-0.11.3-use-non-deprecated-hashlib.patch |
50 |
=================================================================== |
51 |
From 87d6eac62671152c318ea2cb839a748b06723ee2 Mon Sep 17 00:00:00 2001 |
52 |
From: Matthew W. S. Bell <matthew@×××××××××××.uk> |
53 |
Date: Sat, 12 Feb 2011 19:44:18 +0000 |
54 |
Subject: [PATCH 2/4] Use newer (non-deprecataed) hashlib module, if available. |
55 |
|
56 |
--- |
57 |
src/avatar.py | 9 +++++++-- |
58 |
src/legacy/msn/msn.py | 11 +++++++---- |
59 |
src/legacy/msn/msnp11chl.py | 8 ++++++-- |
60 |
src/utils.py | 12 ++++++------ |
61 |
src/xdb.py | 8 ++++++-- |
62 |
5 files changed, 32 insertions(+), 16 deletions(-) |
63 |
|
64 |
diff --git a/src/avatar.py b/src/avatar.py |
65 |
index b9f7dfc..3aa0a3c 100644 |
66 |
--- a/src/avatar.py |
67 |
+++ b/src/avatar.py |
68 |
@@ -6,7 +6,12 @@ from debug import LogEvent, INFO, WARN, ERROR |
69 |
from twisted.internet import reactor |
70 |
from twisted.words.xish.domish import Element |
71 |
|
72 |
-import sha, base64, os, os.path |
73 |
+import base64, os, os.path |
74 |
+ |
75 |
+try: |
76 |
+ from hashlib import sha1 |
77 |
+except ImportError: |
78 |
+ from sha import sha as sha1 |
79 |
|
80 |
import utils |
81 |
import config |
82 |
@@ -34,7 +39,7 @@ def parsePhotoEl(photo): |
83 |
class Avatar: |
84 |
""" Represents an Avatar. Does not store the image in memory. """ |
85 |
def __init__(self, imageData, avatarCache): |
86 |
- self.__imageHash = sha.sha(imageData).hexdigest() |
87 |
+ self.__imageHash = sha1(imageData).hexdigest() |
88 |
self.__avatarCache = avatarCache |
89 |
|
90 |
def getImageHash(self): |
91 |
diff --git a/src/legacy/msn/msn.py b/src/legacy/msn/msn.py |
92 |
index cd36aa8..e27e973 100644 |
93 |
--- a/src/legacy/msn/msn.py |
94 |
+++ b/src/legacy/msn/msn.py |
95 |
@@ -106,9 +106,12 @@ from twisted.words.xish.domish import parseText, unescapeFromXml |
96 |
|
97 |
|
98 |
# System imports |
99 |
-import types, operator, os, sys, base64, random, struct, random, sha, base64, StringIO, array, codecs, binascii |
100 |
+import types, operator, os, sys, base64, random, struct, random, base64, StringIO, array, codecs, binascii |
101 |
from urllib import quote, unquote |
102 |
- |
103 |
+try: |
104 |
+ from hashlib import sha1 |
105 |
+except ImportError: |
106 |
+ from sha import sha as sha1 |
107 |
|
108 |
MSN_PROTOCOL_VERSION = "MSNP11" # protocol version |
109 |
MSN_PORT = 1863 # default dispatch server port |
110 |
@@ -490,7 +493,7 @@ class MSNObject: |
111 |
self.type = 3 |
112 |
self.location = "TMP" + str(random.randint(1000,9999)) |
113 |
self.friendly = "AAA=" |
114 |
- self.sha1d = b64enc(sha.sha(imageData).digest()) |
115 |
+ self.sha1d = b64enc(sha1(imageData).digest()) |
116 |
self.makeText() |
117 |
|
118 |
def setNull(self): |
119 |
@@ -518,7 +521,7 @@ class MSNObject: |
120 |
h.append(self.friendly) |
121 |
h.append("SHA1D") |
122 |
h.append(self.sha1d) |
123 |
- sha1c = b64enc(sha.sha("".join(h)).digest()) |
124 |
+ sha1c = b64enc(sha1("".join(h)).digest()) |
125 |
self.text = '<msnobj Creator="%s" Size="%s" Type="%s" Location="%s" Friendly="%s" SHA1D="%s" SHA1C="%s"/>' % (self.creator, str(self.size), str(self.type), self.location, self.friendly, self.sha1d, sha1c) |
126 |
|
127 |
def parse(self, s): |
128 |
diff --git a/src/legacy/msn/msnp11chl.py b/src/legacy/msn/msnp11chl.py |
129 |
index bbf4c4d..9368df0 100644 |
130 |
--- a/src/legacy/msn/msnp11chl.py |
131 |
+++ b/src/legacy/msn/msnp11chl.py |
132 |
@@ -1,16 +1,20 @@ |
133 |
# Copyright 2005 James Bunton <james@××××××××.net> |
134 |
# Licensed for distribution under the GPL version 2, check COPYING for details |
135 |
|
136 |
-import md5 |
137 |
import struct |
138 |
|
139 |
+try: |
140 |
+ from hashlib import md5 |
141 |
+except ImportError: |
142 |
+ from md5 import md5 |
143 |
+ |
144 |
MSNP11_PRODUCT_ID = "PROD0090YUAUV{2B" |
145 |
MSNP11_PRODUCT_KEY = "YMM8C_H7KCQ2S_KL" |
146 |
MSNP11_MAGIC_NUM = 0x0E79A9C1 |
147 |
|
148 |
|
149 |
def doChallenge(chlData): |
150 |
- md5digest = md5.md5(chlData + MSNP11_PRODUCT_KEY).digest() |
151 |
+ md5digest = md5(chlData + MSNP11_PRODUCT_KEY).digest() |
152 |
|
153 |
# Make array of md5 string ints |
154 |
md5Ints = struct.unpack("<llll", md5digest) |
155 |
diff --git a/src/utils.py b/src/utils.py |
156 |
index cb73ea3..88110ae 100644 |
157 |
--- a/src/utils.py |
158 |
+++ b/src/utils.py |
159 |
@@ -1,17 +1,17 @@ |
160 |
# Copyright 2004-2005 James Bunton <james@××××××××.net> |
161 |
# Licensed for distribution under the GPL version 2, check COPYING for details |
162 |
|
163 |
+try: |
164 |
+ from hashlib import sha1 |
165 |
+except ImportError: |
166 |
+ from sha import sha as sha1 |
167 |
|
168 |
+def socks5Hash(sid, initiator, target): |
169 |
+ return sha1("%s%s%s" % (sid, initiator, target)).hexdigest() |
170 |
|
171 |
def getLang(el): |
172 |
return el.getAttribute((u'http://www.w3.org/XML/1998/namespace', u'lang')) |
173 |
|
174 |
- |
175 |
-import sha |
176 |
-def socks5Hash(sid, initiator, target): |
177 |
- return sha.new("%s%s%s" % (sid, initiator, target)).hexdigest() |
178 |
- |
179 |
- |
180 |
import urllib |
181 |
import os.path |
182 |
def getURLBits(url, assumedType=None): |
183 |
diff --git a/src/xdb.py b/src/xdb.py |
184 |
index a3e3b5d..bd48582 100644 |
185 |
--- a/src/xdb.py |
186 |
+++ b/src/xdb.py |
187 |
@@ -6,9 +6,13 @@ from debug import LogEvent, INFO, WARN |
188 |
import os |
189 |
import os.path |
190 |
import shutil |
191 |
-import md5 |
192 |
import config |
193 |
|
194 |
+try: |
195 |
+ from hashlib import md5 |
196 |
+except ImportError: |
197 |
+ from md5 import md5 |
198 |
+ |
199 |
X = os.path.sep |
200 |
SPOOL_UMASK = 0077 |
201 |
|
202 |
@@ -23,7 +27,7 @@ def mangle(file): |
203 |
return file.replace("@", "%") |
204 |
|
205 |
def makeHash(file): |
206 |
- return md5.md5(file).hexdigest()[0:3] |
207 |
+ return md5(file).hexdigest()[0:3] |
208 |
|
209 |
|
210 |
class XDB: |
211 |
-- |
212 |
1.7.2.3 |