File: mod.h

package info (click to toggle)
courier 0.47-4sarge5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 32,680 kB
  • ctags: 12,265
  • sloc: ansic: 164,045; cpp: 23,863; sh: 19,569; perl: 7,225; makefile: 4,192; yacc: 316; sed: 16
file content (50 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
** Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
** distribution information.
*/

#include	"auth.h"
#include	"authmod.h"
#include	"debug.h"
#include	<stdio.h>
#include	<stdlib.h>
#include	<errno.h>

extern char *MODULE(const char *, const char *, char *, int,
	void (*)(struct authinfo *, void *), void *);

static const char mod_h_rcsid[]="$Id: mod.h,v 1.5 2004/04/18 15:54:39 mrsam Exp $";

#ifndef MODNAME
/* The ANSI-C way to convert a token into a string */
#define DEFSTR(x) #x
#define DEFSTR2(x) DEFSTR(x)
#define MODNAME DEFSTR2(MODULE)
#endif

int main(int argc, char **argv)
{
const char *service, *type;
char *authdata;
char	*user;

	auth_debug_login_init();
	authmod_init(argc, argv, &service, &type, &authdata);
	dprintf(MODNAME ": starting client module");
	user=MODULE(service, type, authdata, 1, 0, 0);
	if (!user || !*user)
	{
		if (user || errno != EPERM)
		{
			dprintf(MODNAME ": TEMPFAIL - no more modules will be tried");
			authmod_fail_completely();
		}

		dprintf(MODNAME ": REJECT");
		authmod_fail(argc, argv);
	}
	dprintf(MODNAME ": ACCEPT, username %s", user);
	authmod_success(argc, argv, user);
	return (0);
}