kopia lustrzana https://gitlab.com/sane-project/backends
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 functionDEVEL_2_0_BRANCH-1
rodzic
f537d9f801
commit
0c4074a130
|
@ -45,11 +45,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef NEED_STRINGS_H
|
|
||||||
# include <strings.h>
|
|
||||||
#else
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -193,16 +189,29 @@ 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 ((strlen (line) > 0) && (line[strlen (line) - 1] == '\r'))
|
||||||
|
line[strlen (line) - 1] = '\r';
|
||||||
|
|
||||||
|
if (strchr (line, ':') != NULL)
|
||||||
|
{
|
||||||
|
if (strchr (strchr (line, ':') + 1, ':') != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (((index (line, ':')) - line) == (signed) strlen (resource))
|
if (strcmp (strchr (strchr (line, ':') + 1, ':') + 1, resource)
|
||||||
|
== 0)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
entry_found = SANE_TRUE;
|
entry_found = SANE_TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,23 +247,25 @@ 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);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (check_passwd (password, linep, md5resource, username))
|
if (check_passwd (password, linep, md5resource, username))
|
||||||
{
|
{
|
||||||
|
@ -265,7 +276,6 @@ sanei_authorize (const char *resource,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue