Author: andar

Revision: 5375

Log:
        If a 'localclient' entry is not in the auth file, then have the daemon 
add one.

Diff:
Modified: trunk/deluge/core/authmanager.py
===================================================================
--- trunk/deluge/core/authmanager.py    2009-06-10 16:37:21 UTC (rev 5374)
+++ trunk/deluge/core/authmanager.py    2009-06-10 18:11:14 UTC (rev 5375)
@@ -86,16 +86,22 @@
 
         return 0
 
+    def __create_localclient_account(self):
+        """
+        Returns the string.
+        """
+        # We create a 'localclient' account with a random password
+        try:
+            from hashlib import sha1 as sha_hash
+        except ImportError:
+            from sha import new as sha_hash
+        return "localclient:" + sha_hash(str(random.random())).hexdigest() + 
":" + str(AUTH_LEVEL_ADMIN) + "\n"
+
     def __load_auth_file(self):
         auth_file = configmanager.get_config_dir("auth")
         # Check for auth file and create if necessary
         if not os.path.exists(auth_file):
-            # We create a 'localclient' account with a random password
-            try:
-                from hashlib import sha1 as sha_hash
-            except ImportError:
-                from sha import new as sha_hash
-            open(auth_file, "w").write("localclient:" + 
sha_hash(str(random.random())).hexdigest() + ":" + str(AUTH_LEVEL_ADMIN) + "\n")
+            open(auth_file, "w").write(self.__create_localclient_account())
             # Change the permissions on the file so only this user can 
read/write it
             os.chmod(auth_file, stat.S_IREAD | stat.S_IWRITE)
 
@@ -121,3 +127,7 @@
                 continue
 
             self.__auth[username.strip()] = (password.strip(), level)
+
+        f.close()
+        if "localclient" not in self.__auth:
+            open(auth_file, "a").write(self.__create_localclient_account())



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to