Searching libcrypto.so in more locations
diff --git a/shadowsocks/crypto/ctypes_openssl.py b/shadowsocks/crypto/ctypes_openssl.py
index 9e0dfca87..22238c0a9 100644
--- a/shadowsocks/crypto/ctypes_openssl.py
+++ b/shadowsocks/crypto/ctypes_openssl.py
@@ -45,9 +45,29 @@ def load_openssl():
         if libcrypto_path:
             break
     else:
+        # We may get here when find_library fails because, for example,
+        # the user does not have sufficient privileges to access those
+        # tools underlying find_library on linux.
+
         import glob
-        for libcrypto_path in glob.glob('/usr/lib/libcrypto.*'):
-            pass
+        import sys
+
+        patterns = ['/usr/lib/libcrypto.*']
+
+        # Some linux distros may store so in alternative locations
+        if sys.maxsize > 2 ** 32:
+            # Python is 64-bit
+            patterns.extend(['/usr/lib64/libcrypto.*'])
+        else:
+            # Python is 32-bit
+            patterns.extend(['/usr/lib32/libcrypto.*'])
+
+        for pat in patterns:
+            files = glob.glob(pat)
+            if files:
+                libcrypto_path = files[0]
+                break
+
     if libcrypto_path is None:
         raise Exception('libcrypto(OpenSSL) not found')
     logging.info('loading libcrypto from %s', libcrypto_path)
@@ -83,9 +103,9 @@ def load_cipher(cipher_name):
 
 class CtypesCrypto(object):
     def __init__(self, cipher_name, key, iv, op):
+        self._ctx = None
         if not loaded:
             load_openssl()
-        self._ctx = None
         cipher = libcrypto.EVP_get_cipherbyname(cipher_name)
         if not cipher:
             cipher = load_cipher(cipher_name)
diff --git a/shadowsocks/crypto/rc4_md5.py b/shadowsocks/crypto/rc4_md5.py
index 3062dcc0f..aa22b1682 100644
--- a/shadowsocks/crypto/rc4_md5.py
+++ b/shadowsocks/crypto/rc4_md5.py
@@ -39,7 +39,7 @@ def create_cipher(alg, key, iv, op, key_as_bytes=0, d=None, salt=None,
     try:
         from shadowsocks.crypto import ctypes_openssl
         return ctypes_openssl.CtypesCrypto(b'rc4', rc4_key, b'', op)
-    except:
+    except Exception:
         import M2Crypto.EVP
         return M2Crypto.EVP.Cipher(b'rc4', rc4_key, b'', op,
                                    key_as_bytes=0, d='md5', salt=None, i=1,
diff --git a/shadowsocks/eventloop.py b/shadowsocks/eventloop.py
index 55c30bb98..304b22920 100644
--- a/shadowsocks/eventloop.py
+++ b/shadowsocks/eventloop.py
@@ -232,8 +232,9 @@ def run(self):
                     logging.error(e)
                     import traceback
                     traceback.print_exc()
-            for handler in self._handlers_to_remove:
-                self._handlers.remove(handler)
+            if self._handlers_to_remove:
+                for handler in self._handlers_to_remove:
+                    self._handlers.remove(handler)
                 self._handlers_to_remove = []
             self._iterating = False
 

When I tried to setup `ss` server on my host, which was a shared shard, `crypto` searching failed, because `libcrypto.so` was put in `/usr/lib64` rather than `/usr/lib`.

A few minor fixes are also included.

Change 6eadfca was missing in #256.
