1993-08-04 23:33:40 +04:00
|
|
|
|
/* callin.c
|
|
|
|
|
Check a login name and password against the UUCP password file.
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
Copyright (C) 1992, 1993 Ian Lance Taylor
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
This file is part of the Taylor UUCP uuconf library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
The author of the program may be contacted at ian@airs.com or
|
1994-10-25 01:17:41 +03:00
|
|
|
|
c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
|
1993-08-04 23:33:40 +04:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "uucnfi.h"
|
|
|
|
|
|
|
|
|
|
#if USE_RCS_ID
|
1994-10-25 01:17:41 +03:00
|
|
|
|
const char _uuconf_callin_rcsid[] = "$Id: callin.c,v 1.2 1994/10/24 22:20:42 jtc Exp $";
|
1993-08-04 23:33:40 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
static int ipcheck P((pointer pglobal, int argc, char **argv,
|
1993-08-04 23:33:40 +04:00
|
|
|
|
pointer pvar, pointer pinfo));
|
1994-10-25 01:17:41 +03:00
|
|
|
|
|
|
|
|
|
struct sinfo
|
|
|
|
|
{
|
|
|
|
|
int (*pcmpfn) P((int, pointer, const char *));
|
|
|
|
|
pointer pinfo;
|
|
|
|
|
boolean ffound;
|
|
|
|
|
boolean fmatched;
|
|
|
|
|
};
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
/* Check a login name and password against the UUCP password file.
|
|
|
|
|
This looks at the Taylor UUCP password file, but will work even if
|
1994-10-25 01:17:41 +03:00
|
|
|
|
uuconf_taylor_init was not called. It accepts either spaces or
|
|
|
|
|
colons as field delimiters. */
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
int
|
1994-10-25 01:17:41 +03:00
|
|
|
|
uuconf_callin (pglobal, pcmpfn, pinfo)
|
1993-08-04 23:33:40 +04:00
|
|
|
|
pointer pglobal;
|
1994-10-25 01:17:41 +03:00
|
|
|
|
int (*pcmpfn) P((int, pointer, const char *));
|
|
|
|
|
pointer pinfo;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
{
|
|
|
|
|
struct sglobal *qglobal = (struct sglobal *) pglobal;
|
|
|
|
|
int iret;
|
|
|
|
|
char **pz;
|
1994-10-25 01:17:41 +03:00
|
|
|
|
struct uuconf_cmdtab as[1];
|
|
|
|
|
struct sinfo s;
|
|
|
|
|
char *zline;
|
|
|
|
|
size_t cline;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
/* If we have no password file names, fill in the default name. */
|
|
|
|
|
if (qglobal->qprocess->pzpwdfiles == NULL)
|
|
|
|
|
{
|
|
|
|
|
char ab[sizeof NEWCONFIGLIB + sizeof PASSWDFILE - 1];
|
|
|
|
|
|
|
|
|
|
memcpy ((pointer) ab, (pointer) NEWCONFIGLIB,
|
|
|
|
|
sizeof NEWCONFIGLIB - 1);
|
|
|
|
|
memcpy ((pointer) (ab + sizeof NEWCONFIGLIB - 1), (pointer) PASSWDFILE,
|
|
|
|
|
sizeof PASSWDFILE);
|
|
|
|
|
iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE,
|
|
|
|
|
&qglobal->qprocess->pzpwdfiles,
|
|
|
|
|
qglobal->pblock);
|
|
|
|
|
if (iret != UUCONF_SUCCESS)
|
|
|
|
|
return iret;
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
as[0].uuconf_zcmd = NULL;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
s.pcmpfn = pcmpfn;
|
|
|
|
|
s.pinfo = pinfo;
|
|
|
|
|
s.ffound = FALSE;
|
|
|
|
|
s.fmatched = FALSE;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
zline = NULL;
|
|
|
|
|
cline = 0;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
iret = UUCONF_SUCCESS;
|
|
|
|
|
|
|
|
|
|
for (pz = qglobal->qprocess->pzpwdfiles; *pz != NULL; pz++)
|
|
|
|
|
{
|
|
|
|
|
FILE *e;
|
|
|
|
|
|
|
|
|
|
e = fopen (*pz, "r");
|
|
|
|
|
if (e == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (FNO_SUCH_FILE ())
|
|
|
|
|
continue;
|
|
|
|
|
qglobal->ierrno = errno;
|
|
|
|
|
iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
qglobal->ilineno = 0;
|
|
|
|
|
|
|
|
|
|
iret = UUCONF_SUCCESS;
|
|
|
|
|
|
|
|
|
|
while (getline (&zline, &cline, e) > 0)
|
|
|
|
|
{
|
|
|
|
|
char *zcolon;
|
|
|
|
|
|
|
|
|
|
++qglobal->ilineno;
|
|
|
|
|
|
|
|
|
|
/* Turn the first two colon characters into spaces. This is
|
|
|
|
|
a hack to make Unix style passwd files work. */
|
|
|
|
|
zcolon = strchr (zline, ':');
|
|
|
|
|
if (zcolon != NULL)
|
|
|
|
|
{
|
|
|
|
|
*zcolon = ' ';
|
|
|
|
|
zcolon = strchr (zcolon, ':');
|
|
|
|
|
if (zcolon != NULL)
|
|
|
|
|
*zcolon = ' ';
|
|
|
|
|
}
|
|
|
|
|
iret = uuconf_cmd_line (pglobal, zline, as, (pointer) &s,
|
|
|
|
|
ipcheck, 0, (pointer) NULL);
|
|
|
|
|
if ((iret & UUCONF_CMDTABRET_EXIT) != 0)
|
|
|
|
|
{
|
|
|
|
|
iret &=~ UUCONF_CMDTABRET_EXIT;
|
|
|
|
|
if (iret != UUCONF_SUCCESS)
|
|
|
|
|
iret |= UUCONF_ERROR_LINENO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iret = UUCONF_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
1993-08-04 23:33:40 +04:00
|
|
|
|
(void) fclose (e);
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
if (iret != UUCONF_SUCCESS || s.ffound)
|
1993-08-04 23:33:40 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
if (zline != NULL)
|
|
|
|
|
free ((pointer) zline);
|
|
|
|
|
|
1993-08-04 23:33:40 +04:00
|
|
|
|
if (iret != UUCONF_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
qglobal->zfilename = *pz;
|
|
|
|
|
iret |= UUCONF_ERROR_FILENAME;
|
|
|
|
|
}
|
1994-10-25 01:17:41 +03:00
|
|
|
|
else if (! s.ffound || ! s.fmatched)
|
1993-08-04 23:33:40 +04:00
|
|
|
|
iret = UUCONF_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
return iret;
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
/* This is called on each line of the file. It checks to see if the
|
|
|
|
|
login name from the file is the one we are looking for. If it is,
|
|
|
|
|
it sets ffound, and then sets fmatched according to whether the
|
|
|
|
|
password matches or not. */
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
static int
|
1994-10-25 01:17:41 +03:00
|
|
|
|
ipcheck (pglobal, argc, argv, pvar, pinfo)
|
1993-08-04 23:33:40 +04:00
|
|
|
|
pointer pglobal;
|
|
|
|
|
int argc;
|
|
|
|
|
char **argv;
|
|
|
|
|
pointer pvar;
|
|
|
|
|
pointer pinfo;
|
|
|
|
|
{
|
1994-10-25 01:17:41 +03:00
|
|
|
|
struct sinfo *q = (struct sinfo *) pinfo;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
1994-10-25 01:17:41 +03:00
|
|
|
|
if (argc != 2)
|
|
|
|
|
return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT;
|
|
|
|
|
|
|
|
|
|
if (! (*q->pcmpfn) (0, q->pinfo, argv[0]))
|
|
|
|
|
return UUCONF_CMDTABRET_CONTINUE;
|
|
|
|
|
|
|
|
|
|
q->ffound = TRUE;
|
|
|
|
|
q->fmatched = (*q->pcmpfn) (1, q->pinfo, argv[1]) != 0;
|
1993-08-04 23:33:40 +04:00
|
|
|
|
|
|
|
|
|
return UUCONF_CMDTABRET_EXIT;
|
|
|
|
|
}
|