2000-11-24 Jochen Eisinger <jochen.eisinger@gmx.net>

* doc/scanimage.man doc/saned.man: updated description of password
	  file
	* sanei/sanei_auth.c frontend/saned.c frontend/scanimage.c: replaced
	  index() by strchr(). Changed style of password file
	* backend/net.c: the net backend now prepends net:host: to the
	  resource before calling the auth_callback function
DEVEL_2_0_BRANCH-1
Jochen Eisinger 2000-11-24 15:05:21 +00:00
rodzic f537d9f801
commit 0c4074a130
1 zmienionych plików z 38 dodań i 28 usunięć

Wyświetl plik

@ -45,11 +45,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef NEED_STRINGS_H #include <string.h>
# include <strings.h>
#else
# include <string.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
@ -193,15 +189,28 @@ sanei_authorize (const char *resource,
while (sanei_config_read (line, 1024, passwd_file)) while (sanei_config_read (line, 1024, passwd_file))
{ {
if (strncmp (line, resource, strlen (resource)) == 0) if ((strlen (line) > 0) && (line[strlen (line) - 1] == '\n'))
{ line[strlen (line) - 1] = '\n';
if (((index (line, ':')) - line) == (signed) strlen (resource)) if ((strlen (line) > 0) && (line[strlen (line) - 1] == '\r'))
line[strlen (line) - 1] = '\r';
if (strchr (line, ':') != NULL)
{
if (strchr (strchr (line, ':') + 1, ':') != NULL)
{ {
entry_found = SANE_TRUE; if (strcmp (strchr (strchr (line, ':') + 1, ':') + 1, resource)
break; == 0)
{
entry_found = SANE_TRUE;
break;
}
} }
} }
@ -238,35 +247,36 @@ sanei_authorize (const char *resource,
while (sanei_config_read (line, 1024, passwd_file)) while (sanei_config_read (line, 1024, passwd_file))
{ {
if ((strlen (line) > 0) && (line[strlen (line) - 1] == '\n'))
line[strlen (line) - 1] = '\n';
if ((strncmp (line, resource, strlen (resource)) == 0) && if ((strlen (line) > 0) && (line[strlen (line) - 1] == '\r'))
(((index (line, ':')) - line) == (signed) strlen (resource))) line[strlen (line) - 1] = '\r';
if ((strncmp (line, username, strlen (username)) == 0) &&
(((strchr (line, ':')) - line) == (signed) strlen (username)))
{ {
linep = index (line, ':') + 1; linep = strchr (line, ':') + 1;
if ((strncmp (linep, username, strlen (username)) == 0) && if ((strchr (linep, ':') != NULL)
(((index (linep, ':')) - linep) == (signed) strlen (username))) && (strcmp (strchr (linep, ':') + 1, resource) == 0))
{ {
linep = index (linep, ':') + 1; *(strchr (linep, ':')) = 0;
if (strlen (linep) > 127)
DBG (1, "%s contains invalid entries...\n", passwd_filename); if (check_passwd (password, linep, md5resource, username))
else
{ {
fclose (passwd_file);
if (check_passwd (password, linep, md5resource, username)) DBG (2, "authorization succeeded\n");
{ return SANE_STATUS_GOOD;
fclose (passwd_file);
DBG (2, "authorization succeeded\n");
return SANE_STATUS_GOOD;
}
} }
} }
} }
} }
fclose (passwd_file); fclose (passwd_file);