/[pengfork]/pengfork/src/getpass.c
ViewVC logotype

Diff of /pengfork/src/getpass.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by chupa, Sat Nov 30 10:28:52 2002 UTC revision 1.2 by chupa, Sun Dec 1 01:19:07 2002 UTC
# Line 20  Line 20 
20   *                   *                
21   */   */
22    
23    #include "config.h"
24    
25  #include <stdio.h>  #include <stdio.h>
26  #include <errno.h>  #include <errno.h>
27  #include <string.h>  #include <string.h>
28  #include <ctype.h>  #include <ctype.h>
29    
30    #include "gettext.h"
31  #include "options.h"  #include "options.h"
32  #include "log.h"  #include "log.h"
33  #include "utils.h"  #include "utils.h"
34    
35  int  int
36  get_password( sn, pass )  get_password (sn, pass)
37       char *sn;       char *sn;
38       char **pass;       char **pass;
39  {  {
# Line 42  get_password( sn, pass ) Line 45  get_password( sn, pass )
45    f = fopen (PARAM_SECRET_FILE, "r");    f = fopen (PARAM_SECRET_FILE, "r");
46    if (f == NULL)    if (f == NULL)
47      {      {
48        log (LOG_ERR,"%s: %s(%d)\n", PARAM_SECRET_FILE, strerror(errno), errno);        log (LOG_ERR, "%s: %s(%d)\n", PARAM_SECRET_FILE, strerror (errno),
49               errno);
50        return 0;        return 0;
51      }      }
52    
# Line 54  get_password( sn, pass ) Line 58  get_password( sn, pass )
58        strip_comments (line);        strip_comments (line);
59        trim (line);        trim (line);
60    
61        if(strlen(line) > 0)        if (strlen (line) > 0)
62          {          {
63          c=line;            c = line;
64          while(!isspace(*c) && *c!='\0') c++;            while (!isspace (*c) && *c != '\0')
65          if(*c != '\0')              c++;
66            *c='\0';            if (*c != '\0')
67          else              *c = '\0';
68            log (LOG_WARNING, "%s:%d bad line format\n", PARAM_SECRET_FILE, lineno);            else
69                        log (LOG_WARNING, gettext ("%s:%d bad line format\n"), PARAM_SECRET_FILE,
70          c++;                   lineno);
71          if( !strcmp(line, sn) )  
72            {            c++;
73              if(pass) {            if (!strcmp (line, sn))
74                trim(c);              {
75                *pass=strdup(c);                if (pass)
76              }                  {
77              fclose(f);                    trim (c);
78              return 1;                    *pass = strdup (c);
79            }                  }
80                  fclose (f);
81                  return 1;
82                }
83          }          }
84      }      }
85    
86    *pass=NULL;    *pass = NULL;
87    fclose(f);    fclose (f);
88    return 0;    return 0;
89  }  }
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26