[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/src
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/src |
Date: |
Mon, 20 Dec 2004 02:14:38 +0100 |
Update of /home/cvs/gsasl/lib/src
In directory dopio:/tmp/cvs-serv4288/lib/src
Modified Files:
error.c gsasl-compat.h gsasl.h.in md5pwd.c obsolete.c
Log Message:
Replace gsasl_md5pwd_get_password with gsasl_simple_getpass, and update callers.
--- /home/cvs/gsasl/lib/src/error.c 2004/12/15 00:50:27 1.14
+++ /home/cvs/gsasl/lib/src/error.c 2004/12/20 01:14:38 1.15
@@ -62,14 +62,6 @@
p = _("SASL mechanism called too many times");
break;
- case GSASL_FOPEN_ERROR:
- p = _("Could not open file in SASL library");
- break;
-
- case GSASL_FCLOSE_ERROR:
- p = _("Could not close file in SASL library");
- break;
-
case GSASL_MALLOC_ERROR:
p = _("Memory allocation error in SASL library");
break;
@@ -165,10 +157,6 @@
p = _("Integrity error in application payload");
break;
- case GSASL_NO_MORE_REALMS:
- p = _("No more realms available (non-fatal)");
- break;
-
case GSASL_NO_CLIENT_CODE:
p = _("Client-side functionality not available in library "
"(application error)");
@@ -236,6 +224,14 @@
p = _("SASL function need larger buffer (internal error)");
break;
+ case GSASL_FOPEN_ERROR:
+ p = _("Could not open file in SASL library");
+ break;
+
+ case GSASL_FCLOSE_ERROR:
+ p = _("Could not close file in SASL library");
+ break;
+
case GSASL_CANNOT_GET_CTX:
p = _("Cannot get internal library handle (library error)");
break;
@@ -360,6 +356,10 @@
case GSASL_UNICODE_NORMALIZATION_ERROR:
p = _("Failed to perform Unicode Normalization on string.");
break;
+
+ case GSASL_NO_MORE_REALMS:
+ p = _("No more realms available (non-fatal)");
+ break;
#endif
default:
--- /home/cvs/gsasl/lib/src/gsasl-compat.h 2004/12/15 00:51:36 1.18
+++ /home/cvs/gsasl/lib/src/gsasl-compat.h 2004/12/20 01:14:38 1.19
@@ -33,6 +33,8 @@
enum
{
GSASL_TOO_SMALL_BUFFER = 4,
+ GSASL_FOPEN_ERROR = 5,
+ GSASL_FCLOSE_ERROR = 6,
GSASL_GCRYPT_ERROR = GSASL_CRYPTO_ERROR,
GSASL_CANNOT_GET_CTX = 32,
GSASL_NEED_CLIENT_ANONYMOUS_CALLBACK = 11,
@@ -52,7 +54,8 @@
GSASL_NEED_SERVER_SERVICE_CALLBACK = 25,
GSASL_NEED_SERVER_GSSAPI_CALLBACK = 26,
GSASL_NEED_SERVER_RETRIEVE_CALLBACK = 27,
- GSASL_UNICODE_NORMALIZATION_ERROR = 28
+ GSASL_UNICODE_NORMALIZATION_ERROR = 28,
+ GSASL_NO_MORE_REALMS = 34
} __attribute__ ((deprecated));
typedef Gsasl Gsasl_ctx __attribute__ ((deprecated));
@@ -134,6 +137,11 @@
extern char *gsasl_stringprep_trace (const char *in, int *stringprep_rc)
__attribute__ ((deprecated));
+extern int gsasl_md5pwd_get_password (const char *filename,
+ const char *username,
+ char *key, size_t * keylen)
+ __attribute__ ((deprecated));
+
/* Callback prototypes */
typedef int (*Gsasl_client_callback_anonymous) (Gsasl_session * sctx,
char *out, size_t * outlen);
--- /home/cvs/gsasl/lib/src/gsasl.h.in 2004/12/19 08:39:19 1.56
+++ /home/cvs/gsasl/lib/src/gsasl.h.in 2004/12/20 01:14:38 1.57
@@ -59,8 +59,6 @@
GSASL_NEEDS_MORE = 1,
GSASL_UNKNOWN_MECHANISM = 2,
GSASL_MECHANISM_CALLED_TOO_MANY_TIMES = 3,
- GSASL_FOPEN_ERROR = 5,
- GSASL_FCLOSE_ERROR = 6,
GSASL_MALLOC_ERROR = 7,
GSASL_BASE64_ERROR = 8,
GSASL_CRYPTO_ERROR = 9,
@@ -68,7 +66,6 @@
GSASL_MECHANISM_PARSE_ERROR = 30,
GSASL_AUTHENTICATION_ERROR = 31,
GSASL_INTEGRITY_ERROR = 33,
- GSASL_NO_MORE_REALMS = 34,
GSASL_NO_CLIENT_CODE = 35,
GSASL_NO_SERVER_CODE = 36,
GSASL_INVALID_HANDLE = 50,
--- /home/cvs/gsasl/lib/src/md5pwd.c 2004/04/15 22:02:50 1.2
+++ /home/cvs/gsasl/lib/src/md5pwd.c 2004/12/20 01:14:38 1.3
@@ -22,15 +22,14 @@
#include "internal.h"
/**
- * gsasl_md5pwd_get_password:
+ * gsasl_simple_getpass:
* @filename: filename of file containing passwords.
* @username: username string.
- * @key: output character array.
- * @keylen: input maximum size of output character array, on output
- * contains actual length of output array.
+ * @key: newly allocated output character array.
*
- * Retrieve password for user from specified file. To find out how
- * large the output array must be, call this function with out=NULL.
+ * Retrieve password for user from specified file. The buffer @key
+ * contain the password if this function is successful. The caller is
+ * responsible for deallocating it.
*
* The file should be on the UoW "MD5 Based Authentication" format,
* which means it is in text format with comments denoted by # first
@@ -38,59 +37,51 @@
* function removes \r and \n at the end of lines before processing.
*
* Return value: Return GSASL_OK if output buffer contains the
- * password, GSASL_AUTHENTICATION_ERROR if the user could not be
- * found, or other error code.
+ * password, GSASL_AUTHENTICATION_ERROR if the user could not be
+ * found, or other error code.
**/
int
-gsasl_md5pwd_get_password (const char *filename,
- const char *username, char *key, size_t * keylen)
+gsasl_simple_getpass (const char *filename,
+ const char *username,
+ char **key)
{
- char matchbuf[BUFSIZ];
- char line[BUFSIZ];
+ size_t userlen = strlen (username);
+ char *line = NULL;
+ size_t n = 0;
FILE *fh;
fh = fopen (filename, "r");
- if (fh == NULL)
- return GSASL_FOPEN_ERROR;
-
- sprintf (matchbuf, "%s\t", username);
-
- while (!feof (fh))
+ if (fh)
{
- if (fgets (line, BUFSIZ, fh) == NULL)
- break;
-
- if (line[0] == '#')
- continue;
+ while (!feof (fh))
+ {
+ if (getline (&line, &n, fh) < 0)
+ break;
- while (strlen (line) > 0 && (line[strlen (line) - 1] == '\n' ||
- line[strlen (line) - 1] == '\r'))
- line[strlen (line) - 1] = '\0';
+ if (line[0] == '#')
+ continue;
- if (strlen (line) <= strlen (matchbuf))
- continue;
+ if (line[strlen (line) - 1] == '\r')
+ line[strlen (line) - 1] = '\0';
+ if (line[strlen (line) - 1] == '\n')
+ line[strlen (line) - 1] = '\0';
- if (strncmp (matchbuf, line, strlen (matchbuf)) == 0)
- {
- if (*keylen < strlen (line) - strlen (matchbuf))
+ if (strncmp (line, username, userlen) == 0 && line[userlen] == '\t')
{
- fclose (fh);
- return GSASL_TOO_SMALL_BUFFER;
- }
-
- *keylen = strlen (line) - strlen (matchbuf);
+ *key = malloc (strlen (line) - userlen);
+ if (!*key)
+ return GSASL_MALLOC_ERROR;
- if (key)
- memcpy (key, &line[strlen (matchbuf)], *keylen);
+ strcpy (*key, line + userlen + 1);
- fclose (fh);
+ fclose (fh);
- return GSASL_OK;
+ return GSASL_OK;
+ }
}
- }
- if (fclose (fh) != 0)
- return GSASL_FCLOSE_ERROR;
+ fclose (fh);
+ }
return GSASL_AUTHENTICATION_ERROR;
}
--- /home/cvs/gsasl/lib/src/obsolete.c 2004/12/15 00:52:08 1.22
+++ /home/cvs/gsasl/lib/src/obsolete.c 2004/12/20 01:14:38 1.23
@@ -21,8 +21,6 @@
#include "internal.h"
-#ifndef GSASL_NO_OBSOLETE
-
/**
* gsasl_client_listmech:
* @ctx: libgsasl handle.
@@ -1654,6 +1652,83 @@
return out;
}
+/**
+ * gsasl_md5pwd_get_password:
+ * @filename: filename of file containing passwords.
+ * @username: username string.
+ * @key: output character array.
+ * @keylen: input maximum size of output character array, on output
+ * contains actual length of output array.
+ *
+ * Retrieve password for user from specified file. To find out how
+ * large the output array must be, call this function with out=NULL.
+ *
+ * The file should be on the UoW "MD5 Based Authentication" format,
+ * which means it is in text format with comments denoted by # first
+ * on the line, with user entries looking as username\tpassword. This
+ * function removes \r and \n at the end of lines before processing.
+ *
+ * Return value: Return GSASL_OK if output buffer contains the
+ * password, GSASL_AUTHENTICATION_ERROR if the user could not be
+ * found, or other error code.
+ *
+ * Deprecated: Use gsasl_simple_getpass() instead.
+ **/
+int
+gsasl_md5pwd_get_password (const char *filename,
+ const char *username, char *key, size_t * keylen)
+{
+ char matchbuf[BUFSIZ];
+ char line[BUFSIZ];
+ FILE *fh;
+
+ fh = fopen (filename, "r");
+ if (fh == NULL)
+ return GSASL_FOPEN_ERROR;
+
+ sprintf (matchbuf, "%s\t", username);
+
+ while (!feof (fh))
+ {
+ if (fgets (line, BUFSIZ, fh) == NULL)
+ break;
+
+ if (line[0] == '#')
+ continue;
+
+ while (strlen (line) > 0 && (line[strlen (line) - 1] == '\n' ||
+ line[strlen (line) - 1] == '\r'))
+ line[strlen (line) - 1] = '\0';
+
+ if (strlen (line) <= strlen (matchbuf))
+ continue;
+
+ if (strncmp (matchbuf, line, strlen (matchbuf)) == 0)
+ {
+ if (*keylen < strlen (line) - strlen (matchbuf))
+ {
+ fclose (fh);
+ return GSASL_TOO_SMALL_BUFFER;
+ }
+
+ *keylen = strlen (line) - strlen (matchbuf);
+
+ if (key)
+ memcpy (key, &line[strlen (matchbuf)], *keylen);
+
+ fclose (fh);
+
+ return GSASL_OK;
+ }
+ }
+
+ if (fclose (fh) != 0)
+ return GSASL_FCLOSE_ERROR;
+
+ return GSASL_AUTHENTICATION_ERROR;
+}
+
+
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
@@ -1926,4 +2001,3 @@
return (tarindex);
}
-#endif
- CVS gsasl/lib/src, (continued)
- CVS gsasl/lib/src, gsasl-commit, 2004/12/14
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src, gsasl-commit, 2004/12/19
- CVS gsasl/lib/src,
gsasl-commit <=
- CVS gsasl/lib/src, gsasl-commit, 2004/12/25
- CVS gsasl/lib/src, gsasl-commit, 2004/12/26
- CVS gsasl/lib/src, gsasl-commit, 2004/12/26