summary refs log tree commit diff stats
path: root/src/common/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 5120c25a..f05a2c9e 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1966,3 +1966,23 @@ get_subdirs (const char *path)
 
 	return dirlist;
 }
+
+char *
+encode_sasl_pass (char *user, char *pass)
+{
+	int passlen;
+	char *buffer;
+	char *encoded;
+
+	/* passphrase generation, nicely copy-pasted from the CAP-SASL plugin */
+	passlen = strlen (user) * 2 + 2 + strlen (pass);
+	buffer = (char*) malloc (passlen + 1);
+	strcpy (buffer, user);
+	strcpy (buffer + strlen (user) + 1, user);
+	strcpy (buffer + strlen (user) * 2 + 2, pass);
+	encoded = g_base64_encode ((unsigned char*) buffer, passlen);
+
+	free (buffer);
+
+	return encoded;
+}