/[muddleftpd]/muddleftpd/modules/auth/authlibmud/authmud.c
ViewVC logotype

Diff of /muddleftpd/modules/auth/authlibmud/authmud.c

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

revision 1.1 by rugger, Sun Oct 20 12:00:41 2002 UTC revision 1.1.6.1 by ganneff, Sat Oct 26 21:58:04 2002 UTC
# Line 1  Line 1 
1    
2  /* Copyright (C) 1999 Beau Kuiper  /* Copyright (C) 1999 Beau Kuiper
3    
4     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
# Line 14  Line 15 
15     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
17    
18  #include "config.h"  #include "../../../config.h"
19  #include "auth.h"  #include "auth.h"
20    
21  /* This file contains code to autheticate for mud users */  /* This file contains code to autheticate for mud users */
# Line 23  Line 24 
24    
25  #define MINLEVEL 20  #define MINLEVEL 20
26    
27  typedef struct  typedef struct
28  {  {
29          char *password;          char *password;
30          int level;          int level;
31  } PASSWDSTRUCT;  }
32    PASSWDSTRUCT;
33    
34  int mudauth_config(char *cmd, char *data, int line, void *h)  int mudauth_config(char *cmd,
35                                       char *data,
36                                       int line,
37                                       void *h)
38  {  {
39          PASSWDSTRUCT *handle = (PASSWDSTRUCT *)h;          PASSWDSTRUCT *handle = (PASSWDSTRUCT *) h;
40            
41          if (strcmp(cmd, "Level") == 0)          if (strcmp(cmd, "Level") == 0)
42                  sscanf(data, "%d", &(handle->level));                  sscanf(data, "%d", &(handle->level));
43          else if ((strcmp(cmd, "Password") == 0) && (strlen(data) > 2))          else if ((strcmp(cmd, "Password") == 0) && (strlen(data) > 2))
# Line 40  int mudauth_config(char *cmd, char *data Line 45  int mudauth_config(char *cmd, char *data
45                  handle->password = strdupwrapper(data + 1);                  handle->password = strdupwrapper(data + 1);
46                  handle->password[strlen(handle->password) - 1] = 0;                  handle->password[strlen(handle->password) - 1] = 0;
47          }          }
48          return(FALSE);          return (FALSE);
49  }  }
50                                    
51  void *gethandle(void *peer, void *tset, char *username, int *err)  void *gethandle(void *peer,
52                                    void *tset,
53                                    char *username,
54                                    int *err)
55  {  {
56          PASSWDSTRUCT *newhandle;          PASSWDSTRUCT *newhandle;
57          int result, error, line;          int result, error, line;
58          char *userfile;          char *userfile;
59            
60          userfile = mktokconfstr(tset, auth_getcursectionid(peer), "playerfile", NULL);          userfile =
61                    mktokconfstr(tset, auth_getcursectionid(peer), "playerfile", NULL);
62    
63          if (userfile == NULL)          if (userfile == NULL)
64          {          {
65                  log_addentry(MYLOG_INFO, NULL, "authmud requires playerfile to specify player file");                  log_addentry(MYLOG_INFO, NULL,
66                                             "authmud requires playerfile to specify player file");
67                  *err = AUTH_ERROR;                  *err = AUTH_ERROR;
68                  return(NULL);                  return (NULL);
69          }          }
70            
71          newhandle = mallocwrapper(sizeof(PASSWDSTRUCT));          newhandle = mallocwrapper(sizeof(PASSWDSTRUCT));
72          newhandle->password = NULL;          newhandle->password = NULL;
73          newhandle->level = 0;          newhandle->level = 0;
74            
75          result = loadconfigfile(userfile, mudauth_config, newhandle, FALSE, &error, &line);          result =
76                            loadconfigfile(userfile, mudauth_config, newhandle, FALSE, &error,
77                                               &line);
78    
79          *err = AUTH_OK;          *err = AUTH_OK;
80          if (result != 0)          if (result != 0)
81                  *err = AUTH_USERNKNOW;                  *err = AUTH_USERNKNOW;
82            
83          if (newhandle->level <= MINLEVEL)          if (newhandle->level <= MINLEVEL)
84          {          {
85                  if (newhandle->password) freewrapper(newhandle->password);                  if (newhandle->password)
86                            freewrapper(newhandle->password);
87                  newhandle = NULL;                  newhandle = NULL;
88                  *err = AUTH_ERROR;                  *err = AUTH_ERROR;
89          }          }
90          freewrapper(userfile);          freewrapper(userfile);
91          return(newhandle);          return (newhandle);
92  }  }
93    
94  void freehandle(void *h)  void freehandle(void *h)
95  {  {
96          PASSWDSTRUCT *handle = (PASSWDSTRUCT *)h;          PASSWDSTRUCT *handle = (PASSWDSTRUCT *) h;
97            
98          freewrapper(handle->password);          freewrapper(handle->password);
99          freewrapper(handle);          freewrapper(handle);
100  }  }
101    
102  int chkpasswd(void *h, char *password, char **errmsg)  int chkpasswd(void *h,
103                              char *password,
104                              char **errmsg)
105  {  {
106          PASSWDSTRUCT *handle = (PASSWDSTRUCT *)h;          PASSWDSTRUCT *handle = (PASSWDSTRUCT *) h;
107            
108          return(chkpassword(handle->password, password));          return (chkpassword(handle->password, password));
109  }  }

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

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