Annotation of coherent/g/usr/lib/uucp/tay104/uuconf/callin.c, revision 1.1.1.1

1.1       root        1: /* callin.c
                      2:    Check a login name and password against the UUCP password file.
                      3: 
                      4:    Copyright (C) 1992 Ian Lance Taylor
                      5: 
                      6:    This file is part of the Taylor UUCP uuconf library.
                      7: 
                      8:    This library is free software; you can redistribute it and/or
                      9:    modify it under the terms of the GNU Library General Public License
                     10:    as published by the Free Software Foundation; either version 2 of
                     11:    the License, or (at your option) any later version.
                     12: 
                     13:    This library is distributed in the hope that it will be useful, but
                     14:    WITHOUT ANY WARRANTY; without even the implied warranty of
                     15:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     16:    Library General Public License for more details.
                     17: 
                     18:    You should have received a copy of the GNU Library General Public
                     19:    License along with this library; if not, write to the Free Software
                     20:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     21: 
                     22:    The author of the program may be contacted at [email protected] or
                     23:    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
                     24:    */
                     25: 
                     26: #include "uucnfi.h"
                     27: 
                     28: #if USE_RCS_ID
                     29: const char _uuconf_callin_rcsid[] = "$Id: callin.c,v 1.1 93/07/30 08:07:02 bin Exp Locker: bin $";
                     30: #endif
                     31: 
                     32: #include <errno.h>
                     33: 
                     34: static int iplogin P((pointer pglobal, int argc, char **argv,
                     35:                      pointer pvar, pointer pinfo));
                     36: 
                     37: /* Check a login name and password against the UUCP password file.
                     38:    This looks at the Taylor UUCP password file, but will work even if
                     39:    uuconf_taylor_init was not called.  */
                     40: 
                     41: int
                     42: uuconf_callin (pglobal, zlogin, zpassword)
                     43:      pointer pglobal;
                     44:      const char *zlogin;
                     45:      const char *zpassword;
                     46: {
                     47:   struct sglobal *qglobal = (struct sglobal *) pglobal;
                     48:   int iret;
                     49:   char **pz;
                     50:   struct uuconf_cmdtab as[2];
                     51:   char *zfilepass;
                     52: 
                     53:   /* If we have no password file names, fill in the default name.  */
                     54:   if (qglobal->qprocess->pzpwdfiles == NULL)
                     55:     {
                     56:       char ab[sizeof NEWCONFIGLIB + sizeof PASSWDFILE - 1];
                     57: 
                     58:       memcpy ((pointer) ab, (pointer) NEWCONFIGLIB,
                     59:              sizeof NEWCONFIGLIB - 1);
                     60:       memcpy ((pointer) (ab + sizeof NEWCONFIGLIB - 1), (pointer) PASSWDFILE,
                     61:              sizeof PASSWDFILE);
                     62:       iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE,
                     63:                                  &qglobal->qprocess->pzpwdfiles,
                     64:                                  qglobal->pblock);
                     65:       if (iret != UUCONF_SUCCESS)
                     66:        return iret;
                     67:     }
                     68: 
                     69:   as[0].uuconf_zcmd = zlogin;
                     70:   as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2;
                     71:   as[0].uuconf_pvar = (pointer) &zfilepass;
                     72:   as[0].uuconf_pifn = iplogin;
                     73: 
                     74:   as[1].uuconf_zcmd = NULL;
                     75: 
                     76:   zfilepass = NULL;
                     77: 
                     78:   iret = UUCONF_SUCCESS;
                     79: 
                     80:   for (pz = qglobal->qprocess->pzpwdfiles; *pz != NULL; pz++)
                     81:     {
                     82:       FILE *e;
                     83: 
                     84:       e = fopen (*pz, "r");
                     85:       if (e == NULL)
                     86:        {
                     87:          if (FNO_SUCH_FILE ())
                     88:            continue;
                     89:          qglobal->ierrno = errno;
                     90:          iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
                     91:          break;
                     92:        }
                     93: 
                     94:       iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL,
                     95:                              (uuconf_cmdtabfn) NULL,
                     96:                              UUCONF_CMDTABFLAG_CASE, (pointer) NULL);
                     97:       (void) fclose (e);
                     98: 
                     99:       if (iret != UUCONF_SUCCESS || zfilepass != NULL)
                    100:        break;
                    101:     }
                    102: 
                    103:   if (iret != UUCONF_SUCCESS)
                    104:     {
                    105:       qglobal->zfilename = *pz;
                    106:       iret |= UUCONF_ERROR_FILENAME;
                    107:     }
                    108:   else if (zfilepass == NULL
                    109:           || strcmp (zfilepass, zpassword) != 0)
                    110:     iret = UUCONF_NOT_FOUND;
                    111: 
                    112:   if (zfilepass != NULL)
                    113:     free ((pointer) zfilepass);
                    114: 
                    115:   return iret;
                    116: }
                    117: 
                    118: /* This is called if it is the name we are looking for.  The pvar
                    119:    argument points to zfilepass, and we set it to the password.  */
                    120: 
                    121: static int
                    122: iplogin (pglobal, argc, argv, pvar, pinfo)
                    123:      pointer pglobal;
                    124:      int argc;
                    125:      char **argv;
                    126:      pointer pvar;
                    127:      pointer pinfo;
                    128: {
                    129:   struct sglobal *qglobal = (struct sglobal *) pglobal;
                    130:   char **pzpass = (char **) pvar;
                    131: 
                    132:   *pzpass = strdup (argv[1]);
                    133:   if (*pzpass == NULL)
                    134:     {
                    135:       qglobal->ierrno = errno;
                    136:       return (UUCONF_MALLOC_FAILED
                    137:              | UUCONF_ERROR_ERRNO
                    138:              | UUCONF_CMDTABRET_EXIT);
                    139:     }
                    140: 
                    141:   return UUCONF_CMDTABRET_EXIT;
                    142: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.