jessie rebuild
[hcoop/debian/courier-authlib.git] / authpwd.c
CommitLineData
d9898ee8 1/*
2** Copyright 1998 - 2004 Double Precision, Inc. See COPYING for
3** distribution information.
4*/
5
6#if HAVE_CONFIG_H
7#include "courier_auth_config.h"
8#endif
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <errno.h>
13#include <pwd.h>
14#if HAVE_UNISTD_H
15#include <unistd.h>
16#endif
17
18#include "auth.h"
b0322a85 19#include "courierauthstaticlist.h"
d9898ee8 20#include "courierauthdebug.h"
21
d9898ee8 22
23extern int auth_pwd_pre(const char *userid, const char *service,
24 int (*callback)(struct authinfo *, void *),
25 void *arg);
26extern void auth_pwd_enumerate( void(*cb_func)(const char *name,
27 uid_t uid,
28 gid_t gid,
29 const char *homedir,
30 const char *maildir,
31 const char *options,
32 void *void_arg),
33 void *void_arg);
34
35int auth_pwd(const char *service, const char *authtype, char *authdata,
36 int (*callback_func)(struct authinfo *, void *),
37 void *callback_arg)
38{
39 const char *user, *pass;
40
41 if (strcmp(authtype, AUTHTYPE_LOGIN) ||
42 (user=strtok(authdata, "\n")) == 0 ||
43 (pass=strtok(0, "\n")) == 0)
44 {
45 errno=EPERM;
46 return (-1);
47 }
48
49 return auth_sys_common(&auth_pwd_pre,
50 user,
51 pass,
52 service,
53 callback_func,
54 callback_arg);
55}
56
57static void auth_pwd_cleanup()
58{
59#if HAVE_ENDPWENT
60
61 endpwent();
62#endif
63}
64
65static struct authstaticinfo authpwd_info={
66 "authpwd",
67 auth_pwd,
68 auth_pwd_pre,
69 auth_pwd_cleanup,
70 auth_syspasswd,
71 auth_pwd_cleanup,
72 auth_pwd_enumerate,
73} ;
74
75
76struct authstaticinfo *courier_authpwd_init()
77{
78 return &authpwd_info;
79}